#!/usr/bin/env python3 """MyxCMake unity.""" import re import os from distutils.dir_util import copy_tree from shutil import copyfile D1 = 'MyxCMake' D2 = 'build/unity/myx' copy_tree(D1, D2) copyfile('myx_setup.cmake', 'build/unity/myx_setup.cmake') with open(D2 + '/MyxCMakeConfig.cmake', encoding='utf-8') as f: lines = list(f) for line in lines: line = line.rstrip() b1 = re.match('.*include.*_BACKPORTS_DIR}/(.*cmake)', line) l1 = re.match('.*include.*_LIB_DIR}/(.*cmake)', line) if b1: fname = D2 + "/backports/" + b1.group(1) with open(fname, encoding='utf-8') as g: print(g.read()) os.remove(fname) elif l1: if l1.group(1) in ['DownloadContent.cmake', 'ProjectIsTopLevel.cmake', 'generators/PrivateConfigHeader.cmake', 'generators/GitInfoHeader.cmake']: print(line) continue fname = D2 + "/lib/" + l1.group(1) with open(fname, encoding='utf-8') as g: print(g.read()) os.remove(fname) else: print(line) os.rmdir(D2 + '/lib/macro')