Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1471)

Unified Diff: mojo/go/rules.gni

Issue 1378993002: Adds new GN template go_binary (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/go/rules.gni
diff --git a/mojo/go/rules.gni b/mojo/go/rules.gni
index 60714f0f088381de992ef2900567d747a55395de..f860f440e2441daf69cac1fdccf5b1f22a56bd7a 100644
--- a/mojo/go/rules.gni
+++ b/mojo/go/rules.gni
@@ -91,6 +91,65 @@ template("go_test_binary") {
}
}
+template("go_application") {
rogulenko 2015/10/01 18:48:07 My high level question is how are you going to use
rudominer 2015/10/02 16:36:00 I plan to use this to build the new version of the
+ assert(is_android || is_linux)
+ assert(defined(invoker.sources))
+ assert(defined(invoker.deps))
+ assert(defined(invoker.static_library_sources))
+ assert(go_build_tool != "")
+
+ static_library_name = target_name + "_static_library"
+ static_library(static_library_name) {
+ complete_static_lib = true
+ sources = invoker.static_library_sources
+ deps = invoker.deps
+ }
+
+ go_binary_name = target_name + "_go"
+ action(go_binary_name) {
+ deps = invoker.deps + [ ":${static_library_name}" ]
+ script = "//mojo/go/go.py"
+ inputs = invoker.sources
+ outputs = [
+ "${target_out_dir}/${target_name}",
+ ]
+
+ # Since go build 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 = []
+ if (is_android) {
+ args += [ "--android" ]
+ }
+ 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),
+ rebase_path(root_out_dir, root_build_dir),
+ "-I" + rebase_path("//"),
+ "-L" + rebase_path(target_out_dir) + " -l" + static_library_name + "",
+ "build",
+ ]
+ args += rebase_path(invoker.sources, build_dir)
+ }
+
+ copy(target_name) {
+ deps = [
+ ":${go_binary_name}",
+ ]
+ sources = [
+ "${target_out_dir}/${go_binary_name}",
+ ]
+ outputs = [
+ "${root_out_dir}/${target_name}",
+ ]
+ }
+}
+
template("go_mojo_application") {
assert(is_android || is_linux)
assert(defined(invoker.sources))
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698