From 7060c802875acc14a6171ab0d444cbdb28f73912 Mon Sep 17 00:00:00 2001 From: gauthamt Date: Tue, 4 Nov 2014 12:15:48 -0800 Subject: [PATCH] Add shared_library build rule for Go on Mojo. Review URL: https://codereview.chromium.org/699873005 Cr-Original-Commit-Position: refs/heads/master@{#302652} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: fa3a3cc37f07130dedf6a017bbca6903d9ef4f7c --- go/rules.gni | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/go/rules.gni b/go/rules.gni index 79453d187..55dd386e4 100644 --- a/go/rules.gni +++ b/go/rules.gni @@ -59,3 +59,39 @@ template("go_test_binary") { ] + rebase_path(invoker.sources, build_dir) } } + +template("go_shared_library") { + # Only available on android for now. + assert(is_android) + assert(defined(invoker.sources)) + assert(go_build_tool != "") + + static_library_name = target_name + "_static_library" + + static_library(static_library_name) { + complete_static_lib = true + deps = invoker.deps + } + + 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 = [ + "--", + "CGO_ENABLED=1 GOOS=android GOARCH=arm GOARM=7 ${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" + static_library_name + "", + "build -ldflags=-shared", + ] + rebase_path(invoker.sources, build_dir) + } +} \ No newline at end of file