Compare commits
No commits in common. "986c76a4768822dcfe6a926e26e791c38b3e0d2b" and "e17ba1e17a1bb35809b11a18352d21d6f93fcb70" have entirely different histories.
986c76a476
...
e17ba1e17a
12
Makefile
12
Makefile
@ -1,12 +1,12 @@
|
|||||||
BC_VAR_PROJECT_NAME=CppProject
|
BC_PROJECT_NAME=CppProject
|
||||||
BC_VAR_VCPKG_PKGS=
|
BC_VCPKG_PKGS=
|
||||||
BUILDCORE_PATH=deps/buildcore
|
BUILDCORE_PATH=deps/buildcore
|
||||||
include ${BUILDCORE_PATH}/base.mk
|
include ${BUILDCORE_PATH}/base.mk
|
||||||
|
|
||||||
ifeq ($(BC_VAR_OS),darwin)
|
ifeq ($(BC_OS),darwin)
|
||||||
PROJECT_EXECUTABLE=./build/${BC_VAR_CURRENT_BUILD}/${BC_VAR_PROJECT_NAME}.app/Contents/MacOS/${BC_VAR_PROJECT_NAME}
|
PROJECT_EXECUTABLE=./build/${BC_CURRENT_BUILD}/${BC_PROJECT_NAME}.app/Contents/MacOS/${BC_PROJECT_NAME}
|
||||||
else
|
else
|
||||||
PROJECT_EXECUTABLE=./build/${BC_VAR_CURRENT_BUILD}/bin/${BC_VAR_PROJECT_NAME}
|
PROJECT_EXECUTABLE=./build/${BC_CURRENT_BUILD}/bin/${BC_PROJECT_NAME}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
@ -14,4 +14,4 @@ run: build
|
|||||||
${BC_ENVRUN} ${PROJECT_EXECUTABLE}
|
${BC_ENVRUN} ${PROJECT_EXECUTABLE}
|
||||||
.PHONY: debug
|
.PHONY: debug
|
||||||
debug: build
|
debug: build
|
||||||
${BC_DEBUGGER} ${PROJECT_EXECUTABLE}
|
${BC_ENVRUN} ${BC_DEBUGGER} ${PROJECT_EXECUTABLE}
|
||||||
|
152
deps/buildcore/base.mk
vendored
152
deps/buildcore/base.mk
vendored
@ -9,76 +9,86 @@
|
|||||||
ifeq (${OS},Windows_NT)
|
ifeq (${OS},Windows_NT)
|
||||||
SHELL := powershell.exe
|
SHELL := powershell.exe
|
||||||
.SHELLFLAGS := -NoProfile -Command
|
.SHELLFLAGS := -NoProfile -Command
|
||||||
BC_VAR_OS=windows
|
BC_OS=windows
|
||||||
|
BC_HOST_ENV=${BC_OS}
|
||||||
else
|
else
|
||||||
BC_VAR_OS=$(shell uname | tr [:upper:] [:lower:])
|
BC_OS=$(shell uname | tr [:upper:] [:lower:])
|
||||||
|
BC_HOST_ENV=${BC_OS}-$(shell uname -m)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef BC_USE_DOCKER_DEVENV
|
ifdef BC_USE_DOCKER_DEVENV
|
||||||
ifneq ($(shell which docker 2> /dev/null),)
|
ifneq ($(shell which docker 2> /dev/null),)
|
||||||
BC_VAR_DEVENV=devenv$(shell pwd | sed 's/\//-/g')
|
BC_DEVENV=devenv$(shell pwd | sed 's/\//-/g')
|
||||||
BC_VAR_DEVENV_IMAGE=${BC_VAR_PROJECT_NAME}-devenv
|
BC_DEVENV_IMAGE=${BC_PROJECT_NAME}-devenv
|
||||||
ifeq ($(shell docker inspect --format="{{.State.Status}}" ${BC_VAR_DEVENV} 2>&1),running)
|
ifeq ($(shell docker inspect --format="{{.State.Status}}" ${BC_DEVENV} 2>&1),running)
|
||||||
BC_CMD_ENVRUN=docker exec -i -t --user $(shell id -u ${USER}) ${BC_VAR_DEVENV}
|
BC_ENVRUN=docker exec -i -t --user $(shell id -u ${USER}) ${BC_DEVENV}
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(shell ${BC_CMD_ENVRUN} which python3 2> /dev/null),)
|
ifneq ($(shell ${BC_ENVRUN} which python3 2> /dev/null),)
|
||||||
BC_PY3=${BC_CMD_ENVRUN} python3
|
BC_PY3=${BC_ENVRUN} python3
|
||||||
else
|
else
|
||||||
ifeq ($(shell ${BC_CMD_ENVRUN} python -c 'import sys; print(sys.version_info[0])'),3)
|
ifeq ($(shell ${BC_ENVRUN} python -c 'import sys; print(sys.version_info[0])'),3)
|
||||||
BC_PY3=${BC_CMD_ENVRUN} python
|
BC_PY3=python
|
||||||
else
|
else
|
||||||
echo 'Please install Python3'
|
echo 'Please install Python3'
|
||||||
exit 1
|
exit 1
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
BC_VAR_SCRIPTS=${BUILDCORE_PATH}/scripts
|
BC_SCRIPTS=${BUILDCORE_PATH}/scripts
|
||||||
BC_CMD_SETUP_BUILD=${BC_PY3} ${BC_VAR_SCRIPTS}/setup-build.py
|
BC_SETUP_BUILD=${BC_PY3} ${BC_SCRIPTS}/setup-build.py
|
||||||
BC_CMD_PYBB=${BC_PY3} ${BC_VAR_SCRIPTS}/pybb.py
|
BC_PYBB=${BC_PY3} ${BC_SCRIPTS}/pybb.py
|
||||||
BC_CMD_CMAKE_BUILD=${BC_CMD_PYBB} cmake-build
|
BC_CMAKE_BUILD=${BC_PYBB} cmake-build
|
||||||
BC_CMD_GETENV=${BC_CMD_PYBB} getenv
|
BC_GETENV=${BC_PYBB} getenv
|
||||||
BC_CMD_CTEST=${BC_CMD_PYBB} ctest-all
|
BC_CTEST=${BC_PYBB} ctest-all
|
||||||
BC_CMD_RM_RF=${BC_CMD_PYBB} rm
|
BC_RM_RF=${BC_PYBB} rm
|
||||||
BC_CMD_MKDIR_P=${BC_CMD_PYBB} mkdir
|
BC_CAT=${BC_PYBB} cat
|
||||||
BC_CMD_CAT=${BC_CMD_PYBB} cat
|
BC_BUILD_PATH=build
|
||||||
BC_CMD_DEBUGGER=${BC_CMD_PYBB} debug
|
ifdef BC_USE_VCPKG
|
||||||
BC_VAR_HOSTENV=$(shell ${BC_CMD_ENVRUN} ${BC_CMD_PYBB} hostenv)
|
ifndef BC_VCPKG_DIR_BASE
|
||||||
BC_VAR_BUILD_PATH=build
|
BC_VCPKG_DIR_BASE=.vcpkg
|
||||||
BC_VAR_CURRENT_BUILD=$(BC_VAR_HOSTENV)-$(shell ${BC_CMD_ENVRUN} ${BC_CMD_CAT} .current_build)
|
endif
|
||||||
|
ifndef BC_VCPKG_VERSION
|
||||||
|
BC_VCPKG_VERSION=2023.08.09
|
||||||
|
endif
|
||||||
|
BC_VCPKG_TOOLCHAIN=--toolchain=${BC_VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake
|
||||||
|
endif
|
||||||
|
BC_DEBUGGER=${BC_PYBB} debug
|
||||||
|
|
||||||
|
BC_VCPKG_DIR=$(BC_VCPKG_DIR_BASE)/$(BC_VCPKG_VERSION)-$(BC_HOST_ENV)
|
||||||
|
BC_CURRENT_BUILD=$(BC_HOST_ENV)-$(shell ${BC_ENVRUN} ${BC_CAT} .current_build)
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build:
|
build:
|
||||||
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH}
|
${BC_ENVRUN} ${BC_CMAKE_BUILD} ${BC_BUILD_PATH}
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install:
|
install:
|
||||||
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH} install
|
${BC_ENVRUN} ${BC_CMAKE_BUILD} ${BC_BUILD_PATH} install
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH} clean
|
${BC_ENVRUN} ${BC_CMAKE_BUILD} ${BC_BUILD_PATH} clean
|
||||||
.PHONY: purge
|
.PHONY: purge
|
||||||
purge:
|
purge:
|
||||||
${BC_CMD_RM_RF} .current_build
|
${BC_ENVRUN} ${BC_RM_RF} .current_build
|
||||||
${BC_CMD_RM_RF} ${BC_VAR_BUILD_PATH}
|
${BC_ENVRUN} ${BC_RM_RF} ${BC_BUILD_PATH}
|
||||||
${BC_CMD_RM_RF} dist
|
${BC_ENVRUN} ${BC_RM_RF} dist
|
||||||
${BC_CMD_RM_RF} compile_commands.json
|
${BC_ENVRUN} ${BC_RM_RF} compile_commands.json
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: build
|
test: build
|
||||||
${BC_CMD_ENVRUN} mypy ${BC_VAR_SCRIPTS}
|
${BC_ENVRUN} mypy ${BC_SCRIPTS}
|
||||||
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH} test
|
${BC_ENVRUN} ${BC_CMAKE_BUILD} ${BC_BUILD_PATH} test
|
||||||
.PHONY: test-verbose
|
.PHONY: test-verbose
|
||||||
test-verbose: build
|
test-verbose: build
|
||||||
${BC_CMD_CTEST} ${BC_VAR_BUILD_PATH} --output-on-failure
|
${BC_ENVRUN} ${BC_CTEST} ${BC_BUILD_PATH} --output-on-failure
|
||||||
.PHONY: test-rerun-verbose
|
.PHONY: test-rerun-verbose
|
||||||
test-rerun-verbose: build
|
test-rerun-verbose: build
|
||||||
${BC_CMD_CTEST} ${BC_VAR_BUILD_PATH} --rerun-failed --output-on-failure
|
${BC_ENVRUN} ${BC_CTEST} ${BC_BUILD_PATH} --rerun-failed --output-on-failure
|
||||||
|
|
||||||
ifdef BC_USE_DOCKER_DEVENV
|
|
||||||
.PHONY: devenv-image
|
.PHONY: devenv-image
|
||||||
devenv-image:
|
devenv-image:
|
||||||
docker build . -t ${BC_VAR_DEVENV_IMAGE}
|
docker build . -t ${BC_DEVENV_IMAGE}
|
||||||
.PHONY: devenv-create
|
.PHONY: devenv-create
|
||||||
devenv-create:
|
devenv-create:
|
||||||
docker run -d \
|
docker run -d \
|
||||||
@ -90,83 +100,73 @@ devenv-create:
|
|||||||
-v $(shell pwd):/usr/src/project \
|
-v $(shell pwd):/usr/src/project \
|
||||||
-v /dev/shm:/dev/shm \
|
-v /dev/shm:/dev/shm \
|
||||||
--restart=always \
|
--restart=always \
|
||||||
--name ${BC_VAR_DEVENV} \
|
--name ${BC_DEVENV} \
|
||||||
-t ${BC_VAR_DEVENV_IMAGE} bash
|
-t ${BC_DEVENV_IMAGE} bash
|
||||||
.PHONY: devenv-destroy
|
.PHONY: devenv-destroy
|
||||||
devenv-destroy:
|
devenv-destroy:
|
||||||
docker rm -f ${BC_VAR_DEVENV}
|
docker rm -f ${BC_DEVENV}
|
||||||
ifdef BC_CMD_ENVRUN
|
ifdef BC_ENVRUN
|
||||||
.PHONY: devenv-shell
|
.PHONY: devenv-shell
|
||||||
devenv-shell:
|
devenv-shell:
|
||||||
${BC_CMD_ENVRUN} bash
|
${BC_ENVRUN} bash
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef BC_USE_VCPKG
|
ifdef BC_USE_VCPKG
|
||||||
|
|
||||||
ifndef BC_VCPKG_DIR_BASE
|
|
||||||
BC_VCPKG_DIR_BASE=.vcpkg
|
|
||||||
endif
|
|
||||||
ifndef BC_VCPKG_VERSION
|
|
||||||
BC_VCPKG_VERSION=2023.08.09
|
|
||||||
endif
|
|
||||||
BC_VCPKG_TOOLCHAIN=--toolchain=${BC_VAR_VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake
|
|
||||||
BC_VAR_VCPKG_DIR=$(BC_VCPKG_DIR_BASE)/$(BC_VCPKG_VERSION)-$(BC_VAR_HOSTENV)
|
|
||||||
|
|
||||||
.PHONY: vcpkg
|
.PHONY: vcpkg
|
||||||
vcpkg: ${BC_VAR_VCPKG_DIR} vcpkg-install
|
vcpkg: ${BC_VCPKG_DIR} vcpkg-install
|
||||||
|
|
||||||
${BC_VAR_VCPKG_DIR}:
|
${BC_VCPKG_DIR}:
|
||||||
${BC_CMD_RM_RF} ${BC_VAR_VCPKG_DIR}
|
${BC_ENVRUN} ${BC_RM_RF} ${BC_VCPKG_DIR}
|
||||||
${BC_CMD_PYBB} mkdir ${BC_VCPKG_DIR_BASE}
|
${BC_ENVRUN} mkdir -p ${BC_VCPKG_DIR_BASE}
|
||||||
${BC_CMD_ENVRUN} git clone -b release --depth 1 --branch ${BC_VCPKG_VERSION} https://github.com/microsoft/vcpkg.git ${BC_VAR_VCPKG_DIR}
|
${BC_ENVRUN} git clone -b release --depth 1 --branch ${BC_VCPKG_VERSION} https://github.com/microsoft/vcpkg.git ${BC_VCPKG_DIR}
|
||||||
ifneq (${BC_VAR_OS},windows)
|
ifneq (${BC_OS},windows)
|
||||||
${BC_CMD_ENVRUN} ${BC_VAR_VCPKG_DIR}/bootstrap-vcpkg.sh
|
${BC_ENVRUN} ${BC_VCPKG_DIR}/bootstrap-vcpkg.sh
|
||||||
else
|
else
|
||||||
${BC_CMD_ENVRUN} ${BC_VAR_VCPKG_DIR}/bootstrap-vcpkg.bat
|
${BC_ENVRUN} ${BC_VCPKG_DIR}/bootstrap-vcpkg.bat
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: vcpkg-install
|
.PHONY: vcpkg-install
|
||||||
vcpkg-install:
|
vcpkg-install:
|
||||||
ifneq (${BC_VAR_OS},windows)
|
ifneq (${BC_OS},windows)
|
||||||
${BC_CMD_ENVRUN} ${BC_VAR_VCPKG_DIR}/vcpkg install ${BC_VCPKG_PKGS}
|
${BC_ENVRUN} ${BC_VCPKG_DIR}/vcpkg install ${BC_VCPKG_PKGS}
|
||||||
else
|
else
|
||||||
${BC_CMD_ENVRUN} ${BC_VAR_VCPKG_DIR}/vcpkg install --triplet x64-windows ${BC_VCPKG_PKGS}
|
${BC_ENVRUN} ${BC_VCPKG_DIR}/vcpkg install --triplet x64-windows ${BC_VCPKG_PKGS}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
else ifdef USE_CONAN # USE_VCPKG / USE_CONAN ####################################
|
else ifdef USE_CONAN # USE_CONAN ################################################
|
||||||
|
|
||||||
.PHONY: setup-conan
|
.PHONY: setup-conan
|
||||||
conan-config:
|
conan-config:
|
||||||
${BC_CMD_ENVRUN} conan profile new ${BC_VAR_PROJECT_NAME} --detect --force
|
${BC_ENVRUN} conan profile new ${BC_PROJECT_NAME} --detect --force
|
||||||
ifeq ($(BC_VAR_OS),linux)
|
ifeq ($(BC_OS),linux)
|
||||||
${BC_CMD_ENVRUN} conan profile update settings.compiler.libcxx=libstdc++11 ${BC_VAR_PROJECT_NAME}
|
${BC_ENVRUN} conan profile update settings.compiler.libcxx=libstdc++11 ${BC_PROJECT_NAME}
|
||||||
else
|
else
|
||||||
${BC_CMD_ENVRUN} conan profile update settings.compiler.cppstd=20 ${BC_VAR_PROJECT_NAME}
|
${BC_ENVRUN} conan profile update settings.compiler.cppstd=20 ${BC_PROJECT_NAME}
|
||||||
ifeq ($(BC_VAR_OS),windows)
|
ifeq ($(BC_OS),windows)
|
||||||
${BC_CMD_ENVRUN} conan profile update settings.compiler.runtime=static ${BC_VAR_PROJECT_NAME}
|
${BC_ENVRUN} conan profile update settings.compiler.runtime=static ${BC_PROJECT_NAME}
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: conan
|
.PHONY: conan
|
||||||
conan:
|
conan:
|
||||||
${BC_CMD_PYBB} conan-install ${BC_VAR_PROJECT_NAME}
|
${BC_ENVRUN} ${BC_PYBB} conan-install ${BC_PROJECT_NAME}
|
||||||
endif # USE_CONAN ###############################################
|
endif # USE_CONAN ###############################################
|
||||||
|
|
||||||
ifeq (${BC_VAR_OS},darwin)
|
ifeq (${BC_OS},darwin)
|
||||||
.PHONY: configure-xcode
|
.PHONY: configure-xcode
|
||||||
configure-xcode:
|
configure-xcode:
|
||||||
${BC_CMD_SETUP_BUILD} ${BC_VCPKG_TOOLCHAIN} --build_tool=xcode --current_build=0 --build_root=${BC_VAR_BUILD_PATH}
|
${BC_ENVRUN} ${BC_SETUP_BUILD} ${BC_VCPKG_TOOLCHAIN} --build_tool=xcode --current_build=0 --build_root=${BC_BUILD_PATH}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: configure-release
|
.PHONY: configure-release
|
||||||
configure-release:
|
configure-release:
|
||||||
${BC_CMD_SETUP_BUILD} ${BC_VCPKG_TOOLCHAIN} --build_type=release --build_root=${BC_VAR_BUILD_PATH}
|
${BC_ENVRUN} ${BC_SETUP_BUILD} ${BC_VCPKG_TOOLCHAIN} --build_type=release --build_root=${BC_BUILD_PATH}
|
||||||
|
|
||||||
.PHONY: configure-debug
|
.PHONY: configure-debug
|
||||||
configure-debug:
|
configure-debug:
|
||||||
${BC_CMD_SETUP_BUILD} ${BC_VCPKG_TOOLCHAIN} --build_type=debug --build_root=${BC_VAR_BUILD_PATH}
|
${BC_ENVRUN} ${BC_SETUP_BUILD} ${BC_VCPKG_TOOLCHAIN} --build_type=debug --build_root=${BC_BUILD_PATH}
|
||||||
|
|
||||||
.PHONY: configure-asan
|
.PHONY: configure-asan
|
||||||
configure-asan:
|
configure-asan:
|
||||||
${BC_CMD_SETUP_BUILD} ${BC_VCPKG_TOOLCHAIN} --build_type=asan --build_root=${BC_VAR_BUILD_PATH}
|
${BC_ENVRUN} ${BC_SETUP_BUILD} ${BC_VCPKG_TOOLCHAIN} --build_type=asan --build_root=${BC_BUILD_PATH}
|
||||||
|
|
||||||
|
51
deps/buildcore/scripts/pybb.py
vendored
51
deps/buildcore/scripts/pybb.py
vendored
@ -18,20 +18,21 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
import util
|
|
||||||
|
def mkdir(path: str):
|
||||||
|
if not os.path.exists(path):
|
||||||
|
os.mkdir(path)
|
||||||
|
|
||||||
|
|
||||||
def mkdir(path: str) -> int:
|
# this exists because Windows is utterly incapable of providing a proper rm -rf
|
||||||
try:
|
def rm(path: str):
|
||||||
util.mkdir_p(path)
|
file_exists = os.path.exists(path)
|
||||||
except Exception:
|
is_link = os.path.islink(path)
|
||||||
return 1
|
is_dir = os.path.isdir(path)
|
||||||
return 0
|
if (file_exists or is_link) and not is_dir:
|
||||||
|
os.remove(path)
|
||||||
|
elif os.path.isdir(path):
|
||||||
def rm_multi(paths: List[str]):
|
shutil.rmtree(path)
|
||||||
for path in paths:
|
|
||||||
util.rm(path)
|
|
||||||
|
|
||||||
|
|
||||||
def ctest_all() -> int:
|
def ctest_all() -> int:
|
||||||
@ -86,10 +87,11 @@ def cat(paths: List[str]) -> int:
|
|||||||
try:
|
try:
|
||||||
with open(path) as f:
|
with open(path) as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
print(data)
|
sys.stdout.write(data)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
sys.stderr.write(f'cat: {path}: no such file or directory\n')
|
sys.stderr.write(f'cat: {path}: no such file or directory\n')
|
||||||
return 1
|
return 1
|
||||||
|
sys.stdout.write('\n')
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
@ -105,21 +107,12 @@ def debug(paths: List[str]) -> int:
|
|||||||
def get_env(var_name: str) -> int:
|
def get_env(var_name: str) -> int:
|
||||||
if var_name not in os.environ:
|
if var_name not in os.environ:
|
||||||
return 1
|
return 1
|
||||||
print(os.environ[var_name])
|
sys.stdout.write(os.environ[var_name])
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def hostname() -> int:
|
def hostname() -> int:
|
||||||
print(platform.node())
|
sys.stdout.write(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
|
return 0
|
||||||
|
|
||||||
|
|
||||||
@ -130,9 +123,13 @@ def clarg(idx: int) -> Optional[str]:
|
|||||||
def main() -> int:
|
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 Exception:
|
||||||
|
err = 1
|
||||||
elif sys.argv[1] == 'rm':
|
elif sys.argv[1] == 'rm':
|
||||||
rm_multi(sys.argv[2:])
|
for i in range(2, len(sys.argv)):
|
||||||
|
rm(sys.argv[i])
|
||||||
elif sys.argv[1] == 'conan-install':
|
elif sys.argv[1] == 'conan-install':
|
||||||
err = conan()
|
err = conan()
|
||||||
elif sys.argv[1] == 'ctest-all':
|
elif sys.argv[1] == 'ctest-all':
|
||||||
@ -147,8 +144,6 @@ def main() -> int:
|
|||||||
err = get_env(sys.argv[2])
|
err = get_env(sys.argv[2])
|
||||||
elif sys.argv[1] == 'hostname':
|
elif sys.argv[1] == 'hostname':
|
||||||
err = hostname()
|
err = hostname()
|
||||||
elif sys.argv[1] == 'hostenv':
|
|
||||||
err = host_env()
|
|
||||||
else:
|
else:
|
||||||
sys.stderr.write('Command not found\n')
|
sys.stderr.write('Command not found\n')
|
||||||
err = 1
|
err = 1
|
||||||
|
45
deps/buildcore/scripts/setup-build.py
vendored
45
deps/buildcore/scripts/setup-build.py
vendored
@ -15,35 +15,19 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import util
|
from pybb import mkdir, rm
|
||||||
|
|
||||||
|
os_name = os.uname().sysname.lower()
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument('--target', help='Platform target',
|
||||||
'--target',
|
default='{:s}-{:s}'.format(os_name, platform.machine()))
|
||||||
help='Platform target',
|
parser.add_argument('--build_type', help='Build type (asan,debug,release)', default='release')
|
||||||
default=f'{util.get_os()}-{util.get_arch()}')
|
parser.add_argument('--build_tool', help='Build tool (default,xcode)', default='')
|
||||||
parser.add_argument(
|
parser.add_argument('--build_root', help='Path to the root of build directories (must be in project dir)', default='build')
|
||||||
'--build_type',
|
parser.add_argument('--toolchain', help='Path to CMake toolchain file', default='')
|
||||||
help='Build type (asan,debug,release)',
|
parser.add_argument('--current_build', help='Indicates whether or not to make this the active build', default=1)
|
||||||
default='release')
|
|
||||||
parser.add_argument(
|
|
||||||
'--build_tool',
|
|
||||||
help='Build tool (default,xcode)',
|
|
||||||
default='')
|
|
||||||
parser.add_argument(
|
|
||||||
'--build_root',
|
|
||||||
help='Path to the root build directory (must be in project dir)',
|
|
||||||
default='build')
|
|
||||||
parser.add_argument(
|
|
||||||
'--toolchain',
|
|
||||||
help='Path to CMake toolchain file',
|
|
||||||
default='')
|
|
||||||
parser.add_argument(
|
|
||||||
'--current_build',
|
|
||||||
help='Indicates whether or not to make this the active build',
|
|
||||||
default=1)
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.build_type == 'asan':
|
if args.build_type == 'asan':
|
||||||
@ -81,8 +65,8 @@ def main() -> int:
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
project_dir = os.getcwd()
|
project_dir = os.getcwd()
|
||||||
build_dir = f'{project_dir}/{args.build_root}/{build_config}'
|
build_dir = '{:s}/{:s}/{:s}'.format(project_dir, args.build_root, build_config)
|
||||||
util.rm(build_dir)
|
rm(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',
|
||||||
@ -99,16 +83,15 @@ def main() -> int:
|
|||||||
|
|
||||||
subprocess.run(cmake_cmd)
|
subprocess.run(cmake_cmd)
|
||||||
|
|
||||||
util.mkdir_p('dist')
|
mkdir('dist')
|
||||||
if int(args.current_build) != 0:
|
if int(args.current_build) != 0:
|
||||||
cb = open('.current_build', 'w')
|
cb = open('.current_build', 'w')
|
||||||
cb.write(args.build_type)
|
cb.write(args.build_type)
|
||||||
cb.close()
|
cb.close()
|
||||||
|
|
||||||
util.rm('compile_commands.json')
|
rm('compile_commands.json')
|
||||||
if platform.system() != 'Windows':
|
if platform.system() != 'Windows':
|
||||||
os.symlink(f'{build_dir}/compile_commands.json',
|
os.symlink('{:s}/compile_commands.json'.format(build_dir), 'compile_commands.json')
|
||||||
'compile_commands.json')
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
38
deps/buildcore/scripts/util.py
vendored
38
deps/buildcore/scripts/util.py
vendored
@ -1,38 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright 2016 - 2021 gary@drinkingtea.net
|
|
||||||
#
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
#
|
|
||||||
|
|
||||||
import os
|
|
||||||
import platform
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
def mkdir_p(path: str):
|
|
||||||
if not os.path.exists(path):
|
|
||||||
os.mkdir(path)
|
|
||||||
|
|
||||||
|
|
||||||
# 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 get_os() -> str:
|
|
||||||
return os.uname().sysname.lower()
|
|
||||||
|
|
||||||
|
|
||||||
def get_arch() -> str:
|
|
||||||
arch = platform.machine()
|
|
||||||
if arch == 'amd64':
|
|
||||||
arch = 'x86_64'
|
|
||||||
return arch
|
|
Loading…
x
Reference in New Issue
Block a user