-
Notifications
You must be signed in to change notification settings - Fork 0
chore(build): #44: add ODB recipes for Conan 2 #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ac34883
chore(build): #44: add conan receipts of libodb and libodb-pgsql
JDRkow 9d17416
chore(build): #44: add to deps libodb and libodb-pgsql
JDRkow e8f8fac
chore(build): #44: update drogon version
JDRkow 67a0e58
chore(build): #44: delete prebuilded packages installing
JDRkow 4a439bc
chore(build): #44: WIP added env for local conan index store
JDRkow d6c9cb1
chore(build): #44: delete conan index store
JDRkow ebe9f7a
chore(build): #44: add finding libodb from builded by conan packages
JDRkow 3418d00
chore(build): #44: fix collecting of ODB_DETAILS_SOURCES libodb
JDRkow c4e4807
chore(devcontainer): #44: add postbuild command adding a local recipe…
JDRkow 03a2ad0
chore(cmake): #44: add finding libodb packages and searching all mode…
JDRkow f7eb751
chore(models): #44: add script for generating odb files for model
JDRkow 79bbbd3
chore(build): #44: fully rewrite conanfile for libodb-pgsql
JDRkow c154178
chore(cmake): #44: add .hxx to database_models
JDRkow b84c569
docs(orm): #44: update readme regard new build instructions
JDRkow 7dea31b
chore(build): #44: increase speed building
JDRkow fa88116
ci: #44: add local recipes store
JDRkow e2e8e2c
chore(build): #44: delete unnecessary windows checking
JDRkow eaaf476
chore(build): #44: add options switcher for shared configuration
JDRkow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| import os | ||
| import textwrap | ||
| from conan import ConanFile | ||
| from conan.errors import ConanInvalidConfiguration | ||
| from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout | ||
| from conan.tools.files import get, save, rmdir | ||
|
|
||
| class LibOdbPgsqlConan(ConanFile): | ||
| name = "libodb-pgsql" | ||
| version = "2.5.0" | ||
| license = "GPL-2.0-only" | ||
| homepage = "https://www.codesynthesis.com/products/odb/" | ||
| topics = ("odb", "orm", "database", "c++") | ||
|
|
||
| settings = "os", "compiler", "build_type", "arch" | ||
| options = {"shared": [True, False], "fPIC": [True, False]} | ||
| default_options = {"shared": False, "fPIC": True} | ||
|
|
||
| def config_options(self): | ||
| pass | ||
|
|
||
| def configure(self): | ||
| if self.options.shared: | ||
| self.options.rm_safe("fPIC") | ||
|
|
||
| def layout(self): | ||
| cmake_layout(self, src_folder="src") | ||
|
|
||
| def validate(self): | ||
| if self.settings.os != "Linux": | ||
| raise ConanInvalidConfiguration( | ||
| f"{self.ref} is supported only on Linux" | ||
| ) | ||
| try: | ||
| with open("/etc/os-release") as f: | ||
| info = dict( | ||
| line.strip().split("=", 1) | ||
| for line in f if "=" in line | ||
| ) | ||
| distro = info.get("ID", "").strip('"') | ||
| version = info.get("VERSION_ID", "").strip('"') | ||
| if distro != "ubuntu" or version != "22.04": | ||
| raise ConanInvalidConfiguration( | ||
| f"{self.ref} is supported only on Ubuntu 22.04 " | ||
| f"(detected: {distro} {version})" | ||
| ) | ||
| except FileNotFoundError: | ||
| raise ConanInvalidConfiguration( | ||
| f"{self.ref} requires Ubuntu 22.04 (/etc/os-release not found)" | ||
| ) | ||
|
|
||
| def requirements(self): | ||
| self.requires("libodb/2.5.0") | ||
| self.requires("libpq/17.7") | ||
|
|
||
| def source(self): | ||
| get( | ||
| self, | ||
| url=f"https://www.codesynthesis.com/download/odb/{self.version}/libodb-pgsql-{self.version}.tar.gz", | ||
| sha256="f6e63db4a2f77604f48115f64c74a5854ca20f03f208568966693e95712a3e17", # replace hash if you changing sources | ||
| strip_root=True, | ||
| ) | ||
| self._inject_cmake() | ||
|
|
||
| def _inject_cmake(self): | ||
| major = self.version.split(".")[0] | ||
| cmake = textwrap.dedent(f"""\ | ||
| cmake_minimum_required(VERSION 3.15) | ||
| project(odb-pgsql VERSION {self.version} LANGUAGES CXX) | ||
|
|
||
| find_package(libodb REQUIRED CONFIG) | ||
| find_package(PostgreSQL REQUIRED CONFIG) | ||
|
|
||
| file(GLOB ODB_SOURCES "odb/pgsql/*.cxx") | ||
|
|
||
| file(GLOB ODB_PREGENERATED_SOURCES | ||
| "odb/pgsql/details/pregenerated/odb/pgsql/details/*.cxx" | ||
| ) | ||
|
|
||
| add_library(odb-pgsql | ||
| ${{ODB_SOURCES}} | ||
| ${{ODB_PREGENERATED_SOURCES}} | ||
| ) | ||
|
|
||
| target_include_directories(odb-pgsql PUBLIC | ||
| $<BUILD_INTERFACE:${{CMAKE_CURRENT_SOURCE_DIR}}> | ||
| $<BUILD_INTERFACE:${{CMAKE_CURRENT_SOURCE_DIR}}/odb/pgsql/details/pregenerated> | ||
| $<INSTALL_INTERFACE:include> | ||
| ) | ||
|
|
||
| target_compile_features(odb-pgsql PUBLIC cxx_std_11) | ||
|
|
||
| target_link_libraries(odb-pgsql PUBLIC | ||
| libodb::libodb | ||
| PostgreSQL::PostgreSQL | ||
| ) | ||
|
|
||
| set_target_properties(odb-pgsql PROPERTIES | ||
| VERSION {self.version} | ||
| SOVERSION {major} | ||
| POSITION_INDEPENDENT_CODE ON | ||
| ) | ||
|
|
||
| install(TARGETS odb-pgsql | ||
| ARCHIVE DESTINATION lib | ||
| LIBRARY DESTINATION lib | ||
| RUNTIME DESTINATION bin | ||
| ) | ||
|
|
||
| install(DIRECTORY odb/pgsql | ||
| DESTINATION include/odb | ||
| FILES_MATCHING | ||
| PATTERN "*.hxx" | ||
| PATTERN "*.ixx" | ||
| PATTERN "*.txx" | ||
| PATTERN "*.h" | ||
| PATTERN "pregenerated" EXCLUDE | ||
| ) | ||
|
|
||
| install(DIRECTORY odb/pgsql/details/pregenerated/odb/pgsql/details | ||
| DESTINATION include/odb/pgsql | ||
| FILES_MATCHING | ||
| PATTERN "*.hxx" | ||
| PATTERN "*.ixx" | ||
| ) | ||
| """) | ||
| save(self, os.path.join(self.source_folder, "CMakeLists.txt"), cmake) | ||
|
|
||
| def generate(self): | ||
| tc = CMakeToolchain(self) | ||
| tc.generate() | ||
|
|
||
| deps = CMakeDeps(self) | ||
| deps.generate() | ||
|
|
||
| def build(self): | ||
| cmake = CMake(self) | ||
| cmake.configure() | ||
| cmake.build() | ||
|
|
||
| def package(self): | ||
| cmake = CMake(self) | ||
| cmake.install() | ||
| rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) | ||
| rmdir(self, os.path.join(self.package_folder, "share")) | ||
|
|
||
| def package_info(self): | ||
| self.cpp_info.libs = ["odb-pgsql"] | ||
| self.cpp_info.requires = [ | ||
| "libodb::libodb", | ||
| "libpq::pq", | ||
| ] | ||
| self.cpp_info.set_property("cmake_target_name", "libodb-pgsql::libodb-pgsql") | ||
| self.cpp_info.set_property("pkg_config_name", "libodb-pgsql") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| versions: | ||
| "2.5.0": | ||
| folder: all |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.