Skip to content

Commit

Permalink
Add ability to disable aligned storage for bridged types (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
leemaguire authored Jun 25, 2024
1 parent bc0e1a6 commit 9170fe1
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 22 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
build-macos:
runs-on: macos-14
name: macOS ${{ matrix.configuration }}, Xcode ${{ matrix.xcode }}
name: macOS ${{ matrix.configuration }}, Xcode ${{ matrix.xcode }}, REALM_DISABLE_ALIGNED_STORAGE=${{ matrix.disable-aligned-storage }}
strategy:
fail-fast: false
matrix:
Expand All @@ -40,6 +40,9 @@ jobs:
configuration:
- Debug
- Release
disable-aligned-storage:
- 1
- 0
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -62,7 +65,7 @@ jobs:
- uses: ammaraskar/gcc-problem-matcher@master

- name: Configure
run: cmake --preset macos -DCMAKE_VERBOSE_MAKEFILE=${RUNNER_DEBUG:-OFF} -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DREALM_ENABLE_EXPERIMENTAL=1 -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
run: cmake --preset macos -DCMAKE_VERBOSE_MAKEFILE=${RUNNER_DEBUG:-OFF} -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DREALM_ENABLE_EXPERIMENTAL=1 -DREALM_DISABLE_ALIGNED_STORAGE=${{ matrix.disable-aligned-storage }} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache

- name: Compile
run: cmake --build --preset macos --config ${{ matrix.configuration }}
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ NEXT RELEASE Release notes (YYYY-MM-DD)
* Add `realm::default_scheduler::make_default()` which generates a platform default scheduler if `realm::default_scheduler::set_default_factory` is not set.
* Add `managed<T>::to_json(std::ostream&)` which allows managed objects to be printed as json.
* Add `rbool::truepredicate()` and `rbool::falsepredicate()` expressions for type safe queries.
* Add ability to build the Realm C++ SDK without stack allocated bridging types. Use the CMake flag `-DREALM_DISABLE_ALIGNED_STORAGE=1` to disable.

### Compatibility
* Fileformat: Generates files with format v24. Reads and automatically upgrade from fileformat v10.
Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def source(self):
git = Git(self)
git.clone(url="https://github.com/realm/realm-cpp", target=".")
git.folder = "."
git.checkout(commit="fd20cf3d9f226dac8a21c89300728ac9be8bd2e2")
git.checkout(commit="9f0dc47ceaf5c2842df930aca28e98d7f594d0ce")
git.run("submodule update --init --recursive")

def layout(self):
Expand Down
46 changes: 27 additions & 19 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cpprealm/version_numbers.hpp
DESTINATION include/cpprealm
COMPONENT devel)

add_custom_command(
COMMAND ${CMAKE_COMMAND} -D SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/cpprealm/internal/bridge
-D BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/cpprealm/internal/bridge
-D BRIDGE_TYPE_INFO_BIN=$<TARGET_FILE:BridgeTypeInfoGenerator>
-P ${CMAKE_CURRENT_SOURCE_DIR}/cpprealm/internal/bridge/generator/bridge_type_info_parser.cmake
DEPENDS BridgeTypeInfoGenerator
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cpprealm/internal/bridge/generator/bridge_type_info_parser.cmake
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cpprealm/internal/bridge/bridge_types.hpp.in
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cpprealm/internal/bridge/bridge_types.hpp
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cpprealm/internal/bridge/bridge_types.hpp
DESTINATION include/cpprealm/internal/bridge
COMPONENT devel)

set(SOURCES
cpprealm/analytics.cpp
cpprealm/app.cpp
Expand Down Expand Up @@ -136,9 +121,28 @@ set(HEADERS
../include/cpprealm/thread_safe_reference.hpp
../include/cpprealm/sdk.hpp) # REALM_INSTALL_HEADERS

if (NOT REALM_DISABLE_ALIGNED_STORAGE)
add_custom_command(
COMMAND ${CMAKE_COMMAND} -D SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/cpprealm/internal/bridge
-D BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/cpprealm/internal/bridge
-D BRIDGE_TYPE_INFO_BIN=$<TARGET_FILE:BridgeTypeInfoGenerator>
-P ${CMAKE_CURRENT_SOURCE_DIR}/cpprealm/internal/bridge/generator/bridge_type_info_parser.cmake
DEPENDS BridgeTypeInfoGenerator
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cpprealm/internal/bridge/generator/bridge_type_info_parser.cmake
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cpprealm/internal/bridge/bridge_types.hpp.in
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cpprealm/internal/bridge/bridge_types.hpp
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cpprealm/internal/bridge/bridge_types.hpp
DESTINATION include/cpprealm/internal/bridge
COMPONENT devel)

set(BRIDGING_HEADER ${CMAKE_CURRENT_BINARY_DIR}/cpprealm/internal/bridge/bridge_types.hpp)
endif()

include(GNUInstallDirs)

add_library(cpprealm ${SOURCES} ${HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/cpprealm/internal/bridge/bridge_types.hpp)
add_library(cpprealm ${SOURCES} ${HEADERS} ${BRIDGING_HEADER})

if (NOT VCPKG_TOOLCHAIN)
set(INSTALL_TARGETS ObjectStore Storage QueryParser Sync)
Expand All @@ -155,7 +159,11 @@ foreach(header ${HEADERS})
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${dir}
COMPONENT devel)
endforeach()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cpprealm/internal/bridge/bridge_types.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cpprealm/internal/bridge
COMPONENT devel)

if (NOT REALM_DISABLE_ALIGNED_STORAGE)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cpprealm/internal/bridge/bridge_types.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cpprealm/internal/bridge
COMPONENT devel)
endif()

install()

0 comments on commit 9170fe1

Please sign in to comment.