[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
|
||||
|
Reference in New Issue
Block a user