Skip to content

Commit

Permalink
UPD: conanfile.py
Browse files Browse the repository at this point in the history
  • Loading branch information
user committed Jun 9, 2021
1 parent 8fa9d70 commit a929d79
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 59 deletions.
90 changes: 45 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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*
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
31 changes: 20 additions & 11 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <>"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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")

Expand Down Expand Up @@ -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()
Expand Down
8 changes: 5 additions & 3 deletions test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down

0 comments on commit a929d79

Please sign in to comment.