Skip to content

Commit

Permalink
Control over debug defines rather than hardcoding, also add them to g…
Browse files Browse the repository at this point in the history
…enerated projects
  • Loading branch information
mitchcapper committed Jan 14, 2025
1 parent 91a2df2 commit ad9c54a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
27 changes: 25 additions & 2 deletions ConfigParser.csx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ class ConfigRead {
if (val.StartsWith("(")){
isArrayItem= true;
val = val.Substring(1, val.Length - 2).Trim();
}
if (val.StartsWith("\"") && val.EndsWith("\""))
} else if (val.StartsWith("\"") && val.EndsWith("\"")) //dont dequote array items by default
val = val.Substring(1, val.Length - 2).Trim();
var name = arr[0].Trim();

Expand All @@ -70,5 +69,29 @@ class ConfigRead {
public bool IsNumeric(String name) => TryGetVar(name)?.isNumeric ?? false;
public string GetRealName(String name) => TryGetVar(name)?.name;
public string GetVal(String name) => TryGetVar(name)?.value;

/// <summary>
/// doesn't do great at handling escaped quotes beware
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public string[] GetArrParse(String name) {
var val = GetVal(name);
if (String.IsNullOrWhiteSpace(val))
return new string[0];

var matches = Regex.Matches(val, @"""(?:[^""\\]|\\.)*""|[^\s""]+");

var ret = new List<string>();
foreach (Match match in matches) {
var value = match.Value;
if (value.StartsWith("\"")) {
value = value.Trim('"');
value = Regex.Replace(value, @"\\([""])", "$1");//deslash the quote itself if has escaped inside quote
}
ret.Add(value);
}
return ret.ToArray();
}
public string GetComment(String name) => TryGetVar(name)?.comments;
}
5 changes: 3 additions & 2 deletions default_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ BUILD_MAKE_INSTALL_CMD_ADDL=() #any additional args to pass to make install
CONFIG_NO_TESTS=1
CONFIG_NO_PO=1
CONFIG_NO_DOCS=1
OUR_OS_FIXES_COMPILE=0 #compile our osfixes.c/h libs
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
OUR_OS_FIXES_COMPILE=0 #compile our osfixes.c/h libs (does not automatically link them in)
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.
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
GIT_CLONE_BRANCH="" #force a specific branch
GIT_PRINT_LAST_COMMIT_ON_CLONE=0 #print the last commit message in the repo on clone
GIT_NO_RECURSE=0 #Don't recurse submodules by deafult
Expand Down
13 changes: 10 additions & 3 deletions helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,24 @@ apply_our_repo_patch () {
SKIP_STEP=""
}

osfixes_set_locations_dbg_add_to_libs(){
osfixes_set_locations_dbg_add_to_libs(){ #the defines to control how it operates are set when it is compiled in osfixes_bare_compile
osfixes_set_locations "$@"
if [[ ! $BLD_CONFIG_BUILD_DEBUG ]]; then
if [[ $BLD_CONFIG_BUILD_DEBUG -ne 1 ]]; then
return;
fi
LDFLAGS+=" -Xlinker $OSFIXES_LIB"
}
osfixes_bare_compile(){
pushd $OSFIXES_SRC_DST_FLDR
osfixes_link_in_if_dbg_and_stg
ex cl.exe -D_DEBUG -DDEBUG /nologo /c /ZI /MTd -DWLB_DISABLE_DEBUG_ASSERT_POPUP_AT_LAUNCH "$OSFIXES_SRC_DST"
local defines_add=""

for def in "${OUR_OS_FIXES_DEFINES[@]}"; do
defines_add+=" -D${def}"
done


ex cl.exe -D_DEBUG -DDEBUG /nologo /c /ZI /MTd $defines_add "$OSFIXES_SRC_DST"
#ex lib.exe /nologo "${OSFIXES_SRC_DST::-1}obj" want to do obj to make sure it is always incldued
popd
}
Expand Down
4 changes: 4 additions & 0 deletions vs_debug_help/DebugProjGen.csx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ Dictionary<string, string> BuildTemplateDict(ConfigRead config, Opts opts) {
var libs = opts.GetArrVal("libraries");
var compile = opts.GetArrVal("compile");
var define = opts.GetArrVal("define");
var osFixDefines = config.GetArrParse("OUR_OS_FIXES_DEFINES");
foreach (var def in osFixDefines)
define.Add(def);

define = define.Select(a => a.StartsWith("-D") ? a.Substring(2) : a).ToList();
var include = opts.GetArrVal("include");
var exclude = opts.GetArrVal("exclude");
Expand Down

0 comments on commit ad9c54a

Please sign in to comment.