constabulary / gb

gb, the project based build tool for Go
https://getgb.io/
MIT License
2.15k stars 148 forks source link

+ `-o` flag to set output binary file path for `gb build`. fixes #309 #696

Closed mkorolyov closed 7 years ago

mkorolyov commented 7 years ago

When we pass tags through gb build for project foo (e.g. gb build -tags 'production monitoring') gb generates bin file foo-production-monitoring while we expects just foo.

The idea is to add -o flag to specify output file name(e.g. db build -tags 'production monitoring' -o SOME_PATH/foo')

codecov-io commented 7 years ago

Codecov Report

Merging #696 into master will decrease coverage by 0.67%. The diff coverage is 23.8%.

@@            Coverage Diff             @@
##           master     #696      +/-   ##
==========================================
- Coverage   53.32%   52.65%   -0.68%     
==========================================
  Files          40       42       +2     
  Lines        3036     3168     +132     
==========================================
+ Hits         1619     1668      +49     
- Misses       1241     1356     +115     
+ Partials      176      144      -32
Impacted Files Coverage Δ
cmd/gb/build.go 4.76% <0%> (ø)
context.go 74.16% <0%> (-1.26%) :x:
cmd/gb/main.go 8.91% <0%> (-0.09%) :x:
package.go 68.34% <33.33%> (-5.1%) :x:
depfile.go 8% <0%> (-24.07%) :x:
internal/depfile/depfile.go 87.65% <0%> (ø)
build.go 85.33% <0%> (+5.2%) :white_check_mark:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d4ba64b...72490e6. Read the comment docs.

mkorolyov commented 7 years ago

any comments/thoughts/etc?

davecheney commented 7 years ago

I'm not keen on adding this, gb works on projects not packages, -o implies a specialisation on a single output binary which I don't feel comfortable with.

mkorolyov commented 7 years ago

@davecheney Hi Deve, Didn't get why you mentioned packages here. Problem that i wan't to solve is when we build i project with set of flags i don't want the output binary name to change with -flag1-flag2-flag3-etc. Simple option -o implemented for a wide list of tools that produce something, why gb should be exception?

mkorolyov commented 7 years ago

@davecheney
What if we will ad possibility to set format of output for binary files? like ${project_name}-${tags} or ${project_name}_{$arch_name} with predefined placeholders?

davecheney commented 7 years ago

gb works on projects, and projects can have multiple outputs. Adding -o would put gb in the same position as the go tool; go build -o only works in some cases.

On 13 Mar 2017, at 20:51, Maxim Korolyov notifications@github.com wrote:

@davecheney Hi Deve, Didn't get why you mentioned packages here. Problem that i wan't to solve is when we build i project with set of flags i don't want the output binary name to change with -flag1-flag2-flag3-etc. Simple option -o implemented for a wide list of tools that produce something, why gb should be exception?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

davecheney commented 7 years ago

Doesn't that exist already?

What is the problem you are trying to solve?

On 13 Mar 2017, at 21:10, Maxim Korolyov notifications@github.com wrote:

@davecheney What if we will ad possibility to set format of output for binary files? like ${project_name}-${tags} or ${projectname}{$arch_name}?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

mkorolyov commented 7 years ago

@davecheney

What is the problem you are trying to solve?

when we use build flags we got binaries with formatting projectname-flag1-flag2 while need just simple projectname

currently there is a possibility only to set output bin dir.

davecheney commented 7 years ago

when we use build flags we got binaries with formatting projectname-flag1-flag2 while need just simple projectname

You get command-flag, not project-name, flag. If there is only one command in your project and it is the name of the project, this will be the same thing.

currently there is a possibility only to set output bin dir.

The output directory is hard coded, that is why files with a different tag have a different suffix.

What would you say to

$PROJECT/bin/tag/tag/tag/binary

so

gb build -tag release would generate $PROJECT/bin/release/command

mkorolyov commented 7 years ago

@davecheney what if we have more than 1 build tag? 5 for example? it is not convenient to build by hand binary path that depends on specified go build flags.

davecheney commented 7 years ago

@davecheney what if we have more than 1 build tag? 5 for example? it is not convenient to build by hand binary path that depends on specified go build flags.

But you would know the path, it's the same as the flags you passed in.

Please, there is something you are not telling me, something about how your Ci or build and release process works that has put you in a position of needing to change how gb works. If you can explain what the problem is that you are solving, maybe there is a different way to achieve what you need.

mkorolyov commented 7 years ago

@davecheney

gb build -tag release would generate $PROJECT/bin/release/command

didn't find such logic in the code, could you pls show it? Asking because current gb produced $project/bin/projectname-release for me and not $project/bin/release/projectname

davecheney commented 7 years ago

Yes, sorry for the confusion, this was an alternative proposal. It is not implemented.

On 13 Mar 2017, at 22:04, Maxim Korolyov notifications@github.com wrote:

@davecheney

gb build -tag release would generate $PROJECT/bin/release/command

didn't find such logic in the code, could you pls show it? Asking because current gb produced $project/bin/projectname-release for me and not $project/bin/release/projectname

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

mkorolyov commented 7 years ago

@davecheney so how about proposal for possibility to set output binary format?

davecheney commented 7 years ago

I'm sorry, I don't want to add this flag for the reasons I've explained above.

We can talk about alternatives.

On 13 Mar 2017, at 22:09, Maxim Korolyov notifications@github.com wrote:

@davecheney so how about proposal for possibility to set output binary format?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

mkorolyov commented 7 years ago

@davecheney i am already proposing an alternative i mean add something like --output-bin-format with usage gb build --output-bin-format '${name}-${tags}' -tags release or gb build --output-bin-format '${name}-${arch}' or gb build --output-bin-format '${name}' which produce $projectdir/bin/projectname-release or $projectdir/bin/projectname-arm or $projectdir/bin/projectname

davecheney commented 7 years ago

No, I'm sorry I won't want to add that. It's a more complicated version of -o

On 13 Mar 2017, at 22:15, Maxim Korolyov notifications@github.com wrote:

@davecheney i am already proposing an alternative i mean add something like --output-bin-format with usage gb build --output-bin-format '${name}-${tags}' -tags release or gb build --output-bin-format '${name}-${arch}' or gb build --output-bin-format '${name}' which produce $projectdir/bin/projectname-release or $projectdir/bin/projectname-armor$projectdir/bin/projectname`

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

mkorolyov commented 7 years ago

@davecheney it is adoption of -o for gb multi binary semantics.

What would you propose than to achieve same result?

davecheney commented 7 years ago

My counter proposal is

  1. do nothing, the name of the final binary is predictable from the inputs to gb build
  2. -or-, mvoe from $PROJECT/bin/command-tag-tag-tag to $PROJECT/bin/tag/tag/tag/command

On Mon, Mar 13, 2017 at 10:24 PM, Maxim Korolyov notifications@github.com wrote:

@davecheney https://github.com/davecheney it is adoption of -o for gb multi binary semantics.

What would you propose than to achieve same result?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/constabulary/gb/pull/696#issuecomment-286081018, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcA-sBp5Ofz_VGwvajljI7jFHUC2Rwks5rlSdggaJpZM4MViR4 .

davecheney commented 7 years ago

Thank you for this pr, but I am not going to merge. It. As I explained I do not want to make -o configurable. I am going to close this pr and the issue.

Thank you for you understanding