Skip to content

Commit

Permalink
Add support for hygienic
Browse files Browse the repository at this point in the history
  • Loading branch information
markbenvenuto committed Feb 6, 2020
1 parent f8849c5 commit a010fab
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def __init__(self, name, env):
self.unittest_shortcuts = {}
self.unittest_skipped_shortcuts = set()
self.setup_test_execution = not env.get('_NINJA_NO_TEST_EXECUTION', False)

self.init_idl_dependencies()
self.find_build_nodes()
self.find_aliases()
Expand Down Expand Up @@ -286,7 +286,7 @@ def add_run_test_builds(self):
# Rules for executing tests where added upstream, if they're enabled this method is a no-op
if not self.setup_test_execution:
return

# For everything that gets installed to build/unittests, add a rule for +basename
# that runs the test from its original location.
paths = (
Expand Down Expand Up @@ -473,13 +473,18 @@ def find_aliases(self):
# For some reason we sometimes define a task then alias it to itself.
continue

if not alias.has_builder():
# Hygienic mode produces empty aliases
continue

if alias.get_builder() == SCons.Environment.AliasBuilder:
# "pure" aliases
self.aliases[str(alias)] = [str(s) for s in alias.sources]
pass
else:
# Ignore these for now
assert (str(alias) in ('dist', 'lint'))
# aib targets are specific to hygienic
assert (str(alias) in ('dist', 'lint', 'list-aib-components', 'list-aib-targets'))

# Fix integration_tests alias to point to files rather than directories.
# TODO remove after CR merged
Expand Down Expand Up @@ -551,7 +556,6 @@ def find_build_nodes(self):
if isinstance(n, SCons.Node.FS.Dir): continue
if str(n.executor).startswith('write_uuid_to_file('): continue
if os.path.join('','sconf_temp','conftest') in str(n): continue
if str(n).startswith(os.path.join('build','install','')): continue

# We see each build task once per target, but we handle all targets the first time.
if id(n.executor) not in seen:
Expand Down Expand Up @@ -590,10 +594,16 @@ def handle_build_node(self, n):
# different ways in different places. For now, only support this usage.
assert len(n.executor.post_actions) == 1
assert len(n.executor.action_list) == 1
assert n.executor.action_list[0] == SCons.Tool.textfile._subst_builder.action
if str(n.executor.post_actions[0]) != 'chmod 755 $TARGET':
assert str(n.executor.post_actions[0]).startswith('Chmod(')
assert 'oug+x' in str(n.executor.post_actions[0])
if n.executor.action_list[0] == SCons.Tool.textfile._subst_builder.action:
if str(n.executor.post_actions[0]) != 'chmod 755 $TARGET':
assert str(n.executor.post_actions[0]).startswith('Chmod(')
assert 'oug+x' in str(n.executor.post_actions[0])
elif isinstance(n.executor.action_list[0], SCons.Action.FunctionAction):
if str(n.executor.post_actions[0]) != 'chmod 755 $TARGET':
assert str(n.executor.post_actions[0]).startswith('Chmod(')
assert 'oug+x' in str(n.executor.post_actions[0])
else:
raise ValueError("Unknown post action: %s" % (n.executor.action_list[0]))
n.executor.post_actions = []
do_chmod = True
else:
Expand All @@ -614,6 +624,12 @@ def handle_build_node(self, n):
sources = n.executor.get_all_sources()
implicit_deps = strmap(n.depends)

# Archives generated in hygienic defer their dependency generation so we need to call generator()
if isinstance(action, SCons.Action.CommandGeneratorAction) and \
"aib_make_archive.py" in str(n.executor):
cmd = action.generator(sources, targets, myEnv, for_signature=False)
n.executor.set_action_list([Action(cmd)])

for target in targets:
if target.always_build:
implicit_deps.append('_ALWAYS_BUILD')
Expand Down

0 comments on commit a010fab

Please sign in to comment.