Colin Blundell | 5baa5ac | 2014-12-08 14:13:02 +0100 | [diff] [blame] | 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 | import("../public/mojo_sdk.gni") |
Viet-Trung Luu | 3a02f15 | 2015-11-06 13:23:05 -0800 | [diff] [blame] | 6 | import("//testing/test.gni") |
Colin Blundell | 5baa5ac | 2014-12-08 14:13:02 +0100 | [diff] [blame] | 7 | |
| 8 | # A mojo_edk_source_set is a mojo_sdk_source_set that does not restrict |
| 9 | # external dependencies and understands the following additional variables, all |
| 10 | # of which admit a list of the relevant elements specified relative to the |
| 11 | # location of the Mojo EDK: |
| 12 | # mojo_edk_configs |
| 13 | # allow_circular_mojo_edk_includes_from |
| 14 | # mojo_edk_public_deps |
| 15 | # mojo_edk_deps |
| 16 | |
| 17 | # Note that it is assumed that the Mojo EDK is a sibling of the Mojo SDK in a |
| 18 | # client repo; the distinctions made above are for the sake of clarity in |
| 19 | # writing targets. |
| 20 | template("mojo_edk_source_set") { |
| 21 | mojo_sdk_source_set(target_name) { |
Viet-Trung Luu | b14defc | 2015-06-24 13:38:03 -0700 | [diff] [blame] | 22 | if (defined(invoker.public_deps) || defined(invoker.deps)) { |
| 23 | restrict_external_deps = false |
| 24 | } |
Colin Blundell | 4c3ffa2 | 2014-12-12 09:51:24 +0100 | [diff] [blame] | 25 | |
Colin Blundell | 5baa5ac | 2014-12-08 14:13:02 +0100 | [diff] [blame] | 26 | if (defined(invoker.visibility)) { |
| 27 | visibility = invoker.visibility |
| 28 | } |
| 29 | if (defined(invoker.mojo_edk_visibility)) { |
| 30 | mojo_sdk_visibility = invoker.mojo_edk_visibility |
| 31 | } |
| 32 | if (defined(invoker.testonly)) { |
| 33 | testonly = invoker.testonly |
| 34 | } |
| 35 | if (defined(invoker.sources)) { |
| 36 | sources = invoker.sources |
| 37 | } |
| 38 | if (defined(invoker.defines)) { |
| 39 | defines = invoker.defines |
| 40 | } |
| 41 | if (defined(invoker.public_configs)) { |
| 42 | public_configs = invoker.public_configs |
| 43 | } |
| 44 | |
| 45 | configs = [] |
| 46 | if (defined(invoker.configs)) { |
| 47 | configs = invoker.configs |
| 48 | } |
| 49 | if (defined(invoker.mojo_edk_configs)) { |
| 50 | foreach(edk_config, invoker.mojo_edk_configs) { |
| 51 | # Check that the EDK config was not mistakenly given as an absolute |
| 52 | # path. |
| 53 | assert(get_path_info(edk_config, "abspath") != edk_config) |
| 54 | configs += [ rebase_path(edk_config, ".", mojo_root) ] |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | allow_circular_includes_from = [] |
| 59 | if (defined(invoker.allow_circular_includes_from)) { |
| 60 | allow_circular_includes_from += invoker.allow_circular_includes_from |
| 61 | } |
| 62 | if (defined(invoker.allow_circular_mojo_edk_includes_from)) { |
| 63 | foreach(edk_target, invoker.allow_circular_mojo_edk_includes_from) { |
| 64 | # Check that the EDK target was not mistakenly given as an absolute |
| 65 | # path. |
| 66 | assert(get_path_info(edk_target, "abspath") != edk_target) |
Colin Blundell | 4c3ffa2 | 2014-12-12 09:51:24 +0100 | [diff] [blame] | 67 | allow_circular_includes_from += |
| 68 | [ rebase_path(edk_target, ".", mojo_root) ] |
Colin Blundell | 5baa5ac | 2014-12-08 14:13:02 +0100 | [diff] [blame] | 69 | } |
| 70 | } |
| 71 | |
| 72 | if (defined(invoker.public_deps)) { |
| 73 | public_deps = invoker.public_deps |
| 74 | } |
| 75 | mojo_sdk_public_deps = [] |
| 76 | if (defined(invoker.mojo_edk_public_deps)) { |
| 77 | # The EDK is required to be a sibling of the SDK, so the relative |
| 78 | # dependencies are rewritten in the same way. |
| 79 | mojo_sdk_public_deps = invoker.mojo_edk_public_deps |
| 80 | } |
| 81 | if (defined(invoker.mojo_sdk_public_deps)) { |
| 82 | mojo_sdk_public_deps += invoker.mojo_sdk_public_deps |
| 83 | } |
| 84 | |
| 85 | if (defined(invoker.deps)) { |
| 86 | deps = invoker.deps |
| 87 | } |
| 88 | mojo_sdk_deps = [] |
| 89 | if (defined(invoker.mojo_edk_deps)) { |
| 90 | # The EDK is required to be a sibling of the SDK, so the relative |
| 91 | # dependencies are rewritten in the same way. |
| 92 | mojo_sdk_deps = invoker.mojo_edk_deps |
| 93 | } |
| 94 | if (defined(invoker.mojo_sdk_deps)) { |
| 95 | mojo_sdk_deps += invoker.mojo_sdk_deps |
| 96 | } |
| 97 | } |
| 98 | } |
Viet-Trung Luu | 2ee13a9 | 2015-07-06 16:32:42 -0700 | [diff] [blame] | 99 | |
Viet-Trung Luu | 3a02f15 | 2015-11-06 13:23:05 -0800 | [diff] [blame] | 100 | template("mojo_edk_unittests") { |
| 101 | test(target_name) { |
| 102 | deps = [ |
| 103 | rebase_path("mojo/edk/system/test:run_all_unittests", ".", mojo_root), |
| 104 | ] |
| 105 | if (defined(invoker.sources)) { |
| 106 | sources = invoker.sources |
| 107 | } |
| 108 | if (defined(invoker.deps)) { |
| 109 | foreach(dep, invoker.deps) { |
| 110 | # The only deps that are not specified relative to the location of the |
| 111 | # Mojo EDK should be on targets within the same file or on a whitelisted |
| 112 | # set of external dependencies. |
| 113 | # TODO(vtl): Get rid of //base dependencies (and stop allowing it). |
| 114 | assert(get_path_info(dep, "dir") == "." || dep == "//testing/gtest" || |
| 115 | dep == "//base") |
| 116 | deps += [ dep ] |
| 117 | } |
| 118 | } |
| 119 | if (defined(invoker.mojo_sdk_deps)) { |
| 120 | foreach(sdk_dep, invoker.mojo_sdk_deps) { |
| 121 | # Check that the SDK dep was not mistakenly given as an absolute path. |
| 122 | assert(get_path_info(sdk_dep, "abspath") != sdk_dep) |
| 123 | deps += [ rebase_path(sdk_dep, ".", mojo_root) ] |
| 124 | } |
| 125 | } |
| 126 | if (defined(invoker.mojo_edk_deps)) { |
| 127 | foreach(edk_dep, invoker.mojo_edk_deps) { |
| 128 | # Check that the EDK dep was not mistakenly given as an absolute path. |
| 129 | assert(get_path_info(edk_dep, "abspath") != edk_dep) |
| 130 | deps += [ rebase_path(edk_dep, ".", mojo_root) ] |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | template("mojo_edk_perftests") { |
| 137 | test(target_name) { |
| 138 | deps = [ |
| 139 | rebase_path("mojo/edk/system/test:run_all_perftests", ".", mojo_root), |
| 140 | ] |
| 141 | if (defined(invoker.sources)) { |
| 142 | sources = invoker.sources |
| 143 | } |
| 144 | if (defined(invoker.deps)) { |
| 145 | foreach(dep, invoker.deps) { |
| 146 | # The only deps that are not specified relative to the location of the |
| 147 | # Mojo EDK should be on targets within the same file or on a whitelisted |
| 148 | # set of external dependencies. |
| 149 | # TODO(vtl): Get rid of //base dependencies (and stop allowing it). |
| 150 | assert(get_path_info(dep, "dir") == "." || dep == "//testing/gtest" || |
| 151 | dep == "//base") |
| 152 | deps += [ dep ] |
| 153 | } |
| 154 | } |
| 155 | if (defined(invoker.mojo_sdk_deps)) { |
| 156 | foreach(sdk_dep, invoker.mojo_sdk_deps) { |
| 157 | # Check that the SDK dep was not mistakenly given as an absolute path. |
| 158 | assert(get_path_info(sdk_dep, "abspath") != sdk_dep) |
| 159 | deps += [ rebase_path(sdk_dep, ".", mojo_root) ] |
| 160 | } |
| 161 | } |
| 162 | if (defined(invoker.mojo_edk_deps)) { |
| 163 | foreach(edk_dep, invoker.mojo_edk_deps) { |
| 164 | # Check that the EDK dep was not mistakenly given as an absolute path. |
| 165 | assert(get_path_info(edk_dep, "abspath") != edk_dep) |
| 166 | deps += [ rebase_path(edk_dep, ".", mojo_root) ] |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | |
Viet-Trung Luu | 2ee13a9 | 2015-07-06 16:32:42 -0700 | [diff] [blame] | 172 | # Build EDK things with static thread annotation analysis enabled. |
| 173 | # TODO(vtl): Should we set this at a higher level? |
| 174 | if (is_clang) { |
| 175 | cflags = [ "-Wthread-safety" ] |
| 176 | } |