Optionals - Load dynamically based on presence of mod (__has_include) (#9116)

* 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 <bjorn@dahlgren.io>

* Update settings.json

* cleanup interm hemtt changes

* Update .github/workflows/arma.yml

* Apply suggestions from code review

Co-authored-by: jonpas <jonpas33@gmail.com>

---------

Co-authored-by: Björn Dahlgren <bjorn@dahlgren.io>
Co-authored-by: jonpas <jonpas33@gmail.com>
This commit is contained in:
PabstMirror 2023-04-30 16:53:43 -05:00 committed by GitHub
parent 76e1aafb33
commit fbe23ee45f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 73 additions and 13 deletions

View File

@ -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

View File

@ -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;
};

View File

@ -0,0 +1 @@
preprocess = false

View File

@ -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

View File

@ -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"

6
tools/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,6 @@
{
"files.exclude": {
"**/.hemttout": true,
"**/include": true
}
}

View File

@ -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"
}

View File

@ -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"]

View File

@ -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