aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/configure_file.py
diff options
context:
space:
mode:
authorsnowball <snowball@yandex-team.ru>2022-02-10 16:46:32 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:32 +0300
commit83a8efcf3af051e3dd59c00d1d5dafc96412ec1e (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /build/scripts/configure_file.py
parent4d57126b1bae3cfd0f4f95c32d1a85ca684ee92c (diff)
downloadydb-83a8efcf3af051e3dd59c00d1d5dafc96412ec1e.tar.gz
Restoring authorship annotation for <snowball@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'build/scripts/configure_file.py')
-rwxr-xr-xbuild/scripts/configure_file.py104
1 files changed, 52 insertions, 52 deletions
diff --git a/build/scripts/configure_file.py b/build/scripts/configure_file.py
index 14eec7fa57..1873ed70eb 100755
--- a/build/scripts/configure_file.py
+++ b/build/scripts/configure_file.py
@@ -1,59 +1,59 @@
-#!/usr/bin/env python2.7
-
-import sys
-import os.path
+#!/usr/bin/env python2.7
+
+import sys
+import os.path
import re
-
-cmakeDef01 = "#cmakedefine01"
-cmakeDef = "#cmakedefine"
-
-
-def replaceLine(l, varDict, define):
- words = l.split()
- if words:
- if words[0] == cmakeDef:
- sPos = l.find(cmakeDef)
- ePos = sPos + len(cmakeDef)
- l = l[:sPos] + define + l[ePos:] + '\n'
- if words[0] == cmakeDef01:
- var = words[1]
- cmakeValue = varDict.get(var)
- if cmakeValue == 'yes':
- val = '1'
- else:
- val = '0'
- sPos = l.find(cmakeDef01)
- ePos = l.find(var) + len(var)
- l = l[:sPos] + define + ' ' + var + ' ' + val + l[ePos + 1:] + '\n'
-
+
+cmakeDef01 = "#cmakedefine01"
+cmakeDef = "#cmakedefine"
+
+
+def replaceLine(l, varDict, define):
+ words = l.split()
+ if words:
+ if words[0] == cmakeDef:
+ sPos = l.find(cmakeDef)
+ ePos = sPos + len(cmakeDef)
+ l = l[:sPos] + define + l[ePos:] + '\n'
+ if words[0] == cmakeDef01:
+ var = words[1]
+ cmakeValue = varDict.get(var)
+ if cmakeValue == 'yes':
+ val = '1'
+ else:
+ val = '0'
+ sPos = l.find(cmakeDef01)
+ ePos = l.find(var) + len(var)
+ l = l[:sPos] + define + ' ' + var + ' ' + val + l[ePos + 1:] + '\n'
+
finder = re.compile(".*?(@[a-zA-Z0-9_]+@).*")
- while True:
+ while True:
re_result = finder.match(l)
if not re_result:
- return l
+ return l
key = re_result.group(1)[1:-1]
l = l[:re_result.start(1)] + varDict.get(key, '') + l[re_result.end(1):]
-
-
-def main(inputPath, outputPath, varDict):
- define = '#define' if os.path.splitext(outputPath)[1] != '.asm' else '%define'
- with open(outputPath, 'w') as output:
- with open(inputPath, 'r') as input:
- for l in input:
- output.write(replaceLine(l, varDict, define))
-
-
-def usage():
- print "usage: configure_file.py inputPath outputPath key1=value1 ..."
- exit(1)
-
-
-if __name__ == "__main__":
- if len(sys.argv) < 3:
- usage()
- varDict = {}
- for x in sys.argv[3:]:
+
+
+def main(inputPath, outputPath, varDict):
+ define = '#define' if os.path.splitext(outputPath)[1] != '.asm' else '%define'
+ with open(outputPath, 'w') as output:
+ with open(inputPath, 'r') as input:
+ for l in input:
+ output.write(replaceLine(l, varDict, define))
+
+
+def usage():
+ print "usage: configure_file.py inputPath outputPath key1=value1 ..."
+ exit(1)
+
+
+if __name__ == "__main__":
+ if len(sys.argv) < 3:
+ usage()
+ varDict = {}
+ for x in sys.argv[3:]:
key, value = str(x).split('=', 1)
- varDict[key] = value
-
- main(sys.argv[1], sys.argv[2], varDict)
+ varDict[key] = value
+
+ main(sys.argv[1], sys.argv[2], varDict)