Use CBA Versioning System properly (#7173)

* Use CBA Versioning System properly

* Update CBA include to CBA v3.12.2 + excessive concatenation cleanup
This commit is contained in:
jonpas 2019-09-10 17:49:07 +02:00 committed by GitHub
parent 5dbaef4e07
commit 2d0c61a874
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 101 additions and 21 deletions

View File

@ -5,7 +5,8 @@
#include "script_version.hpp"
#define VERSION MAJOR.MINOR.PATCHLVL.BUILD
#define VERSION MAJOR.MINOR
#define VERSION_STR MAJOR.MINOR.PATCHLVL.BUILD
#define VERSION_AR MAJOR,MINOR,PATCHLVL,BUILD
// MINIMAL required version for the Mod. Components can specify others..

View File

@ -51,21 +51,55 @@
#define MAINLOGIC main
#endif
#define ADDON DOUBLES(PREFIX,COMPONENT)
#define MAIN_ADDON DOUBLES(PREFIX,main)
/* -------------------------------------------
Macro: VERSION_CONFIG
Define CBA Versioning System config entries.
VERSION should be a floating-point number (1 separator).
VERSION_STR is a string representation of the version.
VERSION_AR is an array representation of the version.
VERSION must always be defined, otherwise it is 0.
VERSION_STR and VERSION_AR default to VERSION if undefined.
Parameters:
None
Example:
(begin example)
#define VERSION 1.0
#define VERSION_STR 1.0.1
#define VERSION_AR 1,0,1
class CfgPatches {
class MyMod_main {
VERSION_CONFIG;
};
};
(end)
Author:
?, Jonpas
------------------------------------------- */
#ifndef VERSION
#define VERSION 0
#endif
#ifndef VERSION_STR
#define VERSION_STR VERSION
#endif
#ifndef VERSION_AR
#define VERSION_AR VERSION
#endif
#ifndef VERSION_CONFIG
#define VERSION_CONFIG version = VERSION; versionStr = QUOTE(VERSION); versionAr[] = {VERSION_AR}
#define VERSION_CONFIG version = VERSION; versionStr = QUOTE(VERSION_STR); versionAr[] = {VERSION_AR}
#endif
#define ADDON DOUBLES(PREFIX,COMPONENT)
#define MAIN_ADDON DOUBLES(PREFIX,main)
/* -------------------------------------------
Group: Debugging
------------------------------------------- */
@ -775,7 +809,7 @@ Author:
// This only works for binarized configs after recompiling the pbos
// TODO: Reduce amount of calls / code..
#define COMPILE_FILE2_CFG_SYS(var1) compile preProcessFileLineNumbers var1
#define COMPILE_FILE2_CFG_SYS(var1) compile preprocessFileLineNumbers var1
#define COMPILE_FILE2_SYS(var1) COMPILE_FILE2_CFG_SYS(var1)
#define COMPILE_FILE_SYS(var1,var2,var3) COMPILE_FILE2_SYS('PATHTO_SYS(var1,var2,var3)')
@ -785,13 +819,13 @@ Author:
#define SETVARMAINS(var1) SETVARS(var1,MAINLOGIC)
#define GVARMAINS(var1,var2) var1##_##var2
#define CFGSETTINGSS(var1,var2) configFile >> "CfgSettings" >> #var1 >> #var2
//#define SETGVARS(var1,var2,var3) ##var1##_##var2##_##var3 =
//#define SETGVARMAINS(var1,var2) ##var1##_##var2 =
//#define SETGVARS(var1,var2,var3) var1##_##var2##_##var3 =
//#define SETGVARMAINS(var1,var2) var1##_##var2 =
// Compile-Once, JIT: On first use.
// #define PREPMAIN_SYS(var1,var2,var3) ##var1##_fnc_##var3 = { ##var1##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)); if (isNil "_this") then { call ##var1##_fnc_##var3 } else { _this call ##var1##_fnc_##var3 } }
// #define PREP_SYS(var1,var2,var3) ##var1##_##var2##_fnc_##var3 = { ##var1##_##var2##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)); if (isNil "_this") then { call ##var1##_##var2##_fnc_##var3 } else { _this call ##var1##_##var2##_fnc_##var3 } }
// #define PREP_SYS2(var1,var2,var3,var4) ##var1##_##var2##_fnc_##var4 = { ##var1##_##var2##_fnc_##var4 = COMPILE_FILE_SYS(var1,var3,DOUBLES(fnc,var4)); if (isNil "_this") then { call ##var1##_##var2##_fnc_##var4 } else { _this call ##var1##_##var2##_fnc_##var4 } }
// #define PREPMAIN_SYS(var1,var2,var3) var1##_fnc_##var3 = { var1##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)); if (isNil "_this") then { call var1##_fnc_##var3 } else { _this call var1##_fnc_##var3 } }
// #define PREP_SYS(var1,var2,var3) var1##_##var2##_fnc_##var3 = { var1##_##var2##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)); if (isNil "_this") then { call var1##_##var2##_fnc_##var3 } else { _this call var1##_##var2##_fnc_##var3 } }
// #define PREP_SYS2(var1,var2,var3,var4) var1##_##var2##_fnc_##var4 = { var1##_##var2##_fnc_##var4 = COMPILE_FILE_SYS(var1,var3,DOUBLES(fnc,var4)); if (isNil "_this") then { call var1##_##var2##_fnc_##var4 } else { _this call var1##_##var2##_fnc_##var4 } }
// Compile-Once, at Macro. As opposed to Compile-Once, on first use.
#define PREPMAIN_SYS(var1,var2,var3) var1##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3))
@ -890,6 +924,39 @@ Author:
#define SETVARMAIN SETVARMAINS(PREFIX)
#define IFCOUNT(var1,var2,var3) if (count var1 > var2) then { var3 = var1 select var2 };
/* -------------------------------------------
Macro: PREP()
Description:
Defines a function.
Full file path:
'\MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\fnc_<FNC>.sqf'
Resulting function name:
'PREFIX_COMPONENT_<FNC>'
The PREP macro should be placed in a script run by a XEH preStart and XEH preInit event.
The PREP macro allows for CBA function caching, which drastically speeds up load times.
Beware though that function caching is enabled by default and as such to disable it, you need to
#define DISABLE_COMPILE_CACHE above your #include "script_components.hpp" include!
The function will be defined in ui and mission namespace. It can not be overwritten without
a mission restart.
Parameters:
FUNCTION NAME - Name of the function, unquoted <STRING>
Examples:
(begin example)
PREP(banana);
call FUNC(banana);
(end)
Author:
dixon13
------------------------------------------- */
//#define PREP(var1) PREP_SYS(PREFIX,COMPONENT_F,var1)
#ifdef DISABLE_COMPILE_CACHE
@ -900,13 +967,6 @@ Author:
#define PREPMAIN(var1) ['PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))', 'TRIPLES(PREFIX,fnc,var1)'] call SLX_XEH_COMPILE_NEW
#endif
#ifdef RECOMPILE
#undef RECOMPILE
#define RECOMPILE recompile = 1
#else
#define RECOMPILE recompile = 0
#endif
/* -------------------------------------------
Macro: PATHTO_FNC()
@ -916,6 +976,7 @@ Description:
Full file path in addons:
'\MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\fnc_<FNC>.sqf'
Define 'RECOMPILE' to enable recompiling.
Define 'SKIP_FUNCTION_HEADER' to skip adding function header.
Parameters:
FUNCTION NAME - Name of the function, unquoted <STRING>
@ -936,8 +997,22 @@ Examples:
Author:
dixon13, commy2
------------------------------------------- */
#ifdef RECOMPILE
#undef RECOMPILE
#define RECOMPILE recompile = 1
#else
#define RECOMPILE recompile = 0
#endif
// Set function header type: -1 - no header; 0 - default header; 1 - system header.
#ifdef SKIP_FUNCTION_HEADER
#define CFGFUNCTION_HEADER headerType = -1
#else
#define CFGFUNCTION_HEADER headerType = 0
#endif
#define PATHTO_FNC(func) class func {\
file = QPATHTOF(DOUBLES(fnc,func).sqf);\
CFGFUNCTION_HEADER;\
RECOMPILE;\
}
@ -1086,6 +1161,7 @@ Author:
/* -------------------------------------------
Macro: SCRIPT()
Sets name of script (relies on PREFIX and COMPONENT values being #defined).
Define 'SKIP_SCRIPT_NAME' to skip adding scriptName.
Parameters:
NAME - Name of script [Indentifier]
@ -1098,8 +1174,11 @@ Example:
Author:
Spooner
------------------------------------------- */
#define SCRIPT(NAME) \
scriptName 'PREFIX\COMPONENT\NAME'
#ifndef SKIP_SCRIPT_NAME
#define SCRIPT(NAME) scriptName 'PREFIX\COMPONENT\NAME'
#else
#define SCRIPT(NAME) /* nope */
#endif
/* -------------------------------------------
Macros: EXPLODE_n()