mirror of
https://github.com/gtalent/sc9k.git
synced 2025-01-22 21:03:37 -06:00
[buildcore] Update buildcore
This commit is contained in:
parent
215f9b4d1d
commit
b96b75a735
1
deps/buildcore/base.cmake
vendored
1
deps/buildcore/base.cmake
vendored
@ -14,7 +14,6 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
# enable ccache
|
||||
if(NOT DEFINED ENV{BUILDCORE_SUPPRESS_CCACHE})
|
||||
find_program(CCACHE_PROGRAM ccache)
|
||||
|
200
deps/buildcore/base.mk
vendored
200
deps/buildcore/base.mk
vendored
@ -6,97 +6,106 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
|
||||
ifndef USE_CONAN
|
||||
USE_CONAN=0
|
||||
endif
|
||||
|
||||
ifeq (${OS},Windows_NT)
|
||||
SHELL := powershell.exe
|
||||
.SHELLFLAGS := -NoProfile -Command
|
||||
OS=windows
|
||||
HOST_ENV=${OS}
|
||||
BC_VAR_OS=windows
|
||||
BC_CMD_HOST_PY3=python
|
||||
else
|
||||
OS=$(shell uname | tr [:upper:] [:lower:])
|
||||
HOST_ENV=${OS}-$(shell uname -m)
|
||||
endif
|
||||
|
||||
DEVENV=devenv$(shell pwd | sed 's/\//-/g')
|
||||
DEVENV_IMAGE=${PROJECT_NAME}-devenv
|
||||
ifneq ($(shell which docker 2> /dev/null),)
|
||||
ifeq ($(shell docker inspect --format="{{.State.Status}}" ${DEVENV} 2>&1),running)
|
||||
ENV_RUN=docker exec -i -t --user $(shell id -u ${USER}) ${DEVENV}
|
||||
BC_VAR_OS=$(shell uname | tr [:upper:] [:lower:])
|
||||
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
|
||||
endif
|
||||
|
||||
ifneq ($(shell ${ENV_RUN} which python3 2> /dev/null),)
|
||||
PYTHON3=python3
|
||||
else
|
||||
ifeq ($(shell ${ENV_RUN} python -c 'import sys; print(sys.version_info[0])'),3)
|
||||
PYTHON3=python
|
||||
|
||||
ifdef BC_VAR_USE_DOCKER_DEVENV
|
||||
ifneq ($(shell which docker 2> /dev/null),)
|
||||
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
|
||||
ifneq ($(shell ${BC_CMD_ENVRUN} which python3 2> /dev/null),)
|
||||
BC_CMD_PY3=${BC_CMD_ENVRUN} python3
|
||||
else
|
||||
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
|
||||
endif
|
||||
ifndef BC_VAR_DEVENV_ROOT
|
||||
BC_VAR_DEVENV_ROOT="."
|
||||
endif
|
||||
else
|
||||
BC_CMD_PY3=${BC_CMD_HOST_PY3}
|
||||
endif
|
||||
|
||||
SCRIPTS=${BUILDCORE_PATH}/scripts
|
||||
SETUP_BUILD=${PYTHON3} ${SCRIPTS}/setup-build.py
|
||||
PYBB=${PYTHON3} ${SCRIPTS}/pybb.py
|
||||
CMAKE_BUILD=${PYBB} cmake-build
|
||||
GET_ENV=${PYBB} getenv
|
||||
CTEST=${PYBB} ctest-all
|
||||
RM_RF=${PYBB} rm
|
||||
HOST=$(shell ${PYBB} hostname)
|
||||
BUILDCORE_HOST_SPECIFIC_BUILDPATH=$(shell ${GET_ENV} BUILDCORE_HOST_SPECIFIC_BUILDPATH)
|
||||
ifneq (${BUILDCORE_HOST_SPECIFIC_BUILDPATH},)
|
||||
BUILD_PATH=build/${HOST}
|
||||
else
|
||||
BUILD_PATH=build
|
||||
endif
|
||||
ifdef USE_VCPKG
|
||||
ifndef VCPKG_DIR_BASE
|
||||
VCPKG_DIR_BASE=.vcpkg
|
||||
endif
|
||||
ifndef VCPKG_VERSION
|
||||
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
|
||||
BC_VAR_SCRIPTS=${BUILDCORE_PATH}/scripts
|
||||
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
|
||||
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_CMD_HOST_DEBUGGER=${BC_CMD_HOST_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)
|
||||
|
||||
VCPKG_DIR=$(VCPKG_DIR_BASE)/$(VCPKG_VERSION)-$(HOST_ENV)
|
||||
CURRENT_BUILD=$(HOST_ENV)-$(shell ${ENV_RUN} ${PYBB} cat .current_build)
|
||||
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
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
${ENV_RUN} ${CMAKE_BUILD} ${BUILD_PATH}
|
||||
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH}
|
||||
.PHONY: install
|
||||
install:
|
||||
${ENV_RUN} ${CMAKE_BUILD} ${BUILD_PATH} install
|
||||
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH} install
|
||||
.PHONY: clean
|
||||
clean:
|
||||
${ENV_RUN} ${CMAKE_BUILD} ${BUILD_PATH} clean
|
||||
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH} clean
|
||||
.PHONY: purge
|
||||
purge:
|
||||
${ENV_RUN} ${RM_RF} .current_build
|
||||
${ENV_RUN} ${RM_RF} ${BUILD_PATH}
|
||||
${ENV_RUN} ${RM_RF} dist
|
||||
${ENV_RUN} ${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
|
||||
${ENV_RUN} mypy ${SCRIPTS}
|
||||
${ENV_RUN} ${CMAKE_BUILD} ${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
|
||||
${ENV_RUN} ${CTEST} ${BUILD_PATH} --output-on-failure
|
||||
${BC_CMD_CTEST} ${BC_VAR_BUILD_PATH} --output-on-failure
|
||||
.PHONY: test-rerun-verbose
|
||||
test-rerun-verbose: build
|
||||
${ENV_RUN} ${CTEST} ${BUILD_PATH} --rerun-failed --output-on-failure
|
||||
${BC_CMD_CTEST} ${BC_VAR_BUILD_PATH} --rerun-failed --output-on-failure
|
||||
|
||||
ifdef BC_VAR_USE_DOCKER_DEVENV
|
||||
.PHONY: devenv-image
|
||||
devenv-image:
|
||||
docker build . -t ${DEVENV_IMAGE}
|
||||
docker build ${BC_VAR_DEVENV_ROOT} -t ${BC_VAR_DEVENV_IMAGE}
|
||||
.PHONY: devenv-create
|
||||
devenv-create:
|
||||
docker run -d \
|
||||
@ -108,66 +117,77 @@ devenv-create:
|
||||
-v $(shell pwd):/usr/src/project \
|
||||
-v /dev/shm:/dev/shm \
|
||||
--restart=always \
|
||||
--name ${DEVENV} \
|
||||
-t ${DEVENV_IMAGE} bash
|
||||
--name ${BC_VAR_DEVENV} \
|
||||
-t ${BC_VAR_DEVENV_IMAGE} bash
|
||||
.PHONY: devenv-destroy
|
||||
devenv-destroy:
|
||||
docker rm -f ${DEVENV}
|
||||
ifdef ENV_RUN
|
||||
docker rm -f ${BC_VAR_DEVENV}
|
||||
ifdef BC_CMD_ENVRUN
|
||||
.PHONY: devenv-shell
|
||||
devenv-shell:
|
||||
${ENV_RUN} bash
|
||||
${BC_CMD_ENVRUN} bash
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef USE_VCPKG
|
||||
ifdef BC_VAR_USE_VCPKG
|
||||
|
||||
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)
|
||||
|
||||
.PHONY: vcpkg
|
||||
vcpkg: ${VCPKG_DIR} vcpkg-install
|
||||
vcpkg: ${BC_VAR_VCPKG_DIR} vcpkg-install
|
||||
|
||||
${VCPKG_DIR}:
|
||||
${ENV_RUN} ${RM_RF} ${VCPKG_DIR}
|
||||
${ENV_RUN} mkdir -p ${VCPKG_DIR_BASE}
|
||||
${ENV_RUN} git clone -b release --depth 1 --branch ${VCPKG_VERSION} https://github.com/microsoft/vcpkg.git ${VCPKG_DIR}
|
||||
ifneq (${OS},windows)
|
||||
${ENV_RUN} ${VCPKG_DIR}/bootstrap-vcpkg.sh
|
||||
${BC_VAR_VCPKG_DIR}:
|
||||
${BC_CMD_RM_RF} ${BC_VAR_VCPKG_DIR}
|
||||
${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}
|
||||
ifneq (${BC_VAR_OS},windows)
|
||||
${BC_CMD_ENVRUN} ${BC_VAR_VCPKG_DIR}/bootstrap-vcpkg.sh
|
||||
else
|
||||
${ENV_RUN} ${VCPKG_DIR}/bootstrap-vcpkg.bat
|
||||
endif
|
||||
|
||||
${BC_CMD_ENVRUN} ${BC_VAR_VCPKG_DIR}/bootstrap-vcpkg.bat
|
||||
endif
|
||||
|
||||
.PHONY: vcpkg-install
|
||||
vcpkg-install:
|
||||
ifneq (${OS},windows)
|
||||
${VCPKG_DIR}/vcpkg install ${VCPKG_PKGS}
|
||||
ifneq (${BC_VAR_OS},windows)
|
||||
${BC_CMD_ENVRUN} ${BC_VAR_VCPKG_DIR}/vcpkg install ${BC_VAR_VCPKG_PKGS}
|
||||
else
|
||||
${VCPKG_DIR}/vcpkg install --triplet x64-windows ${VCPKG_PKGS}
|
||||
${BC_CMD_ENVRUN} ${BC_VAR_VCPKG_DIR}/vcpkg install --triplet x64-windows ${BC_VAR_VCPKG_PKGS}
|
||||
endif
|
||||
|
||||
ifeq (${USE_CONAN},1) # USE_CONAN ################################################
|
||||
.PHONY: conan-config
|
||||
else ifdef USE_CONAN # USE_VCPKG / USE_CONAN ####################################
|
||||
.PHONY: setup-conan
|
||||
conan-config:
|
||||
${ENV_RUN} conan profile detect -f --name ${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_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:
|
||||
${ENV_RUN} ${PYBB} conan-install ${PROJECT_NAME}
|
||||
${BC_CMD_PYBB} conan-install ${BC_VAR_PROJECT_NAME}
|
||||
endif # USE_CONAN ###############################################
|
||||
|
||||
ifeq (${OS},darwin)
|
||||
ifeq (${BC_VAR_OS},darwin)
|
||||
.PHONY: configure-xcode
|
||||
configure-xcode:
|
||||
${ENV_RUN} ${SETUP_BUILD} ${VCPKG_TOOLCHAIN} --build_tool=xcode --current_build=0 --build_root=${BUILD_PATH} --use_conan=${USE_CONAN}
|
||||
${BC_CMD_SETUP_BUILD} ${BC_VAR_VCPKG_TOOLCHAIN} --build_tool=xcode --current_build=0 --build_root=${BC_VAR_BUILD_PATH}
|
||||
endif
|
||||
|
||||
.PHONY: configure-release
|
||||
configure-release:
|
||||
${ENV_RUN} ${SETUP_BUILD} ${VCPKG_TOOLCHAIN} --build_type=release --build_root=${BUILD_PATH} --use_conan=${USE_CONAN}
|
||||
${BC_CMD_SETUP_BUILD} ${BC_VAR_VCPKG_TOOLCHAIN} --build_type=release --build_root=${BC_VAR_BUILD_PATH}
|
||||
|
||||
.PHONY: configure-debug
|
||||
configure-debug:
|
||||
${ENV_RUN} ${SETUP_BUILD} ${VCPKG_TOOLCHAIN} --build_type=debug --build_root=${BUILD_PATH} --use_conan=${USE_CONAN}
|
||||
${BC_CMD_SETUP_BUILD} ${BC_VAR_VCPKG_TOOLCHAIN} --build_type=debug --build_root=${BC_VAR_BUILD_PATH}
|
||||
|
||||
.PHONY: configure-asan
|
||||
configure-asan:
|
||||
${ENV_RUN} ${SETUP_BUILD} ${VCPKG_TOOLCHAIN} --build_type=asan --build_root=${BUILD_PATH} --use_conan=${USE_CONAN}
|
||||
${BC_CMD_SETUP_BUILD} ${BC_VAR_VCPKG_TOOLCHAIN} --build_type=asan --build_root=${BC_VAR_BUILD_PATH}
|
||||
|
||||
|
28
deps/buildcore/scripts/file_to_c.py
vendored
Normal file
28
deps/buildcore/scripts/file_to_c.py
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
#! /usr/bin/env python3
|
||||
|
||||
#
|
||||
# Copyright 2016 - 2022 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 argparse
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--out-cpp', help='path to output cpp file')
|
||||
parser.add_argument('--out-hpp', help='path to output hpp file')
|
||||
args = parser.parse_args()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
err = main()
|
||||
sys.exit(err)
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(1)
|
79
deps/buildcore/scripts/pybb.py
vendored
79
deps/buildcore/scripts/pybb.py
vendored
@ -1,7 +1,7 @@
|
||||
#! /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
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -18,18 +18,20 @@ import subprocess
|
||||
import sys
|
||||
from typing import List, Optional
|
||||
|
||||
|
||||
def mkdir(path: str):
|
||||
if not os.path.exists(path):
|
||||
os.mkdir(path)
|
||||
import util
|
||||
|
||||
|
||||
# this exists because Windows is utterly incapable of providing a proper rm -rf
|
||||
def rm(path: str):
|
||||
if (os.path.exists(path) or os.path.islink(path)) and not os.path.isdir(path):
|
||||
os.remove(path)
|
||||
elif os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
def mkdir(path: str) -> int:
|
||||
try:
|
||||
util.mkdir_p(path)
|
||||
except Exception:
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
def rm_multi(paths: List[str]):
|
||||
for path in paths:
|
||||
util.rm(path)
|
||||
|
||||
|
||||
def ctest_all() -> int:
|
||||
@ -70,16 +72,13 @@ def conan() -> int:
|
||||
err = 0
|
||||
try:
|
||||
mkdir(conan_dir)
|
||||
except:
|
||||
except Exception:
|
||||
return 1
|
||||
if err != 0:
|
||||
return err
|
||||
args = ['conan', 'install', '../', '-of', '.', '--build=missing', '-pr', project_name]
|
||||
args = ['conan', 'install', '../', '--build=missing', '-pr', project_name]
|
||||
os.chdir(conan_dir)
|
||||
err = subprocess.run(args).returncode
|
||||
if err != 0:
|
||||
return err
|
||||
return 0
|
||||
return subprocess.run(args).returncode
|
||||
|
||||
|
||||
def cat(paths: List[str]) -> int:
|
||||
@ -87,48 +86,70 @@ def cat(paths: List[str]) -> int:
|
||||
try:
|
||||
with open(path) as f:
|
||||
data = f.read()
|
||||
sys.stdout.write(data)
|
||||
print(data)
|
||||
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
|
||||
sys.stdout.write('\n')
|
||||
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', '--']
|
||||
else:
|
||||
sys.stderr.write('debug: could not find a supported debugger\n')
|
||||
return 1
|
||||
args.extend(paths)
|
||||
return subprocess.run(args).returncode
|
||||
|
||||
|
||||
def get_env(var_name: str) -> int:
|
||||
if var_name not in os.environ:
|
||||
return 1
|
||||
sys.stdout.write(os.environ[var_name])
|
||||
print(os.environ[var_name])
|
||||
return 0
|
||||
|
||||
|
||||
def hostname() -> int:
|
||||
sys.stdout.write(platform.node())
|
||||
print(platform.node())
|
||||
return 0
|
||||
|
||||
|
||||
def host_env() -> int:
|
||||
os_name = platform.system().lower()
|
||||
arch = util.get_arch()
|
||||
print(f'{os_name}-{arch}')
|
||||
return 0
|
||||
|
||||
|
||||
def clarg(idx: int) -> Optional[str]:
|
||||
return sys.argv[idx] if len(sys.argv) > idx else None
|
||||
|
||||
|
||||
def main() -> int:
|
||||
err = 0
|
||||
if sys.argv[1] == 'mkdir':
|
||||
try:
|
||||
mkdir(sys.argv[2])
|
||||
except:
|
||||
err = 1
|
||||
err = mkdir(sys.argv[2])
|
||||
elif sys.argv[1] == 'rm':
|
||||
for i in range(2, len(sys.argv)):
|
||||
rm(sys.argv[i])
|
||||
rm_multi(sys.argv[2:])
|
||||
elif sys.argv[1] == 'conan-install':
|
||||
err = conan()
|
||||
elif sys.argv[1] == 'ctest-all':
|
||||
err = ctest_all()
|
||||
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':
|
||||
err = cat(sys.argv[2:])
|
||||
elif sys.argv[1] == 'debug':
|
||||
err = debug(sys.argv[2:])
|
||||
elif sys.argv[1] == 'getenv':
|
||||
err = get_env(sys.argv[2])
|
||||
elif sys.argv[1] == 'hostname':
|
||||
err = hostname()
|
||||
elif sys.argv[1] == 'hostenv':
|
||||
err = host_env()
|
||||
else:
|
||||
sys.stderr.write('Command not found\n')
|
||||
err = 1
|
||||
|
60
deps/buildcore/scripts/setup-build.py
vendored
60
deps/buildcore/scripts/setup-build.py
vendored
@ -1,7 +1,7 @@
|
||||
#! /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
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -15,20 +15,35 @@ import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from pybb import mkdir, rm
|
||||
import util
|
||||
|
||||
os_name = os.uname().sysname.lower()
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--target', help='Platform target',
|
||||
default='{:s}-{:s}'.format(os_name, platform.machine()))
|
||||
parser.add_argument('--build_type', help='Build type (asan,debug,release)', default='release')
|
||||
parser.add_argument('--build_tool', help='Build tool (default,xcode)', default='')
|
||||
parser.add_argument('--build_root', help='Path to the root of build directories (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)
|
||||
parser.add_argument('--use_conan', help='Indicates whether or not should use .conanbuild/conan_toolchain.cmake', default='0')
|
||||
parser.add_argument(
|
||||
'--target',
|
||||
help='Platform target',
|
||||
default=f'{util.get_os()}-{util.get_arch()}')
|
||||
parser.add_argument(
|
||||
'--build_type',
|
||||
help='Build type (asan,debug,release)',
|
||||
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()
|
||||
|
||||
if args.build_type == 'asan':
|
||||
@ -66,10 +81,10 @@ def main() -> int:
|
||||
return 1
|
||||
|
||||
project_dir = os.getcwd()
|
||||
build_dir = '{:s}/{:s}/{:s}'.format(project_dir, args.build_root, build_config)
|
||||
rm(build_dir)
|
||||
build_dir = f'{project_dir}/{args.build_root}/{build_config}'
|
||||
util.rm(build_dir)
|
||||
cmake_cmd = [
|
||||
'cmake', '-S', project_dir, '-B', build_dir, build_tool,
|
||||
'cmake', '-S', project_dir, '-B', build_dir,
|
||||
'-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
|
||||
'-DCMAKE_TOOLCHAIN_FILE={:s}'.format(args.toolchain),
|
||||
'-DCMAKE_BUILD_TYPE={:s}'.format(build_type_arg),
|
||||
@ -77,24 +92,27 @@ def main() -> int:
|
||||
'-DBUILDCORE_BUILD_CONFIG={:s}'.format(build_config),
|
||||
'-DBUILDCORE_TARGET={:s}'.format(args.target),
|
||||
]
|
||||
if args.use_conan != '0':
|
||||
cmake_cmd.append('-DCMAKE_TOOLCHAIN_FILE={:s}'.format('.conanbuild/conan_toolchain.cmake'))
|
||||
if build_tool != '':
|
||||
cmake_cmd.append(build_tool)
|
||||
if qt_path != '':
|
||||
cmake_cmd.append(qt_path)
|
||||
if platform.system() == 'Windows':
|
||||
if platform.system() == 'Windows' and platform.system() == 'AMD64':
|
||||
cmake_cmd.append('-A x64')
|
||||
|
||||
subprocess.run(cmake_cmd)
|
||||
cmake_err = subprocess.run(cmake_cmd).returncode
|
||||
if cmake_err != 0:
|
||||
return cmake_err
|
||||
|
||||
mkdir('dist')
|
||||
util.mkdir_p('dist')
|
||||
if int(args.current_build) != 0:
|
||||
cb = open('.current_build', 'w')
|
||||
cb.write(args.build_type)
|
||||
cb.close()
|
||||
|
||||
rm('compile_commands.json')
|
||||
util.rm('compile_commands.json')
|
||||
if platform.system() != 'Windows':
|
||||
os.symlink('{:s}/compile_commands.json'.format(build_dir), 'compile_commands.json')
|
||||
os.symlink(f'{build_dir}/compile_commands.json',
|
||||
'compile_commands.json')
|
||||
return 0
|
||||
|
||||
|
||||
|
38
deps/buildcore/scripts/util.py
vendored
Normal file
38
deps/buildcore/scripts/util.py
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
#
|
||||
# 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 platform.system().lower()
|
||||
|
||||
|
||||
def get_arch() -> str:
|
||||
arch = platform.machine().lower()
|
||||
if arch == 'amd64':
|
||||
arch = 'x86_64'
|
||||
return arch
|
Loading…
Reference in New Issue
Block a user