[buildcore] Update buildcore

This commit is contained in:
2023-08-25 00:12:40 -05:00
parent 257389129f
commit 84e82b224b
3 changed files with 97 additions and 101 deletions

150
deps/buildcore/base.mk vendored
View File

@ -9,87 +9,76 @@
ifeq (${OS},Windows_NT)
SHELL := powershell.exe
.SHELLFLAGS := -NoProfile -Command
BC_OS=windows
BC_HOST_ENV=${BC_OS}
BC_VAR_OS=windows
else
BC_OS=$(shell uname | tr [:upper:] [:lower:])
BC_HOST_ENV=${BC_OS}-$(shell uname -m)
BC_VAR_OS=$(shell uname | tr [:upper:] [:lower:])
endif
ifdef BC_USE_DOCKER_DEVENV
ifneq ($(shell which docker 2> /dev/null),)
BC_DEVENV=devenv$(shell pwd | sed 's/\//-/g')
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}
BC_VAR_DEVENV=devenv$(shell pwd | sed 's/\//-/g')
BC_VAR_DEVENV_IMAGE=${BC_VAR_PROJECT_NAME}-devenv
ifeq ($(shell docker inspect --format="{{.State.Status}}" ${BC_VAR_DEVENV} 2>&1),running)
BC_CMD_ENVRUN=docker exec -i -t --user $(shell id -u ${USER}) ${BC_VAR_DEVENV}
endif
endif
endif
ifneq ($(shell ${BC_ENVRUN} which python3 2> /dev/null),)
BC_PY3=${BC_ENVRUN} python3
ifneq ($(shell ${BC_CMD_ENVRUN} which python3 2> /dev/null),)
BC_PY3=${BC_CMD_ENVRUN} python3
else
ifeq ($(shell ${BC_ENVRUN} python -c 'import sys; print(sys.version_info[0])'),3)
BC_PY3=${BC_ENVRUN} python
ifeq ($(shell ${BC_CMD_ENVRUN} python -c 'import sys; print(sys.version_info[0])'),3)
BC_PY3=${BC_CMD_ENVRUN} python
else
echo 'Please install Python3'
exit 1
endif
endif
BC_SCRIPTS=${BUILDCORE_PATH}/scripts
BC_SETUP_BUILD=${BC_PY3} ${BC_SCRIPTS}/setup-build.py
BC_PYBB=${BC_PY3} ${BC_SCRIPTS}/pybb.py
BC_CMAKE_BUILD=${BC_PYBB} cmake-build
BC_GETENV=${BC_PYBB} getenv
BC_CTEST=${BC_PYBB} ctest-all
BC_RM_RF=${BC_PYBB} rm
BC_CAT=${BC_PYBB} cat
BC_BUILD_PATH=build
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_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)
BC_VAR_SCRIPTS=${BUILDCORE_PATH}/scripts
BC_CMD_SETUP_BUILD=${BC_PY3} ${BC_VAR_SCRIPTS}/setup-build.py
BC_CMD_PYBB=${BC_PY3} ${BC_VAR_SCRIPTS}/pybb.py
BC_CMD_CMAKE_BUILD=${BC_CMD_PYBB} cmake-build
BC_CMD_GETENV=${BC_CMD_PYBB} getenv
BC_CMD_CTEST=${BC_CMD_PYBB} ctest-all
BC_CMD_RM_RF=${BC_CMD_PYBB} rm
BC_CMD_MKDIR_P=${BC_CMD_PYBB} mkdir
BC_CMD_CAT=${BC_CMD_PYBB} cat
BC_CMD_DEBUGGER=${BC_CMD_PYBB} debug
BC_VAR_HOSTENV=$(shell ${BC_CMD_ENVRUN} ${BC_CMD_PYBB} hostenv)
BC_VAR_BUILD_PATH=build
BC_VAR_CURRENT_BUILD=$(BC_VAR_HOSTENV)-$(shell ${BC_CMD_ENVRUN} ${BC_CMD_CAT} .current_build)
.PHONY: build
build:
${BC_ENVRUN} ${BC_CMAKE_BUILD} ${BC_BUILD_PATH}
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH}
.PHONY: install
install:
${BC_ENVRUN} ${BC_CMAKE_BUILD} ${BC_BUILD_PATH} install
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH} install
.PHONY: clean
clean:
${BC_ENVRUN} ${BC_CMAKE_BUILD} ${BC_BUILD_PATH} clean
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH} clean
.PHONY: purge
purge:
${BC_ENVRUN} ${BC_RM_RF} .current_build
${BC_ENVRUN} ${BC_RM_RF} ${BC_BUILD_PATH}
${BC_ENVRUN} ${BC_RM_RF} dist
${BC_ENVRUN} ${BC_RM_RF} compile_commands.json
${BC_CMD_RM_RF} .current_build
${BC_CMD_RM_RF} ${BC_VAR_BUILD_PATH}
${BC_CMD_RM_RF} dist
${BC_CMD_RM_RF} compile_commands.json
.PHONY: test
test: build
${BC_ENVRUN} mypy ${BC_SCRIPTS}
${BC_ENVRUN} ${BC_CMAKE_BUILD} ${BC_BUILD_PATH} test
${BC_CMD_ENVRUN} mypy ${BC_VAR_SCRIPTS}
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH} test
.PHONY: test-verbose
test-verbose: build
${BC_ENVRUN} ${BC_CTEST} ${BC_BUILD_PATH} --output-on-failure
${BC_CMD_CTEST} ${BC_VAR_BUILD_PATH} --output-on-failure
.PHONY: test-rerun-verbose
test-rerun-verbose: build
${BC_ENVRUN} ${BC_CTEST} ${BC_BUILD_PATH} --rerun-failed --output-on-failure
${BC_CMD_CTEST} ${BC_VAR_BUILD_PATH} --rerun-failed --output-on-failure
ifdef BC_USE_DOCKER_DEVENV
.PHONY: devenv-image
devenv-image:
docker build . -t ${BC_DEVENV_IMAGE}
docker build . -t ${BC_VAR_DEVENV_IMAGE}
.PHONY: devenv-create
devenv-create:
docker run -d \
@ -101,74 +90,83 @@ devenv-create:
-v $(shell pwd):/usr/src/project \
-v /dev/shm:/dev/shm \
--restart=always \
--name ${BC_DEVENV} \
-t ${BC_DEVENV_IMAGE} bash
--name ${BC_VAR_DEVENV} \
-t ${BC_VAR_DEVENV_IMAGE} bash
.PHONY: devenv-destroy
devenv-destroy:
docker rm -f ${BC_DEVENV}
ifdef BC_ENVRUN
docker rm -f ${BC_VAR_DEVENV}
ifdef BC_CMD_ENVRUN
.PHONY: devenv-shell
devenv-shell:
${BC_ENVRUN} bash
${BC_CMD_ENVRUN} bash
endif
endif
ifdef BC_USE_VCPKG
.PHONY: vcpkg
vcpkg: ${BC_VCPKG_DIR} vcpkg-install
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)
${BC_VCPKG_DIR}:
${BC_ENVRUN} ${BC_RM_RF} ${BC_VCPKG_DIR}
${BC_ENVRUN} mkdir -p ${BC_VCPKG_DIR_BASE}
${BC_ENVRUN} git clone -b release --depth 1 --branch ${BC_VCPKG_VERSION} https://github.com/microsoft/vcpkg.git ${BC_VCPKG_DIR}
ifneq (${BC_OS},windows)
${BC_ENVRUN} ${BC_VCPKG_DIR}/bootstrap-vcpkg.sh
.PHONY: vcpkg
vcpkg: ${BC_VAR_VCPKG_DIR} vcpkg-install
${BC_VAR_VCPKG_DIR}:
${BC_CMD_RM_RF} ${BC_VAR_VCPKG_DIR}
${BC_CMD_PYBB} mkdir ${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}
ifneq (${BC_VAR_OS},windows)
${BC_CMD_ENVRUN} ${BC_VAR_VCPKG_DIR}/bootstrap-vcpkg.sh
else
${BC_ENVRUN} ${BC_VCPKG_DIR}/bootstrap-vcpkg.bat
${BC_CMD_ENVRUN} ${BC_VAR_VCPKG_DIR}/bootstrap-vcpkg.bat
endif
.PHONY: vcpkg-install
vcpkg-install:
ifneq (${BC_OS},windows)
${BC_ENVRUN} ${BC_VCPKG_DIR}/vcpkg install ${BC_VCPKG_PKGS}
ifneq (${BC_VAR_OS},windows)
${BC_CMD_ENVRUN} ${BC_VAR_VCPKG_DIR}/vcpkg install ${BC_VCPKG_PKGS}
else
${BC_ENVRUN} ${BC_VCPKG_DIR}/vcpkg install --triplet x64-windows ${BC_VCPKG_PKGS}
${BC_CMD_ENVRUN} ${BC_VAR_VCPKG_DIR}/vcpkg install --triplet x64-windows ${BC_VCPKG_PKGS}
endif
else ifdef USE_CONAN # USE_CONAN ################################################
else ifdef USE_CONAN # USE_VCPKG / USE_CONAN ####################################
.PHONY: setup-conan
conan-config:
${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}
${BC_CMD_ENVRUN} conan profile new ${BC_VAR_PROJECT_NAME} --detect --force
ifeq ($(BC_VAR_OS),linux)
${BC_CMD_ENVRUN} conan profile update settings.compiler.libcxx=libstdc++11 ${BC_VAR_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}
${BC_CMD_ENVRUN} conan profile update settings.compiler.cppstd=20 ${BC_VAR_PROJECT_NAME}
ifeq ($(BC_VAR_OS),windows)
${BC_CMD_ENVRUN} conan profile update settings.compiler.runtime=static ${BC_VAR_PROJECT_NAME}
endif
endif
.PHONY: conan
conan:
${BC_ENVRUN} ${BC_PYBB} conan-install ${BC_PROJECT_NAME}
${BC_CMD_PYBB} conan-install ${BC_VAR_PROJECT_NAME}
endif # USE_CONAN ###############################################
ifeq (${BC_OS},darwin)
ifeq (${BC_VAR_OS},darwin)
.PHONY: configure-xcode
configure-xcode:
${BC_ENVRUN} ${BC_SETUP_BUILD} ${BC_VCPKG_TOOLCHAIN} --build_tool=xcode --current_build=0 --build_root=${BC_BUILD_PATH}
${BC_CMD_SETUP_BUILD} ${BC_VCPKG_TOOLCHAIN} --build_tool=xcode --current_build=0 --build_root=${BC_VAR_BUILD_PATH}
endif
.PHONY: configure-release
configure-release:
${BC_ENVRUN} ${BC_SETUP_BUILD} ${BC_VCPKG_TOOLCHAIN} --build_type=release --build_root=${BC_BUILD_PATH}
${BC_CMD_SETUP_BUILD} ${BC_VCPKG_TOOLCHAIN} --build_type=release --build_root=${BC_VAR_BUILD_PATH}
.PHONY: configure-debug
configure-debug:
${BC_ENVRUN} ${BC_SETUP_BUILD} ${BC_VCPKG_TOOLCHAIN} --build_type=debug --build_root=${BC_BUILD_PATH}
${BC_CMD_SETUP_BUILD} ${BC_VCPKG_TOOLCHAIN} --build_type=debug --build_root=${BC_VAR_BUILD_PATH}
.PHONY: configure-asan
configure-asan:
${BC_ENVRUN} ${BC_SETUP_BUILD} ${BC_VCPKG_TOOLCHAIN} --build_type=asan --build_root=${BC_BUILD_PATH}
${BC_CMD_SETUP_BUILD} ${BC_VCPKG_TOOLCHAIN} --build_type=asan --build_root=${BC_VAR_BUILD_PATH}