diff options
author | 杨宇千 <crupest@outlook.com> | 2019-07-10 17:23:29 +0800 |
---|---|---|
committer | 杨宇千 <crupest@outlook.com> | 2019-07-10 17:23:29 +0800 |
commit | d163bafa461779a3795818aa8c8b5238880ede24 (patch) | |
tree | 9eadf181655e293158cab095bb688cad9c0b1f18 /tools | |
parent | e37dd256e5bca4caf819d18c73cd2d11e06683df (diff) | |
download | cru-d163bafa461779a3795818aa8c8b5238880ede24.tar.gz cru-d163bafa461779a3795818aa8c8b5238880ede24.tar.bz2 cru-d163bafa461779a3795818aa8c8b5238880ede24.zip |
...
Diffstat (limited to 'tools')
-rw-r--r-- | tools/generate_clang_complete.py | 43 | ||||
-rw-r--r-- | tools/win_build.py | 17 |
2 files changed, 59 insertions, 1 deletions
diff --git a/tools/generate_clang_complete.py b/tools/generate_clang_complete.py new file mode 100644 index 00000000..44da60f3 --- /dev/null +++ b/tools/generate_clang_complete.py @@ -0,0 +1,43 @@ +import os +import os.path + +clang_complete_file_name = '.clang_complete' + +# project root dir +project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) +os.chdir(project_root) + +global_std_standard = 'c++17' # change this to change standard +global_std_standard_arg = '-std={}'.format(global_std_standard) + +global_include_paths = [ + os.path.abspath('include') +] + +global_definitions = [] + + +def generate_clang_complete_content(additional_include_paths=[], additional_definitions=[]): + include_args = [ + '-I{}'.format(path) for path in additional_include_paths + global_include_paths] + definition_args = [ + '-D{}'.format(definition) for definition in additional_definitions + global_definitions] + args = [global_std_standard_arg] + include_args + definition_args + return '\n'.join(args) + + +def generate_root_clang_complete(): + with open(os.path.join('src/', clang_complete_file_name), 'w') as f: + print(generate_clang_complete_content(), file=f) + + +def generate_win_clang_complete_content(): + return generate_clang_complete_content(additional_definitions=['UNICODE', '_UNICODE', 'WIN32', '_WINDOWS']) + + +def generate_win_clang_complete(): + with open(os.path.join('src/win/', clang_complete_file_name), 'w') as f: + print(generate_win_clang_complete_content(), file=f) + +generate_root_clang_complete() +generate_win_clang_complete() diff --git a/tools/win_build.py b/tools/win_build.py index c3f1ec57..ab1c7107 100644 --- a/tools/win_build.py +++ b/tools/win_build.py @@ -1,6 +1,7 @@ import argparse import os import os.path +import shutil import subprocess import sys @@ -17,6 +18,20 @@ args = parser.parse_args() project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) +def init_vc_environment(arch): + arch_bat_map = { + 'x86': 'vcvarsamd64_x86', + 'x64': 'vcvars64' + } + vars = subprocess.check_output(['C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\{}'.format( + arch_bat_map[arch]), '&&', 'set'], shell=True, text=True) + for var in vars.splitlines(): + k, _, v = map(str.strip, var.strip().partition('=')) + if k.startswith('?'): + continue + os.environ[k] = v + + def configure(): generater_vs_arch_map = { 'x86': 'Win32', @@ -33,7 +48,7 @@ def build(): os.chdir(project_root) -configure() +configure() if args.command == 'build': build() |