diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 006fe84..33734e2 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -8,7 +8,7 @@ // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "conan remote add local-recipes ./deps --type=local-recipes-index", // Add a local recipes store for odb libraries + "postCreateCommand": "git submodule update --init && conan remote add local-recipes ./deps/conan-tourmalinecore-index --type=local-recipes-index", // Add a local recipes store for odb libraries // Configure tool-specific properties. // "customizations": {}, // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. diff --git a/.github/workflows/reusable-docker-build-and-push.yml b/.github/workflows/reusable-docker-build-and-push.yml index 43d6b1c..170b757 100644 --- a/.github/workflows/reusable-docker-build-and-push.yml +++ b/.github/workflows/reusable-docker-build-and-push.yml @@ -19,6 +19,8 @@ jobs: steps: - name: Check out the repo uses: actions/checkout@v7 + with: + submodules: true # this is needed to address this issue according to the comment https://github.com/devcontainers/ci/issues/271#issuecomment-2301764487 # otherwise our TourmalineCore org name cannot be used in docker image names, only tourmalinecore @@ -79,6 +81,8 @@ jobs: steps: - name: Check out the repo uses: actions/checkout@v4 + with: + submodules: true # this is needed to address this issue according to the comment https://github.com/devcontainers/ci/issues/271#issuecomment-2301764487 # otherwise our TourmalineCore org name cannot be used in docker image names, only tourmalinecore diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..df6c730 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "deps/conan-tourmalinecore-index"] + path = deps/conan-tourmalinecore-index + url = https://github.com/TourmalineCore/conan-tourmalinecore-recipes.git + branch = "feature/#70-preparing-prs-for-the-libodb-and-libodb-pgsql-packages-in-the-conan-center-index" diff --git a/Dockerfile b/Dockerfile index d5cabb7..0120d7b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ RUN apt-get -y install --no-install-recommends \ RUN pip install conan # this is necessary so that Conan can see the local dependency recipes -RUN conan remote add local-recipes ./deps --type=local-recipes-index +RUN conan remote add local-recipes ./deps/conan-tourmalinecore-index --type=local-recipes-index RUN conan build . --build=missing \ --profile:all=.devcontainer/to-dos-conan-profile.conf \ diff --git a/README.md b/README.md index 0ec184c..b433405 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,12 @@ For development purposes use a devcontainer named `developing`. ### Project building +First, you need to update the `conan-tourmalinecore-index` submodule, which contains Conan recipes for project dependencies not included in `conan-center-index`. Without this step, the project build will fail. + +> If you're working inside a VSCode devcontainer, the submodules were pulled automatically; check the `deps/` directory. + +To do this, run the command `git submodule update --init`. After running this command, the submodules will be pulled locally based on the state of the submodule’s fixed commit. If you need to update a fixed commit in the submodule, run the command `git submodule update --init --remote`. + To build this project, open the VS Code terminal (`Ctrl + Shift + ~`) and run `conan install . --build=missing`. After the Conan install process, open the CMake extension and click Configure.

cmakeConfigure

diff --git a/deps/conan-tourmalinecore-index b/deps/conan-tourmalinecore-index new file mode 160000 index 0000000..ee19d54 --- /dev/null +++ b/deps/conan-tourmalinecore-index @@ -0,0 +1 @@ +Subproject commit ee19d54a03c5a50d6fd0ad1d5792ffb00f846a10 diff --git a/deps/recipes/libodb-pgsql/all/conanfile.py b/deps/recipes/libodb-pgsql/all/conanfile.py deleted file mode 100644 index ae3aca8..0000000 --- a/deps/recipes/libodb-pgsql/all/conanfile.py +++ /dev/null @@ -1,154 +0,0 @@ -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 - $ - $ - $ - ) - - 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") diff --git a/deps/recipes/libodb-pgsql/config.yml b/deps/recipes/libodb-pgsql/config.yml deleted file mode 100644 index fca5391..0000000 --- a/deps/recipes/libodb-pgsql/config.yml +++ /dev/null @@ -1,3 +0,0 @@ -versions: - "2.5.0": - folder: all \ No newline at end of file diff --git a/deps/recipes/libodb/all/conanfile.py b/deps/recipes/libodb/all/conanfile.py deleted file mode 100644 index 317ec35..0000000 --- a/deps/recipes/libodb/all/conanfile.py +++ /dev/null @@ -1,124 +0,0 @@ -import os -import textwrap -from conan import ConanFile -from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout -from conan.tools.files import get, save, rmdir - - -class LibOdbConan(ConanFile): - name = "libodb" - version = "2.5.0" - description = "ODB C++ ORM — core runtime library" - 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 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 source(self): - get( - self, - url=f"https://www.codesynthesis.com/download/odb/{self.version}/libodb-{self.version}.tar.gz", - sha256="700038a73c6cbead011129b15030b7cdd3f73510b687f2c4504808df4230441b", # 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(libodb VERSION {self.version} LANGUAGES CXX) - - file(GLOB ODB_SOURCES "odb/*.cxx") - file(GLOB_RECURSE ODB_DETAILS_SOURCES "odb/details/*.cxx") - - add_library(odb - ${{ODB_SOURCES}} - ${{ODB_DETAILS_SOURCES}} - ) - - target_include_directories(odb PUBLIC - $ - $ - ) - - target_compile_features(odb PUBLIC cxx_std_11) - - find_package(Threads REQUIRED) - target_compile_definitions(odb PUBLIC ODB_THREADS_POSIX) - target_link_libraries(odb PUBLIC Threads::Threads) - - set_target_properties(odb PROPERTIES - VERSION {self.version} - SOVERSION {major} - ) - - install(TARGETS odb - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin - ) - install(DIRECTORY odb/ - DESTINATION include/odb - FILES_MATCHING - PATTERN "*.hxx" - PATTERN "*.ixx" - PATTERN "*.txx" - PATTERN "*.h" - ) - """) - save(self, os.path.join(self.source_folder, "CMakeLists.txt"), cmake) - - def generate(self): - tc = CMakeToolchain(self) - tc.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"] - self.cpp_info.system_libs = ["pthread"] - self.cpp_info.set_property("cmake_target_name", "libodb::libodb") - self.cpp_info.set_property("pkg_config_name", "libodb") diff --git a/deps/recipes/libodb/config.yml b/deps/recipes/libodb/config.yml deleted file mode 100644 index fca5391..0000000 --- a/deps/recipes/libodb/config.yml +++ /dev/null @@ -1,3 +0,0 @@ -versions: - "2.5.0": - folder: all \ No newline at end of file