Skip to content

Commit ad9c54a

Browse files
committed
Control over debug defines rather than hardcoding, also add them to generated projects
1 parent 91a2df2 commit ad9c54a

File tree

4 files changed

+42
-7
lines changed

4 files changed

+42
-7
lines changed

ConfigParser.csx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ class ConfigRead {
4848
if (val.StartsWith("(")){
4949
isArrayItem= true;
5050
val = val.Substring(1, val.Length - 2).Trim();
51-
}
52-
if (val.StartsWith("\"") && val.EndsWith("\""))
51+
} else if (val.StartsWith("\"") && val.EndsWith("\"")) //dont dequote array items by default
5352
val = val.Substring(1, val.Length - 2).Trim();
5453
var name = arr[0].Trim();
5554

@@ -70,5 +69,29 @@ class ConfigRead {
7069
public bool IsNumeric(String name) => TryGetVar(name)?.isNumeric ?? false;
7170
public string GetRealName(String name) => TryGetVar(name)?.name;
7271
public string GetVal(String name) => TryGetVar(name)?.value;
72+
73+
/// <summary>
74+
/// doesn't do great at handling escaped quotes beware
75+
/// </summary>
76+
/// <param name="name"></param>
77+
/// <returns></returns>
78+
public string[] GetArrParse(String name) {
79+
var val = GetVal(name);
80+
if (String.IsNullOrWhiteSpace(val))
81+
return new string[0];
82+
83+
var matches = Regex.Matches(val, @"""(?:[^""\\]|\\.)*""|[^\s""]+");
84+
85+
var ret = new List<string>();
86+
foreach (Match match in matches) {
87+
var value = match.Value;
88+
if (value.StartsWith("\"")) {
89+
value = value.Trim('"');
90+
value = Regex.Replace(value, @"\\([""])", "$1");//deslash the quote itself if has escaped inside quote
91+
}
92+
ret.Add(value);
93+
}
94+
return ret.ToArray();
95+
}
7396
public string GetComment(String name) => TryGetVar(name)?.comments;
7497
}

default_config.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ BUILD_MAKE_INSTALL_CMD_ADDL=() #any additional args to pass to make install
5555
CONFIG_NO_TESTS=1
5656
CONFIG_NO_PO=1
5757
CONFIG_NO_DOCS=1
58-
OUR_OS_FIXES_COMPILE=0 #compile our osfixes.c/h libs
59-
OUR_OS_FIXES_APPLY_TO_DBG=0 #will force our osfixes.obj to be linked in useful for stopping the dbgassert popups at start/end, will enable OUR_OS_FIXES_COMPILE if not enabled
58+
OUR_OS_FIXES_COMPILE=0 #compile our osfixes.c/h libs (does not automatically link them in)
59+
OUR_OS_FIXES_APPLY_TO_DBG=0 #will force our osfixes.obj to be linked in to debug builds useful for stopping the dbgassert popups at start/end, will enable OUR_OS_FIXES_COMPILE if not enabled.
60+
OUR_OS_FIXES_DEFINES=( "WLB_DISABLE_DEBUG_ASSERT_POPUP_AT_LAUNCH" "WLB_DISABLE_DEBUG_ASSERT_POPUP_AT_EXIT" ) #see osfixes.h for all options, note these popup blocks add some specific constructor support to do their magic with MSVC
6061
GIT_CLONE_BRANCH="" #force a specific branch
6162
GIT_PRINT_LAST_COMMIT_ON_CLONE=0 #print the last commit message in the repo on clone
6263
GIT_NO_RECURSE=0 #Don't recurse submodules by deafult

helpers.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,17 +168,24 @@ apply_our_repo_patch () {
168168
SKIP_STEP=""
169169
}
170170

171-
osfixes_set_locations_dbg_add_to_libs(){
171+
osfixes_set_locations_dbg_add_to_libs(){ #the defines to control how it operates are set when it is compiled in osfixes_bare_compile
172172
osfixes_set_locations "$@"
173-
if [[ ! $BLD_CONFIG_BUILD_DEBUG ]]; then
173+
if [[ $BLD_CONFIG_BUILD_DEBUG -ne 1 ]]; then
174174
return;
175175
fi
176176
LDFLAGS+=" -Xlinker $OSFIXES_LIB"
177177
}
178178
osfixes_bare_compile(){
179179
pushd $OSFIXES_SRC_DST_FLDR
180180
osfixes_link_in_if_dbg_and_stg
181-
ex cl.exe -D_DEBUG -DDEBUG /nologo /c /ZI /MTd -DWLB_DISABLE_DEBUG_ASSERT_POPUP_AT_LAUNCH "$OSFIXES_SRC_DST"
181+
local defines_add=""
182+
183+
for def in "${OUR_OS_FIXES_DEFINES[@]}"; do
184+
defines_add+=" -D${def}"
185+
done
186+
187+
188+
ex cl.exe -D_DEBUG -DDEBUG /nologo /c /ZI /MTd $defines_add "$OSFIXES_SRC_DST"
182189
#ex lib.exe /nologo "${OSFIXES_SRC_DST::-1}obj" want to do obj to make sure it is always incldued
183190
popd
184191
}

vs_debug_help/DebugProjGen.csx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ Dictionary<string, string> BuildTemplateDict(ConfigRead config, Opts opts) {
153153
var libs = opts.GetArrVal("libraries");
154154
var compile = opts.GetArrVal("compile");
155155
var define = opts.GetArrVal("define");
156+
var osFixDefines = config.GetArrParse("OUR_OS_FIXES_DEFINES");
157+
foreach (var def in osFixDefines)
158+
define.Add(def);
159+
156160
define = define.Select(a => a.StartsWith("-D") ? a.Substring(2) : a).ToList();
157161
var include = opts.GetArrVal("include");
158162
var exclude = opts.GetArrVal("exclude");

0 commit comments

Comments
 (0)