diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-11-04 21:35:33 +0800 |
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-11-04 21:35:33 +0800 |
| commit | 08cce61ac9e4b7ebb557b68d57097bd7eab930f3 (patch) | |
| tree | 0e97c24a9ed539fd10ffd0c5ba5af2eb179f2486 | |
| parent | 327f54b605b92a7b81a5a4de95f9f3741b786be5 (diff) | |
| download | cru-08cce61ac9e4b7ebb557b68d57097bd7eab930f3.tar.gz cru-08cce61ac9e4b7ebb557b68d57097bd7eab930f3.tar.bz2 cru-08cce61ac9e4b7ebb557b68d57097bd7eab930f3.zip | |
Remove unused tools.
| -rw-r--r-- | .github/workflows/ci.yml | 4 | ||||
| -rw-r--r-- | scripts/Use-VC.ps1 (renamed from tools/Use-VC.ps1) | 0 | ||||
| -rw-r--r-- | scripts/cppmerge/.gitignore (renamed from tools/cppmerge/.gitignore) | 0 | ||||
| -rw-r--r-- | scripts/cppmerge/main.py (renamed from tools/cppmerge/main.py) | 0 | ||||
| -rw-r--r-- | tools/generate_compile_flags.py | 54 | ||||
| -rw-r--r-- | tools/migrate-1/migrate-cmake.py | 26 | ||||
| -rw-r--r-- | tools/migrate-1/migrate-files.py | 43 | ||||
| -rw-r--r-- | tools/migrate-2/rename-hpp-to-h.py | 34 | ||||
| -rw-r--r-- | tools/proxy_domains.txt | 6 | ||||
| -rw-r--r-- | tools/win_build.py | 71 |
10 files changed, 2 insertions, 236 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62eb32c4..f0352ab2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: - name: Build run: | - . tools/Use-VC.ps1 + . scripts/Use-VC.ps1 Use-VC cmake -DCMAKE_BUILD_TYPE=Debug -S. -Bbuild -G Ninja cmake --build build --config Debug --target all @@ -66,7 +66,7 @@ jobs: - name: Build run: | - . tools/Use-VC.ps1 + . scripts/Use-VC.ps1 Use-VC cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=1 -S. -Bbuild-dynamic -G Ninja cmake --build build-dynamic --config Debug --target all diff --git a/tools/Use-VC.ps1 b/scripts/Use-VC.ps1 index ad3dbcba..ad3dbcba 100644 --- a/tools/Use-VC.ps1 +++ b/scripts/Use-VC.ps1 diff --git a/tools/cppmerge/.gitignore b/scripts/cppmerge/.gitignore index 0b6b38d0..0b6b38d0 100644 --- a/tools/cppmerge/.gitignore +++ b/scripts/cppmerge/.gitignore diff --git a/tools/cppmerge/main.py b/scripts/cppmerge/main.py index 6c73ff0d..6c73ff0d 100644 --- a/tools/cppmerge/main.py +++ b/scripts/cppmerge/main.py diff --git a/tools/generate_compile_flags.py b/tools/generate_compile_flags.py deleted file mode 100644 index 210933cf..00000000 --- a/tools/generate_compile_flags.py +++ /dev/null @@ -1,54 +0,0 @@ -import argparse -import os -import os.path - -parser = argparse.ArgumentParser() -parser.add_argument('-d', '--debug', action='store_true', - default=True, help='indicates whether is in debug mode') -args = parser.parse_args() - -file_name = 'compile_flags.txt' - -# 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 = [] - -if args.debug: - global_definitions.append('_DEBUG') - - -def generate_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_file(): - with open(file_name, 'w') as f: - print(generate_content(), file=f) - - -def generate_win_content(): - return generate_content(additional_definitions=['UNICODE', '_UNICODE', 'WIN32', '_WINDOWS']) - - -def generate_win_file(): - for path in ['src/win/', 'include/cru/win/']: - with open(os.path.join(path, file_name), 'w') as f: - print(generate_win_content(), file=f) - - -generate_root_file() -generate_win_file() diff --git a/tools/migrate-1/migrate-cmake.py b/tools/migrate-1/migrate-cmake.py deleted file mode 100644 index b90bd2e9..00000000 --- a/tools/migrate-1/migrate-cmake.py +++ /dev/null @@ -1,26 +0,0 @@ -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) - - diff --git a/tools/migrate-1/migrate-files.py b/tools/migrate-1/migrate-files.py deleted file mode 100644 index 8ea8bde6..00000000 --- a/tools/migrate-1/migrate-files.py +++ /dev/null @@ -1,43 +0,0 @@ -import re -import pathlib - -regex = re.compile(r'#include\s+"(.*\/)*(.*)"') - - -def xstr(s): - if s is None: - return '' - return str(s) - - -def migrate_includes(path: pathlib.Path): - text = '' - with path.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 = '#include "{}{}"\n'.format(xstr(m.group(1)), t) - text += t - else: - text += line - - with path.open(mode='w', encoding='utf-8') as f: - f.write(text) - - -for p in pathlib.Path('./src').rglob('*.cpp'): - migrate_includes(p) - p.rename(p.parent.joinpath( - ''.join([i.capitalize() for i in p.name.split('_')]))) - -for p in pathlib.Path('./src').rglob('*.hpp'): - migrate_includes(p) - p.rename(p.parent.joinpath( - ''.join([i.capitalize() for i in p.name.split('_')]))) - -for p in pathlib.Path('./include/cru').rglob('*.hpp'): - migrate_includes(p) - p.rename(p.parent.joinpath( - ''.join([i.capitalize() for i in p.name.split('_')]))) diff --git a/tools/migrate-2/rename-hpp-to-h.py b/tools/migrate-2/rename-hpp-to-h.py deleted file mode 100644 index c72fb2e0..00000000 --- a/tools/migrate-2/rename-hpp-to-h.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 - -import os.path - -project_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - -def rename_hpp_to_h(dir): - for root, dirs, files in os.walk(dir): - for file in files: - if file.endswith(".hpp"): - os.rename(os.path.join(root, file), os.path.join(root, file[:-4] + ".h")) - -rename_hpp_to_h(os.path.join(project_root, "include")) -rename_hpp_to_h(os.path.join(project_root, "src")) -rename_hpp_to_h(os.path.join(project_root, "test")) -rename_hpp_to_h(os.path.join(project_root, "demos")) - -def replace_hpp_with_h(file): - with open(file, "r") as f: - content = f.read() - content = content.replace(".hpp", ".h") - with open(file, "w") as f: - f.write(content) - -def replace_hpp_with_h_recursive(dir): - for root, dirs, files in os.walk(dir): - for file in files: - if file.endswith(".cpp") or file.endswith(".h") or file.endswith(".mm"): - replace_hpp_with_h(os.path.join(root, file)) - -replace_hpp_with_h_recursive(os.path.join(project_root, "include")) -replace_hpp_with_h_recursive(os.path.join(project_root, "src")) -replace_hpp_with_h_recursive(os.path.join(project_root, "test")) -replace_hpp_with_h_recursive(os.path.join(project_root, "demos")) diff --git a/tools/proxy_domains.txt b/tools/proxy_domains.txt deleted file mode 100644 index c13a1d6f..00000000 --- a/tools/proxy_domains.txt +++ /dev/null @@ -1,6 +0,0 @@ -measonbuild.com -github.com -zlib.net -download.gnome.org -mirror.ossplanet.net - diff --git a/tools/win_build.py b/tools/win_build.py deleted file mode 100644 index 9e0371ac..00000000 --- a/tools/win_build.py +++ /dev/null @@ -1,71 +0,0 @@ -import argparse -import os -import os.path -import shutil -import subprocess -import sys - -parser = argparse.ArgumentParser() -parser.add_argument('command', choices=[ - 'configure', 'build', 'test'], nargs='?', default='test', help='specify command to execute') -parser.add_argument('-a', '--arch', choices=['x86', 'x64'], - default='x64', help='specify target cpu architecture') -parser.add_argument('-c', '--config', choices=['Debug', 'Release'], - default='Debug', help='specify build configuration') -parser.add_argument('-d', '--work-dir', default='build', - help='specify working directory for building') -args = parser.parse_args() - - -project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -work_dir = os.path.join(project_root, args.work_dir) - -# this is not used when generator is Visual Studio - - -# 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', - 'x64': 'x64' - } - - # -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - subprocess.check_call('cmake -S . -B {build_dir} -G "Visual Studio 16 2019" -A {arch} -T host=x64' - .format(build_dir=work_dir, arch=generater_vs_arch_map[args.arch]), - stdout=sys.stdout, stderr=sys.stderr) - - -def build(): - subprocess.check_call('cmake --build {build_dir} --target ALL_BUILD --config {config}' - .format(build_dir=work_dir, config=args.config), - stdout=sys.stdout, stderr=sys.stderr) - - -def test(): - os.chdir(work_dir) - subprocess.check_call('ctest') - os.chdir(project_root) - - -os.chdir(project_root) - -configure() -if args.command == 'configure': - exit(0) -build() -if args.command == 'build': - exit(0) -test() |
