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.
Allow pure go cross compilation within a single build (bazel-contrib#…
…1114) This adds goos and goarch attributes to a go_binary If specified they force the binary to cross compile to the specified architecture. It also adds a test that uses this to cross compile and verify the binary was correctly cross compiled. This also required multiple rules for the same binary in different modes, which meant we needed control over the binary file name (so not using the rule name) Fixes bazel-contrib#1104 Fixes bazel-contrib#1030
- Loading branch information
Showing
13 changed files
with
237 additions
and
61 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
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
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,44 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_test", "go_source") | ||
|
||
go_source( | ||
name = "cross", | ||
srcs = ["main.go"], | ||
) | ||
|
||
go_binary( | ||
name = "windows", | ||
embed = [":cross"], | ||
basename = "cross", | ||
goos = "windows", | ||
goarch = "amd64", | ||
pure = "on", | ||
) | ||
|
||
go_binary( | ||
name = "linux", | ||
embed = [":cross"], | ||
basename = "cross", | ||
goos = "linux", | ||
goarch = "amd64", | ||
pure = "on", | ||
) | ||
|
||
go_binary( | ||
name = "darwin", | ||
embed = [":cross"], | ||
basename = "cross", | ||
goos = "darwin", | ||
goarch = "amd64", | ||
pure = "on", | ||
) | ||
|
||
go_test( | ||
name = "cross_test", | ||
size = "small", | ||
srcs = ["cross_test.go"], | ||
data = [ | ||
":linux", | ||
":darwin", | ||
":windows", | ||
], | ||
) |
Oops, something went wrong.