| 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 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 | 33 |
| 34 # Declare a go test binary target. | 34 # Declare a go test binary target. |
| 35 # | 35 # |
| 36 # The target generates a go test executable, linking against other C code, | 36 # The target generates a go test executable, linking against other C code, |
| 37 # which is compiled into a static library and linked against Go. | 37 # which is compiled into a static library and linked against Go. |
| 38 # | 38 # |
| 39 # Only works on linux. |go_build_tool| must be set to the absolute path | 39 # Only works on linux. |go_build_tool| must be set to the absolute path |
| 40 # of the go build tool. | 40 # of the go build tool. |
| 41 # | 41 # |
| 42 # Variables (all required) | 42 # Variables |
| 43 # sources: list of .go files to compile | 43 # sources: list of .go files to compile |
| 44 # inputs: list of files that are input dependencies. Use this to |
| 45 # specify your imported .go files. These files will not be |
| 46 # specified in the command line to go test but they will cause |
| 47 # a re-compile if they are touched. (optional) |
| 44 # static_library_sources: list of C sources needed for the static library | 48 # static_library_sources: list of C sources needed for the static library |
| 45 # deps: dependencies for the static library | 49 # (optional) |
| 50 # deps: dependencies (optional) |
| 46 | 51 |
| 47 template("go_test_binary") { | 52 template("go_test_binary") { |
| 48 # Only available on linux for now. | 53 # Only available on linux for now. |
| 49 assert(is_linux) | 54 assert(is_linux) |
| 50 assert(defined(invoker.sources)) | 55 assert(defined(invoker.sources)) |
| 51 assert(go_build_tool != "") | 56 assert(go_build_tool != "") |
| 52 | 57 |
| 53 static_library_name = target_name + "_static_library" | 58 static_library_name = target_name + "_static_library" |
| 54 | 59 |
| 55 static_library(static_library_name) { | 60 static_library(static_library_name) { |
| 56 testonly = true | 61 testonly = true |
| 57 sources = invoker.static_library_sources | |
| 58 deps = invoker.deps | |
| 59 complete_static_lib = true | 62 complete_static_lib = true |
| 63 if (defined(invoker.static_library_sources)) { |
| 64 sources = invoker.static_library_sources |
| 65 } |
| 66 if (defined(invoker.deps)) { |
| 67 deps = invoker.deps |
| 68 } |
| 60 } | 69 } |
| 61 | 70 |
| 62 action(target_name) { | 71 action(target_name) { |
| 63 testonly = true | 72 testonly = true |
| 64 deps = [ | 73 deps = [ |
| 65 ":$static_library_name", | 74 ":$static_library_name", |
| 66 ] | 75 ] |
| 76 if (defined(invoker.deps)) { |
| 77 deps += invoker.deps |
| 78 } |
| 67 script = "//mojo/go/go.py" | 79 script = "//mojo/go/go.py" |
| 68 inputs = invoker.sources | 80 inputs = invoker.sources |
| 81 if (defined(invoker.inputs)) { |
| 82 inputs += invoker.inputs |
| 83 } |
| 69 outputs = [ | 84 outputs = [ |
| 70 "${target_out_dir}/${target_name}", | 85 "${target_out_dir}/${target_name}", |
| 71 ] | 86 ] |
| 72 | 87 |
| 73 # Since go test does not permit specifying an output directory or output | 88 # Since go test does not permit specifying an output directory or output |
| 74 # binary name, we create a temporary build directory, and the python | 89 # binary name, we create a temporary build directory, and the python |
| 75 # script will later identify the output, copy it to the target location, | 90 # script will later identify the output, copy it to the target location, |
| 76 # and clean up the temporary build directory. | 91 # and clean up the temporary build directory. |
| 77 build_dir = "${target_out_dir}/${target_name}_build" | 92 build_dir = "${target_out_dir}/${target_name}_build" |
| 78 args = [ | 93 args = [ |
| (...skipping 22 matching lines...) Expand all Loading... |
| 101 # | 116 # |
| 102 # Variables | 117 # Variables |
| 103 # sources: list of top-level .go files to compile (required) | 118 # sources: list of top-level .go files to compile (required) |
| 104 # inputs: list of files that are input dependencies. Use this to | 119 # inputs: list of files that are input dependencies. Use this to |
| 105 # specify your imported .go files. These files will not be | 120 # specify your imported .go files. These files will not be |
| 106 # specified in the command line to go build but they will cause | 121 # specified in the command line to go build but they will cause |
| 107 # a re-compile if they are touched. (optional) | 122 # a re-compile if they are touched. (optional) |
| 108 # static_library_sources: list of C sources needed for the static library | 123 # static_library_sources: list of C sources needed for the static library |
| 109 # (optional) | 124 # (optional) |
| 110 # deps: dependencies (optional) | 125 # deps: dependencies (optional) |
| 111 # deps: output_binary_name (optional) name to use for the generated binary. | 126 # output_binary_name: name to use for the generated binary. |
| 112 # If not provided the name ${target_name}_go will be used. | 127 # If not provided the name ${target_name}_go will be used. |
| 113 # Do not specify this to be equal to target_name or Ninja will | 128 # Do not specify this to be equal to target_name or Ninja will |
| 114 # give a warning about multiple targets generating the same output. | 129 # give a warning about multiple targets generating the same output. |
| 115 template("go_binary") { | 130 template("go_binary") { |
| 116 assert(is_linux) | 131 assert(is_linux) |
| 117 assert(defined(invoker.sources)) | 132 assert(defined(invoker.sources)) |
| 118 assert(go_build_tool != "") | 133 assert(go_build_tool != "") |
| 119 | 134 |
| 120 static_library_name = target_name + "_static_library" | 135 static_library_name = target_name + "_static_library" |
| 121 | 136 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 ":${go_library_name}", | 257 ":${go_library_name}", |
| 243 ] | 258 ] |
| 244 sources = [ | 259 sources = [ |
| 245 "${target_out_dir}/${go_library_name}", | 260 "${target_out_dir}/${go_library_name}", |
| 246 ] | 261 ] |
| 247 outputs = [ | 262 outputs = [ |
| 248 "${root_out_dir}/${target_name}.mojo", | 263 "${root_out_dir}/${target_name}.mojo", |
| 249 ] | 264 ] |
| 250 } | 265 } |
| 251 } | 266 } |
| OLD | NEW |