Skip to content

Commit

Permalink
Remove SQLite completely from the repository (#887)
Browse files Browse the repository at this point in the history
* Remove soci_sqlite3, sqlcipher, MemoryDatabaseProxy and corresponding tests
* Remove release builds for iOS and Android
  • Loading branch information
viktorb-ledger authored Jul 25, 2022
1 parent ae3f8cb commit 0bf0899
Show file tree
Hide file tree
Showing 69 changed files with 428 additions and 260,881 deletions.
8 changes: 4 additions & 4 deletions .circleci/build_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function command_target_jni {
else
export JAVA_HOME="$(dirname $(dirname $(readlink -f $(which javac))))"
fi
add_to_cmake_params -DSYS_OPENSSL=ON -DTARGET_JNI=ON -DSSL_SUPPORT=ON -DPG_SUPPORT=ON -DPostgreSQL_INCLUDE_DIR="$PG_INCLUDE_DIR" #ACTIVATIN SSL ONLY WHEN USING PG FOR WD
add_to_cmake_params -DSYS_OPENSSL=ON -DTARGET_JNI=ON -DSSL_SUPPORT=ON -DPostgreSQL_INCLUDE_DIR="$PG_INCLUDE_DIR" #ACTIVATIN SSL ONLY WHEN USING PG FOR WD
}

function command_Release {
Expand All @@ -35,7 +35,7 @@ function command_Release {

function command_Debug {
BUILD_CONFIG="Debug"
add_to_cmake_params -DBUILD_TESTS=ON -DPG_SUPPORT=ON -DPostgreSQL_INCLUDE_DIR=/usr/include/postgresql -DSYS_OPENSSL=ON -DOPENSSL_USE_STATIC_LIBS=TRUE
add_to_cmake_params -DBUILD_TESTS=ON -DPostgreSQL_INCLUDE_DIR=/usr/include/postgresql -DSYS_OPENSSL=ON -DOPENSSL_USE_STATIC_LIBS=TRUE
}

function command_arch_ssl_1_1 {
Expand Down Expand Up @@ -139,9 +139,9 @@ echo "======> CMake config for $unamestr in $BUILD_CONFIG mode"

if [ "$BUILD_CONFIG" == "Debug" ]; then
if [ "$unamestr" == "Linux" ]; then
add_to_cmake_params "-DCMAKE_PREFIX=$HOME" "-DCMAKE_BUILD_TYPE=Debug"
add_to_cmake_params "-DCMAKE_PREFIX=$HOME" "-DCMAKE_BUILD_TYPE=Debug"
elif [ "$unamestr" == "Darwin" ]; then
add_to_cmake_params -DPostgreSQL_INCLUDE_DIR="$PG_INCLUDE_DIR"
add_to_cmake_params -DPostgreSQL_INCLUDE_DIR="$PG_INCLUDE_DIR"
add_to_cmake_params "-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/"
fi
fi
Expand Down
120 changes: 0 additions & 120 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,65 +79,6 @@ jobs:
command: |
. .circleci/deploy.sh
build_android_release:
<<: *linux_job
environment:
CORE_SSL_1_1: arch_ssl_1_1
working_directory: ~/lib-ledger-core
steps:
- checkout
- run:
name: Submodule_Initialization
command: |
. .circleci/init_submodules.sh
- run:
name: Export_Lib_Version
command: |
. .circleci/export_lib_version.sh
- run:
name: Setup NDK
command: |
apt-get install -y zip unzip
wget --quiet https://dl.google.com/android/repository/android-ndk-r18b-linux-x86_64.zip
unzip -q android-ndk-r18b-linux-x86_64.zip -d /home/circleci
ls -la /home/circleci/android-ndk-r18b
- run:
name: Build_Library_android
command: |
. .circleci/build_lib.sh android
- run:
name: Copy_Artifacts_Android
command: |
. .circleci/copy_artifacts.sh android
- run:
name: Build_Library_android_x86_64
command: |
. .circleci/build_lib.sh android x86_64
- run:
name: Copy_Artifacts_Android_x86_64
command: |
. .circleci/copy_artifacts.sh android x86_64
- run:
name: Build_Library_android_armeabi-v7a
command: |
. .circleci/build_lib.sh android armeabi-v7a
- run:
name: Copy_Artifacts_Android_armeabi-v7a
command: |
. .circleci/copy_artifacts.sh android armeabi-v7a
- run:
name: Build_Library_android_arm64-v8a
command: |
. .circleci/build_lib.sh android arm64-v8a
- run:
name: Copy_Artifacts_Android_arm64-v8a
command: |
. .circleci/copy_artifacts.sh android arm64-v8a
- deploy:
name: Deploy_Artifacts
command: |
. .circleci/deploy.sh
build_linux_debug:
<<: *linux_job
working_directory: ~/lib-ledger-core
Expand Down Expand Up @@ -191,53 +132,6 @@ jobs:
name: Deploy_Artifacts
command: |
. .circleci/deploy.sh
build_macos_ios_release:
macos:
xcode: "12.0.0"
working_directory: ~/lib-ledger-core
steps:
- checkout
- run:
name: Setup
command: |
.circleci/setup_macos.sh Release
- run:
name: Submodule_Initialization
command: |
. .circleci/init_submodules.sh
- run:
name: Export_Lib_Version
command: |
. .circleci/export_lib_version.sh
- run:
name: Build_Library_ios_x86
command: |
. .circleci/build_lib.sh ios
- run:
name: Copy_Artifacts_ios_x86
command: |
. .circleci/copy_artifacts.sh ios
- run:
name: Build_Library_ios_armv7
command: |
. .circleci/build_lib.sh ios armv7
- run:
name: Copy_Artifacts_ios_armv7
command: |
. .circleci/copy_artifacts.sh ios armv7
- run:
name: Build_Library_ios_arm64
command: |
. .circleci/build_lib.sh ios arm64
- run:
name: Copy_Artifacts_ios_arm64
command: |
. .circleci/copy_artifacts.sh ios arm64
- deploy:
name: Deploy_Artifacts
command: |
. .circleci/deploy.sh
. .circleci/deploy_fat_lib.sh
build_macos_jni_release:
macos:
xcode: "12.0.0"
Expand Down Expand Up @@ -386,25 +280,11 @@ workflows:
only: /.*/
branches:
only: /^(?!pull\/).*$/
- build_android_release:
<<: *default_context
filters:
tags:
only: /.*/
branches:
only: /^(?!pull\/).*$/
- build_macos_release:
<<: *default_context
filters:
tags:
only: /.*/
- build_macos_ios_release:
<<: *default_context
filters:
tags:
only: /.*/
branches:
only: /^(?!pull\/).*$/
- build_macos_jni_release:
<<: *default_context
filters:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/clang-tidty-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
with:
build_dir: build
# List of packages to install
apt_packages: libssl-dev
apt_packages: libssl-dev,libpq-dev,postgresql-server-dev-all
# Googletest triggers a _lot_ of clang-tidy warnings, so ignore all
# the unit tests until they're fixed or ignored upstream
exclude: "core/test/*,core/lib/*,core/test/lib/*,core/src/api/*,core/src/jni/*"
config_file: '.clang-tidy'
# CMake command to run in order to generate compile_commands.json
cmake_command: cmake . -B build -DSYS_OPENSSL=ON -DOPENSSL_USE_STATIC_LIBS=TRUE -DTARGET_JNI=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=on && cmake --build build --target secp256k1
cmake_command: cmake . -B build -DSYS_OPENSSL=ON -DOPENSSL_USE_STATIC_LIBS=TRUE -DPostgreSQL_INCLUDE_DIR=/usr/include/postgresql -DTARGET_JNI=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=on && cmake --build build --target secp256k1
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ jobs:
- name: Build and run tests
run: nix-shell --run "bash nix/scripts/build_run_tests.sh" default.nix
env:
BUILD_LOAD_LIMIT: 3
BUILD_LOAD_LIMIT: 2
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ set(CMAKE_MACOSX_RPATH 1)

add_definitions("-DSQLITE_HAS_CODEC")

# To compile with PostgreSQL support
if (PG_SUPPORT)
add_definitions("-DPG_SUPPORT")
endif()

# To add SSL support
if (SSL_SUPPORT)
add_definitions("-DSSL_SUPPORT")
Expand Down
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ brew install openssl
you can then use the argument `-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl` in the above cmake command
"DOPENSSL_INCLUDE_DIR" and "DOPENSSL_SSL_LIBRARIES" are not necessary on mac.

> On `Linux`,
> On `Linux`,
```
apt-get install libssl-dev
```
you can then use the argument `-DOPENSSL_SSL_LIBRARIES=/usr/lib/x86_64-linux-gnu -DOPENSSL_INCLUDE_DIR=/usr/include/openssl` in the above cmake command
"DOPENSSL_ROOT_DIR" is not necessary on linux.

> On `Windows`,
> On `Windows`,
Openssl can be downloaded and installed from https://slproweb.com/products/Win32OpenSSL.html
"DOPENSSL_ROOT_DIR" is then the installed path of Openssl in the above cmake command
"DOPENSSL_INCLUDE_DIR" and "DOPENSSL_SSL_LIBRARIES" are not necessary on windows.
Expand Down Expand Up @@ -180,17 +180,14 @@ This will add JNI files to the library compilation and remove tests. You need at

#### Dependencies

Make sure that your have `PostgreSQL` installed on your machine, otherwise the `CMake`
Make sure that your have `PostgreSQL` installed on your machine, otherwise the `CMake`
command `find_package(PostgreSQL REQUIRED)` will fail during configuration.

All Nix builds currently build with Postgres support by default.

#### Build

To compile libcore with PostgreSQL support, you should add `-DPG_SUPPORT=ON` to your
`CMake` configuration command.

You also need to add `-DPostgreSQL_INCLUDE_DIR=path/to/include/dir` in your configuration
You need to add `-DPostgreSQL_INCLUDE_DIR=path/to/include/dir` in your configuration
as a hint for headers' location (e.g. `/usr/include/postgresql`).

All Nix builds currently build with Postgres support by default.
Expand All @@ -200,16 +197,15 @@ All Nix builds currently build with Postgres support by default.
To use with libcore, simply set value of the key `api::PoolConfiguration::DATABASE_NAME`
to the database's URL connection and set it in the pool's configuration.

It is also possible to configure the size of the connection pool and read-only connection pool when instantiating the
It is also possible to configure the size of the connection pool and read-only connection pool when instantiating the
PostgreSQL `DatabaseBackend` : `api::DatabaseBackend::getPostgreSQLBackend(int32_t connectionPoolSize, int32_t readonlyConnectionPoolSize)`.

#### Local testing

If you don't build the library with PostgreSQL, sqlite3 shall be used as Database.
If you build the library with PostgreSQL, make sure to have a running PostgreSQL server or PostgreSQL docker container
Make sure to have a running PostgreSQL server or PostgreSQL docker container.
As an example, if you are running it on `localhost:5432` and `test_db` as database name,
database's name forwarded to the pool (through configuration key `api::PoolConfiguration::DATABASE_NAME`)
should look like : `postgres://localhost:5432/test_db` .
database's name forwarded to the pool (through configuration key `api::PoolConfiguration::DATABASE_NAME`)
should look like : `postgres://localhost:5432/test_db` .
In order to run local tests
```
cd lib-ledger-core-build
Expand Down
5 changes: 0 additions & 5 deletions core/idl/database/database.djinni
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# An enum representing a type of database backend (ones supported now through SOCI).
DatabaseBackendType = enum {
SQLite3;
PostgreSQL;
}
# An enum representing a SQL type.
Expand Down Expand Up @@ -250,10 +249,6 @@ DatabaseBackend = interface +c {
# @return trye if query logging is enabled, false otherwise.
isLoggingEnabled(): bool;

# Create an instance of SQLite3 database.
# @return DatabaseBackend object
static getSqlite3Backend(): DatabaseBackend;

# Create an instance of PostgreSQL database.
# @return DatabaseBackend object
static getPostgreSQLBackend(connectionPoolSize: i32, readonlyConnectionPoolSize: i32): DatabaseBackend;
Expand Down
18 changes: 2 additions & 16 deletions core/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,6 @@ add_subdirectory(sha512256)

add_subdirectory(spdlog)

if (${CMAKE_SYSTEM_NAME} STREQUAL "Android")
# On Android, temporary directories are a bit special and are not located in the same place, such
# as /tmp or /usr/tmp; for this reason, we ask temporary files to be stored in memory instead
message("Compiling SQLCipher for Android with file temporary directory disabled (all-on-memory).")
add_definitions(-DSQLITE_TEMP_STORE=3)
endif ()

add_subdirectory(sqlcipher)

set(SQLITE_LIB sqlcipher)

# SOCI configuration
set(SOCI_STATIC ON)
#set(SOCI_SHARED OFF)
Expand All @@ -49,11 +38,8 @@ add_subdirectory(soci)
# Fix undefined symbol related to dl library on Unix system
# The dl library is linked here to avoid to modify vendor cmake files
target_link_libraries(soci_core_static ${CMAKE_DL_LIBS})
add_subdirectory(soci_sqlite3)

if (PG_SUPPORT)
add_subdirectory(soci_postgresql)
endif()
add_subdirectory(soci_postgresql)

# Typically you don't care so much for a third party library's tests to be
# run from your own project's code.
Expand All @@ -63,4 +49,4 @@ set(JSON_BuildTests OFF CACHE INTERNAL "")
# need to install it when your main project gets installed.
set(JSON_Install OFF CACHE INTERNAL "")

add_subdirectory(nlohmann_json)
add_subdirectory(nlohmann_json)
18 changes: 0 additions & 18 deletions core/lib/soci_sqlite3/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit 0bf0899

Please sign in to comment.