2021-03-02 21:35:27 -06:00
|
|
|
#
|
2023-06-15 19:49:05 -05:00
|
|
|
# Copyright 2016 - 2023 gary@drinkingtea.net
|
2021-03-02 21:35:27 -06:00
|
|
|
#
|
|
|
|
# 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/.
|
|
|
|
#
|
|
|
|
|
2021-03-02 19:44:10 -06:00
|
|
|
ifeq (${OS},Windows_NT)
|
|
|
|
SHELL := powershell.exe
|
|
|
|
.SHELLFLAGS := -NoProfile -Command
|
2023-08-25 00:12:40 -05:00
|
|
|
BC_VAR_OS=windows
|
2021-03-02 19:44:10 -06:00
|
|
|
else
|
2023-08-25 00:12:40 -05:00
|
|
|
BC_VAR_OS=$(shell uname | tr [:upper:] [:lower:])
|
2021-03-02 19:44:10 -06:00
|
|
|
endif
|
|
|
|
|
2023-08-26 00:37:16 -05:00
|
|
|
ifneq ($(shell which python3 2> /dev/null),)
|
|
|
|
BC_CMD_HOST_PY3=python3
|
|
|
|
else
|
|
|
|
ifeq ($(shell python -c 'import sys; print(sys.version_info[0])'),3)
|
|
|
|
BC_CMD_HOST_PY3=python
|
|
|
|
else
|
|
|
|
echo 'Please install Python3 on host'
|
|
|
|
exit 1
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef BC_VAR_USE_DOCKER_DEVENV
|
2023-08-24 00:04:24 -05:00
|
|
|
ifneq ($(shell which docker 2> /dev/null),)
|
2023-08-25 00:12:40 -05:00
|
|
|
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}
|
2023-08-24 00:04:24 -05:00
|
|
|
endif
|
2021-12-17 20:55:15 -06:00
|
|
|
endif
|
2023-08-26 00:37:16 -05:00
|
|
|
ifneq ($(shell ${BC_CMD_ENVRUN} which python3 2> /dev/null),)
|
|
|
|
BC_CMD_PY3=${BC_CMD_ENVRUN} python3
|
2023-08-24 00:04:24 -05:00
|
|
|
else
|
2023-08-26 00:37:16 -05:00
|
|
|
ifeq ($(shell ${BC_CMD_ENVRUN} python -c 'import sys; print(sys.version_info[0])'),3)
|
|
|
|
BC_CMD_PY3=${BC_CMD_ENVRUN} python
|
|
|
|
else
|
|
|
|
echo 'Please install Python3 in devenv'
|
|
|
|
exit 1
|
|
|
|
endif
|
2022-05-21 16:21:24 -05:00
|
|
|
endif
|
2023-08-26 00:37:16 -05:00
|
|
|
else
|
|
|
|
BC_CMD_PY3=${BC_CMD_HOST_PY3}
|
2021-07-29 02:59:59 -05:00
|
|
|
endif
|
|
|
|
|
2023-08-25 00:12:40 -05:00
|
|
|
BC_VAR_SCRIPTS=${BUILDCORE_PATH}/scripts
|
2023-08-26 00:37:16 -05:00
|
|
|
BC_CMD_SETUP_BUILD=${BC_CMD_PY3} ${BC_VAR_SCRIPTS}/setup-build.py
|
|
|
|
BC_CMD_PYBB=${BC_CMD_PY3} ${BC_VAR_SCRIPTS}/pybb.py
|
|
|
|
BC_CMD_HOST_PYBB=${BC_CMD_HOST_PY3} ${BC_VAR_SCRIPTS}/pybb.py
|
2023-08-25 00:12:40 -05:00
|
|
|
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
|
2023-08-26 00:37:16 -05:00
|
|
|
BC_CMD_HOST_DEBUGGER=${BC_CMD_HOST_PYBB} debug
|
2023-08-25 00:12:40 -05:00
|
|
|
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)
|
2021-03-02 19:44:10 -06:00
|
|
|
|
2023-08-26 00:37:16 -05:00
|
|
|
ifdef BC_VAR_USE_VCPKG
|
|
|
|
ifndef BC_VAR_VCPKG_DIR_BASE
|
|
|
|
BC_VAR_VCPKG_DIR_BASE=.vcpkg
|
|
|
|
endif
|
|
|
|
ifndef BC_VAR_VCPKG_VERSION
|
|
|
|
BC_VAR_VCPKG_VERSION=2023.08.09
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2021-03-02 19:44:10 -06:00
|
|
|
.PHONY: build
|
|
|
|
build:
|
2023-08-25 00:12:40 -05:00
|
|
|
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH}
|
2021-03-02 19:44:10 -06:00
|
|
|
.PHONY: install
|
|
|
|
install:
|
2023-08-25 00:12:40 -05:00
|
|
|
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH} install
|
2021-03-02 19:44:10 -06:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2023-08-25 00:12:40 -05:00
|
|
|
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH} clean
|
2021-03-02 19:44:10 -06:00
|
|
|
.PHONY: purge
|
|
|
|
purge:
|
2023-08-25 00:12:40 -05:00
|
|
|
${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
|
2021-03-02 19:44:10 -06:00
|
|
|
.PHONY: test
|
|
|
|
test: build
|
2023-08-25 00:12:40 -05:00
|
|
|
${BC_CMD_ENVRUN} mypy ${BC_VAR_SCRIPTS}
|
|
|
|
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH} test
|
2021-07-30 00:00:03 -05:00
|
|
|
.PHONY: test-verbose
|
|
|
|
test-verbose: build
|
2023-08-25 00:12:40 -05:00
|
|
|
${BC_CMD_CTEST} ${BC_VAR_BUILD_PATH} --output-on-failure
|
2021-07-30 19:34:11 -05:00
|
|
|
.PHONY: test-rerun-verbose
|
|
|
|
test-rerun-verbose: build
|
2023-08-25 00:12:40 -05:00
|
|
|
${BC_CMD_CTEST} ${BC_VAR_BUILD_PATH} --rerun-failed --output-on-failure
|
2021-03-02 19:44:10 -06:00
|
|
|
|
2023-08-26 00:37:16 -05:00
|
|
|
ifdef BC_VAR_USE_DOCKER_DEVENV
|
2021-03-02 19:44:10 -06:00
|
|
|
.PHONY: devenv-image
|
|
|
|
devenv-image:
|
2023-08-25 00:12:40 -05:00
|
|
|
docker build . -t ${BC_VAR_DEVENV_IMAGE}
|
2021-03-02 19:44:10 -06:00
|
|
|
.PHONY: devenv-create
|
|
|
|
devenv-create:
|
|
|
|
docker run -d \
|
|
|
|
-e LOCAL_USER_ID=$(shell id -u ${USER}) \
|
|
|
|
-e DISPLAY=$(DISPLAY) \
|
|
|
|
-e QT_AUTO_SCREEN_SCALE_FACTOR=1 \
|
|
|
|
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
|
|
|
-v /run/dbus/:/run/dbus/ \
|
|
|
|
-v $(shell pwd):/usr/src/project \
|
|
|
|
-v /dev/shm:/dev/shm \
|
|
|
|
--restart=always \
|
2023-08-25 00:12:40 -05:00
|
|
|
--name ${BC_VAR_DEVENV} \
|
|
|
|
-t ${BC_VAR_DEVENV_IMAGE} bash
|
2021-03-02 19:44:10 -06:00
|
|
|
.PHONY: devenv-destroy
|
|
|
|
devenv-destroy:
|
2023-08-25 00:12:40 -05:00
|
|
|
docker rm -f ${BC_VAR_DEVENV}
|
|
|
|
ifdef BC_CMD_ENVRUN
|
2021-03-02 19:44:10 -06:00
|
|
|
.PHONY: devenv-shell
|
|
|
|
devenv-shell:
|
2023-08-25 00:12:40 -05:00
|
|
|
${BC_CMD_ENVRUN} bash
|
2023-08-24 00:04:24 -05:00
|
|
|
endif
|
2021-12-17 20:55:15 -06:00
|
|
|
endif
|
2021-03-02 19:44:10 -06:00
|
|
|
|
2023-08-26 00:37:16 -05:00
|
|
|
ifdef BC_VAR_USE_VCPKG
|
2021-11-05 19:46:48 -05:00
|
|
|
|
2023-08-26 00:37:16 -05:00
|
|
|
BC_VAR_VCPKG_TOOLCHAIN=--toolchain=${BC_VAR_VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake
|
|
|
|
BC_VAR_VCPKG_DIR=$(BC_VAR_VCPKG_DIR_BASE)/$(BC_VAR_VCPKG_VERSION)-$(BC_VAR_HOSTENV)
|
2023-08-25 00:12:40 -05:00
|
|
|
|
2021-03-02 19:44:10 -06:00
|
|
|
.PHONY: vcpkg
|
2023-08-25 00:12:40 -05:00
|
|
|
vcpkg: ${BC_VAR_VCPKG_DIR} vcpkg-install
|
|
|
|
|
|
|
|
${BC_VAR_VCPKG_DIR}:
|
|
|
|
${BC_CMD_RM_RF} ${BC_VAR_VCPKG_DIR}
|
2023-08-26 00:37:16 -05:00
|
|
|
${BC_CMD_PYBB} mkdir ${BC_VAR_VCPKG_DIR_BASE}
|
|
|
|
${BC_CMD_ENVRUN} git clone -b release --depth 1 --branch ${BC_VAR_VCPKG_VERSION} https://github.com/microsoft/vcpkg.git ${BC_VAR_VCPKG_DIR}
|
2023-08-25 00:12:40 -05:00
|
|
|
ifneq (${BC_VAR_OS},windows)
|
|
|
|
${BC_CMD_ENVRUN} ${BC_VAR_VCPKG_DIR}/bootstrap-vcpkg.sh
|
2021-03-02 19:44:10 -06:00
|
|
|
else
|
2023-08-25 00:12:40 -05:00
|
|
|
${BC_CMD_ENVRUN} ${BC_VAR_VCPKG_DIR}/bootstrap-vcpkg.bat
|
2021-03-02 19:44:10 -06:00
|
|
|
endif
|
|
|
|
|
|
|
|
.PHONY: vcpkg-install
|
|
|
|
vcpkg-install:
|
2023-08-25 00:12:40 -05:00
|
|
|
ifneq (${BC_VAR_OS},windows)
|
2023-08-26 00:37:16 -05:00
|
|
|
${BC_CMD_ENVRUN} ${BC_VAR_VCPKG_DIR}/vcpkg install ${BC_VAR_VCPKG_PKGS}
|
2021-03-02 19:44:10 -06:00
|
|
|
else
|
2023-08-26 00:37:16 -05:00
|
|
|
${BC_CMD_ENVRUN} ${BC_VAR_VCPKG_DIR}/vcpkg install --triplet x64-windows ${BC_VAR_VCPKG_PKGS}
|
2021-03-02 19:44:10 -06:00
|
|
|
endif
|
2021-11-05 19:46:48 -05:00
|
|
|
|
2023-08-25 00:12:40 -05:00
|
|
|
else ifdef USE_CONAN # USE_VCPKG / USE_CONAN ####################################
|
2021-03-28 00:24:50 -05:00
|
|
|
.PHONY: setup-conan
|
2021-03-28 00:41:34 -05:00
|
|
|
conan-config:
|
2023-08-25 00:12:40 -05:00
|
|
|
${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}
|
2022-03-12 11:50:21 -06:00
|
|
|
else
|
2023-08-25 00:12:40 -05:00
|
|
|
${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}
|
2022-03-12 11:50:21 -06:00
|
|
|
endif
|
2021-03-28 00:24:50 -05:00
|
|
|
endif
|
2023-08-24 00:04:24 -05:00
|
|
|
|
2021-03-28 00:24:50 -05:00
|
|
|
.PHONY: conan
|
|
|
|
conan:
|
2023-08-25 00:12:40 -05:00
|
|
|
${BC_CMD_PYBB} conan-install ${BC_VAR_PROJECT_NAME}
|
2023-08-24 00:04:24 -05:00
|
|
|
endif # USE_CONAN ###############################################
|
2021-03-02 19:44:10 -06:00
|
|
|
|
2023-08-25 00:12:40 -05:00
|
|
|
ifeq (${BC_VAR_OS},darwin)
|
2021-03-02 19:44:10 -06:00
|
|
|
.PHONY: configure-xcode
|
|
|
|
configure-xcode:
|
2023-08-26 00:37:16 -05:00
|
|
|
${BC_CMD_SETUP_BUILD} ${BC_VAR_VCPKG_TOOLCHAIN} --build_tool=xcode --current_build=0 --build_root=${BC_VAR_BUILD_PATH}
|
2023-06-15 19:49:05 -05:00
|
|
|
endif
|
2021-03-02 19:44:10 -06:00
|
|
|
|
|
|
|
.PHONY: configure-release
|
|
|
|
configure-release:
|
2023-08-26 00:37:16 -05:00
|
|
|
${BC_CMD_SETUP_BUILD} ${BC_VAR_VCPKG_TOOLCHAIN} --build_type=release --build_root=${BC_VAR_BUILD_PATH}
|
2021-03-02 19:44:10 -06:00
|
|
|
|
|
|
|
.PHONY: configure-debug
|
|
|
|
configure-debug:
|
2023-08-26 00:37:16 -05:00
|
|
|
${BC_CMD_SETUP_BUILD} ${BC_VAR_VCPKG_TOOLCHAIN} --build_type=debug --build_root=${BC_VAR_BUILD_PATH}
|
2021-03-02 19:44:10 -06:00
|
|
|
|
|
|
|
.PHONY: configure-asan
|
|
|
|
configure-asan:
|
2023-08-26 00:37:16 -05:00
|
|
|
${BC_CMD_SETUP_BUILD} ${BC_VAR_VCPKG_TOOLCHAIN} --build_type=asan --build_root=${BC_VAR_BUILD_PATH}
|
2021-03-02 19:44:10 -06:00
|
|
|
|