OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 declare_args() { | 5 declare_args() { |
6 # By default, there is no go build tool, because go builds are not supported. | 6 # By default, there is no go build tool, because go builds are not supported. |
7 go_build_tool = "" | 7 go_build_tool = "" |
8 } | 8 } |
9 | 9 |
10 # Declare a go test binary target. | 10 # Declare a go test binary target. |
(...skipping 22 matching lines...) Expand all Loading... |
33 deps = invoker.deps | 33 deps = invoker.deps |
34 complete_static_lib = true | 34 complete_static_lib = true |
35 } | 35 } |
36 | 36 |
37 action(target_name) { | 37 action(target_name) { |
38 deps = [ | 38 deps = [ |
39 ":$static_library_name", | 39 ":$static_library_name", |
40 ] | 40 ] |
41 script = "//build/go/go.py" | 41 script = "//build/go/go.py" |
42 outputs = [ "${target_out_dir}/${target_name}" ] | 42 outputs = [ "${target_out_dir}/${target_name}" ] |
| 43 |
43 # Since go test does not permit specifying an output directory or output | 44 # Since go test does not permit specifying an output directory or output |
44 # binary name, we create a temporary build directory, and the python | 45 # binary name, we create a temporary build directory, and the python |
45 # script will later identify the output, copy it to the target location, | 46 # script will later identify the output, copy it to the target location, |
46 # and clean up the temporary build directory. | 47 # and clean up the temporary build directory. |
47 build_dir = "${target_out_dir}/${target_name}_build" | 48 build_dir = "${target_out_dir}/${target_name}_build" |
48 args = [ | 49 args = [ |
49 "--", | 50 "--", |
50 "${go_build_tool}", | 51 "${go_build_tool}", |
51 rebase_path(build_dir, root_build_dir), | 52 rebase_path(build_dir, root_build_dir), |
52 rebase_path(target_out_dir, root_build_dir) + "/${target_name}", | 53 rebase_path(target_out_dir, root_build_dir) + "/${target_name}", |
53 rebase_path("//", root_build_dir), | 54 rebase_path("//", root_build_dir), |
54 "-I" + rebase_path("//"), | 55 "-I" + rebase_path("//"), |
55 " -L" + rebase_path(target_out_dir) + | 56 " -L" + rebase_path(target_out_dir) + " -l" + static_library_name + |
56 " -l" + static_library_name + | 57 " -lstdc++ -lpthread -lm -lglib-2.0", |
57 " -lstdc++ -lpthread -lm -lglib-2.0", | 58 "test", |
58 "test", "-c", | 59 "-c", |
59 ] + rebase_path(invoker.sources, build_dir) | 60 ] + rebase_path(invoker.sources, build_dir) |
60 } | 61 } |
61 } | 62 } |
62 | 63 |
63 template("go_shared_library") { | 64 template("go_shared_library") { |
64 # Only available on android for now. | 65 # Only available on android for now. |
65 assert(is_android) | 66 assert(is_android) |
66 assert(defined(invoker.sources)) | 67 assert(defined(invoker.sources)) |
67 assert(go_build_tool != "") | 68 assert(go_build_tool != "") |
68 | 69 |
69 static_library_name = target_name + "_static_library" | 70 static_library_name = target_name + "_static_library" |
70 | 71 |
71 static_library(static_library_name) { | 72 static_library(static_library_name) { |
72 complete_static_lib = true | 73 complete_static_lib = true |
73 deps = invoker.deps | 74 deps = invoker.deps |
74 } | 75 } |
75 | 76 |
76 action(target_name) { | 77 action(target_name) { |
77 deps = [ ":$static_library_name" ] | 78 deps = [ |
| 79 ":$static_library_name", |
| 80 ] |
78 script = "//build/go/go.py" | 81 script = "//build/go/go.py" |
79 outputs = [ "${target_out_dir}/${target_name}" ] | 82 outputs = [ "${target_out_dir}/${target_name}" ] |
| 83 |
80 # Since go test does not permit specifying an output directory or output | 84 # Since go test does not permit specifying an output directory or output |
81 # binary name, we create a temporary build directory, and the python | 85 # binary name, we create a temporary build directory, and the python |
82 # script will later identify the output, copy it to the target location, | 86 # script will later identify the output, copy it to the target location, |
83 # and clean up the temporary build directory. | 87 # and clean up the temporary build directory. |
84 build_dir = "${target_out_dir}/${target_name}_build" | 88 build_dir = "${target_out_dir}/${target_name}_build" |
85 args = [ | 89 args = [ |
86 "--", | 90 "--", |
87 "CGO_ENABLED=1 GOOS=android GOARCH=arm GOARM=7 ${go_build_tool}", | 91 "CGO_ENABLED=1 GOOS=android GOARCH=arm GOARM=7 ${go_build_tool}", |
88 rebase_path(build_dir, root_build_dir), | 92 rebase_path(build_dir, root_build_dir), |
89 rebase_path(target_out_dir, root_build_dir) + "/${target_name}", | 93 rebase_path(target_out_dir, root_build_dir) + "/${target_name}", |
90 rebase_path("//", root_build_dir), | 94 rebase_path("//", root_build_dir), |
91 "-I" + rebase_path("//"), | 95 "-I" + rebase_path("//"), |
92 " -L" + rebase_path(target_out_dir) + | 96 " -L" + rebase_path(target_out_dir) + " -l" + static_library_name + |
93 " -l" + static_library_name + "", | 97 "", |
94 "build -ldflags=-shared", | 98 "build -ldflags=-shared", |
95 ] + rebase_path(invoker.sources, build_dir) | 99 ] + rebase_path(invoker.sources, build_dir) |
96 } | 100 } |
97 } | 101 } |
OLD | NEW |