1 Star 0 Fork 1

openFyde/project-ime

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
add_cros_enable_cxx_exceptions.py 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
jdxin0 提交于 2021-10-26 11:43 . Initial commit
#!/usr/bin/env python3
import os
OVERLAY_DIR = os.path.dirname(os.path.abspath(__file__))
CMD = "cros_enable_cxx_exceptions"
FUNCTION = "src_prepare"
def enable_exception(fp):
lines = []
mock = False
with open(fp) as f:
text = f.read()
if CMD in text:
return
for l in text.split('\n'):
if l.strip().startswith(FUNCTION) and l.replace(' ', '').startswith('src_prepare(){'):
mock = True
if l.strip() == FUNCTION + '() {':
lines.append(l)
lines.append(' '*8 + CMD)
else:
print(fp, ':', 'mock src_prepare error')
else:
lines.append(l)
if not mock:
lines.append(FUNCTION + '() {')
lines.append(' '*8 + CMD)
lines.append('}')
with open(fp, 'w') as f:
f.write('\n'.join(lines))
def scan_ebuilds(folder):
fps = []
for root, dirs, files in os.walk(folder, topdown=False):
for fp in files:
if fp.endswith('.ebuild'):
fps.append(os.path.join(root, fp))
return fps
def main():
for fp in scan_ebuilds(OVERLAY_DIR):
enable_exception(fp)
if __name__ == "__main__":
main()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openFyde/project-ime.git
git@gitee.com:openFyde/project-ime.git
openFyde
project-ime
project-ime
main

搜索帮助