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 library. | 10 # Declare a go library. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 rebase_path(root_out_dir, root_build_dir), | 84 rebase_path(root_out_dir, root_build_dir), |
85 "-I" + rebase_path("//"), | 85 "-I" + rebase_path("//"), |
86 "-L" + rebase_path(target_out_dir) + " -l" + static_library_name + | 86 "-L" + rebase_path(target_out_dir) + " -l" + static_library_name + |
87 " -lstdc++ -lpthread -lm -lglib-2.0 -lrt", | 87 " -lstdc++ -lpthread -lm -lglib-2.0 -lrt", |
88 "test", | 88 "test", |
89 "-c", | 89 "-c", |
90 ] + rebase_path(invoker.sources, build_dir) | 90 ] + rebase_path(invoker.sources, build_dir) |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 template("go_shared_library") { | 94 template("go_mojo_application") { |
95 # Only available on android for now. | 95 # Only available on android for now. |
96 assert(is_android) | 96 assert(is_android) |
97 assert(defined(invoker.sources)) | 97 assert(defined(invoker.sources)) |
98 assert(go_build_tool != "") | 98 assert(go_build_tool != "") |
99 | 99 |
100 static_library_name = target_name + "_static_library" | 100 static_library_name = target_name + "_static_library" |
101 | |
102 static_library(static_library_name) { | 101 static_library(static_library_name) { |
103 complete_static_lib = true | 102 complete_static_lib = true |
104 deps = invoker.deps | 103 deps = invoker.deps |
105 } | 104 } |
106 | 105 |
107 action(target_name) { | 106 go_library_name = target_name + "_go" |
| 107 action(go_library_name) { |
108 deps = [ | 108 deps = [ |
109 ":$static_library_name", | 109 ":${static_library_name}", |
110 ] | 110 ] |
111 script = "//mojo/go/go.py" | 111 script = "//mojo/go/go.py" |
112 inputs = invoker.sources | 112 inputs = invoker.sources |
113 outputs = [ | 113 outputs = [ |
114 "${target_out_dir}/${target_name}", | 114 "${target_out_dir}/${target_name}", |
115 ] | 115 ] |
116 | 116 |
117 # Since go test does not permit specifying an output directory or output | 117 # Since go test does not permit specifying an output directory or output |
118 # binary name, we create a temporary build directory, and the python | 118 # binary name, we create a temporary build directory, and the python |
119 # script will later identify the output, copy it to the target location, | 119 # script will later identify the output, copy it to the target location, |
120 # and clean up the temporary build directory. | 120 # and clean up the temporary build directory. |
121 build_dir = "${target_out_dir}/${target_name}_build" | 121 build_dir = "${target_out_dir}/${target_name}_build" |
122 args = | 122 args = |
123 [ | 123 [ |
124 "--android", | 124 "--android", |
125 "--", | 125 "--", |
126 "${go_build_tool}", | 126 "${go_build_tool}", |
127 rebase_path(build_dir, root_build_dir), | 127 rebase_path(build_dir, root_build_dir), |
128 rebase_path(target_out_dir, root_build_dir) + "/${target_name}", | 128 rebase_path(target_out_dir, root_build_dir) + "/${target_name}", |
129 rebase_path("//", root_build_dir), | 129 rebase_path("//", root_build_dir), |
130 rebase_path(root_out_dir, root_build_dir), | 130 rebase_path(root_out_dir, root_build_dir), |
131 "-I" + rebase_path("//"), | 131 "-I" + rebase_path("//"), |
132 "-L" + rebase_path(target_out_dir) + " -l" + static_library_name + "", | 132 "-L" + rebase_path(target_out_dir) + " -l" + static_library_name + "", |
133 "build", | 133 "build", |
134 "-ldflags=-shared", | 134 "-ldflags=-shared", |
135 ] + rebase_path(invoker.sources, build_dir) | 135 ] + rebase_path(invoker.sources, build_dir) |
136 } | 136 } |
| 137 |
| 138 copy(target_name) { |
| 139 deps = [ |
| 140 ":${go_library_name}", |
| 141 ] |
| 142 sources = [ |
| 143 "${target_out_dir}/${go_library_name}", |
| 144 ] |
| 145 outputs = [ |
| 146 "${root_out_dir}/${target_name}.mojo", |
| 147 ] |
| 148 } |
137 } | 149 } |
OLD | NEW |