Skip to content

Commit

Permalink
watchman: pass version info down to watchman build via environment
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wez authored and facebook-github-bot committed Oct 17, 2019
1 parent 8b0e801 commit d92ca2f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ set(WATCHMAN_VERSION_OVERRIDE "" CACHE STRING "Use this version code for \
Watchman instead of the default (${PACKAGE_VERSION})")
if (WATCHMAN_VERSION_OVERRIDE)
set(PACKAGE_VERSION "${WATCHMAN_VERSION_OVERRIDE}")
elseif(DEFINED ENV{WATCHMAN_VERSION_OVERRIDE})
set(PACKAGE_VERSION "$ENV{WATCHMAN_VERSION_OVERRIDE}")
endif ()

set(PACKAGE_NAME "watchman")
Expand Down
5 changes: 4 additions & 1 deletion build/fbcode_builder/getdeps/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ def _compute_project_hash(self, manifest):
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 = {}
Expand All @@ -272,6 +274,8 @@ def _compute_project_hash(self, manifest):
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()
Expand All @@ -282,7 +286,6 @@ def _compute_project_hash(self, manifest):
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())
Expand Down
1 change: 1 addition & 0 deletions build/fbcode_builder/getdeps/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
},
},
"dependencies": {"optional_section": True, "allow_values": False},
"depends.environment": {"optional_section": True},
"git": {
"optional_section": True,
"fields": {"repo_url": REQUIRED, "rev": OPTIONAL, "depth": OPTIONAL},
Expand Down
3 changes: 3 additions & 0 deletions build/fbcode_builder/manifests/watchman
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d92ca2f

Please sign in to comment.