diff options
author | crupest <crupest@outlook.com> | 2020-05-24 01:40:02 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-05-24 01:40:02 +0800 |
commit | d86a71f79afe0e4dac768f61d6bff690567aca5b (patch) | |
tree | 4957e9a64c77680deb07201fbd879bf036616dae /tools/migrate-1/migrate-cmake.py | |
parent | f3a8fd608a9776ef0a5f547da918a32cf6074060 (diff) | |
download | cru-d86a71f79afe0e4dac768f61d6bff690567aca5b.tar.gz cru-d86a71f79afe0e4dac768f61d6bff690567aca5b.tar.bz2 cru-d86a71f79afe0e4dac768f61d6bff690567aca5b.zip |
...
Diffstat (limited to 'tools/migrate-1/migrate-cmake.py')
-rw-r--r-- | tools/migrate-1/migrate-cmake.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/migrate-1/migrate-cmake.py b/tools/migrate-1/migrate-cmake.py new file mode 100644 index 00000000..b90bd2e9 --- /dev/null +++ b/tools/migrate-1/migrate-cmake.py @@ -0,0 +1,26 @@ +import re +from pathlib import Path + +regex = re.compile(r'\s*(.*\/)*(.*)(\.[hc]pp)$') + +def xstr(s): + if s is None: + return '' + return str(s) + +for p in Path('./src').rglob('CMakeLists.txt'): + text = '' + with p.open(mode='r', encoding='utf-8') as f: + for line in f.readlines(): + m = regex.match(line) + if m: + t = m.group(2) + t = ''.join(([i.capitalize() for i in t.split('_')])) + t = '\t{}{}{}\n'.format(xstr(m.group(1)), t, m.group(3)) + text += t + else: + text += line + with p.open(mode='w', encoding='utf-8') as f: + f.write(text) + + |