Index: build/go/rules.gni |
diff --git a/build/go/rules.gni b/build/go/rules.gni |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b16a98eeace3961f088bd53abebd5862bfd4e40f |
--- /dev/null |
+++ b/build/go/rules.gni |
@@ -0,0 +1,49 @@ |
+# Copyright 2014 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+declare_args() { |
+ # By default, there is no go build tool, because go builds are not supported. |
+ go_build_tool = "" |
+} |
+ |
+template("go_test_binary") { |
brettw
2014/09/24 19:25:45
This needs documentation. What variables does it e
tburkard
2014/09/26 13:31:09
Done.
|
+ # Only available on linux for now. |
+ assert(is_linux) |
+ assert(defined(invoker.sources)) |
+ assert(go_build_tool != "") |
+ |
+ static_library_name = target_name + "_static_library" |
+ |
+ static_library(static_library_name) { |
+ sources = invoker.additional_sources |
brettw
2014/09/24 19:25:45
This requires "additional_sources" be set. Will th
tburkard
2014/09/26 13:31:09
In general, I think any mojo code will require int
|
+ deps = invoker.deps |
+ complete_static_lib = true |
+ } |
+ |
+ action(target_name) { |
+ deps = [ |
+ ":$static_library_name", |
+ ] |
+ script = "//build/go/go.py" |
+ outputs = [ "${target_out_dir}/${target_name}" ] |
+ # Since go test does not permit specifying an output directory or output |
+ # binary name, we create a temporary build directory, and the python |
+ # script will later identify the output, copy it to the target location, |
+ # and clean up the temporary build directory. |
+ build_dir = "${target_out_dir}/${target_name}_build" |
+ args = [ |
+ "--", |
+ "${go_build_tool}", |
+ rebase_path(build_dir, root_build_dir), |
+ rebase_path(target_out_dir, root_build_dir) + "/${target_name}", |
+ rebase_path("//", root_build_dir), |
+ "-I" + rebase_path("//"), |
+ " -L" + rebase_path(target_out_dir) + |
+ " -L" + rebase_path(root_build_dir + "/obj/third_party/libevent") + |
+ " -l" + static_library_name + |
+ " -lstdc++ -lpthread -lm -lglib-2.0 -levent", |
+ "test", "-c", |
+ ] + rebase_path(invoker.sources, build_dir) |
+ } |
+} |