[buildcore] Cleanup type annotations in Python scripts
This commit is contained in:
parent
84d54ba340
commit
b0faac199f
30
deps/buildcore/scripts/pybb.py
vendored
30
deps/buildcore/scripts/pybb.py
vendored
@ -15,9 +15,10 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
from typing import List, Optional
|
||||||
|
|
||||||
|
|
||||||
def cat(paths: [str]) -> int:
|
def cat(paths: List[str]) -> int:
|
||||||
for path in paths:
|
for path in paths:
|
||||||
try:
|
try:
|
||||||
with open(path) as f:
|
with open(path) as f:
|
||||||
@ -32,23 +33,15 @@ def cat(paths: [str]) -> int:
|
|||||||
|
|
||||||
def mkdir(path: str) -> int:
|
def mkdir(path: str) -> int:
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
try:
|
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
except:
|
|
||||||
return 1
|
|
||||||
return 0
|
|
||||||
if os.path.isdir(path):
|
|
||||||
return 0
|
|
||||||
return 1
|
|
||||||
|
|
||||||
|
|
||||||
# this exists because Windows is utterly incapable of providing a proper rm -rf
|
# this exists because Windows is utterly incapable of providing a proper rm -rf
|
||||||
def rm(path: str) -> int:
|
def rm(path: str):
|
||||||
if (os.path.exists(path) or os.path.islink(path)) and not os.path.isdir(path):
|
if (os.path.exists(path) or os.path.islink(path)) and not os.path.isdir(path):
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
elif os.path.isdir(path):
|
elif os.path.isdir(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
def ctest_all() -> int:
|
def ctest_all() -> int:
|
||||||
@ -66,7 +59,7 @@ def ctest_all() -> int:
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def cmake_build(base_path: str, target: str) -> int:
|
def cmake_build(base_path: str, target: Optional[str]) -> int:
|
||||||
if not os.path.isdir(base_path):
|
if not os.path.isdir(base_path):
|
||||||
# nothing to build
|
# nothing to build
|
||||||
return 0
|
return 0
|
||||||
@ -83,7 +76,11 @@ def cmake_build(base_path: str, target: str) -> int:
|
|||||||
def conan() -> int:
|
def conan() -> int:
|
||||||
project_name = sys.argv[2]
|
project_name = sys.argv[2]
|
||||||
conan_dir = '.conanbuild'
|
conan_dir = '.conanbuild'
|
||||||
err = mkdir(conan_dir)
|
err = 0
|
||||||
|
try:
|
||||||
|
mkdir(conan_dir)
|
||||||
|
except:
|
||||||
|
return 1
|
||||||
if err != 0:
|
if err != 0:
|
||||||
return err
|
return err
|
||||||
args = ['conan', 'install', '../', '--build=missing', '-pr', project_name]
|
args = ['conan', 'install', '../', '--build=missing', '-pr', project_name]
|
||||||
@ -94,10 +91,13 @@ def conan() -> int:
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main() -> int:
|
||||||
err = 0
|
err = 0
|
||||||
if sys.argv[1] == 'mkdir':
|
if sys.argv[1] == 'mkdir':
|
||||||
err = mkdir(sys.argv[2])
|
try:
|
||||||
|
mkdir(sys.argv[2])
|
||||||
|
except:
|
||||||
|
err = 1
|
||||||
elif sys.argv[1] == 'rm':
|
elif sys.argv[1] == 'rm':
|
||||||
for i in range(2, len(sys.argv)):
|
for i in range(2, len(sys.argv)):
|
||||||
rm(sys.argv[i])
|
rm(sys.argv[i])
|
||||||
@ -120,4 +120,4 @@ if __name__ == '__main__':
|
|||||||
err = main()
|
err = main()
|
||||||
sys.exit(err)
|
sys.exit(err)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
sys.exit(1)
|
sys.exit(err)
|
||||||
|
10
deps/buildcore/scripts/setup-build.py
vendored
10
deps/buildcore/scripts/setup-build.py
vendored
@ -18,7 +18,7 @@ import sys
|
|||||||
from pybb import mkdir, rm
|
from pybb import mkdir, rm
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main() -> int:
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--target', help='Platform target',
|
parser.add_argument('--target', help='Platform target',
|
||||||
default='{:s}-{:s}'.format(sys.platform, platform.machine()))
|
default='{:s}-{:s}'.format(sys.platform, platform.machine()))
|
||||||
@ -39,7 +39,7 @@ def main():
|
|||||||
sanitizer_status = 'OFF'
|
sanitizer_status = 'OFF'
|
||||||
else:
|
else:
|
||||||
print('Error: Invalid build tool')
|
print('Error: Invalid build tool')
|
||||||
sys.exit(1)
|
return 1
|
||||||
|
|
||||||
if args.build_tool == 'xcode':
|
if args.build_tool == 'xcode':
|
||||||
build_config = '{:s}-{:s}'.format(args.target, args.build_tool)
|
build_config = '{:s}-{:s}'.format(args.target, args.build_tool)
|
||||||
@ -60,12 +60,11 @@ def main():
|
|||||||
build_tool = '-GXcode'
|
build_tool = '-GXcode'
|
||||||
else:
|
else:
|
||||||
print('Error: Invalid build tool')
|
print('Error: Invalid build tool')
|
||||||
sys.exit(1)
|
return 1
|
||||||
|
|
||||||
project_dir = os.getcwd()
|
project_dir = os.getcwd()
|
||||||
build_dir = '{:s}/build/{:s}'.format(project_dir, build_config)
|
build_dir = '{:s}/build/{:s}'.format(project_dir, build_config)
|
||||||
rm(build_dir)
|
rm(build_dir)
|
||||||
mkdir(build_dir)
|
|
||||||
cmake_cmd = [
|
cmake_cmd = [
|
||||||
'cmake', '-S', project_dir, '-B', build_dir, build_tool,
|
'cmake', '-S', project_dir, '-B', build_dir, build_tool,
|
||||||
'-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
|
'-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
|
||||||
@ -91,10 +90,11 @@ def main():
|
|||||||
rm('compile_commands.json')
|
rm('compile_commands.json')
|
||||||
if platform.system() != 'Windows':
|
if platform.system() != 'Windows':
|
||||||
os.symlink('build/{:s}/compile_commands.json'.format(build_config), 'compile_commands.json')
|
os.symlink('build/{:s}/compile_commands.json'.format(build_config), 'compile_commands.json')
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
main()
|
sys.exit(main())
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user