Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from conan import ConanFile
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain
from conan.tools.files import copy
from conan.tools.files import copy,save,load
from conan.tools.scm import Git

required_conan_version = ">=2.12.2"
Expand Down Expand Up @@ -38,7 +38,16 @@ class ForestdbConan(ConanFile):
"build_tests": False
}

exports_sources = "CMakeLists.txt", "src/*", "include/*", "cmake/*", "tools/*", "LICENSE"
exports_sources = "CMakeLists.txt", "src/*", "include/*", "cmake/*", "tools/*", "option/*", "utils/*", "LICENSE"

def set_version(self):
if self.version:
return

git = Git(self, folder=self.recipe_folder)
self.version = git.run(cmd="describe --tags --long")
if self.version.startswith("v"):
self.version = self.version[1:]

def requirements(self):
if self.options.with_snappy:
Expand All @@ -47,12 +56,27 @@ def requirements(self):
if self.options.with_jemalloc:
self.requires("jemalloc/[*]")

def _computeCommitHash(self):
hash_file = os.path.join(self.recipe_folder, "COMMIT_HASH")
if (os.path.exists(hash_file)):
hash = load(self,path=hash_file)
self.output.info(f"Fetched commit hash from {hash_file}")
else: # we are building from local source, i.e. in editable mode
git = Git(self, folder=self.recipe_folder)
hash = git.get_commit()
diff = git.run(cmd="diff --stat")
if diff:
hash +="-dirty"
self.output.info(f"Fetched commit hash {hash} from local Git in {self.recipe_folder}")
return hash

def export(self):
save(self, path=os.path.join(self.export_folder, "COMMIT_HASH"), content=self._computeCommitHash())

def layout(self):
cmake_layout(self, generator="CMakeDeps")
self.cpp.package.libs = [f"lib{self.name}.so" if self.options.shared else f"lib{self.name}.a"]

hash = Git(self).get_commit()
self.cpp.package.defines = self.cpp.build.defines = ["_FDB_COMMIT_HASH=%s" % hash]
self.cpp.package.defines = self.cpp.build.defines = ["_FDB_COMMIT_HASH=%s" % self._computeCommitHash()]

def generate(self):
tc = CMakeToolchain(self)
Expand All @@ -79,7 +103,3 @@ def package(self):
cmake.install()
assert copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")), "Copy failed"

def package_info(self):
self.cpp_info.system_libs.extend(["pthread", "m", "dl"])
if self.settings.os == "Linux":
self.cpp_info.system_libs.extend(["rt"])