[buildcore] Update buildcore
This commit is contained in:
36
deps/buildcore/scripts/pybb.py
vendored
36
deps/buildcore/scripts/pybb.py
vendored
@ -18,30 +18,20 @@ import subprocess
|
||||
import sys
|
||||
from typing import List, Optional
|
||||
|
||||
import util
|
||||
|
||||
|
||||
def mkdir(path: str) -> int:
|
||||
try:
|
||||
if not os.path.exists(path):
|
||||
os.mkdir(path)
|
||||
util.mkdir_p(path)
|
||||
except Exception:
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
# this exists because Windows is utterly incapable of providing a proper rm -rf
|
||||
def rm(path: str):
|
||||
file_exists = os.path.exists(path)
|
||||
is_link = os.path.islink(path)
|
||||
is_dir = os.path.isdir(path)
|
||||
if (file_exists or is_link) and not is_dir:
|
||||
os.remove(path)
|
||||
elif os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
|
||||
|
||||
def rm_multi(paths: List[str]):
|
||||
for path in paths:
|
||||
rm(path)
|
||||
util.rm(path)
|
||||
|
||||
|
||||
def ctest_all() -> int:
|
||||
@ -96,11 +86,10 @@ def cat(paths: List[str]) -> int:
|
||||
try:
|
||||
with open(path) as f:
|
||||
data = f.read()
|
||||
sys.stdout.write(data)
|
||||
print(data)
|
||||
except FileNotFoundError:
|
||||
sys.stderr.write(f'cat: {path}: no such file or directory\n')
|
||||
return 1
|
||||
sys.stdout.write('\n')
|
||||
return 0
|
||||
|
||||
|
||||
@ -116,12 +105,21 @@ def debug(paths: List[str]) -> int:
|
||||
def get_env(var_name: str) -> int:
|
||||
if var_name not in os.environ:
|
||||
return 1
|
||||
sys.stdout.write(os.environ[var_name])
|
||||
print(os.environ[var_name])
|
||||
return 0
|
||||
|
||||
|
||||
def hostname() -> int:
|
||||
sys.stdout.write(platform.node())
|
||||
print(platform.node())
|
||||
return 0
|
||||
|
||||
|
||||
def host_env() -> int:
|
||||
os_name = os.uname().sysname.lower()
|
||||
arch = platform.machine()
|
||||
if arch == 'amd64':
|
||||
arch = 'x86_64'
|
||||
print(f'{os_name}-{arch}')
|
||||
return 0
|
||||
|
||||
|
||||
@ -149,6 +147,8 @@ def main() -> int:
|
||||
err = get_env(sys.argv[2])
|
||||
elif sys.argv[1] == 'hostname':
|
||||
err = hostname()
|
||||
elif sys.argv[1] == 'hostenv':
|
||||
err = host_env()
|
||||
else:
|
||||
sys.stderr.write('Command not found\n')
|
||||
err = 1
|
||||
|
12
deps/buildcore/scripts/setup-build.py
vendored
12
deps/buildcore/scripts/setup-build.py
vendored
@ -15,9 +15,7 @@ import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from pybb import mkdir, rm
|
||||
|
||||
os_name = os.uname().sysname.lower()
|
||||
import util
|
||||
|
||||
|
||||
def main() -> int:
|
||||
@ -25,7 +23,7 @@ def main() -> int:
|
||||
parser.add_argument(
|
||||
'--target',
|
||||
help='Platform target',
|
||||
default=f'{os_name}-{platform.machine()}')
|
||||
default=f'{util.get_os()}-{util.get_arch()}')
|
||||
parser.add_argument(
|
||||
'--build_type',
|
||||
help='Build type (asan,debug,release)',
|
||||
@ -84,7 +82,7 @@ def main() -> int:
|
||||
|
||||
project_dir = os.getcwd()
|
||||
build_dir = f'{project_dir}/{args.build_root}/{build_config}'
|
||||
rm(build_dir)
|
||||
util.rm(build_dir)
|
||||
cmake_cmd = [
|
||||
'cmake', '-S', project_dir, '-B', build_dir, build_tool,
|
||||
'-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
|
||||
@ -101,13 +99,13 @@ def main() -> int:
|
||||
|
||||
subprocess.run(cmake_cmd)
|
||||
|
||||
mkdir('dist')
|
||||
util.mkdir_p('dist')
|
||||
if int(args.current_build) != 0:
|
||||
cb = open('.current_build', 'w')
|
||||
cb.write(args.build_type)
|
||||
cb.close()
|
||||
|
||||
rm('compile_commands.json')
|
||||
util.rm('compile_commands.json')
|
||||
if platform.system() != 'Windows':
|
||||
os.symlink(f'{build_dir}/compile_commands.json',
|
||||
'compile_commands.json')
|
||||
|
Reference in New Issue
Block a user