From a929d79655dc1d4e1dabd2fe5b2391f8ab4f041e Mon Sep 17 00:00:00 2001 From: user Date: Wed, 9 Jun 2021 12:23:48 +0300 Subject: [PATCH] UPD: conanfile.py --- README.md | 90 +++++++++++++++++++-------------------- conanfile.py | 31 +++++++++----- test_package/conanfile.py | 8 ++-- 3 files changed, 70 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index 76da123..ec1bdb6 100644 --- a/README.md +++ b/README.md @@ -96,19 +96,21 @@ Code generator processes `flextool_input_files` from `tests/CMakeLists.txt` export CXX=clang++-10 export CC=clang-10 +export VERBOSE=1 +export CONAN_REVISIONS_ENABLED=1 +export CONAN_VERBOSE_TRACEBACK=1 +export CONAN_PRINT_RUN_COMMANDS=1 +export CONAN_LOGGING_LEVEL=10 +export GIT_SSL_NO_VERIFY=true + # NOTE: change `build_type=Debug` to `build_type=Release` in production # NOTE: use --build=missing if you got error `ERROR: Missing prebuilt package` -CONAN_REVISIONS_ENABLED=1 \ -CONAN_VERBOSE_TRACEBACK=1 \ -CONAN_PRINT_RUN_COMMANDS=1 \ -CONAN_LOGGING_LEVEL=10 \ -GIT_SSL_NO_VERIFY=true \ - cmake -E time \ - conan create . conan/stable \ - -s build_type=Debug -s cling_conan:build_type=Release \ - --profile clang \ - -o flex_pimpl_plugin:enable_clang_from_conan=False \ - -e flex_pimpl_plugin:enable_tests=True +cmake -E time \ + conan create . conan/stable \ + -s build_type=Debug -s cling_conan:build_type=Release \ + --profile clang \ + -o flex_pimpl_plugin:enable_clang_from_conan=False \ + -e flex_pimpl_plugin:enable_tests=True # clean build cache conan remove "*" --build --force @@ -134,18 +136,13 @@ cmake -E make_directory build build_type=Debug # install conan requirements -CONAN_REVISIONS_ENABLED=1 \ - CONAN_VERBOSE_TRACEBACK=1 \ - CONAN_PRINT_RUN_COMMANDS=1 \ - CONAN_LOGGING_LEVEL=10 \ - GIT_SSL_NO_VERIFY=true \ - cmake -E chdir build cmake -E time \ - conan install \ - -s build_type=${build_type} -s cling_conan:build_type=Release \ - --build=missing \ - --profile clang \ - -e enable_tests=True \ - .. +cmake -E chdir build cmake -E time \ + conan install \ + -s build_type=${build_type} -s cling_conan:build_type=Release \ + --build=missing \ + --profile clang \ + -e enable_tests=True \ + .. # optional: remove generated files (change paths to yours) rm build/*generated* @@ -182,33 +179,34 @@ See for details [https://docs.conan.io/en/latest/developing_packages/editable_pa Build locally: ```bash -CONAN_REVISIONS_ENABLED=1 \ -CONAN_VERBOSE_TRACEBACK=1 \ -CONAN_PRINT_RUN_COMMANDS=1 \ -CONAN_LOGGING_LEVEL=10 \ -GIT_SSL_NO_VERIFY=true \ - cmake -E time \ - conan install . \ - --install-folder local_build \ - -s build_type=Debug -s cling_conan:build_type=Release \ - --profile clang \ - -o flex_pimpl_plugin:enable_clang_from_conan=False \ - -e flex_pimpl_plugin:enable_tests=True - -CONAN_REVISIONS_ENABLED=1 \ -CONAN_VERBOSE_TRACEBACK=1 \ -CONAN_PRINT_RUN_COMMANDS=1 \ -CONAN_LOGGING_LEVEL=10 \ -GIT_SSL_NO_VERIFY=true \ - cmake -E time \ - conan source . --source-folder local_build +export VERBOSE=1 +export CONAN_REVISIONS_ENABLED=1 +export CONAN_VERBOSE_TRACEBACK=1 +export CONAN_PRINT_RUN_COMMANDS=1 +export CONAN_LOGGING_LEVEL=10 +export GIT_SSL_NO_VERIFY=true + +cmake -E time \ + conan install . \ + --install-folder local_build \ + -s build_type=Debug -s cling_conan:build_type=Release \ + --profile clang \ + -o flex_pimpl_plugin:enable_clang_from_conan=False \ + -e flex_pimpl_plugin:enable_tests=True + +cmake -E time \ + conan source . \ + --source-folder local_build \ + --install-folder local_build conan build . \ --build-folder local_build conan package . \ --build-folder local_build \ - --package-folder local_build/package_dir + --package-folder local_build/package_dir \ + --source-folder local_build \ + --install-folder local_build ``` Set package to editable mode: @@ -228,7 +226,9 @@ conan build . \ conan package . \ --build-folder local_build \ - --package-folder local_build/package_dir + --package-folder local_build/package_dir \ + --source-folder local_build \ + --install-folder local_build ``` Build your test project diff --git a/conanfile.py b/conanfile.py index 82dcc60..4e87527 100644 --- a/conanfile.py +++ b/conanfile.py @@ -23,10 +23,20 @@ conan_build_helper = python_requires("conan_build_helper/[~=0.0]@conan/stable") +# Users locally they get the 1.0.0 version, +# without defining any env-var at all, +# and CI servers will append the build number. +# USAGE +# version = get_version("1.0.0") +# BUILD_NUMBER=-pre1+build2 conan export-pkg . my_channel/release +def get_version(version): + bn = os.getenv("BUILD_NUMBER") + return (version + bn) if bn else version + class flex_pimpl_plugin_conan_project(conan_build_helper.CMakePackage): name = "flex_pimpl_plugin" - version = "master" + version = get_version("master") url = "https://CHANGE_ME" license = "MIT" # CHANGE_ME author = "CHANGE_ME <>" @@ -129,10 +139,6 @@ class flex_pimpl_plugin_conan_project(conan_build_helper.CMakePackage): "openssl:shared=True", # flex_reflect_plugin "flex_reflect_plugin:shared=True", - # chromium_base - "chromium_base:use_alloc_shim=True", - # chromium_tcmalloc - "chromium_tcmalloc:use_alloc_shim=True", ) # Custom attributes for Bincrafters recipe conventions @@ -172,7 +178,7 @@ def requirements(self): if self._is_tests_enabled(): self.requires("catch2/[>=2.1.0]@bincrafters/stable") - self.requires("conan_gtest/release-1.10.0@conan/stable") + self.requires("conan_gtest/stable@conan/stable") self.requires("FakeIt/[>=2.0.4]@gasuketsu/stable") self.requires("boost/1.71.0@dev/stable") @@ -188,7 +194,7 @@ def requirements(self): self.requires("clang_ast/6.0.1@Manu343726/testing") self.requires("llvm/6.0.1@Manu343726/testing") else: - self.requires("cling_conan/master@conan/stable") + self.requires("cling_conan/v0.9@conan/stable") self.requires("chromium_base/master@conan/stable") @@ -248,10 +254,13 @@ def package(self): self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) cmake = self._configure_cmake() cmake.install() - # Local build - # see https://docs.conan.io/en/latest/developing_packages/editable_packages.html - if not self.in_local_cache: - self.copy("conanfile.py", dst=".", keep_path=False) + + self.copy_conanfile_for_editable_package(".") + + self.rmdir_if_packaged('.git') + self.rmdir_if_packaged('tests') + self.rmdir_if_packaged('lib/tests') + self.rmdir_if_packaged('lib/pkgconfig') def build(self): cmake = self._configure_cmake() diff --git a/test_package/conanfile.py b/test_package/conanfile.py index b1df956..8edd3c8 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -58,15 +58,17 @@ def test(self): cling_includes = os.path.join(cling_includes, "include") self.output.info('cling_includes = %s' % (cling_includes)) # - # clang_includes must point to stddef.h from lib/clang/5.0.0/include + # clang_includes must point to stddef.h from lib/clang/9.0.1/include clang_includes = cling_conan_ROOT clang_includes = os.path.join(clang_includes, "lib") clang_includes = os.path.join(clang_includes, "clang") - clang_includes = os.path.join(clang_includes, "5.0.0") + clang_includes = os.path.join(clang_includes, "9.0.1") clang_includes = os.path.join(clang_includes, "include") + if not os.path.isdir(clang_includes): + raise Exception('ERROR: Unable to find directory %s' % (clang_includes)) self.output.info('clang_includes = %s' % (clang_includes)) # - flextool_cmd = "flextool" \ + flextool_cmd = os.environ['flextool_BIN'] \ " --outdir ." \ " --indir ." \ " --vmodule=*=100 --enable-logging=stderr --log-level=100" \