Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ src/CMakeUserPresets.json
__pycache__/
compile_commands.json
.cache/
cor_recipe_utils_version.yml
46 changes: 33 additions & 13 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from conan.errors import ConanInvalidConfiguration
from conan.tools.scm import Version

from cor_recipe_utils_version import COR_RECIPE_UTILS_VERSION


class LlfsConan(ConanFile):
name = "llfs"
Expand All @@ -26,18 +28,25 @@ class LlfsConan(ConanFile):

description = "Low-Level File System Utilities (C++)"

python_requires = f"cor_recipe_utils/{COR_RECIPE_UTILS_VERSION}"
python_requires_extend = "cor_recipe_utils.ConanFileBase"

settings = "os", "compiler", "build_type", "arch"

options = {
"shared": [True, False],
"package_tests": [False, True],
}

default_options = {
"shared": False,
"package_tests": True,
}

python_requires = "cor_recipe_utils/0.19.1"
python_requires_extend = "cor_recipe_utils.ConanFileBase"
options_description = {
"shared": "Whether to build as shared library (or static)",
"package_tests": "Include test binaries in the exported package",
}

tool_requires = [
"cmake/[>=3.20.0 <4]",
Expand All @@ -46,6 +55,11 @@ class LlfsConan(ConanFile):

build_policy = "missing"

exports = [
"cor.yml",
"cor_recipe_utils_version.*",
]

exports_sources = [
"CMakeLists.txt",
"src/CMakeLists.txt",
Expand All @@ -60,7 +74,7 @@ class LlfsConan(ConanFile):
"ninja/[>=1.12.1 <2]",
]

_is_header_only = (platform.system() != "Linux")
_is_header_only = False

package_id_embed_mode = "full_mode"
package_id_non_embed_mode = "full_mode"
Expand Down Expand Up @@ -90,7 +104,7 @@ def requirements(self):
self.requires("zlib/[>=1.3.1 <2]")

self.test_requires("gtest/[>=1.16.0 <2]")

if platform.system() == "Linux":
self.requires("liburing/[>=2.11 <3]", **VISIBLE)
self.requires("libfuse/[>=3.16.2 <4]", **VISIBLE)
Expand All @@ -99,7 +113,7 @@ def requirements(self):
#+++++++++++-+-+--+----- --- -- - - - -

def set_version(self):
return self.cor.set_version_from_git_tags(self)
self.cor.set_version_from_git_tags(self)

def layout(self):
self.cor.layout_cmake_unified_src(self)
Expand All @@ -108,24 +122,32 @@ def layout(self):
self.cpp.build.libs += ['llfs']

def generate(self):
return self.cor.generate_cmake_default(self)
self.cor.generate_cmake_default(self)

def build(self):
return self.cor.build_cmake_default(self)
self.cor.build_cmake_default(self)

def package(self):
return self.cor.package_cmake_install(self)
self.cor.package_cmake_install(self)

if self.options.package_tests:
src_build = self.build_folder
dst_bin = os.path.join(self.package_folder, "bin")
exe_ext = '.exe' if platform.system().lower() == 'windows' else ''
for pattern in [f'*_Test{exe_ext}', f'*_Benchmark{exe_ext}']:
copy(self, pattern, src=src_build, dst=dst_bin, keep_path=False)


def package_info(self):
return self.cor.package_info_lib_default(self)
self.cor.package_info_lib_default(self)

def package_id(self):
return self.cor.package_id_lib_default(self)
self.cor.package_id_lib_default(self)

#+++++++++++-+-+--+----- --- -- - - - -

def validate_build(self):
if self.settings.compiler == "gcc":
if self.settings.compiler == "gcc" and platform.system().lower() == "linux":
out_capture = io.StringIO()
from_conf = self.conf.get('tools.build:compiler_executables')
cc_name = (
Expand All @@ -145,5 +167,3 @@ def validate_build(self):
f", expected={profile_compiler_version}")

#+++++++++++-+-+--+----- --- -- - - - -


32 changes: 32 additions & 0 deletions cor_recipe_utils_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from pathlib import Path
import yaml


def _load_version():
# Find the location of the current file.
#
self_path = Path(__file__)
self_dir = self_path.resolve().parent

# Probe for 'cor_recipe_utils_version.yml'; if not found, fall back
# on 'cor.yml'.
#
yml_file = self_dir / 'cor_recipe_utils_version.yml'
yml_path = ('cor', 'recipe_utils', 'version')
if not yml_file.exists():
yml_file = self_dir / 'cor.yml'
yml_path = ('cor', 'cli', 'version')

# Read version from the selected yml file.
#
with open(yml_file, 'r') as f:
y = yaml.safe_load(f)
for p in yml_path:
if y is None:
break
y = y.get(p)

return y


COR_RECIPE_UTILS_VERSION = _load_version()