[buildcore] Update buildcore
This commit is contained in:
parent
629383e2e2
commit
401ff5a287
158
deps/buildcore/base.mk
vendored
158
deps/buildcore/base.mk
vendored
@ -9,90 +9,86 @@
|
|||||||
ifeq (${OS},Windows_NT)
|
ifeq (${OS},Windows_NT)
|
||||||
SHELL := powershell.exe
|
SHELL := powershell.exe
|
||||||
.SHELLFLAGS := -NoProfile -Command
|
.SHELLFLAGS := -NoProfile -Command
|
||||||
OS=windows
|
BC_OS=windows
|
||||||
HOST_ENV=${OS}
|
BC_HOST_ENV=${BC_OS}
|
||||||
else
|
else
|
||||||
OS=$(shell uname | tr [:upper:] [:lower:])
|
BC_OS=$(shell uname | tr [:upper:] [:lower:])
|
||||||
HOST_ENV=${OS}-$(shell uname -m)
|
BC_HOST_ENV=${BC_OS}-$(shell uname -m)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
DEVENV=devenv$(shell pwd | sed 's/\//-/g')
|
ifdef BC_USE_DOCKER_DEVENV
|
||||||
DEVENV_IMAGE=${PROJECT_NAME}-devenv
|
|
||||||
ifneq ($(shell which docker 2> /dev/null),)
|
ifneq ($(shell which docker 2> /dev/null),)
|
||||||
ifeq ($(shell docker inspect --format="{{.State.Status}}" ${DEVENV} 2>&1),running)
|
BC_DEVENV=devenv$(shell pwd | sed 's/\//-/g')
|
||||||
ENV_RUN=docker exec -i -t --user $(shell id -u ${USER}) ${DEVENV}
|
BC_DEVENV_IMAGE=${BC_PROJECT_NAME}-devenv
|
||||||
|
ifeq ($(shell docker inspect --format="{{.State.Status}}" ${BC_DEVENV} 2>&1),running)
|
||||||
|
BC_ENVRUN=docker exec -i -t --user $(shell id -u ${USER}) ${BC_DEVENV}
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(shell ${ENV_RUN} which python3 2> /dev/null),)
|
ifneq ($(shell ${BC_ENVRUN} which python3 2> /dev/null),)
|
||||||
PYTHON3=python3
|
BC_PY3=${BC_ENVRUN} python3
|
||||||
else
|
else
|
||||||
ifeq ($(shell ${ENV_RUN} python -c 'import sys; print(sys.version_info[0])'),3)
|
ifeq ($(shell ${BC_ENVRUN} python -c 'import sys; print(sys.version_info[0])'),3)
|
||||||
PYTHON3=python
|
BC_PY3=python
|
||||||
|
else
|
||||||
|
echo 'Please install Python3'
|
||||||
|
exit 1
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
SCRIPTS=${BUILDCORE_PATH}/scripts
|
BC_SCRIPTS=${BUILDCORE_PATH}/scripts
|
||||||
SETUP_BUILD=${PYTHON3} ${SCRIPTS}/setup-build.py
|
BC_SETUP_BUILD=${BC_PY3} ${BC_SCRIPTS}/setup-build.py
|
||||||
PYBB=${PYTHON3} ${SCRIPTS}/pybb.py
|
BC_PYBB=${BC_PY3} ${BC_SCRIPTS}/pybb.py
|
||||||
CMAKE_BUILD=${PYBB} cmake-build
|
BC_CMAKE_BUILD=${BC_PYBB} cmake-build
|
||||||
GET_ENV=${PYBB} getenv
|
BC_GETENV=${BC_PYBB} getenv
|
||||||
CTEST=${PYBB} ctest-all
|
BC_CTEST=${BC_PYBB} ctest-all
|
||||||
RM_RF=${PYBB} rm
|
BC_RM_RF=${BC_PYBB} rm
|
||||||
HOST=$(shell ${PYBB} hostname)
|
BC_CAT=${BC_PYBB} cat
|
||||||
BUILDCORE_HOST_SPECIFIC_BUILDPATH=$(shell ${GET_ENV} BUILDCORE_HOST_SPECIFIC_BUILDPATH)
|
BC_BUILD_PATH=build
|
||||||
ifneq (${BUILDCORE_HOST_SPECIFIC_BUILDPATH},)
|
ifdef BC_USE_VCPKG
|
||||||
BUILD_PATH=build/${HOST}
|
ifndef BC_VCPKG_DIR_BASE
|
||||||
else
|
BC_VCPKG_DIR_BASE=.vcpkg
|
||||||
BUILD_PATH=build
|
|
||||||
endif
|
endif
|
||||||
ifdef USE_VCPKG
|
ifndef BC_VCPKG_VERSION
|
||||||
ifndef VCPKG_DIR_BASE
|
BC_VCPKG_VERSION=2023.08.09
|
||||||
VCPKG_DIR_BASE=.vcpkg
|
|
||||||
endif
|
endif
|
||||||
ifndef VCPKG_VERSION
|
BC_VCPKG_TOOLCHAIN=--toolchain=${BC_VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake
|
||||||
VCPKG_VERSION=2020.06
|
|
||||||
endif
|
|
||||||
VCPKG_TOOLCHAIN=--toolchain=${VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake
|
|
||||||
endif
|
|
||||||
ifeq ($(OS),darwin)
|
|
||||||
DEBUGGER=lldb --
|
|
||||||
else
|
|
||||||
DEBUGGER=gdb --args
|
|
||||||
endif
|
endif
|
||||||
|
BC_DEBUGGER=${BC_PYBB} debug
|
||||||
|
|
||||||
VCPKG_DIR=$(VCPKG_DIR_BASE)/$(VCPKG_VERSION)-$(HOST_ENV)
|
BC_VCPKG_DIR=$(BC_VCPKG_DIR_BASE)/$(BC_VCPKG_VERSION)-$(BC_HOST_ENV)
|
||||||
CURRENT_BUILD=$(HOST_ENV)-$(shell ${ENV_RUN} ${PYBB} cat .current_build)
|
BC_CURRENT_BUILD=$(BC_HOST_ENV)-$(shell ${BC_ENVRUN} ${BC_CAT} .current_build)
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build:
|
build:
|
||||||
${ENV_RUN} ${CMAKE_BUILD} ${BUILD_PATH}
|
${BC_ENVRUN} ${BC_CMAKE_BUILD} ${BC_BUILD_PATH}
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install:
|
install:
|
||||||
${ENV_RUN} ${CMAKE_BUILD} ${BUILD_PATH} install
|
${BC_ENVRUN} ${BC_CMAKE_BUILD} ${BC_BUILD_PATH} install
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
${ENV_RUN} ${CMAKE_BUILD} ${BUILD_PATH} clean
|
${BC_ENVRUN} ${BC_CMAKE_BUILD} ${BC_BUILD_PATH} clean
|
||||||
.PHONY: purge
|
.PHONY: purge
|
||||||
purge:
|
purge:
|
||||||
${ENV_RUN} ${RM_RF} .current_build
|
${BC_ENVRUN} ${BC_RM_RF} .current_build
|
||||||
${ENV_RUN} ${RM_RF} ${BUILD_PATH}
|
${BC_ENVRUN} ${BC_RM_RF} ${BC_BUILD_PATH}
|
||||||
${ENV_RUN} ${RM_RF} dist
|
${BC_ENVRUN} ${BC_RM_RF} dist
|
||||||
${ENV_RUN} ${RM_RF} compile_commands.json
|
${BC_ENVRUN} ${BC_RM_RF} compile_commands.json
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: build
|
test: build
|
||||||
${ENV_RUN} mypy ${SCRIPTS}
|
${BC_ENVRUN} mypy ${BC_SCRIPTS}
|
||||||
${ENV_RUN} ${CMAKE_BUILD} ${BUILD_PATH} test
|
${BC_ENVRUN} ${BC_CMAKE_BUILD} ${BC_BUILD_PATH} test
|
||||||
.PHONY: test-verbose
|
.PHONY: test-verbose
|
||||||
test-verbose: build
|
test-verbose: build
|
||||||
${ENV_RUN} ${CTEST} ${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
|
||||||
${ENV_RUN} ${CTEST} ${BUILD_PATH} --rerun-failed --output-on-failure
|
${BC_ENVRUN} ${BC_CTEST} ${BC_BUILD_PATH} --rerun-failed --output-on-failure
|
||||||
|
|
||||||
.PHONY: devenv-image
|
.PHONY: devenv-image
|
||||||
devenv-image:
|
devenv-image:
|
||||||
docker build . -t ${DEVENV_IMAGE}
|
docker build . -t ${BC_DEVENV_IMAGE}
|
||||||
.PHONY: devenv-create
|
.PHONY: devenv-create
|
||||||
devenv-create:
|
devenv-create:
|
||||||
docker run -d \
|
docker run -d \
|
||||||
@ -104,65 +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 ${DEVENV} \
|
--name ${BC_DEVENV} \
|
||||||
-t ${DEVENV_IMAGE} bash
|
-t ${BC_DEVENV_IMAGE} bash
|
||||||
.PHONY: devenv-destroy
|
.PHONY: devenv-destroy
|
||||||
devenv-destroy:
|
devenv-destroy:
|
||||||
docker rm -f ${DEVENV}
|
docker rm -f ${BC_DEVENV}
|
||||||
ifdef ENV_RUN
|
ifdef BC_ENVRUN
|
||||||
.PHONY: devenv-shell
|
.PHONY: devenv-shell
|
||||||
devenv-shell:
|
devenv-shell:
|
||||||
${ENV_RUN} bash
|
${BC_ENVRUN} bash
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef USE_VCPKG
|
ifdef BC_USE_VCPKG
|
||||||
|
|
||||||
.PHONY: vcpkg
|
.PHONY: vcpkg
|
||||||
vcpkg: ${VCPKG_DIR} vcpkg-install
|
vcpkg: ${BC_VCPKG_DIR} vcpkg-install
|
||||||
|
|
||||||
${VCPKG_DIR}:
|
${BC_VCPKG_DIR}:
|
||||||
${ENV_RUN} ${RM_RF} ${VCPKG_DIR}
|
${BC_ENVRUN} ${BC_RM_RF} ${BC_VCPKG_DIR}
|
||||||
${ENV_RUN} mkdir -p ${VCPKG_DIR_BASE}
|
${BC_ENVRUN} mkdir -p ${BC_VCPKG_DIR_BASE}
|
||||||
${ENV_RUN} git clone -b release --depth 1 --branch ${VCPKG_VERSION} https://github.com/microsoft/vcpkg.git ${VCPKG_DIR}
|
${BC_ENVRUN} git clone -b release --depth 1 --branch ${BC_VCPKG_VERSION} https://github.com/microsoft/vcpkg.git ${BC_VCPKG_DIR}
|
||||||
ifneq (${OS},windows)
|
ifneq (${BC_OS},windows)
|
||||||
${ENV_RUN} ${VCPKG_DIR}/bootstrap-vcpkg.sh
|
${BC_ENVRUN} ${BC_VCPKG_DIR}/bootstrap-vcpkg.sh
|
||||||
else
|
else
|
||||||
${ENV_RUN} ${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 (${OS},windows)
|
ifneq (${BC_OS},windows)
|
||||||
${VCPKG_DIR}/vcpkg install ${VCPKG_PKGS}
|
${BC_ENVRUN} ${BC_VCPKG_DIR}/vcpkg install ${BC_VCPKG_PKGS}
|
||||||
else
|
else
|
||||||
${VCPKG_DIR}/vcpkg install --triplet x64-windows ${VCPKG_PKGS}
|
${BC_ENVRUN} ${BC_VCPKG_DIR}/vcpkg install --triplet x64-windows ${BC_VCPKG_PKGS}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
else ifdef USE_CONAN # USE_VCPKG ################################################
|
else ifdef USE_CONAN # USE_CONAN ################################################
|
||||||
|
|
||||||
.PHONY: setup-conan
|
.PHONY: setup-conan
|
||||||
conan-config:
|
conan-config:
|
||||||
${ENV_RUN} conan profile detect -f --name ${PROJECT_NAME}
|
${BC_ENVRUN} conan profile new ${BC_PROJECT_NAME} --detect --force
|
||||||
|
ifeq ($(BC_OS),linux)
|
||||||
|
${BC_ENVRUN} conan profile update settings.compiler.libcxx=libstdc++11 ${BC_PROJECT_NAME}
|
||||||
|
else
|
||||||
|
${BC_ENVRUN} conan profile update settings.compiler.cppstd=20 ${BC_PROJECT_NAME}
|
||||||
|
ifeq ($(BC_OS),windows)
|
||||||
|
${BC_ENVRUN} conan profile update settings.compiler.runtime=static ${BC_PROJECT_NAME}
|
||||||
|
endif
|
||||||
|
endif
|
||||||
.PHONY: conan
|
.PHONY: conan
|
||||||
conan:
|
conan:
|
||||||
${ENV_RUN} ${PYBB} conan-install ${PROJECT_NAME}
|
${BC_ENVRUN} ${BC_PYBB} conan-install ${BC_PROJECT_NAME}
|
||||||
endif # USE_VCPKG ###############################################
|
endif # USE_CONAN ###############################################
|
||||||
|
|
||||||
ifeq (${OS},darwin)
|
ifeq (${BC_OS},darwin)
|
||||||
.PHONY: configure-xcode
|
.PHONY: configure-xcode
|
||||||
configure-xcode:
|
configure-xcode:
|
||||||
${ENV_RUN} ${SETUP_BUILD} ${VCPKG_TOOLCHAIN} --build_tool=xcode --current_build=0 --build_root=${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:
|
||||||
${ENV_RUN} ${SETUP_BUILD} ${VCPKG_TOOLCHAIN} --build_type=release --build_root=${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:
|
||||||
${ENV_RUN} ${SETUP_BUILD} ${VCPKG_TOOLCHAIN} --build_type=debug --build_root=${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:
|
||||||
${ENV_RUN} ${SETUP_BUILD} ${VCPKG_TOOLCHAIN} --build_type=asan --build_root=${BUILD_PATH}
|
${BC_ENVRUN} ${BC_SETUP_BUILD} ${BC_VCPKG_TOOLCHAIN} --build_type=asan --build_root=${BC_BUILD_PATH}
|
||||||
|
|
||||||
|
35
deps/buildcore/scripts/pybb.py
vendored
35
deps/buildcore/scripts/pybb.py
vendored
@ -1,7 +1,7 @@
|
|||||||
#! /usr/bin/env python3
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2016 - 2023 gary@drinkingtea.net
|
# Copyright 2016 - 2021 gary@drinkingtea.net
|
||||||
#
|
#
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
# 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
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
@ -26,7 +26,10 @@ def mkdir(path: str):
|
|||||||
|
|
||||||
# this exists because Windows is utterly incapable of providing a proper rm -rf
|
# this exists because Windows is utterly incapable of providing a proper rm -rf
|
||||||
def rm(path: str):
|
def rm(path: str):
|
||||||
if (os.path.exists(path) or os.path.islink(path)) and not os.path.isdir(path):
|
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)
|
os.remove(path)
|
||||||
elif os.path.isdir(path):
|
elif os.path.isdir(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
@ -70,16 +73,13 @@ def conan() -> int:
|
|||||||
err = 0
|
err = 0
|
||||||
try:
|
try:
|
||||||
mkdir(conan_dir)
|
mkdir(conan_dir)
|
||||||
except:
|
except Exception:
|
||||||
return 1
|
return 1
|
||||||
if err != 0:
|
if err != 0:
|
||||||
return err
|
return err
|
||||||
args = ['conan', 'install', '../', '--build=missing', '-pr', project_name]
|
args = ['conan', 'install', '../', '--build=missing', '-pr', project_name]
|
||||||
os.chdir(conan_dir)
|
os.chdir(conan_dir)
|
||||||
err = subprocess.run(args).returncode
|
return subprocess.run(args).returncode
|
||||||
if err != 0:
|
|
||||||
return err
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
def cat(paths: List[str]) -> int:
|
def cat(paths: List[str]) -> int:
|
||||||
@ -89,12 +89,21 @@ def cat(paths: List[str]) -> int:
|
|||||||
data = f.read()
|
data = f.read()
|
||||||
sys.stdout.write(data)
|
sys.stdout.write(data)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
sys.stderr.write('cat: {}: no such file or directory\n'.format(path))
|
sys.stderr.write(f'cat: {path}: no such file or directory\n')
|
||||||
return 1
|
return 1
|
||||||
sys.stdout.write('\n')
|
sys.stdout.write('\n')
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def debug(paths: List[str]) -> int:
|
||||||
|
if shutil.which('gdb') is not None:
|
||||||
|
args = ['gdb', '--args']
|
||||||
|
elif shutil.which('lldb') is not None:
|
||||||
|
args = ['lldb', '--']
|
||||||
|
args.extend(paths)
|
||||||
|
return subprocess.run(args).returncode
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
@ -107,12 +116,16 @@ def hostname() -> int:
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def clarg(idx: int) -> Optional[str]:
|
||||||
|
return sys.argv[idx] if len(sys.argv) > idx else None
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
err = 0
|
err = 0
|
||||||
if sys.argv[1] == 'mkdir':
|
if sys.argv[1] == 'mkdir':
|
||||||
try:
|
try:
|
||||||
mkdir(sys.argv[2])
|
mkdir(sys.argv[2])
|
||||||
except:
|
except Exception:
|
||||||
err = 1
|
err = 1
|
||||||
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)):
|
||||||
@ -122,9 +135,11 @@ def main() -> int:
|
|||||||
elif sys.argv[1] == 'ctest-all':
|
elif sys.argv[1] == 'ctest-all':
|
||||||
err = ctest_all()
|
err = ctest_all()
|
||||||
elif sys.argv[1] == 'cmake-build':
|
elif sys.argv[1] == 'cmake-build':
|
||||||
err = cmake_build(sys.argv[2], sys.argv[3] if len(sys.argv) > 3 else None)
|
err = cmake_build(sys.argv[2], clarg(3))
|
||||||
elif sys.argv[1] == 'cat':
|
elif sys.argv[1] == 'cat':
|
||||||
err = cat(sys.argv[2:])
|
err = cat(sys.argv[2:])
|
||||||
|
elif sys.argv[1] == 'debug':
|
||||||
|
err = debug(sys.argv[2:])
|
||||||
elif sys.argv[1] == 'getenv':
|
elif sys.argv[1] == 'getenv':
|
||||||
err = get_env(sys.argv[2])
|
err = get_env(sys.argv[2])
|
||||||
elif sys.argv[1] == 'hostname':
|
elif sys.argv[1] == 'hostname':
|
||||||
|
2
deps/buildcore/scripts/setup-build.py
vendored
2
deps/buildcore/scripts/setup-build.py
vendored
@ -1,7 +1,7 @@
|
|||||||
#! /usr/bin/env python3
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2016 - 2023 gary@drinkingtea.net
|
# Copyright 2016 - 2021 gary@drinkingtea.net
|
||||||
#
|
#
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
# 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
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
Loading…
Reference in New Issue
Block a user