OLD | NEW |
---|---|
(Empty) | |
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 | |
3 # found in the LICENSE file. | |
4 | |
5 declare_args() { | |
6 # By default, there is no go build tool, because go builds are not supported. | |
7 go_build_tool = "" | |
8 } | |
9 | |
10 # Declare a go test binary target. | |
11 # | |
12 # The target generates a go test executable, linking against other C code, | |
13 # which is compiled into a static library and linked against Go. | |
14 # | |
15 # Only works on linux. |go_build_tool| must be set to the absolute path | |
16 # of the go build tool. | |
17 # | |
18 # Variables (all required) | |
19 # sources: list of .go files to compile | |
20 # static_library_sources: list of C sources needed for the static library | |
21 # deps: dependencies for the static library | |
22 | |
23 template("go_test_binary") { | |
24 # Only available on linux for now. | |
25 assert(is_linux) | |
26 assert(defined(invoker.sources)) | |
27 assert(go_build_tool != "") | |
28 | |
29 static_library_name = target_name + "_static_library" | |
30 | |
31 static_library(static_library_name) { | |
32 sources = invoker.static_library_sources | |
qsr
2014/09/26 13:33:41
I do not think you should force C sources. When th
brettw
2014/09/26 18:15:34
The problem is you can't make a static library if
| |
33 deps = invoker.deps | |
34 complete_static_lib = true | |
35 } | |
36 | |
37 action(target_name) { | |
38 deps = [ | |
39 ":$static_library_name", | |
40 ] | |
41 script = "//build/go/go.py" | |
42 outputs = [ "${target_out_dir}/${target_name}" ] | |
43 # 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 # script will later identify the output, copy it to the target location, | |
46 # and clean up the temporary build directory. | |
47 build_dir = "${target_out_dir}/${target_name}_build" | |
48 args = [ | |
49 "--", | |
50 "${go_build_tool}", | |
51 rebase_path(build_dir, root_build_dir), | |
52 rebase_path(target_out_dir, root_build_dir) + "/${target_name}", | |
53 rebase_path("//", root_build_dir), | |
54 "-I" + rebase_path("//"), | |
55 " -L" + rebase_path(target_out_dir) + | |
56 " -L" + rebase_path(root_build_dir + "/obj/third_party/libevent") + | |
57 " -l" + static_library_name + | |
58 " -lstdc++ -lpthread -lm -lglib-2.0 -levent", | |
59 "test", "-c", | |
60 ] + rebase_path(invoker.sources, build_dir) | |
61 } | |
62 } | |
OLD | NEW |