Skip to content

Commit

Permalink
pw_env_setup: Add relative_pigweed_root to pigweed.json
Browse files Browse the repository at this point in the history
Bug: b/300632028
Change-Id: Ib3ba7b98fbbdb05d10dac4611ae30fa5b27eab57
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/171218
Reviewed-by: Ted Pudlik <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
Pigweed-Auto-Submit: Rob Mohr <[email protected]>
Presubmit-Verified: CQ Bot Account <[email protected]>
  • Loading branch information
mohrr authored and CQ Bot Account committed Sep 15, 2023
1 parent 4b9353e commit 2f69ffa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions pigweed.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
},
"pw_env_setup": {
"root_variable": "PW_ROOT",
"relative_pigweed_root": ".",
"rosetta": "allow",
"gni_file": "build_overrides/pigweed_environment.gni",
"cipd_package_files": [
Expand Down
5 changes: 5 additions & 0 deletions pw_env_setup/docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ here.
use ``PW_PROJECT_ROOT`` instead. (That variable will be set regardless of
whether this is provided.)

``pw.pw_env_setup.relative_pigweed_root``
Location of the Pigweed submodule within the source tree. Optional—environment
setup will work correctly without this. If present, will confirm that it's
correct. May be used by other tooling.

``pw.pw_env_setup.cipd_package_files``
CIPD package file. JSON file consisting of a list of additional CIPD package
files to import and a list of dictionaries with "path", "platforms", "subdir",
Expand Down
14 changes: 14 additions & 0 deletions pw_env_setup/py/pw_env_setup/env_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,20 @@ def _parse_config_file(self, config_file):

self._root_variable = config.pop('root_variable', None)

# This variable is not used by env setup since we already have it.
# However, other tools may use it, so we double-check that it's correct.
pigweed_root = os.path.join(
self._project_root,
config.pop('relative_pigweed_root', self._pw_root),
)
if os.path.abspath(self._pw_root) != os.path.abspath(pigweed_root):
raise ValueError(
'expected Pigweed root {!r} in config but found {!r}'.format(
os.path.relpath(self._pw_root, self._project_root),
os.path.relpath(pigweed_root, self._project_root),
)
)

rosetta = config.pop('rosetta', 'allow')
if rosetta not in ('never', 'allow', 'force'):
raise ValueError(rosetta)
Expand Down

0 comments on commit 2f69ffa

Please sign in to comment.