From fbe23ee45f64090c8ec80144c089211459b9a6fa Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 30 Apr 2023 16:53:43 -0500 Subject: [PATCH] Optionals - Load dynamically based on presence of mod (`__has_include`) (#9116) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Optionals - Load dynamically * Update XEH_preStart.sqf * Update pboproject.yml * Update script_macros.hpp * use addon.toml for hemtt * Update pboproject.yml * update all actions ref Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16: actions/checkout@v2, actions/upload-artifact@v2. * Update arma.yml * Update arma.yml * Update arma.yml * Update arma.yml * Update arma.yml * Update arma.yml * Apply suggestions from code review Co-authored-by: Björn Dahlgren * Update settings.json * cleanup interm hemtt changes * Update .github/workflows/arma.yml * Apply suggestions from code review Co-authored-by: jonpas --------- Co-authored-by: Björn Dahlgren Co-authored-by: jonpas --- .github/workflows/pboproject.yml | 14 +++++++------- addons/common/XEH_preStart.sqf | 7 +++++++ {optionals => addons}/compat_ws/$PBOPREFIX$ | 0 {optionals => addons}/compat_ws/CfgWeapons.hpp | 0 addons/compat_ws/addon.toml | 1 + {optionals => addons}/compat_ws/config.cpp | 10 ++++++++++ .../compat_ws/script_component.hpp | 0 addons/main/script_macros.hpp | 15 +++++++++++++++ tools/.vscode/settings.json | 6 ++++++ tools/.vscode/tasks.json | 8 +++++--- tools/make.py | 14 +++++++++++--- tools/sqfvmChecker.py | 11 +++++++++++ 12 files changed, 73 insertions(+), 13 deletions(-) rename {optionals => addons}/compat_ws/$PBOPREFIX$ (100%) rename {optionals => addons}/compat_ws/CfgWeapons.hpp (100%) create mode 100644 addons/compat_ws/addon.toml rename {optionals => addons}/compat_ws/config.cpp (70%) rename {optionals => addons}/compat_ws/script_component.hpp (100%) create mode 100644 tools/.vscode/settings.json diff --git a/.github/workflows/pboproject.yml b/.github/workflows/pboproject.yml index 7b03e65077..bb9f036860 100644 --- a/.github/workflows/pboproject.yml +++ b/.github/workflows/pboproject.yml @@ -8,14 +8,14 @@ on: jobs: pboproject: - runs-on: windows-2019 + runs-on: windows-2022 steps: - name: Install Arma 3 Tools uses: arma-actions/arma3-tools@master with: toolsUrl: ${{ secrets.ARMA3_TOOLS_URL }} - name: Install Mikero Tools - uses: arma-actions/mikero-tools@2021-11-06 + uses: arma-actions/mikero-tools@2023-01-04 - name: Download game data run: | Invoke-WebRequest "$env:ARMA3_DATA_URL" -OutFile arma3.zip @@ -35,18 +35,18 @@ jobs: RHSSAF_URL: ${{ secrets.RHSSAF_URL }} RHSUSF_URL: ${{ secrets.RHSUSF_URL }} - name: Checkout CBA A3 - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: x\cba ref: master repository: CBATeam/CBA_A3.git - name: Checkout ACE3 - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: z\ace persist-credentials: false - name: Checkout pull request - uses: actions/checkout@v2 + uses: actions/checkout@v3 if: ${{ github.event_name == 'pull_request_target' }} with: path: pullrequest @@ -72,13 +72,13 @@ jobs: env: PYTHONUNBUFFERED: 1 - name: Archive logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: ${{ always() }} with: name: logs path: temp/*.log - name: Archive @ace - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: '@ace3-${{ github.sha }}' path: z\ace\release\@ace diff --git a/addons/common/XEH_preStart.sqf b/addons/common/XEH_preStart.sqf index 022888575e..83ec36162f 100644 --- a/addons/common/XEH_preStart.sqf +++ b/addons/common/XEH_preStart.sqf @@ -1,3 +1,10 @@ #include "script_component.hpp" #include "XEH_PREP.hpp" + +if (isFilePatchingEnabled) then { + private _notLoaded = configProperties [configfile >> "ace_notLoaded", "isText _x"]; + { + INFO_2("%1 not loaded because %2",configName _x, getText _x); + } forEach _notLoaded; +}; diff --git a/optionals/compat_ws/$PBOPREFIX$ b/addons/compat_ws/$PBOPREFIX$ similarity index 100% rename from optionals/compat_ws/$PBOPREFIX$ rename to addons/compat_ws/$PBOPREFIX$ diff --git a/optionals/compat_ws/CfgWeapons.hpp b/addons/compat_ws/CfgWeapons.hpp similarity index 100% rename from optionals/compat_ws/CfgWeapons.hpp rename to addons/compat_ws/CfgWeapons.hpp diff --git a/addons/compat_ws/addon.toml b/addons/compat_ws/addon.toml new file mode 100644 index 0000000000..942a70dde5 --- /dev/null +++ b/addons/compat_ws/addon.toml @@ -0,0 +1 @@ +preprocess = false diff --git a/optionals/compat_ws/config.cpp b/addons/compat_ws/config.cpp similarity index 70% rename from optionals/compat_ws/config.cpp rename to addons/compat_ws/config.cpp index a4533a1119..3be9d1797e 100644 --- a/optionals/compat_ws/config.cpp +++ b/addons/compat_ws/config.cpp @@ -1,5 +1,13 @@ #include "script_component.hpp" +#if __has_include("\lxWS\data_f_lxWS\config.bin") +#else +#define PATCH_SKIP "Western Sahara" +#endif + +#ifdef PATCH_SKIP +ACE_PATCH_NOT_LOADED(ADDON,PATCH_SKIP) +#else class CfgPatches { class ADDON { name = COMPONENT_NAME; @@ -15,3 +23,5 @@ class CfgPatches { }; #include "CfgWeapons.hpp" + +#endif diff --git a/optionals/compat_ws/script_component.hpp b/addons/compat_ws/script_component.hpp similarity index 100% rename from optionals/compat_ws/script_component.hpp rename to addons/compat_ws/script_component.hpp diff --git a/addons/main/script_macros.hpp b/addons/main/script_macros.hpp index cc02c06b94..af91e31401 100644 --- a/addons/main/script_macros.hpp +++ b/addons/main/script_macros.hpp @@ -149,4 +149,19 @@ #define SUBSKILLS ["aimingAccuracy", "aimingShake", "aimingSpeed", "spotDistance", "spotTime", "courage", "reloadSpeed", "commanding", "general"] +// macro add a dummy cfgPatch and notLoaded entry +#define ACE_PATCH_NOT_LOADED(NAME,CAUSE) \ +class CfgPatches { \ + class DOUBLES(NAME,notLoaded) { \ + units[] = {}; \ + weapons[] = {}; \ + requiredVersion = REQUIRED_VERSION; \ + requiredAddons[] = {"ace_main"}; \ + VERSION_CONFIG; \ + }; \ +}; \ +class ace_notLoaded { \ + NAME = CAUSE; \ +}; + #include "script_debug.hpp" diff --git a/tools/.vscode/settings.json b/tools/.vscode/settings.json new file mode 100644 index 0000000000..57fcac4d62 --- /dev/null +++ b/tools/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "files.exclude": { + "**/.hemttout": true, + "**/include": true + } +} \ No newline at end of file diff --git a/tools/.vscode/tasks.json b/tools/.vscode/tasks.json index 7058365fa9..5b54cf3f4d 100644 --- a/tools/.vscode/tasks.json +++ b/tools/.vscode/tasks.json @@ -72,7 +72,8 @@ "cwd": "${workspaceFolder}/tools" }, "args": [ - "make.py", "ci" + "make.py", + "ci" ], "group": { "kind": "build", @@ -80,13 +81,14 @@ } }, { - "label": "Build: Hemtt Release", + "label": "Build: Hemtt", "command": "hemtt.exe", "options": { "cwd": "${workspaceFolder}" }, "args": [ - "build", "--release", "--ci" + "build", + "-v" ], "group": "build" } diff --git a/tools/make.py b/tools/make.py index 0d48aade14..fc1dc56eee 100644 --- a/tools/make.py +++ b/tools/make.py @@ -877,6 +877,7 @@ Examples: If a file called $NOBIN$ is found in the module directory, that module will not be binarized. +If preprocess = false is set in the addon.toml, that module's config will not be binarized. See the make.cfg file for additional build options. """) @@ -1293,15 +1294,22 @@ See the make.cfg file for additional build options. build_successful = False if build_tool == "pboproject": try: - nobinFilePath = os.path.join(work_drive, prefix, module, "$NOBIN$") backup_config(module) version_stamp_pboprefix(module,commit_id) - if os.path.isfile(nobinFilePath): + skipPreprocessing = False + addonTomlPath = os.path.join(work_drive, prefix, module, "addon.toml") + if os.path.isfile(addonTomlPath): + with open(addonTomlPath, "r") as f: + skipPreprocessing = "preprocess = false" in f.read() #python 3.11 has real toml but this is fine for now + + if os.path.isfile(os.path.join(work_drive, prefix, module, "$NOBIN$")): print_green("$NOBIN$ Found. Proceeding with non-binarizing!") cmd = [makepboTool, "-P","-A","-X=*.backup", os.path.join(work_drive, prefix, module),os.path.join(module_root, release_dir, project,"addons")] - + elif skipPreprocessing: + print_green("addon.toml set [preprocess = false]. Proceeding with non-binerized config build!") + cmd = [pboproject, "-B", "-P", os.path.join(work_drive, prefix, module), "+Engine=Arma3", "-S", "+Noisy", "+Clean", "-Warnings", "+Mod="+os.path.join(module_root, release_dir, project), "-Key"] else: cmd = [pboproject, "+B", "-P", os.path.join(work_drive, prefix, module), "+Engine=Arma3", "-S", "+Noisy", "+Clean", "-Warnings", "+Mod="+os.path.join(module_root, release_dir, project), "-Key"] diff --git a/tools/sqfvmChecker.py b/tools/sqfvmChecker.py index ab9c74ceee..1f3fabb41f 100644 --- a/tools/sqfvmChecker.py +++ b/tools/sqfvmChecker.py @@ -25,6 +25,17 @@ def get_files_to_process(basePath): if file.endswith(".sqf") or file == "config.cpp": if file.lower() in files_to_ignore_lower: continue + skipPreprocessing = False + addonTomlPath = os.path.join(root, "addon.toml") + if os.path.isfile(addonTomlPath): + with open(addonTomlPath, "r") as f: + skipPreprocessing = "preprocess = false" in f.read() + addonTomlPath = os.path.join(os.path.dirname(root), "addon.toml") + if os.path.isfile(addonTomlPath): + with open(addonTomlPath, "r") as f: + skipPreprocessing = "preprocess = false" in f.read() + if file == "config.cpp" and skipPreprocessing: + continue # ignore configs with __has_include filePath = os.path.join(root, file) arma_files.append(filePath) return arma_files