Allow transitive dependencies for mojom targets
Bug: 822804 Change-Id: I188fcfad992c7508125bc1ca7d196bb086687f44 Reviewed-on: https://chromium-review.googlesource.com/c/1281886 Reviewed-by: Ken Rockot <rockot@google.com> Commit-Queue: Oksana Zhuravlova <oksamyt@chromium.org> Cr-Commit-Position: refs/heads/master@{#600580}
This commit is contained in:

committed by
Commit Bot

parent
52c7752191
commit
674715b721
mojo/public/tools/bindings
@ -444,7 +444,7 @@ template("mojom") {
|
||||
if (!defined(invoker.skip_deps_check) || !invoker.skip_deps_check) {
|
||||
verify_deps_target_name = "${target_name}__verify_deps"
|
||||
verify_deps_target_names += [ ":$verify_deps_target_name" ]
|
||||
source_file_name = target_name
|
||||
mojom_target_name = target_name
|
||||
|
||||
action(verify_deps_target_name) {
|
||||
script = mojom_generator_script
|
||||
@ -468,7 +468,7 @@ template("mojom") {
|
||||
"verify",
|
||||
"--filelist={{response_file_name}}",
|
||||
"-f",
|
||||
rebase_path("$target_gen_dir/$source_file_name.deps_sources_list",
|
||||
rebase_path("$target_gen_dir/$mojom_target_name.deps_sources_list",
|
||||
root_build_dir),
|
||||
"--gen_dir",
|
||||
rebase_path(root_gen_dir, root_build_dir),
|
||||
|
@ -326,6 +326,24 @@ def _Precompile(args, _):
|
||||
template_expander.PrecompileTemplates(generator_modules, args.output_dir)
|
||||
return 0
|
||||
|
||||
def GetSourcesList(target_prefix, sources_list, gen_dir):
|
||||
deps_list_path = target_prefix + ".deps_sources_list"
|
||||
f_deps_list = open(deps_list_path, 'r')
|
||||
for deps_sources_path in f_deps_list:
|
||||
target_name_with_dir = deps_sources_path.split(".sources_list")[0]
|
||||
if (target_name_with_dir == target_prefix):
|
||||
# add files from the target itself
|
||||
deps_sources_path = deps_sources_path.rstrip('\n')
|
||||
f_sources = open(deps_sources_path, 'r')
|
||||
for source_file in f_sources:
|
||||
full_source_path = os.path.dirname(target_name_with_dir.split(gen_dir \
|
||||
+ "/", 1)[1]) + "/" + source_file
|
||||
sources_list.add(full_source_path.rstrip('\n'))
|
||||
else:
|
||||
# recurse into target's dependencies to get their lists of files
|
||||
sources_list = GetSourcesList(target_name_with_dir, sources_list, gen_dir)
|
||||
return sources_list
|
||||
|
||||
def _VerifyImportDeps(args, __):
|
||||
fileutil.EnsureDirectoryExists(args.gen_dir)
|
||||
|
||||
@ -341,23 +359,20 @@ def _VerifyImportDeps(args, __):
|
||||
parsed_imp.import_filename for parsed_imp in tree.import_list
|
||||
)
|
||||
|
||||
# read the paths from the file
|
||||
f_deps = open(args.deps_file, 'r')
|
||||
deps_sources = set()
|
||||
for deps_path in f_deps:
|
||||
deps_path = deps_path.rstrip('\n')
|
||||
f_sources = open(deps_path, 'r')
|
||||
sources = set()
|
||||
|
||||
for source_file in f_sources:
|
||||
source_dir = deps_path.split(args.gen_dir + "/", 1)[1]
|
||||
full_source_path = os.path.dirname(source_dir) + "/" + \
|
||||
source_file
|
||||
deps_sources.add(full_source_path.rstrip('\n'))
|
||||
target_prefix = args.deps_file.split(".deps_sources_list")[0]
|
||||
sources = GetSourcesList(target_prefix, sources, args.gen_dir)
|
||||
|
||||
if (not deps_sources.issuperset(mojom_imports)):
|
||||
print ">>> [%s] Missing dependencies for the following imports: %s" % ( \
|
||||
args.filename[0], \
|
||||
list(mojom_imports.difference(deps_sources)))
|
||||
if (not sources.issuperset(mojom_imports)):
|
||||
target_name = target_prefix.rsplit("/", 1)[1]
|
||||
target_prefix_without_gen_dir = target_prefix.split(
|
||||
args.gen_dir + "/", 1)[1]
|
||||
full_target_name = "//" + target_prefix_without_gen_dir.rsplit(
|
||||
"/", 1)[0] + ":" + target_name
|
||||
print ">>> File \n\t%s\nfrom target \n\t%s\nis missing dependencies " + \
|
||||
"for the following imports:\n\t%s" % (args.filename[0], \
|
||||
full_target_name, list(mojom_imports.difference(sources)))
|
||||
sys.exit(1)
|
||||
|
||||
source_filename, _ = os.path.splitext(rel_path.relative_path())
|
||||
|
Reference in New Issue
Block a user