1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-18 20:31:35 +02:00

add the define to enable if it was not found in the block

This commit is contained in:
odaki
2020-03-24 00:50:59 +09:00
parent b3c1eb07bc
commit 3f415dadf0

View File

@@ -136,6 +136,9 @@ def writeConfig(path, buf):
def changeConfig(src, enabled, disabled, verbose=False):
dst = ""
numEnabledDic = {}
for name in enabled:
numEnabledDic[name] = 0
regstart = re.compile(r'^\s*//\s*' + eyecatchBeginString)
regend = re.compile(r'^\s*//\s*' + eyecatchEndString)
state = 0;
@@ -149,6 +152,10 @@ def changeConfig(src, enabled, disabled, verbose=False):
# in the defines block to modify
if regend.match(line):
# end of block found
for name in enabled:
# add the define to enable if it was not found in the block
if numEnabledDic[name] == 0:
dst += "#define " + enablePrefix + name + '\n'
state = 2
dst += line
else:
@@ -159,6 +166,7 @@ def changeConfig(src, enabled, disabled, verbose=False):
m = re.match(r'^s*//\s*#define\s+(' + s + r'.*)$', line)
if m:
dstLine = "#define " + m.group(1) + '\n'
numEnabledDic[name] += 1
break
if len(disabled) > 0:
for name in disabled: