forked from bazel-contrib/rules_go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add go_binary out attribute for custom file names
go_binary now has an "out" attribute which allows users to set the output filename for the generated executable. When set, go_binary will write this file without mode-specific directory prefixes, without linkmode-specific prefixes, and without platform-specific extensions. Fixes bazel-contrib#1239
- Loading branch information
Jay Conrod
committed
Mar 20, 2018
1 parent
63cd14e
commit 44d78de
Showing
8 changed files
with
101 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_test") | ||
|
||
test_suite(name = "go_binary") | ||
|
||
go_test( | ||
name = "go_default_test", | ||
srcs = ["out_test.go"], | ||
data = [":custom_bin"], | ||
) | ||
|
||
go_binary( | ||
name = "custom_bin", | ||
srcs = ["custom_bin.go"], | ||
out = "alt_bin", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Basic go_binary functionality | ||
============================= | ||
|
||
.. _go_binary: /go/core.rst#_go_binary | ||
|
||
Tests to ensure the basic features of go_binary are working as expected. | ||
|
||
out_test | ||
-------- | ||
|
||
Test that a go_binary_ rule can write its executable file with a custom name | ||
in the package directory (not the mode directory). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package main | ||
|
||
func main() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestCustomBinaryName(t *testing.T) { | ||
_, err := os.Stat("alt_bin") | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
} |