| 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 # The absolute path to the directory containing the mojo public SDK (i.e., the | |
| 6 # directory containing mojo/public). The build files within the Mojo public | |
| 7 # SDK use this variable to allow themselves to be parameterized by the location | |
| 8 # of the public SDK within a client repo. | |
| 9 mojo_root = get_path_info("../..", "abspath") | |
| 10 | |
| 11 # Takes as input a "source_set" that includes dependencies that are relative to | |
| 12 # the parent directory of the Mojo public SDK (given in |mojo_sdk_deps|). | |
| 13 # Generates a source_set that has the mojo_sdk_deps added as ordinary deps | |
| 14 # rebased to the current directory. | |
| 15 # By default, restricts the entries that are given in invoker.deps and | |
| 16 # invoker.public_deps to be only within the same file and on a small set of | |
| 17 # whitelisted external dependencies. This check can be elided by setting | |
| 18 # restrict_external_deps to false in the invoker. DO NOT DO THIS in | |
| 19 # //mojo/public. | |
| 20 # | |
| 21 # Example of a mojo_sdk_source_set: | |
| 22 # | |
| 23 # mojo_sdk_source_set("foo") { | |
| 24 # sources = [ | |
| 25 # "foo.h", | |
| 26 # "foo.cc", | |
| 27 # ] | |
| 28 # | |
| 29 # # Same-file deps are specified in the ordinary way. Any external | |
| 30 # dependencies are specified the same way (although in general there should | |
| 31 # be very few of these). | |
| 32 # deps = [ | |
| 33 # ":bar", | |
| 34 # ] | |
| 35 # | |
| 36 # # Mojo SDK deps are specified relative to the containing directory of the | |
| 37 # SDK via mojo_sdk_deps. | |
| 38 # mojo_sdk_deps = [ | |
| 39 # "mojo/public/cpp/bindings", | |
| 40 # "mojo/public/cpp/environment", | |
| 41 # "mojo/public/cpp/system", | |
| 42 # ] | |
| 43 # } | |
| 44 # | |
| 45 template("mojo_sdk_source_set") { | |
| 46 source_set(target_name) { | |
| 47 forward_variables_from(invoker, | |
| 48 [ | |
| 49 "visibility", | |
| 50 "testonly", | |
| 51 "sources", | |
| 52 "defines", | |
| 53 "libs", | |
| 54 "allow_circular_includes_from", | |
| 55 "cflags", | |
| 56 "cflags_c", | |
| 57 "cflags_cc", | |
| 58 ]) | |
| 59 | |
| 60 if (!defined(visibility)) { | |
| 61 visibility = [ "*" ] | |
| 62 } | |
| 63 | |
| 64 if (defined(invoker.mojo_sdk_visibility)) { | |
| 65 foreach(sdk_target, invoker.mojo_sdk_visibility) { | |
| 66 # Check that the SDK target was not mistakenly given as an absolute | |
| 67 # path. | |
| 68 assert(get_path_info(sdk_target, "abspath") != sdk_target) | |
| 69 visibility += [ rebase_path(sdk_target, ".", mojo_root) ] | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 public_configs = | |
| 74 [ rebase_path("mojo/public/build/config:mojo_sdk", ".", mojo_root) ] | |
| 75 if (defined(invoker.public_configs)) { | |
| 76 public_configs += invoker.public_configs | |
| 77 } | |
| 78 | |
| 79 if (defined(invoker.configs)) { | |
| 80 configs += invoker.configs | |
| 81 } | |
| 82 | |
| 83 if (defined(invoker.public_deps) || defined(invoker.deps)) { | |
| 84 restrict_external_deps = true | |
| 85 if (defined(invoker.restrict_external_deps)) { | |
| 86 restrict_external_deps = invoker.restrict_external_deps | |
| 87 } | |
| 88 } | |
| 89 | |
| 90 public_deps = [] | |
| 91 if (defined(invoker.public_deps)) { | |
| 92 foreach(dep, invoker.public_deps) { | |
| 93 if (restrict_external_deps) { | |
| 94 # The only deps that are not specified relative to the location of | |
| 95 # the Mojo SDK should be on targets within the same file or on a | |
| 96 # whitelisted set of external dependencies. | |
| 97 assert(get_path_info(dep, "dir") == ".") | |
| 98 } | |
| 99 public_deps += [ dep ] | |
| 100 } | |
| 101 } | |
| 102 if (defined(invoker.mojo_sdk_public_deps)) { | |
| 103 foreach(sdk_dep, invoker.mojo_sdk_public_deps) { | |
| 104 # Check that the SDK dep was not mistakenly given as an absolute path. | |
| 105 assert(get_path_info(sdk_dep, "abspath") != sdk_dep) | |
| 106 public_deps += [ rebase_path(sdk_dep, ".", mojo_root) ] | |
| 107 } | |
| 108 } | |
| 109 | |
| 110 deps = [] | |
| 111 if (defined(invoker.deps)) { | |
| 112 foreach(dep, invoker.deps) { | |
| 113 if (restrict_external_deps) { | |
| 114 # The only deps that are not specified relative to the location of | |
| 115 # the Mojo SDK should be on targets within the same file or on a | |
| 116 # whitelisted set of external dependencies. | |
| 117 dep_dir = get_path_info(dep, "dir") | |
| 118 assert(dep_dir == "." || (dep == "//dart/runtime:libdart" && | |
| 119 target_name == "mojo_internal_impl")) | |
| 120 } | |
| 121 deps += [ dep ] | |
| 122 } | |
| 123 } | |
| 124 if (defined(invoker.mojo_sdk_deps)) { | |
| 125 foreach(sdk_dep, invoker.mojo_sdk_deps) { | |
| 126 # Check that the SDK dep was not mistakenly given as an absolute path. | |
| 127 assert(get_path_info(sdk_dep, "abspath") != sdk_dep) | |
| 128 deps += [ rebase_path(sdk_dep, ".", mojo_root) ] | |
| 129 } | |
| 130 } | |
| 131 } | |
| 132 } | |
| OLD | NEW |