[nostalgia] Replace some Makefile macros with a pybb function that will return errors
This commit is contained in:
parent
c399cb3f13
commit
c5dbd724eb
12
Makefile
12
Makefile
@ -10,7 +10,9 @@ endif
|
|||||||
|
|
||||||
DEVENV=devenv$(shell pwd | sed 's/\//-/g')
|
DEVENV=devenv$(shell pwd | sed 's/\//-/g')
|
||||||
DEVENV_IMAGE=nostalgia-devenv
|
DEVENV_IMAGE=nostalgia-devenv
|
||||||
RM_RF=python3 scripts/pybb rm
|
PYBB=python3 scripts/pybb
|
||||||
|
CMAKE_BUILD=${PYBB} cmake-build
|
||||||
|
RM_RF=${PYBB} rm
|
||||||
ifndef VCPKG_DIR_BASE
|
ifndef VCPKG_DIR_BASE
|
||||||
VCPKG_DIR_BASE=.vcpkg
|
VCPKG_DIR_BASE=.vcpkg
|
||||||
endif
|
endif
|
||||||
@ -33,17 +35,17 @@ endif
|
|||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build:
|
build:
|
||||||
$(foreach file, $(wildcard build/*), ${ENV_RUN} cmake --build $(file) --target;)
|
${ENV_RUN} ${CMAKE_BUILD} build
|
||||||
.PHONY: pkg-gba
|
.PHONY: pkg-gba
|
||||||
pkg-gba:
|
pkg-gba:
|
||||||
$(foreach file, $(wildcard build/*), ${ENV_RUN} cmake --build $(file) --target install;)
|
${ENV_RUN} ${CMAKE_BUILD} build install
|
||||||
${ENV_RUN} ./scripts/pkg-gba sample_project
|
${ENV_RUN} ./scripts/pkg-gba sample_project
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install:
|
install:
|
||||||
$(foreach file, $(wildcard build/*), ${ENV_RUN} cmake --build $(file) --target install;)
|
${ENV_RUN} ${CMAKE_BUILD} build install
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
$(foreach file, $(wildcard build/*), ${ENV_RUN} cmake --build $(file) --target clean;)
|
${ENV_RUN} ${CMAKE_BUILD} build clean
|
||||||
.PHONY: purge
|
.PHONY: purge
|
||||||
purge:
|
purge:
|
||||||
${ENV_RUN} ${RM_RF} .current_build
|
${ENV_RUN} ${RM_RF} .current_build
|
||||||
|
18
scripts/pybb
18
scripts/pybb
@ -3,20 +3,34 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import stat
|
import stat
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def mkdir(path):
|
def mkdir(path):
|
||||||
if not os.path.exists(path) and os.path.isdir(path):
|
if not os.path.exists(path) and os.path.isdir(path):
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
|
|
||||||
|
# this exists because Windows is utterly incapable of providing a proper rm -rf
|
||||||
def rm(path):
|
def rm(path):
|
||||||
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)
|
||||||
|
|
||||||
if sys.argv[1] == 'mkdir':
|
def cmake_build(base_path, target):
|
||||||
|
for d in os.listdir(base_path):
|
||||||
|
args = ['cmake', '--build', os.path.join(base_path, d), '--target']
|
||||||
|
if target is not None:
|
||||||
|
args.append(target)
|
||||||
|
err = subprocess.run(args).returncode
|
||||||
|
if err != 0:
|
||||||
|
sys.exit(err)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
if sys.argv[1] == 'mkdir':
|
||||||
mkdir(sys.argv[2])
|
mkdir(sys.argv[2])
|
||||||
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])
|
||||||
|
elif sys.argv[1] == 'cmake-build':
|
||||||
|
cmake_build(sys.argv[2], sys.argv[3] if len(sys.argv) > 3 else None)
|
||||||
|
Loading…
Reference in New Issue
Block a user