From 56b46124872a7a598e7cc9a710f763a756e7475c Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 17 Dec 2021 20:55:15 -0600 Subject: [PATCH] [buildcore] Fix conan to work in Docker devenv --- deps/buildcore/base.mk | 26 +++++++++++++++----------- deps/buildcore/scripts/pybb.py | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/deps/buildcore/base.mk b/deps/buildcore/base.mk index 41e5aaef..83392380 100644 --- a/deps/buildcore/base.mk +++ b/deps/buildcore/base.mk @@ -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 diff --git a/deps/buildcore/scripts/pybb.py b/deps/buildcore/scripts/pybb.py index 170ab458..12f64f76 100755 --- a/deps/buildcore/scripts/pybb.py +++ b/deps/buildcore/scripts/pybb.py @@ -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':