Skip to content

Setup community edition #22

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 25 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .cargo-husky/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh -xe

cargo clippy --features=community -- -D warnings
cargo clippy --features=enterprise -- -D warnings

# Check fmt (protip: run 'cargo fmt --all -- --emit files' to apply format locally)
cargo fmt --all -- --check
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build

on:
push

env:
CARGO_TERM_COLOR: always
LIBCLANG_PATH: /usr/lib/llvm-14/lib/

jobs:
build:
runs-on: ubuntu-22.04
strategy:
matrix:
version: [community, enterprise]
steps:
- name: Install apt-get
run: sudo apt-get install -y clang llvm
- uses: actions/checkout@v3
- name: Build
run: cargo build --features=${{ matrix.version }} --verbose
9 changes: 7 additions & 2 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
on: push
name: Clippy check

on: push

env:
CARGO_TERM_COLOR: always
LIBCLANG_PATH: /usr/lib/llvm-14/lib/

jobs:
clippy_check:
runs-on: ubuntu-latest
strategy:
matrix:
version: [community, enterprise]
steps:
- uses: actions/checkout@v1
- run: rustup component add clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Clippy default
name: Clippy
args: --features=${{ matrix.version }}
32 changes: 0 additions & 32 deletions .github/workflows/rust.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Test

on:
push

env:
CARGO_TERM_COLOR: always
LIBCLANG_PATH: /usr/lib/llvm-14/lib/

jobs:
test:
runs-on: ubuntu-22.04
strategy:
matrix:
version: [community, enterprise]
steps:
- name: Install apt-get
run: sudo apt-get install -y clang llvm
- name: Install latest nightly
uses: dtolnay/rust-toolchain@v1
with:
toolchain: nightly
components: rustfmt, clippy
- uses: actions/checkout@v3
- name: Run tests
run: cargo test --features=${{ matrix.version }} --verbose
- name: Run tests (with address sanitizer)
run: LSAN_OPTIONS=suppressions=san.supp RUSTFLAGS="-Zsanitizer=address" cargo +nightly test --features=${{ matrix.version }} --verbose
8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "couchbase_lite"
version = "3.2.1-0"
# The first three numbers correspond to the Couchbase Lite C release, the fourth number corresponds to the Doctolib release
version = "3.2.1-0"
edition = "2021"

[dependencies]
Expand All @@ -13,7 +13,7 @@ regex = "1.10.4"
[dev-dependencies.cargo-husky]
version = "1"
default-features = false # Disable features which are enabled by default
features = ["precommit-hook", "run-cargo-clippy", "run-cargo-fmt"]
features = ["user-hooks"]

[build-dependencies]
bindgen = "0.69.4"
Expand All @@ -32,5 +32,7 @@ incremental = false
# See: https://github.com/johnthagen/min-sized-rust

[features]
flaky-test = []
community = []
enterprise = []

unsafe-threads-test = []
31 changes: 9 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
FROM --platform=amd64 rust AS build
RUN apt-get update
RUN apt-get -y install clang
RUN mkdir /build
WORKDIR /build
ENV LIBCLANG_PATH=/usr/lib/llvm-11/lib/
ADD Cargo.toml Cargo.toml
ADD build.rs build.rs
ADD libcblite libcblite
ADD src src
RUN cargo c
RUN cargo test -- --test-threads=1

FROM --platform=amd64 rust AS strip-stage
ARG DIRNAME
RUN apt-get update
RUN apt-get -y install binutils binutils-aarch64-linux-gnu
RUN mkdir /build
WORKDIR /build
ADD libcblite libcblite
RUN strip /build/libcblite/lib/x86_64-linux-android/libcblite.so -o /build/libcblite/lib/x86_64-linux-android/libcblite.stripped.so
RUN strip /build/libcblite/lib/i686-linux-android/libcblite.so -o /build/libcblite/lib/i686-linux-android/libcblite.stripped.so
RUN /usr/aarch64-linux-gnu/bin/strip /build/libcblite/lib/aarch64-linux-android/libcblite.so -o /build/libcblite/lib/aarch64-linux-android/libcblite.stripped.so
RUN /usr/aarch64-linux-gnu/bin/strip /build/libcblite/lib/arm-linux-androideabi/libcblite.so -o /build/libcblite/lib/arm-linux-androideabi/libcblite.stripped.so
RUN strip /build/libcblite/lib/x86_64-pc-windows-gnu/cblite.dll -o /build/libcblite/lib/x86_64-pc-windows-gnu/cblite.stripped.dll
ADD ${DIRNAME} ${DIRNAME}
RUN strip /build/${DIRNAME}/lib/x86_64-linux-android/libcblite.so -o /build/${DIRNAME}/lib/x86_64-linux-android/libcblite.stripped.so
RUN strip /build/${DIRNAME}/lib/i686-linux-android/libcblite.so -o /build/${DIRNAME}/lib/i686-linux-android/libcblite.stripped.so
RUN /usr/aarch64-linux-gnu/bin/strip /build/${DIRNAME}/lib/aarch64-linux-android/libcblite.so -o /build/${DIRNAME}/lib/aarch64-linux-android/libcblite.stripped.so
RUN /usr/aarch64-linux-gnu/bin/strip /build/${DIRNAME}/lib/arm-linux-androideabi/libcblite.so -o /build/${DIRNAME}/lib/arm-linux-androideabi/libcblite.stripped.so
RUN strip /build/${DIRNAME}/lib/x86_64-pc-windows-gnu/cblite.dll -o /build/${DIRNAME}/lib/x86_64-pc-windows-gnu/cblite.stripped.dll

FROM scratch AS strip
COPY --from=strip-stage /build/libcblite/ .
COPY --from=strip-stage /build/libcblite/ .
FROM scratch AS strip
COPY --from=strip-stage /build/${DIRNAME}/ .
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ Installation instructions are [here][BINDGEN_INSTALL].

### 2. Build!

You can use Couchbase Lite C community or entreprise editions:

```shell
$ cargo build --features=enterprise
```

```shell
$ cargo build
$ cargo build --features=community
```

## Maintaining
Expand Down Expand Up @@ -68,12 +74,6 @@ $ LEAK_CHECK=y cargo test -- --test-threads 1
$ LSAN_OPTIONS=suppressions=san.supp RUSTFLAGS="-Zsanitizer=address" cargo +nightly test
```

**To diag flaky test**

```shell
$ LSAN_OPTIONS=suppressions=san.supp RUSTFLAGS="-Zsanitizer=address" cargo +nightly test --verbose --features=flaky-test flaky
```

## Learning

[Official Couchbase Lite documentation][CBL_DOCS]
Expand Down
16 changes: 14 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
// - https://rust-lang.github.io/rust-bindgen/tutorial-3.html
// - https://doc.rust-lang.org/cargo/reference/build-scripts.html

#[cfg(all(not(feature = "community"), not(feature = "enterprise")))]
compile_error!("You need to have one the following features activated: community, enterprise");
#[cfg(all(feature = "community", feature = "enterprise"))]
compile_error!("You need to have one the following features activated: community, enterprise");

extern crate bindgen;
extern crate fs_extra;

Expand All @@ -32,8 +37,15 @@ use std::path::PathBuf;
use std::process::Command;
use fs_extra::dir;

static CBL_INCLUDE_DIR: &str = "libcblite/include";
static CBL_LIB_DIR: &str = "libcblite/lib";
#[cfg(feature = "community")]
static CBL_INCLUDE_DIR: &str = "libcblite_community/include";
#[cfg(feature = "enterprise")]
static CBL_INCLUDE_DIR: &str = "libcblite_enterprise/include";

#[cfg(feature = "community")]
static CBL_LIB_DIR: &str = "libcblite_community/lib";
#[cfg(feature = "enterprise")]
static CBL_LIB_DIR: &str = "libcblite_enterprise/lib";

fn main() -> Result<(), Box<dyn Error>> {
generate_bindings()?;
Expand Down
4 changes: 2 additions & 2 deletions c_playground/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.15)

project(c_playground)

include_directories(${CMAKE_SOURCE_DIR}/../libcblite/include)
include_directories(${CMAKE_SOURCE_DIR}/../libcblite_enterprise/include)

add_executable(Main main.c)

target_link_libraries(Main PUBLIC ${CMAKE_SOURCE_DIR}/../libcblite/lib/macos/libcblite.3.dylib)
target_link_libraries(Main PUBLIC ${CMAKE_SOURCE_DIR}/../libcblite_enterprise/lib/macos/libcblite.3.dylib)
Loading