diff options
author | Jack Rosenthal <jrosenth@chromium.org> | 2021-11-18 21:07:26 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-22 21:20:44 +0000 |
commit | 961062d7f72dd5b2bee75c013f03d7c0a47291bf (patch) | |
tree | 36aafb57b927016deb83a510206f4c87f3f54e30 | |
parent | 788b7337a474e84aef8c8cff019d54c04f6c3b63 (diff) | |
download | chrome-ec-961062d7f72dd5b2bee75c013f03d7c0a47291bf.tar.gz |
zephyr: zmake: Drop support for per-project zephyr versioning
This drops all support for projects to specify which zephyr version
they use. Zmake no longer cares what Zephyr version you give it: it
will simply use whatever's passed for --zephyr-base and be happy with
it.
This intentionally hard-codes the checkout path to the v2.7 branch as
the Zephyr version used to de-couple from the cutover to the main
branch. The follow up CL actually switches to the main branch. (This
is, more or less, just self-contained preparatory work in zmake for the
transition to main.)
BUG=b:205884929
BRANCH=none
TEST=unit tests pass
TEST=https://gitlab.com/zephyr-ec/ec/-/pipelines/412252730
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Change-Id: I9f8e28cec6466c666862c8f46f1608625a3ec53f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3296530
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
-rw-r--r-- | .gitlab-ci.yml | 23 | ||||
-rw-r--r-- | zephyr/zmake/tests/test_project.py | 3 | ||||
-rw-r--r-- | zephyr/zmake/tests/test_toolchains.py | 1 | ||||
-rw-r--r-- | zephyr/zmake/tests/test_version.py | 1 | ||||
-rw-r--r-- | zephyr/zmake/tests/test_zmake.py | 3 | ||||
-rw-r--r-- | zephyr/zmake/zmake/__main__.py | 10 | ||||
-rw-r--r-- | zephyr/zmake/zmake/project.py | 1 | ||||
-rw-r--r-- | zephyr/zmake/zmake/util.py | 30 | ||||
-rw-r--r-- | zephyr/zmake/zmake/zmake.py | 53 |
9 files changed, 19 insertions, 106 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 92a039a1bd..bd77d308cd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,7 +24,7 @@ cache: - .cache/pip - venv/ - modules/ - - zephyr/main + - zephyr/ # The directory structure is: @@ -34,11 +34,9 @@ cache: before_script: - export MODULES_DIR="$CI_PROJECT_DIR/modules" - mkdir -p "${MODULES_DIR}" - - export ZEPHYR_ROOT="$CI_PROJECT_DIR/zephyr/main" - - mkdir -p "${ZEPHYR_ROOT}" - - test -d "${ZEPHYR_ROOT}/v2.6" || git clone --depth 1 -b chromeos-v2.6 https://chromium.googlesource.com/chromiumos/third_party/zephyr "${ZEPHYR_ROOT}/v2.6" - - test -d "${ZEPHYR_ROOT}/v2.7" || git clone --depth 1 -b chromeos-v2.7 https://chromium.googlesource.com/chromiumos/third_party/zephyr "${ZEPHYR_ROOT}/v2.7" - - test -d "${ZEPHYR_ROOT}/v2.8" || git clone --depth 1 -b chromeos-v2.8 https://chromium.googlesource.com/chromiumos/third_party/zephyr "${ZEPHYR_ROOT}/v2.8" + - export ZEPHYR_BASE="${CI_PROJECT_DIR}/zephyr/main" + - mkdir -p "${ZEPHYR_BASE}" + - test -d "${ZEPHYR_BASE}/.git" || git clone --depth 1 -b chromeos-v2.7 https://chromium.googlesource.com/chromiumos/third_party/zephyr "${ZEPHYR_BASE}" - test -d "${MODULES_DIR}/cmsis" || git clone --depth 1 -b chromeos-main https://chromium.googlesource.com/chromiumos/third_party/zephyr/cmsis "${MODULES_DIR}/cmsis" - test -d "${MODULES_DIR}/hal_stm32" || git clone --depth 1 -b chromeos-main https://chromium.googlesource.com/chromiumos/third_party/zephyr/hal_stm32 "${MODULES_DIR}/hal_stm32" - test -d "${MODULES_DIR}/nanopb" || git clone --depth 1 -b main https://chromium.googlesource.com/chromiumos/third_party/zephyr/nanopb "${MODULES_DIR}/nanopb" @@ -48,7 +46,6 @@ before_script: - python3 -m pip install zephyr/zmake --user - python3 -m pip install pyyaml - export BUILD_DIR=build - - export ZEPHYR_DIR=/zephyr - export PATH="$PATH:$HOME/.local/bin" - export PYTHONIOENCODING=utf-8 - export EC_DIR=/builds/zephyr-ec/ec @@ -62,10 +59,10 @@ seed_cache: - .cache/pip - venv/ - modules/ - - zephyr/main + - zephyr/ policy: push script: - - ls "${MODULES_DIR}" "${ZEPHYR_ROOT}" + - ls "${MODULES_DIR}" "${ZEPHYR_BASE}" # Users of this template must set: # $PROJECT to the project to build. E.g., "lazor" @@ -73,7 +70,7 @@ seed_cache: stage: build needs: ["seed_cache"] script: - - zmake --zephyr-root "${ZEPHYR_ROOT}" + - zmake --zephyr-base "${ZEPHYR_BASE}" --modules-dir "${MODULES_DIR}" -l DEBUG configure -b -B "${BUILD_DIR}/${PROJECT}" -t ${TOOLCHAIN:-zephyr} "${PROJECT}" @@ -170,7 +167,7 @@ zephyr_coverage: stage: test needs: ["seed_cache"] script: - - zmake --zephyr-root "${ZEPHYR_ROOT}" + - zmake --zephyr-base "${ZEPHYR_BASE}" --modules-dir "${MODULES_DIR}" -l DEBUG coverage "${BUILD_DIR}/zcoverage" artifacts: @@ -185,7 +182,7 @@ merged_coverage: needs: ["ec_coverage", "zephyr_coverage"] script: - lcov -o build/merged.info -a build/coverage/lcov.info -a build/zcoverage/lcov.info - - lcov -o build/merged_no_zephyr.info -r build/merged.info "${ZEPHYR_ROOT}/*" "${MODULES_DIR}/*" "zephyr/drivers/*" '/usr/include/x86_64-linux-gnu/*' + - lcov -o build/merged_no_zephyr.info -r build/merged.info "${ZEPHYR_BASE}/*" "${MODULES_DIR}/*" "zephyr/drivers/*" '/usr/include/x86_64-linux-gnu/*' artifacts: paths: - build/*.info @@ -197,6 +194,6 @@ testall: stage: test needs: ["seed_cache"] script: - - zmake --zephyr-root "${ZEPHYR_ROOT}" + - zmake --zephyr-base "${ZEPHYR_BASE}" --modules-dir "${MODULES_DIR}" -l DEBUG testall diff --git a/zephyr/zmake/tests/test_project.py b/zephyr/zmake/tests/test_project.py index 4d9994a108..f7688784e7 100644 --- a/zephyr/zmake/tests/test_project.py +++ b/zephyr/zmake/tests/test_project.py @@ -58,7 +58,6 @@ def test_find_dts_overlays(modules): zephyr_board=board, output_packer=zmake.output_packers.ElfPacker, supported_toolchains=["llvm"], - zephyr_version="v2.7", project_dir=pathlib.Path("/fakebuild"), ) ) @@ -93,7 +92,6 @@ def test_prune_modules(modules): zephyr_board="native_posix", output_packer=zmake.output_packers.ElfPacker, supported_toolchains=["coreboot-sdk"], - zephyr_version="v2.7", project_dir=pathlib.Path("/fake"), modules=modules, ), @@ -116,7 +114,6 @@ def test_prune_modules_unavailable(): zephyr_board="native_posix", output_packer=zmake.output_packers.ElfPacker, supported_toolchains=["coreboot-sdk"], - zephyr_version="v2.7", project_dir=pathlib.Path("/fake"), modules=["hal_stm32", "cmsis"], ), diff --git a/zephyr/zmake/tests/test_toolchains.py b/zephyr/zmake/tests/test_toolchains.py index 09d37c4c4e..fb1953052a 100644 --- a/zephyr/zmake/tests/test_toolchains.py +++ b/zephyr/zmake/tests/test_toolchains.py @@ -66,7 +66,6 @@ def fake_project(tmp_path): project.ProjectConfig( project_name="foo", zephyr_board="foo", - zephyr_version="v2.6", supported_toolchains=[ "coreboot-sdk", "host", diff --git a/zephyr/zmake/tests/test_version.py b/zephyr/zmake/tests/test_version.py index cbc1ceff88..b2c6b43fec 100644 --- a/zephyr/zmake/tests/test_version.py +++ b/zephyr/zmake/tests/test_version.py @@ -57,7 +57,6 @@ def _setup_example_repos(tmp_path): zephyr_board="foo", output_packer=zmake.output_packers.RawBinPacker, supported_toolchains=["coreboot-sdk"], - zephyr_version="v2.6", project_dir=project_path, ), ) diff --git a/zephyr/zmake/tests/test_zmake.py b/zephyr/zmake/tests/test_zmake.py index 589ee72c66..f735d942ed 100644 --- a/zephyr/zmake/tests/test_zmake.py +++ b/zephyr/zmake/tests/test_zmake.py @@ -39,7 +39,6 @@ class FakeProject: project_name="fakeproject", zephyr_board="fakeboard", supported_toolchains=["llvm"], - zephyr_version="v2.5", output_packer=zmake.output_packers.ElfPacker, project_dir=pathlib.Path("FakeProjectDir"), ) @@ -129,12 +128,10 @@ def do_test_with_log_level(log_level, use_configure=False, fnames=None): re.compile(r".*build-rw"): get_test_filepath("rw"), } zephyr_base = mock.Mock() - zephyr_root = mock.Mock() zmk = zm.Zmake( jobserver=FakeJobserver(fnames), zephyr_base=zephyr_base, - zephyr_root=zephyr_root, ) with LogCapture(level=log_level) as cap: diff --git a/zephyr/zmake/zmake/__main__.py b/zephyr/zmake/zmake/__main__.py index f776c1dbaa..aef897d1d3 100644 --- a/zephyr/zmake/zmake/__main__.py +++ b/zephyr/zmake/zmake/__main__.py @@ -161,21 +161,11 @@ def main(argv=None): parser.add_argument( "--zephyr-base", type=pathlib.Path, help="Path to Zephyr OS repository" ) - parser.add_argument( - "--zephyr-root", - type=pathlib.Path, - help="Path to Zephyr OS repos, must contain subdirs like v1.2", - ) sub = parser.add_subparsers(dest="subcommand", help="Subcommand") sub.required = True configure = sub.add_parser("configure") - configure.add_argument( - "--ignore-unsupported-zephyr-version", - action="store_true", - help="Don't warn about using an unsupported Zephyr version", - ) configure.add_argument("-t", "--toolchain", help="Name of toolchain to use") configure.add_argument( "--bringup", diff --git a/zephyr/zmake/zmake/project.py b/zephyr/zmake/zmake/project.py index de3bc8413b..0e2e97fd14 100644 --- a/zephyr/zmake/zmake/project.py +++ b/zephyr/zmake/zmake/project.py @@ -91,7 +91,6 @@ class ProjectConfig: zephyr_board: str supported_toolchains: "list[str]" output_packer: type - zephyr_version: str = dataclasses.field(default="v2.7") modules: "list[str]" = dataclasses.field( default_factory=lambda: modules.known_modules, ) diff --git a/zephyr/zmake/zmake/util.py b/zephyr/zmake/zmake/util.py index ca75f1b55e..ee3b245b78 100644 --- a/zephyr/zmake/zmake/util.py +++ b/zephyr/zmake/zmake/util.py @@ -64,19 +64,6 @@ def locate_cros_checkout(): raise FileNotFoundError("Unable to locate a ChromiumOS checkout") -def locate_zephyr_base(zephyr_root, version): - """Locate the path to the Zephyr RTOS in a ChromiumOS checkout. - - Args: - checkout: The path to the ChromiumOS checkout. - version: The requested zephyr version, as a tuple of integers. - - Returns: - The path to the Zephyr source. - """ - return zephyr_root / "v{}.{}".format(*version[:2]) - - def read_kconfig_file(path): """Parse a Kconfig file. @@ -132,23 +119,6 @@ def write_kconfig_file(path, config, only_if_changed=True): f.write("{}={}\n".format(name, value)) -def parse_zephyr_version(version_string): - """Parse a human-readable version string (e.g., "v2.4") as a tuple. - - Args: - version_string: The human-readable version string. - - Returns: - A 2-tuple or 3-tuple of integers representing the version. - """ - match = re.fullmatch(r"v?(\d+)[._](\d+)(?:[._](\d+))?", version_string) - if not match: - raise ValueError( - "{} does not look like a Zephyr version.".format(version_string) - ) - return tuple(int(x) for x in match.groups() if x is not None) - - def read_zephyr_version(zephyr_base): """Read the Zephyr version from a Zephyr OS checkout. diff --git a/zephyr/zmake/zmake/zmake.py b/zephyr/zmake/zmake/zmake.py index 8fc9542dca..d2559a9270 100644 --- a/zephyr/zmake/zmake/zmake.py +++ b/zephyr/zmake/zmake/zmake.py @@ -153,16 +153,17 @@ class Zmake: jobs=0, modules_dir=None, zephyr_base=None, - zephyr_root=None, ): zmake.multiproc.reset() self._checkout = checkout - self._zephyr_base = zephyr_base - if zephyr_root: - self._zephyr_root = zephyr_root + if zephyr_base: + self.zephyr_base = zephyr_base else: - self._zephyr_root = ( - self.checkout / "src" / "third_party" / "zephyr" / "main" + # TODO(b/205884929): Drop v2.7 from path. This is + # intentionally hard-coded here as an intermediate step to + # cutting over to the main branch. + self.zephyr_base = ( + self.checkout / "src" / "third_party" / "zephyr" / "main" / "v2.7" ) if modules_dir: @@ -188,28 +189,11 @@ class Zmake: self._checkout = util.locate_cros_checkout() return self._checkout.resolve() - def locate_zephyr_base(self, version): - """Locate the Zephyr OS repository. - - Args: - version: If a Zephyr OS base was not supplied to Zmake, - which version to search for as a tuple of integers. - This argument is ignored if a Zephyr base was supplied - to Zmake. - Returns: - A pathlib.Path to the found Zephyr OS repository. - """ - if self._zephyr_base: - return self._zephyr_base - - return util.locate_zephyr_base(self._zephyr_root, version) - def configure( self, project_name_or_dir, build_dir=None, toolchain=None, - ignore_unsupported_zephyr_version=False, build_after_configure=False, test_after_configure=False, bringup=False, @@ -234,7 +218,6 @@ class Zmake: project=project, build_dir=build_dir, toolchain=toolchain, - ignore_unsupported_zephyr_version=ignore_unsupported_zephyr_version, build_after_configure=build_after_configure, test_after_configure=test_after_configure, bringup=bringup, @@ -247,7 +230,6 @@ class Zmake: project, build_dir=None, toolchain=None, - ignore_unsupported_zephyr_version=False, build_after_configure=False, test_after_configure=False, bringup=False, @@ -255,23 +237,6 @@ class Zmake: allow_warnings=False, ): """Set up a build directory to later be built by "zmake build".""" - supported_version = util.parse_zephyr_version(project.config.zephyr_version) - zephyr_base = self.locate_zephyr_base(supported_version).resolve() - - # Ignore the patchset from the Zephyr version. - zephyr_version = util.read_zephyr_version(zephyr_base)[:2] - - if ( - not ignore_unsupported_zephyr_version - and zephyr_version != supported_version - ): - raise ValueError( - "The Zephyr OS version (v{}.{}) is not supported by the " - "project. You may wish to either configure BUILD.py to " - "support this version, or pass " - "--ignore-unsupported-zephyr-version.".format(*zephyr_version) - ) - # Resolve build_dir if needed. if not build_dir: build_dir = ( @@ -287,7 +252,7 @@ class Zmake: generated_include_dir = (build_dir / "include").resolve() base_config = zmake.build_config.BuildConfig( - environ_defs={"ZEPHYR_BASE": str(zephyr_base), "PATH": "/usr/bin"}, + environ_defs={"ZEPHYR_BASE": str(self.zephyr_base), "PATH": "/usr/bin"}, cmake_defs={ "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", "DTS_ROOT": str(self.module_paths["ec"] / "zephyr"), @@ -307,7 +272,7 @@ class Zmake: # Symlink the Zephyr base into the build directory so it can # be used in the build phase. - util.update_symlink(zephyr_base, build_dir / "zephyr_base") + util.update_symlink(self.zephyr_base, build_dir / "zephyr_base") dts_overlay_config = project.find_dts_overlays(module_paths) |