diff --git a/.github/AGENT_INSTRUCTIONS.md b/.github/AGENT_INSTRUCTIONS.md index 4060ecf..8731bd2 100644 --- a/.github/AGENT_INSTRUCTIONS.md +++ b/.github/AGENT_INSTRUCTIONS.md @@ -5,7 +5,7 @@ This is the **Vector Bazel Rules** repository (`vectorgrp/bazel-rules` on GitHub), a comprehensive Bazel monorepo for developing, building, and managing custom Bazel rules and modules used across Vector projects. **Current Modules:** -- `rules_cfg5`, `rules_common`, `rules_davinci_developer`, `rules_davinci_project`, `rules_dvteam`, `rules_gradle`, `rules_ocs` +- `rules_cfg5`, `rules_common`, `rules_davinci_developer`, `rules_dvteam`, `rules_gradle`, `rules_ocs` ## Project Structure @@ -17,7 +17,7 @@ This is the **Vector Bazel Rules** repository (`vectorgrp/bazel-rules` on GitHub - Each module follows a standardized directory structure 2. **`bcr-modules/modules/`** - Individual module implementations - - Current modules: `rules_cfg5`, `rules_common`, `rules_davinci_developer`, `rules_davinci_project`, `rules_dvteam`, `rules_gradle`, `rules_ocs` + - Current modules: `rules_cfg5`, `rules_common`, `rules_davinci_developer`, `rules_dvteam`, `rules_gradle`, `rules_ocs` - **Note**: More modules will be added as migration progresses 3. **`bcr-modules/macros/`** - Automation macros diff --git a/.github/workflows/production-release.yml b/.github/workflows/production-release.yml index aab95f3..90a80fb 100644 --- a/.github/workflows/production-release.yml +++ b/.github/workflows/production-release.yml @@ -14,6 +14,7 @@ jobs: runs-on: ubuntu-latest permissions: contents: write # Required for creating releases + actions: write # Required for triggering workflows steps: - name: Checkout repository uses: actions/checkout@v4 @@ -84,7 +85,7 @@ jobs: echo "🚀 Uploading ${module_name} v${version} to production..." # Build the module archive - archive_path="bazel-bin/bcr-modules/modules/${module_name}/${version}/${module_name}.zip" + archive_path="bazel-bin/bcr-modules/modules/${module_name}/${version}/${module_name}.tar.gz" if [ ! -f "$archive_path" ]; then echo "❌ Archive not found: $archive_path" diff --git a/.github/workflows/registry-update.yml b/.github/workflows/registry-update.yml index 0bd2e57..ba710d8 100644 --- a/.github/workflows/registry-update.yml +++ b/.github/workflows/registry-update.yml @@ -90,8 +90,8 @@ jobs: - name: Push Registry Updates if: steps.check_changes.outputs.has_changes == 'true' run: | - git push origin main - echo "✅ Registry updates pushed to main branch" + git push origin HEAD + echo "✅ Registry updates pushed to current branch" - name: Summary run: | diff --git a/.github/workflows/staging-release.yml b/.github/workflows/staging-release.yml index 2bcdd29..c0ee785 100644 --- a/.github/workflows/staging-release.yml +++ b/.github/workflows/staging-release.yml @@ -74,7 +74,7 @@ jobs: echo "🚀 Uploading ${module_name} v${version} to staging..." # Build the module archive - archive_path="bazel-bin/bcr-modules/modules/${module_name}/${version}/${module_name}.zip" + archive_path="bazel-bin/bcr-modules/modules/${module_name}/${version}/${module_name}.tar.gz" if [ ! -f "$archive_path" ]; then echo "❌ Archive not found: $archive_path" diff --git a/bcr-modules/modules/rules_cfg5/0.0.2/BUILD.bazel b/bcr-modules/modules/rules_cfg5/0.0.2/BUILD.bazel index 621b761..2598e42 100644 --- a/bcr-modules/modules/rules_cfg5/0.0.2/BUILD.bazel +++ b/bcr-modules/modules/rules_cfg5/0.0.2/BUILD.bazel @@ -7,7 +7,6 @@ package(default_visibility = ["//visibility:public"]) module_upload( name = "upload", archive = ":rules_cfg5", - redeploy_if_exists = "true", upload_module_name = "rules_cfg5", version = "0.0.2", ) @@ -49,7 +48,6 @@ module( "bazel_skylib@1.7.1", "rules_common@0.0.1", ], - integrity = "sha256-4tI5CEYLVy+65imezH41J8SPZXo+VzcsUh9odv+FZRU=", module_version = "0.0.2", pkg_files_targets = [ "public", diff --git a/bcr-modules/modules/rules_common/0.2.0/BUILD.bazel b/bcr-modules/modules/rules_common/0.2.0/BUILD.bazel index 1943fd3..0ecc693 100644 --- a/bcr-modules/modules/rules_common/0.2.0/BUILD.bazel +++ b/bcr-modules/modules/rules_common/0.2.0/BUILD.bazel @@ -7,7 +7,6 @@ package(default_visibility = ["//visibility:public"]) module_upload( name = "upload", archive = ":rules_common", - redeploy_if_exists = "true", upload_module_name = "rules_common", version = "0.2.0", ) @@ -31,7 +30,6 @@ module( "ape@1.0.1", "bazel_skylib@1.7.1", ], - integrity = "sha256-Cc1zM2N1DR11kilDE4hIvSbD2Bpj2Z0wm1K30f56Pws=", module_version = "0.2.0", pkg_files_targets = [ "public", diff --git a/bcr-modules/modules/rules_davinci_developer/0.0.1/BUILD.bazel b/bcr-modules/modules/rules_davinci_developer/0.0.1/BUILD.bazel index 9ff11d9..c7f5312 100644 --- a/bcr-modules/modules/rules_davinci_developer/0.0.1/BUILD.bazel +++ b/bcr-modules/modules/rules_davinci_developer/0.0.1/BUILD.bazel @@ -7,7 +7,6 @@ package(default_visibility = ["//visibility:public"]) module_upload( name = "upload", archive = ":rules_davinci_developer", - redeploy_if_exists = "true", upload_module_name = "rules_davinci_developer", version = "0.0.1", ) @@ -24,7 +23,9 @@ pkg_files( module( name = "rules_davinci_developer", - integrity = "sha256-fmXY/e9BCbzNnWzei23U4TRH+GcbaJZ0EBxTjnvbKgU=", + additional_dependencies = [ + "rules_common@0.2.0", + ], module_version = "0.0.1", pkg_files_targets = [ "public", diff --git a/bcr-modules/modules/rules_davinci_project/0.0.1/BUILD.bazel b/bcr-modules/modules/rules_davinci_project/0.0.1/BUILD.bazel deleted file mode 100644 index 39c3f05..0000000 --- a/bcr-modules/modules/rules_davinci_project/0.0.1/BUILD.bazel +++ /dev/null @@ -1,44 +0,0 @@ -load("@rules_pkg//:mappings.bzl", "pkg_files") -load("//bcr-modules/macros:module_macro.bzl", "module") -load("//bcr-modules/macros:upload_macro.bzl", "module_upload") - -package(default_visibility = ["//visibility:public"]) - -module_upload( - name = "upload", - archive = ":rules_davinci_project", - redeploy_if_exists = "true", - upload_module_name = "rules_davinci_project", - version = "0.0.1", -) - -pkg_files( - name = "private_pydpa", - srcs = [ - "//bcr-modules/modules/rules_davinci_project/srcs/private/pydpa:BUILD.bazel", - "//bcr-modules/modules/rules_davinci_project/srcs/private/pydpa:pydpa.py", - ], - prefix = "private/pydpa", -) - -pkg_files( - name = "public", - srcs = [ - "//bcr-modules/modules/rules_davinci_project/srcs:BUILD.bazel", - "//bcr-modules/modules/rules_davinci_project/srcs:MODULE.bazel", - "//bcr-modules/modules/rules_davinci_project/srcs:rules.bzl", - ], -) - -module( - name = "rules_davinci_project", - additional_dependencies = [ - "rules_python@1.5.0", - ], - integrity = "", - module_version = "0.0.1", - pkg_files_targets = [ - "public", - "private_pydpa", - ], -) diff --git a/bcr-modules/modules/rules_davinci_project/0.0.2/BUILD.bazel b/bcr-modules/modules/rules_davinci_project/0.0.2/BUILD.bazel deleted file mode 100644 index e1b74cc..0000000 --- a/bcr-modules/modules/rules_davinci_project/0.0.2/BUILD.bazel +++ /dev/null @@ -1,78 +0,0 @@ -load("@rules_pkg//:mappings.bzl", "pkg_files") -load("//bcr-modules/macros:module_macro.bzl", "module") -load("//bcr-modules/macros:upload_macro.bzl", "module_upload") -load("//bcr-modules/rules:defs.bzl", "module_dot_bazel") - -package(default_visibility = ["//visibility:public"]) - -MODULE_NAME = "rules_davinci_project" - -MODULE_VERSION = "0.0.2" - -module_upload( - name = "upload", - archive = ":rules_davinci_project", - redeploy_if_exists = "true", - upload_module_name = MODULE_NAME, - version = MODULE_VERSION, -) - -pkg_files( - name = "private_pydpa", - srcs = [ - "//bcr-modules/modules/rules_davinci_project/srcs/private/pydpa:BUILD.bazel", - "//bcr-modules/modules/rules_davinci_project/srcs/private/pydpa:pydpa.py", - ], - prefix = "private/pydpa", -) - -pkg_files( - name = "templates", - srcs = [ - "//bcr-modules/modules/rules_davinci_project/srcs:templates/pydpa_script_linux.tpl", - "//bcr-modules/modules/rules_davinci_project/srcs:templates/pydpa_script_windows.tpl", - ], - prefix = "templates", -) - -pkg_files( - name = "public", - srcs = [ - ":module", - "//bcr-modules/modules/rules_davinci_project/srcs:BUILD.bazel", - "//bcr-modules/modules/rules_davinci_project/srcs:rules.bzl", - ], -) - -module_dot_bazel( - name = "module", - additional_dependencies = [ - "platforms@0.0.11", - "rules_python@1.5.0", - "ape@1.0.1", - ], - extra_content = """ -python = use_extension("@rules_python//python/extensions:python.bzl", "python") -python.toolchain( - is_default = True, - python_version = "3.13", -) -""", - module_name = MODULE_NAME, - module_version = MODULE_VERSION, -) - -module( - name = MODULE_NAME, - additional_dependencies = [ - "rules_python@1.5.0", - ], - integrity = "", - module_file = ":module", - module_version = MODULE_VERSION, - pkg_files_targets = [ - ":public", - ":templates", - ":private_pydpa", - ], -) diff --git a/bcr-modules/modules/rules_davinci_project/BUILD.bazel b/bcr-modules/modules/rules_davinci_project/BUILD.bazel deleted file mode 100644 index c4f1616..0000000 --- a/bcr-modules/modules/rules_davinci_project/BUILD.bazel +++ /dev/null @@ -1,12 +0,0 @@ -load("//bcr-modules/macros:add_module_macro.bzl", "module_bcr_dir") - -package(default_visibility = ["//visibility:public"]) - -module_bcr_dir( - name = "rules_davinci_project", - versions = [ - "0.0.1", - "0.0.2", - ], - visibility = ["//visibility:public"], -) diff --git a/bcr-modules/modules/rules_davinci_project/srcs/BUILD.bazel b/bcr-modules/modules/rules_davinci_project/srcs/BUILD.bazel deleted file mode 100644 index fe673dd..0000000 --- a/bcr-modules/modules/rules_davinci_project/srcs/BUILD.bazel +++ /dev/null @@ -1,48 +0,0 @@ -# MIT License - -# Copyright (c) 2025 Vector Group - -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: - -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -load("@bazel_skylib//:bzl_library.bzl", "bzl_library") - -exports_files( - [ - "MODULE.bazel", - "BUILD.bazel", - "rules.bzl", - "extensions.bzl", - "templates/pydpa_script_linux.tpl", - "templates/pydpa_script_windows.tpl", - ], -) - -bzl_library( - name = "rules", - srcs = [ - "rules.bzl", - "templates/pydpa_script_linux.tpl", - "templates/pydpa_script_windows.tpl", - "//bcr-modules/modules/rules_davinci_project/src/private/pydpa", - "//bcr-modules/modules/rules_davinci_project/src/private/pydpa:pydpa_lib", - ], - visibility = ["//visibility:public"], - deps = ["//rules/common:create_davinci_tool_workspace"], -) diff --git a/bcr-modules/modules/rules_davinci_project/srcs/private/pydpa/BUILD.bazel b/bcr-modules/modules/rules_davinci_project/srcs/private/pydpa/BUILD.bazel deleted file mode 100644 index 981dcbf..0000000 --- a/bcr-modules/modules/rules_davinci_project/srcs/private/pydpa/BUILD.bazel +++ /dev/null @@ -1,49 +0,0 @@ -# MIT License - -# Copyright (c) 2025 Vector Group - -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: - -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -load("@rules_python//python:defs.bzl", "py_binary", "py_library") - -exports_files( - [ - "BUILD.bazel", - "pydpa.py", - ], -) - -py_library( - name = "pydpa_lib", - srcs = ["pydpa.py"], - imports = [], - visibility = ["//visibility:public"], -) - -py_binary( - name = "pydpa", - srcs = [":pydpa_lib"], - imports = [], - precompile = "disabled", - python_version = "PY3", - srcs_version = "PY3", - visibility = ["//visibility:public"], - deps = [], -) diff --git a/bcr-modules/modules/rules_davinci_project/srcs/private/pydpa/pydpa.py b/bcr-modules/modules/rules_davinci_project/srcs/private/pydpa/pydpa.py deleted file mode 100644 index da78f3d..0000000 --- a/bcr-modules/modules/rules_davinci_project/srcs/private/pydpa/pydpa.py +++ /dev/null @@ -1,901 +0,0 @@ -# MIT License - -# Copyright (c) 2025 Vector Group - -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: - -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -import argparse -import json -import logging -import subprocess -import sys -import xml.etree.ElementTree as ET -from dataclasses import dataclass -from pathlib import Path, PurePosixPath, PureWindowsPath -from zipfile import ZipFile - - -class CFG5_EXEC_NAMES: - WIN_CMD = "DVCfgCmd.exe" - WIN_GUI = "DaVinciCFG.exe" - LIN_CMD = "DVCfgCmd" - LIN_GUI = "DaVinciCFG" - - -@dataclass -class Cfg5ManifestModel: - config_trace: dict - - @classmethod - def load_from_file(cls, manifest: Path): - return Cfg5ManifestModel(json.load(manifest)) - - -@dataclass -class Harmonizer: - xpath: str - - _LOGGER = logging.getLogger("Harmonizer") - - def harmonize(self, xml_root: ET.Element) -> list[tuple[Path, Path]]: - pass - - @staticmethod - def _clean_path(path: str) -> Path: - if "\\" in path: - # propably windows path - _cleaned_path = PureWindowsPath(path) - else: - _cleaned_path = PurePosixPath(path) - - # ToDo: check for remaining strange symbols - - return Path(_cleaned_path) - - -@dataclass -class FileHarmonizer(Harmonizer): - default_folder: Path - - _LOGGER = logging.getLogger("FileHarmonizer") - - def harmonize( - self, xml_root: ET.Element, base_path: Path - ) -> list[tuple[Path, Path]]: - source_dest_tuples = [] - for element in xml_root.findall(self.xpath): - base_source_path = base_path.joinpath(self.default_folder) - - source_path = self._clean_path(element.text) - if not source_path.is_absolute(): - source_path = base_path.joinpath(source_path).resolve() - - if source_path.is_relative_to(base_source_path): - dest_path = self.default_folder.joinpath( - source_path.relative_to(base_source_path) - ) - else: - dest_path = self.default_folder.joinpath(source_path.name) - - self._LOGGER.debug( - "Found %s entry with path: '%s' and target: '%s'", - element.tag, - source_path, - dest_path, - ) - - source_dest_tuples.append((source_path, dest_path)) - - element.text = dest_path.as_posix() - return source_dest_tuples - - -@dataclass -class FolderHarmonizer(Harmonizer): - default_folder: Path - - _LOGGER = logging.getLogger("FolderHarmonizer") - - def harmonize( - self, xml_root: ET.Element, base_path: Path - ) -> list[tuple[Path, Path]]: - source_dest_tuples = [] - for element in xml_root.findall(self.xpath): - base_source_path = base_path.joinpath(self.default_folder) - - source_path = self._clean_path(element.text) - if not source_path.is_absolute(): - source_path = base_path.joinpath(source_path).resolve() - - if source_path.is_relative_to(base_source_path): - dest_path = self.default_folder.joinpath( - source_path.relative_to(base_source_path) - ) - else: - dest_path = self.default_folder - - self._LOGGER.debug( - "Found %s entry with path: '%s' and target: '%s'", - element.tag, - source_path, - dest_path, - ) - - source_dest_tuples.append((source_path, dest_path)) - - element.text = dest_path.as_posix() - return source_dest_tuples - - -@dataclass -class SIPHarmonizer(Harmonizer): - sip_path: Path - - _LOGGER = logging.getLogger("SIPHarmonizer") - - def harmonize(self, xml_root: ET.Element): - element = xml_root.findall(self.xpath) - - if len(element) != 1: - return [] - - element = element[0] - - old_path = element.text - new_path = self.sip_path - - self._LOGGER.debug( - "Found %s entry with path: '%s' and target: '%s'", - element.tag, - old_path, - new_path, - ) - - element.text = new_path.as_posix() - return [(old_path, new_path)] - - -@dataclass -class DevWSHarmonizer(Harmonizer): - default_folder: Path - - _LOGGER = logging.getLogger("DevWSHarmonizer") - - def harmonize( - self, xml_root: ET.Element, base_path: Path - ) -> list[tuple[Path, Path]]: - elements = xml_root.findall(self.xpath) - - if len(elements) != 1: - return [] - - element = elements[0] - base_source_path = base_path.joinpath(self.default_folder) - - source_path = self._clean_path(element.text) - if not source_path.is_absolute(): - source_path = base_path.joinpath(source_path) - - if source_path.is_relative_to(base_source_path): - dest_path = self.default_folder.joinpath( - source_path.relative_to(base_source_path) - ) - else: - dest_path = self.default_folder.joinpath(source_path.name) - - element.text = dest_path.as_posix() - - return [(source_path.parent, dest_path.parent)] - - -@dataclass -class ToolHarmonizer(Harmonizer): - tool_path: Path - - _LOGGER = logging.getLogger("ToolHarmonizer") - - def harmonize(self, xml_root: ET.Element): - source_dest_tuples = [] - for element in xml_root.findall(self.xpath): - old_path = element.text - new_path = self.tool_path - - self._LOGGER.debug( - "Found %s entry with path: '%s' and target: '%s'", - element.tag, - old_path, - new_path, - ) - element.text = new_path.as_posix() - source_dest_tuples.append(old_path, new_path) - return source_dest_tuples - - -@dataclass -class SplitterHarmonizer(Harmonizer): - ecuc_folder: Path - - _LOGGER = logging.getLogger("SplitterHarmonizer") - - def harmonize(self, xml_root: ET.Element): - source_dest_tuples = [] - - for element in xml_root.findall(self.xpath): - old_path = self._clean_path(element.get("File")) - new_path = self.ecuc_folder.joinpath(old_path.name) - - self._LOGGER.debug( - "Found %s entry with path: '%s' and target: '%s'", - element.tag, - old_path, - new_path, - ) - element.text = new_path.as_posix() - source_dest_tuples.append(old_path, new_path) - return source_dest_tuples - - -class DPAProject: - """Class to represent a cfg5 project.""" - - name: str - dpa_file: Path - dpa_tree: ET.ElementTree - manifest: Cfg5ManifestModel - included_module_defs: list[str] - excluded_module_defs: list[str] - - _HARMONIZER_LIST = [ - FolderHarmonizer("./Folders/ECUC", Path("Config/ECUC")), - SplitterHarmonizer("./EcucSplitter/Splitter", Path("Config/ECUC")), - FileHarmonizer("./EcucSplitter/Configuration", Path("Config/ECUC")), - FolderHarmonizer("./Folders/GenData", Path("Appl/GenData")), - FolderHarmonizer("./Folders/GenDataVtt", Path("Appl/GenDataVtt")), - FolderHarmonizer("./Folders/Source", Path("Appl/Source")), - FolderHarmonizer( - "./Folders/ServiceComponents", Path("Config/ServiceComponents") - ), - FolderHarmonizer("./Folders/Logs", Path("Log")), - FolderHarmonizer( - "./Folders/BswInternalBehaviour", Path("Config/InternalBehavior") - ), - FolderHarmonizer("./Folders/McData", Path("Config/McData")), - FolderHarmonizer("./Folders/DefRestrict", Path("DefRestrict")), - FolderHarmonizer("./Folders/AUTOSAR", Path("Config/AUTOSAR")), - FolderHarmonizer( - "./Folders/ApplicationComponents/ApplicationComponent", - Path("Config/ApplicationComponents"), - ), - FolderHarmonizer( - "Folders/TimingExtensionFolders/TimingExtensionFolder", - Path("Config/TimingExtensions"), - ), - FolderHarmonizer("./Input/ECUEX", Path("Config/System")), - FileHarmonizer("./References/FlatMap", Path("Config/System")), - FileHarmonizer("./References/FlatECUEX", Path("Config/System")), - FolderHarmonizer("./References/VttProject", Path("Config/VTT")), - DevWSHarmonizer("./References/DVWorkspace", Path("Config/Developer")), - FolderHarmonizer( - "./Miscellaneous/A2LGenerator/A2LMasterFile", Path("Config/A2L") - ), - FolderHarmonizer( - "./References/EcucFileReferences/EcucFileReference", - Path("Config/EcucFileReferences"), - ), - ] - - _LOGGER = logging.getLogger("DPAProject") - - def __init__( - self, - name: str, - dpa_file: Path, - included_modules: list[str] = [], - excluded_modules: list[str] = [], - manifest: Path | None = None, - cfg5_base_dir: Path | None = None, - tool_dev: Path | None = None, - tool_vtt: Path | None = None, - cfg5_params_folder: Path | None = None, - ): - """Creates a DPAProject instance from a DPA file.""" - self._LOGGER.debug("Initializing DPAProject with name: %s", name) - self._LOGGER.debug("Resolving paths from DPA file %s", dpa_file) - self.name = name - - self.dpa_file = dpa_file.resolve() - self.dpa_tree = ET.parse(self.dpa_file) - - self._MODULE_DEFS = self._get_modules_list() - - self.included_module_defs = [ - self._MODULE_DEFS[mod] - for mod in included_modules - if mod in self._MODULE_DEFS - ] - - self.excluded_module_defs = [ - self._MODULE_DEFS[mod] - for mod in excluded_modules - if mod in self._MODULE_DEFS - ] - - if cfg5_base_dir is not None: - sip_path = self._resolve_cfg5_paths(cfg5_base_dir) - self._HARMONIZER_LIST.append(SIPHarmonizer("./Folders/SIP", sip_path)) - - if tool_dev is not None: - dev_path = self._resolve_tool_path(tool_dev) - self._HARMONIZER_LIST.append(ToolHarmonizer("./Tools/DEV", dev_path)) - - if tool_vtt is not None: - vtt_path = self._resolve_tool_path(tool_vtt) - self._HARMONIZER_LIST.append(ToolHarmonizer("./Tools/VTT", vtt_path)) - - if manifest is not None: - self.manifest = Cfg5ManifestModel.load_from_file(manifest) - - if cfg5_params_folder is None: - cfg5_params_folder = self.dpa_file.parent.joinpath(".cfg5").resolve() - else: - cfg5_params_folder = Path(cfg5_params_folder).resolve() - - self.cfg5_params_folder = cfg5_params_folder - - def _resolve_cfg5_paths(self, cfg5_base_dir: Path): - if not cfg5_base_dir.exists(): - raise FileNotFoundError( - f"Provided SIP path {cfg5_base_dir} does not exist." - ) - - self.cfg5_cmd_windows = cfg5_base_dir.joinpath(CFG5_EXEC_NAMES.WIN_CMD) - self.cfg5_gui_windows = cfg5_base_dir.joinpath(CFG5_EXEC_NAMES.WIN_GUI) - self.cfg5_cmd_linux = cfg5_base_dir.joinpath(CFG5_EXEC_NAMES.LIN_CMD) - - return cfg5_base_dir.resolve().parent - - def _resolve_tool_path(self, tool_path: Path): - if not tool_path.exists(): - if not self.dpa_file.joinpath(tool_path).exists(): - raise FileNotFoundError( - f"Provided tool path {tool_path} does not exist." - ) - tool_path = self.dpa_file.joinpath(tool_path) - return tool_path - - def _get_modules_list(self) -> dict[str, str]: - """Get the list of supported modules from the DPA file.""" - modules = {} - for module in self.dpa_tree.findall( - "./Display/ModuleDefinitionMappings/ModuleDefinitionMapping" - ): - modules[module.get("ModuleConfigName")] = module.get("ModuleDefinitionRef") - - return modules - - @classmethod - def from_archive( - cls, - name: str, - cfg5_project_zip: Path, - dpa_name: str, - workdir: Path, - included_modules: list[str] = [], - excluded_modules: list[str] = [], - cfg5_base_dir: Path | None = None, - tool_dev: Path | None = None, - tool_vtt: Path | None = None, - ): - """Creates a DPAProject instance from a cfg5 project zip file.""" - if not cfg5_project_zip.exists(): - raise FileNotFoundError( - f"Project zip file {cfg5_project_zip} does not exist." - ) - - with ZipFile(cfg5_project_zip, "r") as zip_ref: - zip_ref.extractall(workdir) - - cls._LOGGER.debug("Unzipped project to %s", workdir) - - dpa_path = workdir / dpa_name - if not dpa_path.exists(): - raise FileNotFoundError(f"DPA file {dpa_name} does not exist in the zip.") - - manifest_path = workdir / f"{name}.cfg5.manifest" - if not manifest_path.exists(): - manifest_path = None - - cfg5_params_folder = workdir / ".cfg5" - if not cfg5_params_folder.exists(): - cfg5_params_folder = None - - return cls( - name, - dpa_path, - included_modules, - excluded_modules, - manifest_path, - cfg5_base_dir, - tool_dev, - tool_vtt, - cfg5_params_folder, - ) - - def create_harmonized_zip(self, output_path: Path): - """Creates a harmonized zip file from current project setup.""" - - self._LOGGER.debug("Creating harmonized zip file at %s", output_path) - - with ZipFile(output_path, "w") as zip_file: - for harmonizer in self._HARMONIZER_LIST: - if isinstance(harmonizer, FolderHarmonizer) or isinstance( - harmonizer, DevWSHarmonizer - ): - source_dest_pairs = harmonizer.harmonize( - self.dpa_tree.getroot(), self.dpa_file.parent - ) - - for source, dest in source_dest_pairs: - for source_file in source.glob("**/*"): - if source_file.is_file(): - dest_file = dest.joinpath( - source_file.relative_to(source) - ) - zip_file.write( - source_file, - dest_file.as_posix(), - ) - elif isinstance(harmonizer, SIPHarmonizer) or isinstance( - harmonizer, ToolHarmonizer - ): - harmonizer.harmonize(self.dpa_tree.getroot()) - elif isinstance(harmonizer, FileHarmonizer): - source_dest_pairs = harmonizer.harmonize( - self.dpa_tree.getroot(), self.dpa_file.parent - ) - - for source, dest in source_dest_pairs: - zip_file.write(source, dest.as_posix()) - - zip_file.mkdir(".cfg5") - for file in self.cfg5_params_folder.glob("**/*"): - if file.is_file(): - dest_path = Path(".cfg5").joinpath( - file.relative_to(self.cfg5_params_folder) - ) - zip_file.write(file, dest_path.as_posix()) - - ET.indent(self.dpa_tree) - zip_file.writestr( - f"{self.dpa_file.name}", ET.tostring(self.dpa_tree.getroot()) - ) - - def _run_cfg5(self, command: str, args: list[str], gui: bool = False): - """Run the Cfg5 tool with the specified command and arguments.""" - - if sys.platform.startswith("win"): - executable = self.cfg5_cmd_windows if not gui else self.cfg5_gui_windows - else: - executable = self.cfg5_cmd_linux if not gui else None - - if not executable: - raise ValueError("Cfg5 executable path is not set.") - - cmd = [str(executable), command] + args - cmd += ["-configuration", str(self.cfg5_params_folder)] - self._LOGGER.debug("Running command: %s", " ".join(cmd)) - - def _process_log_output(): - while True: - output = process.stdout.readline().decode("utf-8").strip() - if output: - self._LOGGER.getChild(executable.name).debug(output) - else: - break - - process = subprocess.Popen( - cmd, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - ) - while process.poll() is None: - _process_log_output() - if process.returncode != 0: - raise subprocess.CalledProcessError(process.returncode, cmd) - - def _update_dpa_file(self): - for harmonizer in self._HARMONIZER_LIST: - if isinstance(harmonizer, FolderHarmonizer): - harmonizer.harmonize(self.dpa_tree.getroot(), self.dpa_file.parent) - elif isinstance(harmonizer, SIPHarmonizer) or isinstance( - harmonizer, ToolHarmonizer - ): - harmonizer.harmonize(self.dpa_tree.getroot()) - elif isinstance(harmonizer, FileHarmonizer): - harmonizer.harmonize(self.dpa_tree.getroot(), self.dpa_file.parent) - - ET.indent(self.dpa_tree) - self.dpa_tree.write(self.dpa_file) - - def generate_config(self, output_path: Path): - """Generate a Cfg5 project configuration.""" - - self._update_dpa_file() - - args = ["-p", str(self.dpa_file.resolve()), "-g", "--verbose"] - if len(self.included_module_defs) > 0: - args += ["--modulesToInclude", ",".join(self.included_module_defs)] - if len(self.excluded_module_defs) > 0: - args += ["--modulesToExclude", ",".join(self.excluded_module_defs)] - self._run_cfg5("generate", args) - - def run_gui(self): - command = "" - args = ["-p", str(self.dpa_file.resolve()), "--verbose"] - - self._run_cfg5(command=command, args=args, gui=True) - - -class CLI: - _OPTION_ARGUMENTS = { - "__COMMON__": { - "verbose": { - "default": False, - "help": "Enable verbose output.", - "action": "store_true", - }, - }, - "create_zip": { - "name": { - "type": str, - "help": "Name of the project.", - "required": True, - }, - "output": { - "type": Path, - "help": "The output zip file path.", - "required": True, - }, - "dpa": { - "type": Path, - "help": "Path to the DPA file.", - "required": True, - }, - "cfg5_base_dir": { - "type": Path, - "help": "Path to the MSR SIP.", - "required": False, - "default": None, - }, - "vtt": { - "type": Path, - "help": "Path to the vtt tool.", - "required": False, - "default": None, - }, - "developer": { - "type": Path, - "help": "Path to the developer tool.", - "required": False, - "default": None, - }, - "_call": "_call_create_zip", - }, - "generate": { - "name": { - "type": str, - "help": "Name of the project.", - "required": True, - }, - "output": { - "type": Path, - "help": "Folder to contain the outputs", - "required": True, - }, - "dpa": { - "type": Path, - "help": "Path to the DPA file.", - }, - "zip": { - "type": Path, - "help": "Path to the cfg5 project zip file.", - }, - "dpa_name": { - "type": str, - "help": "The name of the dpa file inside the zip.", - }, - "modules_to_include": { - "type": str, - "help": "Modules to include - multiple allowed", - "required": False, - "action": "append", - "default": [], - }, - "modules_to_exclude": { - "type": str, - "help": "Modules to exlcude - multiple allowed", - "required": False, - "action": "append", - "default": [], - }, - "cfg5_base_dir": { - "type": Path, - "help": "Path to the MSR SIP.", - "required": True, - }, - "vtt": { - "type": Path, - "help": "Path to the vtt tool.", - "required": False, - "default": None, - }, - "developer": { - "type": Path, - "help": "Path to the developer tool.", - "required": False, - "default": None, - }, - }, - "open": { - "name": { - "type": str, - "help": "Name of the project.", - "required": True, - }, - "output": { - "type": Path, - "help": "Folder to contain the outputs", - "required": False, - }, - "dpa": { - "type": Path, - "help": "Path to the DPA file.", - }, - "zip": { - "type": Path, - "help": "Path to the cfg5 project zip file.", - }, - "dpa_name": { - "type": str, - "help": "The name of the dpa file inside the zip.", - }, - "modules_to_include": { - "type": str, - "help": "Modules to include - multiple allowed", - "required": False, - "action": "append", - "default": [], - }, - "modules_to_exclude": { - "type": str, - "help": "Modules to exlcude - multiple allowed", - "required": False, - "action": "append", - "default": [], - }, - "cfg5_base_dir": { - "type": Path, - "help": "Path to the MSR SIP.", - "required": True, - }, - "vtt": { - "type": Path, - "help": "Path to the vtt tool.", - "required": False, - "default": None, - }, - "developer": { - "type": Path, - "help": "Path to the developer tool.", - "required": False, - "default": None, - }, - }, - } - - def _call_create_zip(self, args): - """Validate and Call the create_zip command.""" - if not args.name: - raise ValueError("Project name is required.") - if not args.output or not args.output.suffix == ".zip": - raise ValueError("Output must be a valid zip file path.") - if not args.dpa or not args.dpa.exists(): - raise ValueError("DPA file must be provided and must exist.") - project = DPAProject( - name=args.name, - dpa_file=args.dpa, - cfg5_base_dir=args.cfg5_base_dir, - tool_vtt=args.vtt, - tool_dev=args.developer, - ) - project.create_harmonized_zip(args.output) - - def _call_generate(self, args): - """Validate and Call the generate command.""" - if not args.name: - raise ValueError("Project name is required.") - if not args.cfg5_base_dir or not args.cfg5_base_dir.exists(): - raise ValueError("SIP path must be provided and must exist.") - if args.zip: - if not args.dpa_name: - raise ValueError( - "When loading from zip, the name of the dpa file has to be provided." - ) - cfg5_project_zip = Path(args.zip).resolve() - if not cfg5_project_zip.exists(): - raise FileNotFoundError( - f"Cfg5 project zip file does not exist: {cfg5_project_zip}" - ) - if not args.output: - raise ValueError("Output must be a valid directory path.") - args.output.mkdir(parents=True, exist_ok=True) - - project = DPAProject.from_archive( - name=args.name, - cfg5_project_zip=cfg5_project_zip, - dpa_name=args.dpa_name, - included_modules=args.modules_to_include, - excluded_modules=args.modules_to_exclude, - workdir=args.output, - cfg5_base_dir=args.cfg5_base_dir, - tool_vtt=args.vtt, - tool_dev=args.developer, - ) - elif args.dpa: - dpa_path = Path(args.dpa).resolve() - if not dpa_path.exists(): - raise FileNotFoundError(f"DPA file does not exist: {dpa_path}") - project = DPAProject( - name=args.name, - dpa_file=dpa_path, - included_modules=args.modules_to_include, - excluded_modules=args.modules_to_exclude, - cfg5_base_dir=args.cfg5_base_dir, - tool_vtt=args.vtt, - tool_dev=args.developer, - ) - else: - raise ValueError("Either DPA or zip file must be provided.") - - project.generate_config(args.output) - - def _call_open(self, args): - """Validate and Call the open command.""" - if not args.name: - raise ValueError("Project name is required.") - if not args.cfg5_base_dir or not args.cfg5_base_dir.exists(): - raise ValueError("SIP path must be provided and must exist.") - if not (args.dpa or args.zip): - raise ValueError("Either DPA or project zip file must be provided.") - if not args.zip: - raise ValueError("Running GUI is only supported using the zip.") - if not args.dpa_name: - raise ValueError( - "When loading from zip, the name of the dpa file has to be provided." - ) - cfg5_project_zip = Path(args.zip).resolve() - if not cfg5_project_zip.exists(): - raise FileNotFoundError( - f"Cfg5 project zip file does not exist: {cfg5_project_zip}" - ) - if not args.output: - raise ValueError("Output must be a valid directory path.") - args.output.mkdir(parents=True, exist_ok=True) - - project = DPAProject.from_archive( - name=args.name, - cfg5_project_zip=cfg5_project_zip, - dpa_name=args.dpa_name, - workdir=args.output, - cfg5_base_dir=args.cfg5_base_dir, - tool_vtt=args.vtt, - tool_dev=args.developer, - ) - - project.run_gui() - - def _parser_add_arguments(self, parser: argparse.ArgumentParser, command: str): - """Create a parser for a specific command.""" - for arg_name, arg_info in self._OPTION_ARGUMENTS[command].items(): - kwargs = {} - if "help" in arg_info: - kwargs["help"] = arg_info["help"] - if "type" in arg_info: - kwargs["type"] = arg_info["type"] - if "required" in arg_info: - kwargs["required"] = arg_info["required"] - if "default" in arg_info: - kwargs["default"] = arg_info["default"] - if "action" in arg_info: - kwargs["action"] = arg_info["action"] - kwargs["dest"] = arg_name - parser.add_argument(f"--{arg_name}", **kwargs) - return parser - - def _parse_args(self, args=None): - """Parse command line arguments.""" - parser = argparse.ArgumentParser(description="Handle Cfg5 projects.") - subparsers = parser.add_subparsers( - dest="command", title="command", required=True - ) - - # Create parsers for each command - for command in self._OPTION_ARGUMENTS.keys(): - if command == "__COMMON__": - self._parser_add_arguments(parser, command) - continue - else: - subparser = subparsers.add_parser( - command, help=f"Handle {command} command." - ) - self._parser_add_arguments(subparser, command) - self._parser_add_arguments(subparser, "__COMMON__") - - return parser.parse_args(args) - - def _setup_logging(self, verbose: bool): - """Setup logging configuration.""" - if verbose: - logging.basicConfig(level=logging.DEBUG) - else: - logging.basicConfig(level=logging.INFO) - self.logger = logging.getLogger(self.__class__.__name__) - return self.logger - - def run(self): - """Run the CLI with the provided arguments.""" - cmd_args = sys.argv[1:] - - if len(cmd_args) == 1: - # Try to find call config file - call_config = Path(cmd_args[0]).resolve() - if call_config.exists(): - print("Using arguments file: {call_config}") - cmd_args = call_config.read_text(encoding="utf-8").split() - - args = self._parse_args(cmd_args) - logger = self._setup_logging(args.verbose) - - logger.info("This is pydpa - the call wrapper for DaVinci Projects.") - logger.info(f"Current workdir: {Path.cwd()}") - - if args.command == "create_zip": - logger.info("Creating harmonized zip file...") - self._call_create_zip(args) - logger.info("Harmonized zip file created successfully.") - elif args.command == "generate": - logger.info("Generating Cfg5 project...") - self._call_generate(args) - logger.info("Cfg5 project generated successfully.") - elif args.command == "open": - logger.info("Opening Cfg5 project in GUI...") - self._call_open(args) - logger.info("Cfg5 project opened successfully.") - else: - logger.error(f"Unknown command: {args.command}") - - -def main(): - """Main entry point for the CLI.""" - cli = CLI() - cli.run() - - -if __name__ == "__main__": - main() diff --git a/bcr-modules/modules/rules_davinci_project/srcs/rules.bzl b/bcr-modules/modules/rules_davinci_project/srcs/rules.bzl deleted file mode 100644 index c418871..0000000 --- a/bcr-modules/modules/rules_davinci_project/srcs/rules.bzl +++ /dev/null @@ -1,261 +0,0 @@ -# MIT License - -# Copyright (c) 2025 Vector Group - -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: - -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -"""Defines DaVinci Project Rules and Providers""" - -DaVinciProjectInfo = provider( - doc = "Provides a DaVinci Project Info", - fields = { - "project_zip": "The path to the DaVinci project zip file", - "dpa_name": "Path inside the zip to the DPA file", - }, -) - -def _create_cfg5_gui_run_conf(ctx, project_name, project_zip, dpa_name): - """ Get all information from ctx to build cfg5 gui executable and collect all runfiles """ - is_windows = ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) - - wrapper_script = ctx.actions.declare_file(ctx.attr.name + (".bat" if is_windows else ".sh")) - pydpa_call_config = ctx.actions.declare_file("pydpa_call_config.manifest") - - # Create wrapper script - if is_windows: - template = ctx.file._pydpa_script_template_windows - else: - template = ctx.file._pydpa_script_template_linux - - ctx.actions.expand_template( - template = template, - output = wrapper_script, - is_executable = True, - substitutions = { - "executable": ctx.executable._pydpa.short_path, - "call_config_file": pydpa_call_config.short_path, - }, - ) - - runfiles_cfg5_base_dir = ctx.attr.configurator5[DefaultInfo].files.to_list()[0].short_path - runfiles_cfg5_base_dir = runfiles_cfg5_base_dir[:runfiles_cfg5_base_dir.rindex("/")] - - pydpa_call_config_content = "\n".join([ - "open", - "--name", - project_name, - "--zip", - project_zip.short_path, - "--dpa_name", - dpa_name, - "--output", - "somewhere", - "--cfg5_base_dir", - runfiles_cfg5_base_dir, - "--verbose", - ]) - - ctx.actions.write( - output = pydpa_call_config, - content = pydpa_call_config_content, - ) - - # Create runfiles - transitive_runfiles = [ctx.attr._pydpa.default_runfiles, ctx.attr.configurator5[DefaultInfo].default_runfiles] - runfiles = ctx.runfiles( - files = [ctx.executable._pydpa, pydpa_call_config, project_zip] + ctx.attr.configurator5[DefaultInfo].files.to_list(), - collect_default = True, - ).merge_all(transitive_runfiles) - - return wrapper_script, runfiles - -def _dpa_project_impl(ctx): - """Creates a DaVinci project from a given DPA file and configures the project folder structure.""" - - dpa_file = ctx.file.dpa_file - project_name = ctx.attr.name - - configurator5 = ctx.files.configurator5 - cfg5_base_dir = configurator5[0].dirname - - out_project_zip = ctx.actions.declare_file(ctx.attr.name + ".zip") - - args = ctx.actions.args() - args.add("create_zip") - args.add("--name", project_name) - args.add("--dpa", dpa_file) - args.add("--cfg5_base_dir", cfg5_base_dir) - args.add("--output", out_project_zip) - args.add("--verbose") - - ctx.actions.run( - inputs = [dpa_file] + configurator5, - outputs = [out_project_zip], - executable = ctx.executable._pydpa, - arguments = [args], - mnemonic = "DaVinciProject", - progress_message = "Creating DaVinci project from DPA file: {}".format(dpa_file.basename), - ) - - gui_exec, gui_runfiles = _create_cfg5_gui_run_conf(ctx, project_name, out_project_zip, dpa_file.basename) - - return [ - DefaultInfo( - executable = gui_exec, - runfiles = gui_runfiles, - ), - DaVinciProjectInfo( - project_zip = out_project_zip, - dpa_name = dpa_file.basename, - ), - ] - -dpa_project = rule( - implementation = _dpa_project_impl, - attrs = { - "_windows_constraint": attr.label( - default = "@platforms//os:windows", - ), - "_pydpa": attr.label( - default = Label("//private/pydpa"), - allow_files = True, - executable = True, - cfg = "exec", - ), - "_pydpa_lib": attr.label( - default = Label("//private/pydpa:pydpa_lib"), - ), - "_pydpa_script_template_windows": attr.label( - allow_single_file = [".tpl"], - default = Label("//:templates/pydpa_script_windows.tpl"), - ), - "_pydpa_script_template_linux": attr.label( - allow_single_file = [".tpl"], - default = Label("//:templates/pydpa_script_linux.tpl"), - ), - "dpa_file": attr.label( - allow_single_file = [".dpa"], - doc = "DaVinci project file", - mandatory = True, - ), - "configurator5": attr.label( - allow_files = True, - doc = "Configurator 5 target of a MSRC SIP", - ), - }, - toolchains = [ - "@rules_python//python:toolchain_type", - ], - executable = True, -) - -def _dpa_generate_impl(ctx): - """ Uses Cfg5 to generate the given DPA Project. """ - project_name = ctx.attr.name - - configurator5 = ctx.files.configurator5 - cfg5_base_dir = configurator5[0].dirname - - project_zip = ctx.attr.project[DaVinciProjectInfo].project_zip - project_zip_dpa_name = ctx.attr.project[DaVinciProjectInfo].dpa_name - - generate_input_files = [] - generate_input_files.append(project_zip) - generate_input_files.extend(configurator5) - - generate_output = ctx.actions.declare_directory(project_name) - - generate_args = ctx.actions.args() - generate_args.add("generate") - generate_args.add("--name", project_name) - generate_args.add("--zip", project_zip.path) - generate_args.add("--dpa_name", project_zip_dpa_name) - generate_args.add("--output", generate_output.path) - generate_args.add("--cfg5_base_dir", cfg5_base_dir) - generate_args.add("--verbose") - generate_args.add_all(ctx.attr.include_modules, before_each = "--modules_to_include") - generate_args.add_all(ctx.attr.exclude_modules, before_each = "--modules_to_exclude") - - ctx.actions.run( - inputs = depset(generate_input_files), - outputs = [generate_output], - executable = ctx.executable._pydpa, - arguments = [generate_args], - mnemonic = "DaVinciGenerate", - progress_message = "Generate DaVinci project : {}".format(project_zip.basename), - ) - - create_zip_output_zip = ctx.actions.declare_file(ctx.attr.name + ".zip") - - create_zip_args = ctx.actions.args() - create_zip_args.add("create_zip") - create_zip_args.add("--name", project_name) - create_zip_args.add("--dpa", generate_output.path + "/" + project_zip_dpa_name) - create_zip_args.add("--cfg5_base_dir", cfg5_base_dir) - create_zip_args.add("--output", create_zip_output_zip) - create_zip_args.add("--verbose") - - ctx.actions.run( - inputs = [generate_output], - outputs = [create_zip_output_zip], - executable = ctx.executable._pydpa, - arguments = [create_zip_args], - mnemonic = "DaVinciProject", - progress_message = "Creating DaVinci project zip: {}".format(project_zip_dpa_name), - ) - - return [ - DefaultInfo( - files = depset([generate_output]), - ), - DaVinciProjectInfo( - project_zip = create_zip_output_zip, - dpa_name = project_zip_dpa_name, - ), - ] - -dpa_generate = rule( - implementation = _dpa_generate_impl, - attrs = { - "_pydpa": attr.label( - default = Label("//rules/davinci_project/pydpa"), - allow_files = True, - doc = "The DPA parser tool for DaVinci projects", - executable = True, - cfg = "exec", - ), - "project": attr.label( - providers = [DaVinciProjectInfo], - doc = "The DaVinci project", - ), - "include_modules": attr.string_list( - default = [], - doc = "List of modules to include in generation", - ), - "exclude_modules": attr.string_list( - default = [], - doc = "List of modules to exclude from generation", - ), - "configurator5": attr.label( - allow_files = True, - doc = "Configurator 5 target of a MSRC SIP", - ), - }, -) diff --git a/bcr-modules/modules/rules_davinci_project/srcs/templates/pydpa_script_linux.tpl b/bcr-modules/modules/rules_davinci_project/srcs/templates/pydpa_script_linux.tpl deleted file mode 100644 index 7c89e74..0000000 --- a/bcr-modules/modules/rules_davinci_project/srcs/templates/pydpa_script_linux.tpl +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash - -# MIT License - -# Copyright (c) 2025 Vector Group - -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: - -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -set -e - -MANIFEST="${{BASH_SOURCE[0]}}.runfiles_manifest" -if [[ ! -f "$MANIFEST" ]]; then - MANIFEST="${{BASH_SOURCE[0]}}.runfiles/MANIFEST" -fi - -echo $MANIFEST -echo "$(pwd)" -echo "{executable}" - -EXECUTABLE="" -if [[ -f "$MANIFEST" ]]; then - EXECUTABLE=$(grep -m1 "{executable} " "$MANIFEST" | awk '{{print $2}}') -fi - -if [[ -z "$EXECUTABLE" ]]; then - echo "Could not find executable interpreter in runfiles manifest" - exit 1 -fi - -echo "$EXECUTABLE" {call_config_file} -"$EXECUTABLE" "{call_config_file}" \ No newline at end of file diff --git a/bcr-modules/modules/rules_davinci_project/srcs/templates/pydpa_script_windows.tpl b/bcr-modules/modules/rules_davinci_project/srcs/templates/pydpa_script_windows.tpl deleted file mode 100644 index 5965375..0000000 --- a/bcr-modules/modules/rules_davinci_project/srcs/templates/pydpa_script_windows.tpl +++ /dev/null @@ -1,37 +0,0 @@ -# MIT License - -# Copyright (c) 2025 Vector Group - -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: - -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -@echo off -setlocal -set MANIFEST=%~dpnx0.runfiles_manifest - -set EXECUTABLE= -for /f "tokens=2" %%a in ('findstr /r /c:"{executable} " "%MANIFEST%"') do set EXECUTABLE=%%a - -if "%EXECUTABLE%"=="" ( - echo Could not find executable interpreter in runfiles manifest - exit /b 1 -) - -echo %EXECUTABLE% {call_config_file} -"%EXECUTABLE%" {call_config_file} \ No newline at end of file diff --git a/bcr-modules/modules/rules_dvteam/0.0.1/BUILD.bazel b/bcr-modules/modules/rules_dvteam/0.0.1/BUILD.bazel index f74ae2c..4bf1ef7 100644 --- a/bcr-modules/modules/rules_dvteam/0.0.1/BUILD.bazel +++ b/bcr-modules/modules/rules_dvteam/0.0.1/BUILD.bazel @@ -7,7 +7,6 @@ package(default_visibility = ["//visibility:public"]) module_upload( name = "upload", archive = ":rules_dvteam", - redeploy_if_exists = "true", upload_module_name = "rules_dvteam", version = "0.0.1", ) @@ -38,7 +37,6 @@ module( "rules_gradle@0.0.1", "rules_davinci_developer@0.0.1", ], - integrity = "sha256-JRnEgM1HoQgwcKoiIHPkaPPlG7II7OaMZnIeX/HbMHY=", module_version = "0.0.1", pkg_files_targets = [ "public", diff --git a/bcr-modules/modules/rules_gradle/0.0.1/BUILD.bazel b/bcr-modules/modules/rules_gradle/0.0.1/BUILD.bazel index 3b25f39..18fba8c 100644 --- a/bcr-modules/modules/rules_gradle/0.0.1/BUILD.bazel +++ b/bcr-modules/modules/rules_gradle/0.0.1/BUILD.bazel @@ -7,7 +7,6 @@ package(default_visibility = ["//visibility:public"]) module_upload( name = "upload", archive = ":rules_gradle", - redeploy_if_exists = "true", upload_module_name = "rules_gradle", version = "0.0.1", ) @@ -32,7 +31,6 @@ pkg_files( module( name = "rules_gradle", - integrity = "sha256-LOvabek9xEA07uo9/lKLgImwOounM5K46rBAwujJCEs=", module_version = "0.0.1", pkg_files_targets = [ "public", diff --git a/bcr-modules/modules/rules_ocs/0.0.1/BUILD.bazel b/bcr-modules/modules/rules_ocs/0.0.1/BUILD.bazel index 248f1c7..a2624e9 100644 --- a/bcr-modules/modules/rules_ocs/0.0.1/BUILD.bazel +++ b/bcr-modules/modules/rules_ocs/0.0.1/BUILD.bazel @@ -7,7 +7,6 @@ package(default_visibility = ["//visibility:public"]) module_upload( name = "upload", archive = ":rules_ocs", - redeploy_if_exists = "true", upload_module_name = "rules_ocs", version = "0.0.1", ) @@ -38,7 +37,6 @@ module( "bazel_skylib@1.7.1", "rules_davinci_developer@0.0.1", ], - integrity = "sha256-ok95atZcc8sYQRCoV4eavjSWjwBV6WoULINvY0jbrxk=", module_version = "0.0.1", pkg_files_targets = [ "public", diff --git a/docs/creating-new-module.md b/docs/creating-new-module.md index 5d9d328..5f94cb8 100644 --- a/docs/creating-new-module.md +++ b/docs/creating-new-module.md @@ -57,7 +57,6 @@ package(default_visibility = ["//visibility:public"]) module_upload( name = "upload", archive = ":", - redeploy_if_exists = "true", upload_module_name = "", version = "0.0.1", ) @@ -238,4 +237,3 @@ Add the `integrity` attribute to your `module()` call to speed up future builds. - **Simple module**: `bcr-modules/modules/rules_common/` - **With private files**: `bcr-modules/modules/rules_dvteam/` -- **With templates**: `bcr-modules/modules/rules_davinci_project/` diff --git a/docs/getting-started.md b/docs/getting-started.md index 0ee81f0..2cbb779 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -399,7 +399,7 @@ ls -la vector-bazel-central-registry/modules// **Solution:** ```bash # Recalculate hash -sha256sum path/to/archive.zip +sha256sum path/to/archive.tar.gz # Update module definition # Remove integrity attribute temporarily if needed diff --git a/docs/updating-module-version.md b/docs/updating-module-version.md index fdaa043..a863fd7 100644 --- a/docs/updating-module-version.md +++ b/docs/updating-module-version.md @@ -35,7 +35,6 @@ package(default_visibility = ["//visibility:public"]) module_upload( name = "upload", archive = ":", - redeploy_if_exists = "true", upload_module_name = "", version = "0.0.2", # ← Update version ) diff --git a/tools/add_module.sh b/tools/add_module.sh old mode 100644 new mode 100755 diff --git a/tools/build_revisions_diff.sh b/tools/build_revisions_diff.sh old mode 100644 new mode 100755 diff --git a/tools/compare_modules.sh b/tools/compare_modules.sh old mode 100644 new mode 100755 diff --git a/tools/get_archive_override.sh b/tools/get_archive_override.sh old mode 100644 new mode 100755 index 4039cdb..3c21455 --- a/tools/get_archive_override.sh +++ b/tools/get_archive_override.sh @@ -8,7 +8,7 @@ archive_path=$2 # Copy archive_override to clipboard -folder_name=$(basename "$archive_path" .zip) +folder_name=$(basename "$archive_path" .tar.gz) sha256_hash=$(sha256sum "$archive_path" | cut -d ' ' -f 1) diff --git a/vector-bazel-central-registry/modules/rules_cfg5/0.0.2/source.json b/vector-bazel-central-registry/modules/rules_cfg5/0.0.2/source.json index 58022a3..a0dc04e 100644 --- a/vector-bazel-central-registry/modules/rules_cfg5/0.0.2/source.json +++ b/vector-bazel-central-registry/modules/rules_cfg5/0.0.2/source.json @@ -1,4 +1,4 @@ { - "url": "", - "integrity": "" + "url": "https://github.com/vectorgrp/bazel-rules/releases/download/rules_cfg5/0.0.2/rules_cfg5.tar.gz", + "integrity": "sha256:b004b2a9e54e9c2b3eafae7a169eaf9546c0869130676282a2adac29158acc8b" } diff --git a/vector-bazel-central-registry/modules/rules_common/0.2.0/source.json b/vector-bazel-central-registry/modules/rules_common/0.2.0/source.json index 58022a3..6dc8172 100644 --- a/vector-bazel-central-registry/modules/rules_common/0.2.0/source.json +++ b/vector-bazel-central-registry/modules/rules_common/0.2.0/source.json @@ -1,4 +1,4 @@ { - "url": "", - "integrity": "" + "url": "https://github.com/vectorgrp/bazel-rules/releases/download/rules_common/0.2.0/rules_common.tar.gz", + "integrity": "sha256:7bb625b033b0e7ab5934909ff4147f45c4c368c487ffa6d2c0b1a38997144340" } diff --git a/vector-bazel-central-registry/modules/rules_davinci_developer/0.0.1/source.json b/vector-bazel-central-registry/modules/rules_davinci_developer/0.0.1/source.json index 58022a3..449f088 100644 --- a/vector-bazel-central-registry/modules/rules_davinci_developer/0.0.1/source.json +++ b/vector-bazel-central-registry/modules/rules_davinci_developer/0.0.1/source.json @@ -1,4 +1,4 @@ { - "url": "", - "integrity": "" + "url": "https://github.com/vectorgrp/bazel-rules/releases/download/rules_davinci_developer/0.0.1/rules_davinci_developer.tar.gz", + "integrity": "sha256:59294f0a49b6f0c8bb210a9d1a5ac5833cd10b5b3a186d963b007fcb0bd97d55" } diff --git a/vector-bazel-central-registry/modules/rules_davinci_project/0.0.1/MODULE.bazel b/vector-bazel-central-registry/modules/rules_davinci_project/0.0.1/MODULE.bazel deleted file mode 100644 index 790a66e..0000000 --- a/vector-bazel-central-registry/modules/rules_davinci_project/0.0.1/MODULE.bazel +++ /dev/null @@ -1,7 +0,0 @@ -module( - name = "rules_davinci_project", - version = "0.0.1", - compatibility_level = 1, -) - -bazel_dep(name = "rules_python", version = "1.5.0") diff --git a/vector-bazel-central-registry/modules/rules_davinci_project/0.0.1/source.json b/vector-bazel-central-registry/modules/rules_davinci_project/0.0.1/source.json deleted file mode 100644 index 58022a3..0000000 --- a/vector-bazel-central-registry/modules/rules_davinci_project/0.0.1/source.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "", - "integrity": "" -} diff --git a/vector-bazel-central-registry/modules/rules_davinci_project/0.0.2/MODULE.bazel b/vector-bazel-central-registry/modules/rules_davinci_project/0.0.2/MODULE.bazel deleted file mode 100644 index fffd276..0000000 --- a/vector-bazel-central-registry/modules/rules_davinci_project/0.0.2/MODULE.bazel +++ /dev/null @@ -1,15 +0,0 @@ -module( - name = "rules_davinci_project", - version = "0.0.2", - compatibility_level = 1, -) - -bazel_dep(name = "platforms", version = "0.0.11") -bazel_dep(name = "rules_python", version = "1.5.0") -bazel_dep(name = "ape", version = "1.0.1") - -python = use_extension("@rules_python//python/extensions:python.bzl", "python") -python.toolchain( - is_default = True, - python_version = "3.13", -) diff --git a/vector-bazel-central-registry/modules/rules_davinci_project/0.0.2/source.json b/vector-bazel-central-registry/modules/rules_davinci_project/0.0.2/source.json deleted file mode 100644 index 58022a3..0000000 --- a/vector-bazel-central-registry/modules/rules_davinci_project/0.0.2/source.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "", - "integrity": "" -} diff --git a/vector-bazel-central-registry/modules/rules_davinci_project/metadata.json b/vector-bazel-central-registry/modules/rules_davinci_project/metadata.json deleted file mode 100644 index a9a35eb..0000000 --- a/vector-bazel-central-registry/modules/rules_davinci_project/metadata.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "homepage": "", - "maintainers": [], - "repository": [], - "versions": [ - "0.0.1", - "0.0.2" - ], - "yanked_versions": { } -} diff --git a/vector-bazel-central-registry/modules/rules_dvteam/0.0.1/source.json b/vector-bazel-central-registry/modules/rules_dvteam/0.0.1/source.json index 58022a3..73a0b2a 100644 --- a/vector-bazel-central-registry/modules/rules_dvteam/0.0.1/source.json +++ b/vector-bazel-central-registry/modules/rules_dvteam/0.0.1/source.json @@ -1,4 +1,4 @@ { - "url": "", - "integrity": "" + "url": "https://github.com/vectorgrp/bazel-rules/releases/download/rules_dvteam/0.0.1/rules_dvteam.tar.gz", + "integrity": "sha256:a1da91dec7666f7710a0eca2fea696e67dde86863ef2b2abae477df0694d2d9b" } diff --git a/vector-bazel-central-registry/modules/rules_gradle/0.0.1/source.json b/vector-bazel-central-registry/modules/rules_gradle/0.0.1/source.json index 58022a3..4ace14e 100644 --- a/vector-bazel-central-registry/modules/rules_gradle/0.0.1/source.json +++ b/vector-bazel-central-registry/modules/rules_gradle/0.0.1/source.json @@ -1,4 +1,4 @@ { - "url": "", - "integrity": "" + "url": "https://github.com/vectorgrp/bazel-rules/releases/download/rules_gradle/0.0.1/rules_gradle.tar.gz", + "integrity": "sha256:85bc1d74cb28fdfdf7e7c05181c91b7bc3b525294ed2841bd4ab92a9fe35b587" } diff --git a/vector-bazel-central-registry/modules/rules_ocs/0.0.1/source.json b/vector-bazel-central-registry/modules/rules_ocs/0.0.1/source.json index 58022a3..a449d21 100644 --- a/vector-bazel-central-registry/modules/rules_ocs/0.0.1/source.json +++ b/vector-bazel-central-registry/modules/rules_ocs/0.0.1/source.json @@ -1,4 +1,4 @@ { - "url": "", - "integrity": "" + "url": "https://github.com/vectorgrp/bazel-rules/releases/download/rules_ocs/0.0.1/rules_ocs.tar.gz", + "integrity": "sha256:def656c1dfc96dcf59f3996e42c3495a5da597ab7c14c8fe5c08bd3b6dbd5838" }