watchman: pass version info down to watchman build via environment

Summary:
This diff allows passing a watchman version number override
via the environment as well as via the cmake `WATCHMAN_VERSION_OVERRIDE`
option.

To help invalidate the build I've added a new section to the manifest
files that allows listing out additional env vars that the project
hashes should be sensitive to.  The effect of this is that we'll
re-run the cmake configure step if the listed env vars are changed.

Reviewed By: Ben0mega

Differential Revision: D17865896

fbshipit-source-id: 8ea5572b0b9b7af95ec5c310e494cb17a139ced4
This commit is contained in:
Wez Furlong 2019-10-17 02:17:45 -07:00 committed by Facebook Github Bot
parent 38a7106453
commit 39cb261ced
3 changed files with 8 additions and 1 deletions

View File

@ -260,6 +260,8 @@ class ManifestLoader(object):
No caching of the computation is performed, which is theoretically
wasteful but the computation is fast enough that it is not required
to cache across multiple invocations. """
ctx = self.ctx_gen.get_context(manifest.name)
hasher = hashlib.sha256()
# Some environmental and configuration things matter
env = {}
@ -272,6 +274,8 @@ class ManifestLoader(object):
env[name] = os.environ.get(name)
for tool in ["cc", "c++", "gcc", "g++", "clang", "clang++"]:
env["tool-%s" % tool] = path_search(os.environ, tool)
for name in manifest.get_section_as_args("depends.environment", ctx):
env[name] = os.environ.get(name)
fetcher = self.create_fetcher(manifest)
env["fetcher.hash"] = fetcher.hash()
@ -282,7 +286,6 @@ class ManifestLoader(object):
if value is not None:
hasher.update(value.encode("utf-8"))
ctx = self.ctx_gen.get_context(manifest.name)
manifest.update_hash(hasher, ctx)
dep_list = sorted(manifest.get_section_as_dict("dependencies", ctx).keys())

View File

@ -49,6 +49,7 @@ SCHEMA = {
},
},
"dependencies": {"optional_section": True, "allow_values": False},
"depends.environment": {"optional_section": True},
"git": {
"optional_section": True,
"fields": {"repo_url": REQUIRED, "rev": OPTIONAL, "depth": OPTIONAL},

View File

@ -34,3 +34,6 @@ ENABLE_EDEN_SUPPORT=ON
WATCHMAN_STATE_DIR=/opt/facebook/watchman/var/run/watchman
# tell cmake not to try to create /opt/facebook/...
INSTALL_WATCHMAN_STATE_DIR=OFF
[depends.environment]
WATCHMAN_VERSION_OVERRIDE