[buildcore] Fix conan to work in Docker devenv

This commit is contained in:
Gary Talent 2021-12-17 20:55:15 -06:00
parent 0e73f75322
commit 56b4612487
2 changed files with 31 additions and 11 deletions

View File

@ -16,7 +16,15 @@ else
HOST_ENV=${OS}-$(shell uname -m)
endif
ifeq ($(shell python -c 'import sys; print(sys.version_info[0])'),3)
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}
endif
endif
ifeq ($(shell ${ENV_RUN} python -c 'import sys; print(sys.version_info[0])'),3)
PYTHON3=python
else
PYTHON3=python3
@ -44,13 +52,6 @@ else
endif
VCPKG_DIR=$(VCPKG_DIR_BASE)/$(VCPKG_VERSION)-$(HOST_ENV)
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}
endif
endif
CURRENT_BUILD=$(HOST_ENV)-$(shell ${PYBB} cat .current_build)
.PHONY: build
@ -96,9 +97,11 @@ devenv-create:
.PHONY: devenv-destroy
devenv-destroy:
docker rm -f ${DEVENV}
ifdef ENV_RUN
.PHONY: devenv-shell
devenv-shell:
${ENV_RUN} bash
endif
ifdef USE_VCPKG
@ -127,13 +130,14 @@ else # USE_VCPKG ################################################
.PHONY: setup-conan
conan-config:
conan profile new ${PROJECT_NAME} --detect --force
${ENV_RUN} conan profile new ${PROJECT_NAME} --detect --force
ifeq ($(OS),linux)
conan profile update settings.compiler.libcxx=libstdc++11 ${PROJECT_NAME}
${ENV_RUN} conan profile update settings.compiler.libcxx=libstdc++11 ${PROJECT_NAME}
endif
.PHONY: conan
conan:
@mkdir -p .conanbuild && cd .conanbuild && conan install ../ --build=missing -pr=${PROJECT_NAME}
${ENV_RUN} ${PYBB} conan-install ${PROJECT_NAME}
#@mkdir -p .conanbuild && cd .conanbuild && conan install ../ --build=missing -pr=${PROJECT_NAME}
endif # USE_VCPKG ###############################################
.PHONY: configure-xcode

View File

@ -74,6 +74,20 @@ def cmake_build(base_path: str, target: str) -> int:
return 0
def conan() -> int:
project_name = sys.argv[2]
conan_dir = '.conanbuild'
err = mkdir(conan_dir)
if err != 0:
return err
args = ['conan', 'install', '../', '--build=missing', '-pr', project_name]
os.chdir(conan_dir)
err = subprocess.run(args).returncode
if err != 0:
return err
return 0
def main():
err = 0
if sys.argv[1] == 'mkdir':
@ -81,6 +95,8 @@ def main():
elif sys.argv[1] == 'rm':
for i in range(2, len(sys.argv)):
rm(sys.argv[i])
elif sys.argv[1] == 'conan-install':
err = conan()
elif sys.argv[1] == 'ctest-all':
err = ctest_all()
elif sys.argv[1] == 'cmake-build':