Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tools - Binarize configs in make.py #8584

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions addons/rearm/XEH_preStart.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#include "script_component.hpp"

#include "XEH_PREP.hpp"

// Test binerization one time at startup - ref https://github.com/acemod/ACE3/pull/8093
private _test = getText (configFile >> "Cfg3DEN" >> "Object" >> "AttributeCategories" >> "ace_attributes" >> "Attributes" >> "ace_rearm_rearmCargo" >> "defaultValue");
if (!("else {" in _test)) then {
ERROR("3den attribute has ERROR [check binerization]");
PabstMirror marked this conversation as resolved.
Show resolved Hide resolved
};
35 changes: 34 additions & 1 deletion tools/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,12 @@ def backup_config(module):
global work_drive
global prefix

try:
shutil.copyfile(os.path.join(work_drive, prefix, module, "config.cpp"), os.path.join(work_drive, prefix, module, "config.backup"))
os.chdir(work_drive)
except:
print_error("Error creating backup of config.cpp for module {}.".format(module))

try:
configpath = os.path.join(work_drive, prefix, module, "$PBOPREFIX$")
if os.path.isfile(configpath):
Expand All @@ -514,9 +520,33 @@ def backup_config(module):

return True

def convert_config(module):
try:
cmd = [os.path.join(arma3tools_path, "CfgConvert", "CfgConvert.exe"), "-bin", "-dst", os.path.join(work_drive, prefix, module, "config.bin"), os.path.join(work_drive, prefix, module, "config.cpp")]
ret = subprocess.call(cmd)
if ret != 0:
raise Exception(f" -bin return code == {ret}. Usually means there is a syntax error within the config.cpp file.")
cmd = [os.path.join(arma3tools_path, "CfgConvert", "CfgConvert.exe"), "-txt", "-dst", os.path.join(work_drive, prefix, module, "config.cpp"), os.path.join(work_drive, prefix, module, "config.bin")]
ret = subprocess.call(cmd)
if ret != 0:
raise Exception(f" -txt return code == {ret}. Usually means there is a syntax error within the config.cpp file.")
except Exception as e:
print_error(f"convert_config: {e}")
return False

return True

def addon_restore(modulePath):
#restore original $PBOPREFIX$
try:
if os.path.isfile(os.path.join(modulePath, "config.bin")):
os.remove(os.path.join(modulePath, "config.bin"))
if os.path.isfile(os.path.join(modulePath, "config.cpp")):
os.remove(os.path.join(modulePath, "config.cpp"))
if os.path.isfile(os.path.join(modulePath, "config.backup")):
os.rename(os.path.join(modulePath, "config.backup"), os.path.join(modulePath, "config.cpp"))
if os.path.isfile(os.path.join(modulePath, "texHeaders.bin")):
os.remove(os.path.join(modulePath, "texHeaders.bin"))
if os.path.isfile(os.path.join(modulePath, "$PBOPREFIX$.backup")):
if os.path.isfile(os.path.join(modulePath, "$PBOPREFIX$")):
os.remove(os.path.join(modulePath, "$PBOPREFIX$"))
Expand Down Expand Up @@ -1294,14 +1324,17 @@ def main(argv):
nobinFilePath = os.path.join(work_drive, prefix, module, "$NOBIN$")
backup_config(module)

if (not os.path.isfile(nobinFilePath)):
convert_config(module)

version_stamp_pboprefix(module,commit_id)

if os.path.isfile(nobinFilePath):
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")]

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

color("grey")
if quiet:
Expand Down