Commit c0c0f5cf authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook Github Bot

use the correct project-specific context when computing hashes

Summary:
Update `BuildOpts.compute_dirs()` to use the correct project-specific manifest
context when computing project hashes.  Previously it was incorrectly using
the initial project's context when evaluating all dependencies.  This would
result in some projects potentially seeing the wrong values for variables that
may change from project to project (like `test`).

Reviewed By: pkaush

Differential Revision: D16477398

fbshipit-source-id: 6c23f5e5e19b2402000a138b3920b79044446041
parent 4e2e55c6
......@@ -156,7 +156,7 @@ class ShowInstDirCmd(SubCmd):
for m in manifests:
ctx = ctx_gen.get_context(m.name)
fetcher = m.create_fetcher(opts, ctx)
dirs = opts.compute_dirs(m, fetcher, manifests_by_name, ctx)
dirs = opts.compute_dirs(m, fetcher, manifests_by_name, ctx_gen)
inst_dir = dirs["inst_dir"]
print(inst_dir)
......@@ -236,7 +236,7 @@ class BuildCmd(SubCmd):
if args.clean:
fetcher.clean()
dirs = opts.compute_dirs(m, fetcher, manifests_by_name, ctx)
dirs = opts.compute_dirs(m, fetcher, manifests_by_name, ctx_gen)
build_dir = dirs["build_dir"]
inst_dir = dirs["inst_dir"]
......@@ -331,7 +331,7 @@ class FixupDeps(SubCmd):
ctx = ctx_gen.get_context(m.name)
fetcher = m.create_fetcher(opts, ctx)
dirs = opts.compute_dirs(m, fetcher, manifests_by_name, ctx)
dirs = opts.compute_dirs(m, fetcher, manifests_by_name, ctx_gen)
inst_dir = dirs["inst_dir"]
install_dirs.append(inst_dir)
......@@ -388,7 +388,7 @@ class TestCmd(SubCmd):
ctx = ctx_gen.get_context(m.name)
fetcher = m.create_fetcher(opts, ctx)
dirs = opts.compute_dirs(m, fetcher, manifests_by_name, ctx)
dirs = opts.compute_dirs(m, fetcher, manifests_by_name, ctx_gen)
build_dir = dirs["build_dir"]
inst_dir = dirs["inst_dir"]
......
......@@ -148,7 +148,7 @@ class BuildOptions(object):
}
)
def _compute_hash(self, hash_by_name, manifest, manifests_by_name, ctx):
def _compute_hash(self, hash_by_name, manifest, manifests_by_name, ctx_gen):
""" This recursive function computes a hash for a given manifest.
The hash takes into account some environmental factors on the
host machine and includes the hashes of its dependencies.
......@@ -173,6 +173,7 @@ class BuildOptions(object):
for tool in ["cc", "c++", "gcc", "g++", "clang", "clang++"]:
env["tool-%s" % tool] = path_search(os.environ, tool)
ctx = ctx_gen.get_context(manifest.name)
fetcher = manifest.create_fetcher(self, ctx)
env["fetcher.hash"] = fetcher.hash()
......@@ -187,7 +188,7 @@ class BuildOptions(object):
dep_list = sorted(manifest.get_section_as_dict("dependencies", ctx).keys())
for dep in dep_list:
dep_hash = self._compute_hash(
hash_by_name, manifests_by_name[dep], manifests_by_name, ctx
hash_by_name, manifests_by_name[dep], manifests_by_name, ctx_gen
)
hasher.update(dep_hash.encode("utf-8"))
......@@ -203,9 +204,9 @@ class BuildOptions(object):
return h
def compute_dirs(self, manifest, fetcher, manifests_by_name, ctx):
def compute_dirs(self, manifest, fetcher, manifests_by_name, ctx_gen):
hash_by_name = {}
hash = self._compute_hash(hash_by_name, manifest, manifests_by_name, ctx)
hash = self._compute_hash(hash_by_name, manifest, manifests_by_name, ctx_gen)
if manifest.is_first_party_project():
directory = manifest.name
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment