Index: mojo/public/tools/bindings/mojom.gni |
diff --git a/mojo/public/tools/bindings/mojom.gni b/mojo/public/tools/bindings/mojom.gni |
index 45ad58f64e19e1dc03b218fc79cb6b8fa3e2e8ff..d0de67a23838c011560a2cbd93f6f130aebbce8a 100644 |
--- a/mojo/public/tools/bindings/mojom.gni |
+++ b/mojo/public/tools/bindings/mojom.gni |
@@ -8,6 +8,12 @@ import("../../mojo_sdk.gni") |
# will go under the generated file directory tree with the same path as each |
# input file. |
# |
+# If a mojom target is intended for use in a client repo where the location of |
+# the Mojo SDK will be different than its location in the Mojo repo, |
+# dependencies on the SDK should be specified relative to the parent directory |
+# of the Mojo public SDK in |mojo_sdk_deps| rather than via absolute paths in |
+# |deps|. |
+# |
# Parameters: |
# |
# sources (required) |
@@ -16,9 +22,19 @@ import("../../mojo_sdk.gni") |
# deps (optional) |
# Note: this can contain only other mojom targets. |
# |
+# mojo_sdk_deps (optional) |
+# List of deps specified relative to the parent directory of the Mojo |
+# public SDK. These deps will be added as ordinary deps rebased to the |
+# current directory. |
+# |
# public_deps (optional) |
# Note: this can contain only other mojom targets. |
# |
+# mojo_sdk_public_deps (optional) |
+# List of public deps specified relative to the parent directory of the |
+# Mojo public SDK. These deps will be added as ordinary public deps |
+# rebased to the current directory. |
+# |
# testonly (optional) |
# |
# visibility (optional) |
@@ -104,6 +120,24 @@ template("mojom") { |
generator_python_outputs = |
[ "{{source_gen_dir}}/{{source_name_part}}_mojom.py" ] |
+ rebased_mojo_sdk_public_deps = [] |
+ if (defined(invoker.mojo_sdk_public_deps)) { |
+ foreach(sdk_dep, invoker.mojo_sdk_public_deps) { |
+ # Check that the SDK dep was not mistakenly given as an absolute path. |
+ assert(get_path_info(sdk_dep, "abspath") != sdk_dep) |
+ rebased_mojo_sdk_public_deps += [ rebase_path(sdk_dep, ".", mojo_root) ] |
+ } |
+ } |
+ |
+ rebased_mojo_sdk_deps = [] |
+ if (defined(invoker.mojo_sdk_deps)) { |
+ foreach(sdk_dep, invoker.mojo_sdk_deps) { |
+ # Check that the SDK dep was not mistakenly given as an absolute path. |
+ assert(get_path_info(sdk_dep, "abspath") != sdk_dep) |
+ rebased_mojo_sdk_deps += [ rebase_path(sdk_dep, ".", mojo_root) ] |
+ } |
+ } |
+ |
if (defined(invoker.visibility)) { |
# Need to save this because the the target_name is overwritten inside the |
# action to be that of the action itself. Only define this in the case the |
@@ -150,6 +184,7 @@ template("mojom") { |
rebase_path([ "mojo/public/build/config:mojo_sdk" ], ".", mojo_root) |
public_deps = rebase_path([ "mojo/public/cpp/bindings" ], ".", mojo_root) |
+ public_deps += rebased_mojo_sdk_public_deps |
if (defined(invoker.public_deps)) { |
public_deps += invoker.public_deps |
} |
@@ -157,12 +192,13 @@ template("mojom") { |
deps = [ |
":$generator_target_name", |
] |
+ deps += rebased_mojo_sdk_deps |
if (defined(invoker.deps)) { |
deps += invoker.deps |
} |
} |
- all_deps = [] |
+ all_deps = rebased_mojo_sdk_deps + rebased_mojo_sdk_public_deps |
if (defined(invoker.deps)) { |
all_deps += invoker.deps |
} |