Skip to content
Merged
Show file tree
Hide file tree
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 Feb 18, 2026
9d17416
chore(build): #44: add to deps libodb and libodb-pgsql
JDRkow Feb 18, 2026
e8f8fac
chore(build): #44: update drogon version
JDRkow Feb 17, 2026
67a0e58
chore(build): #44: delete prebuilded packages installing
JDRkow Feb 20, 2026
4a439bc
chore(build): #44: WIP added env for local conan index store
JDRkow Feb 20, 2026
d6c9cb1
chore(build): #44: delete conan index store
JDRkow Feb 20, 2026
ebe9f7a
chore(build): #44: add finding libodb from builded by conan packages
JDRkow Feb 20, 2026
3418d00
chore(build): #44: fix collecting of ODB_DETAILS_SOURCES libodb
JDRkow Feb 24, 2026
c4e4807
chore(devcontainer): #44: add postbuild command adding a local recipe…
JDRkow Feb 24, 2026
03a2ad0
chore(cmake): #44: add finding libodb packages and searching all mode…
JDRkow Feb 24, 2026
f7eb751
chore(models): #44: add script for generating odb files for model
JDRkow Feb 24, 2026
79bbbd3
chore(build): #44: fully rewrite conanfile for libodb-pgsql
JDRkow Feb 24, 2026
c154178
chore(cmake): #44: add .hxx to database_models
JDRkow Feb 24, 2026
b84c569
docs(orm): #44: update readme regard new build instructions
JDRkow Feb 24, 2026
7dea31b
chore(build): #44: increase speed building
JDRkow Feb 24, 2026
fa88116
ci: #44: add local recipes store
JDRkow Feb 24, 2026
e2e8e2c
chore(build): #44: delete unnecessary windows checking
JDRkow Feb 25, 2026
eaaf476
chore(build): #44: add options switcher for shared configuration
JDRkow Feb 25, 2026
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
21 changes: 4 additions & 17 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,14 @@ FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04 AS base

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
build-essential clang lld make gdb cmake ninja-build \
git curl wget unzip sudo \
pip \
clang-format clang-tidy \
libpq-dev \
build-essential clang lld make gdb cmake ninja-build \
git curl wget unzip sudo \
pip \
clang-format clang-tidy \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

RUN pip install conan

ARG ODB_VERSION=2.5.0

RUN mkdir -p /opt/odb && \
wget -q -nc -P /opt/odb \
https://www.codesynthesis.com/download/odb/${ODB_VERSION}/ubuntu/ubuntu22.04/x86_64/libodb_${ODB_VERSION}-0~ubuntu22.04_amd64.deb \
https://www.codesynthesis.com/download/odb/${ODB_VERSION}/ubuntu/ubuntu22.04/x86_64/libodb-dev_${ODB_VERSION}-0~ubuntu22.04_amd64.deb \
https://www.codesynthesis.com/download/odb/${ODB_VERSION}/ubuntu/ubuntu22.04/x86_64/libodb-pgsql_${ODB_VERSION}-0~ubuntu22.04_amd64.deb \
https://www.codesynthesis.com/download/odb/${ODB_VERSION}/ubuntu/ubuntu22.04/x86_64/libodb-pgsql-dev_${ODB_VERSION}-0~ubuntu22.04_amd64.deb \
https://www.codesynthesis.com/download/odb/${ODB_VERSION}/ubuntu/ubuntu22.04/x86_64/odb_${ODB_VERSION}-0~ubuntu22.04_amd64.deb

RUN dpkg -i /opt/odb/*.deb && rm -rf /opt/odb

COPY to-dos-conan-profile.conf /root/.conan2/profiles/default
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,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 profile detect --force",
"postCreateCommand": "conan remote add local-recipes ./deps --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.
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/to-dos-conan-profile.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ compiler.cppstd=gnu20

[conf]
tools.build:compiler_executables={"c":"clang","cpp":"clang++"}
tools.build:jobs={{os.cpu_count()}}
tools.system.package_manager:mode=install
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
cp .devcontainer/to-dos-conan-profile.conf .conan2/profiles/default

export CONAN_HOME="$(pwd)/.conan2"
conan remote add local-recipes ./deps --type=local-recipes-index
conan install . --build=missing
# we don't need to push docker image that was built using our Dev Container
push: never
Expand Down
19 changes: 17 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,34 @@ set(PROJECT_OBJECTS ${PROJECT_NAME}_lib)

add_library(${PROJECT_OBJECTS} OBJECT ${sources})

file(GLOB_RECURSE database_models
${CMAKE_CURRENT_SOURCE_DIR}/src/data/models/*.h
${CMAKE_CURRENT_SOURCE_DIR}/src/data/models/*.hxx
)

set(database_model_dirs "")
foreach(header ${database_models})
get_filename_component(dir ${header} DIRECTORY)
list(APPEND database_model_dirs ${dir})
endforeach()
list(REMOVE_DUPLICATES database_model_dirs)

target_include_directories(${PROJECT_OBJECTS} PUBLIC
${CMAKE_SOURCE_DIR}/src
/usr/include
src/data/models/
${database_model_dirs}
)

find_package(Drogon REQUIRED)
find_package(jsoncpp REQUIRED)
find_package(libodb REQUIRED)
find_package(libodb-pgsql REQUIRED)

target_link_libraries(${PROJECT_OBJECTS} PUBLIC
Drogon::Drogon
JsonCpp::JsonCpp
odb odb-pgsql
libodb::libodb
libodb-pgsql::libodb-pgsql
)

add_executable(${PROJECT_NAME}
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ Alternatively, use the CMake Tools Extension in VS Code. To do this, open the CM

### ORM:

After creating the database or model, it is necessary to generate the auxiliary ODB files with the command `odb --std c++20 -d pgsql --generate-query -o odb-gen <model header file>` from the folder `src/data/models`.
After creating the database or model, it is necessary to generate the auxiliary ODB files.
For generating these files use script `./scripts/generate_odb_files.sh`

After executing the command, files will be created or updated in the folder `src/data/models/odb-gen'. Please do not modify or transfer these files for the correct operation of the application.
After executing the script, files will be created or updated in the folder `src/data/models/odb-gen'. Please do not modify or transfer these files for the correct operation of the application.

### Migrations:

Expand Down
4 changes: 3 additions & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@ def package(self):
cmake.install()

def requirements(self):
self.requires("drogon/1.9.10")
self.requires("drogon/1.9.12")
self.requires("gtest/1.14.0")
self.requires("libodb/2.5.0")
self.requires("libodb-pgsql/2.5.0")
154 changes: 154 additions & 0 deletions deps/recipes/libodb-pgsql/all/conanfile.py
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")
3 changes: 3 additions & 0 deletions deps/recipes/libodb-pgsql/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"2.5.0":
folder: all
Loading