Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 1 | # Copyright (C) 2019 The Android Open Source Project |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | import("perfetto.gni") |
| 16 | |
| 17 | # A template to make host tools handier. The main problem it solves is that when |
| 18 | # building host toolchain tools on an Android build, the executables end up in |
| 19 | # out/xxx/gcc_like_host, which is an inconvenient location. Our developers |
| 20 | # (and also some of our scripts) expect them to live in out/xxx/. |
| 21 | # This template takes care takes care of building the target only on the host |
| 22 | # toolchain and copy it over in the root build directory. |
| 23 | template("perfetto_host_executable") { |
Primiano Tucci | f0d7ef8 | 2019-10-04 15:35:24 +0100 | [diff] [blame] | 24 | if (current_toolchain == host_toolchain) { |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 25 | executable(target_name) { |
Primiano Tucci | 5cbeadf | 2020-04-03 22:28:40 +0100 | [diff] [blame] | 26 | if (defined(invoker.configs)) { |
| 27 | configs += invoker.configs |
| 28 | } |
| 29 | forward_variables_from(invoker, "*", [ "configs" ]) |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 30 | } |
| 31 | } else { |
Primiano Tucci | f0d7ef8 | 2019-10-04 15:35:24 +0100 | [diff] [blame] | 32 | not_needed(invoker, "*", [ "testonly" ]) |
| 33 | _host_target = ":$target_name($host_toolchain)" |
| 34 | _testonly = defined(invoker.testonly) && invoker.testonly |
Mikhail Khokhlov | 7866872 | 2019-12-20 10:26:19 +0000 | [diff] [blame] | 35 | if ((perfetto_build_with_embedder && !build_with_chromium) || |
| 36 | is_perfetto_build_generator) { |
| 37 | # Don't copy anything in V8 and other GN embedder builds, just add a |
| 38 | # dependency to the host target. This causes problems on some bots. |
| 39 | # (See crbug.com/1002599). |
Primiano Tucci | f0d7ef8 | 2019-10-04 15:35:24 +0100 | [diff] [blame] | 40 | group(target_name) { |
| 41 | testonly = _testonly |
Primiano Tucci | 2925e9d | 2020-01-27 10:15:58 +0000 | [diff] [blame] | 42 | deps = [ _host_target ] |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 43 | } |
| 44 | } else { |
Primiano Tucci | f0d7ef8 | 2019-10-04 15:35:24 +0100 | [diff] [blame] | 45 | copy(target_name) { |
| 46 | testonly = _testonly |
Primiano Tucci | 2925e9d | 2020-01-27 10:15:58 +0000 | [diff] [blame] | 47 | deps = [ _host_target ] |
Primiano Tucci | f0d7ef8 | 2019-10-04 15:35:24 +0100 | [diff] [blame] | 48 | _host_out_dir = get_label_info(_host_target, "root_out_dir") |
Mikhail Khokhlov | 7866872 | 2019-12-20 10:26:19 +0000 | [diff] [blame] | 49 | _extension = "" |
| 50 | if (host_os == "win") { |
| 51 | _extension = ".exe" |
| 52 | } |
Primiano Tucci | 2925e9d | 2020-01-27 10:15:58 +0000 | [diff] [blame] | 53 | sources = [ "$_host_out_dir/$target_name${_extension}" ] |
| 54 | outputs = [ "$root_out_dir/$target_name${_extension}" ] |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 55 | } |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 56 | } |
Primiano Tucci | f0d7ef8 | 2019-10-04 15:35:24 +0100 | [diff] [blame] | 57 | } |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 58 | } |