[buildcore] Replace gmake < file with pybb cat

This commit is contained in:
Gary Talent 2021-07-09 19:29:45 -05:00
parent 6bd21bf1b4
commit b27d6671fc
2 changed files with 19 additions and 2 deletions

View File

@ -48,7 +48,7 @@ ifneq ($(shell which docker 2> /dev/null),)
ENV_RUN=docker exec -i -t --user $(shell id -u ${USER}) ${DEVENV}
endif
endif
CURRENT_BUILD=$(HOST_ENV)-$(file < .current_build)
CURRENT_BUILD=$(HOST_ENV)-$(shell ${PYBB} cat .current_build)
.PHONY: build
build:

View File

@ -17,10 +17,22 @@ import subprocess
import sys
def cat(path):
try:
with open(path) as f:
data = f.read()
print(data)
return 0
except FileNotFoundError:
sys.stderr.write('cat: {}: no such file or directory\n'.format(path))
return 1
def mkdir(path):
if not os.path.exists(path) and os.path.isdir(path):
os.mkdir(path)
# this exists because Windows is utterly incapable of providing a proper rm -rf
def rm(path):
if (os.path.exists(path) or os.path.islink(path)) and not os.path.isdir(path):
@ -28,6 +40,7 @@ def rm(path):
elif os.path.isdir(path):
shutil.rmtree(path)
def cmake_build(base_path, target):
if not os.path.isdir(base_path):
# nothing to build
@ -40,6 +53,7 @@ def cmake_build(base_path, target):
if err != 0:
return err
def main():
if sys.argv[1] == 'mkdir':
mkdir(sys.argv[2])
@ -49,10 +63,13 @@ def main():
elif sys.argv[1] == 'cmake-build':
err = cmake_build(sys.argv[2], sys.argv[3] if len(sys.argv) > 3 else None)
sys.exit(err)
elif sys.argv[1] == 'cat':
err = cat(sys.argv[2])
sys.exit(err)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
sys.exit(1)