Skip to content

Commit dc5c071

Browse files
authored
feat(): Catch up to the old repo (#2)
1 parent 207dde5 commit dc5c071

File tree

118 files changed

+20341
-1027
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+20341
-1027
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @doctolib/bics

Cargo.toml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
[package]
22
name = "couchbase_lite"
3-
version = "0.2.0"
3+
version = "0.2.1"
44

55
[dependencies]
66
enum_primitive = "*"
77
tempdir = "*"
8+
lazy_static = "1.4.0"
9+
10+
[dev-dependencies.cargo-husky]
11+
version = "1"
12+
default-features = false # Disable features which are enabled by default
13+
features = ["precommit-hook", "run-cargo-clippy", "run-cargo-fmt"]
814

915
[build-dependencies]
10-
bindgen = "0.53.1"
16+
bindgen = "0.63"
17+
fs_extra = "1.2.0"
1118

1219
[lib]
1320
bench = false
@@ -20,3 +27,7 @@ lto = true
2027
codegen-units = 1
2128
incremental = false
2229
# See: https://github.com/johnthagen/min-sized-rust
30+
31+
[features]
32+
flaky-test = []
33+
unsafe-threads-test = []

Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM --platform=amd64 rust AS build
2+
RUN apt-get update
3+
RUN apt-get -y install clang
4+
RUN mkdir /build
5+
WORKDIR /build
6+
ENV LIBCLANG_PATH=/usr/lib/llvm-11/lib/
7+
ADD Cargo.toml Cargo.toml
8+
ADD build.rs build.rs
9+
ADD libcblite libcblite
10+
ADD src src
11+
RUN cargo c
12+
RUN cargo test -- --test-threads=1
13+
14+
FROM --platform=amd64 rust AS strip-stage
15+
RUN apt-get update
16+
RUN apt-get -y install binutils binutils-aarch64-linux-gnu
17+
RUN mkdir /build
18+
WORKDIR /build
19+
ADD libcblite libcblite
20+
RUN strip /build/libcblite/lib/x86_64-linux-android/libcblite.so -o /build/libcblite/lib/x86_64-linux-android/libcblite.stripped.so
21+
RUN strip /build/libcblite/lib/i686-linux-android/libcblite.so -o /build/libcblite/lib/i686-linux-android/libcblite.stripped.so
22+
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
23+
RUN /usr/aarch64-linux-gnu/bin/strip /build/libcblite/lib/armv7-linux-androideabi/libcblite.so -o /build/libcblite/lib/armv7-linux-androideabi/libcblite.stripped.so
24+
RUN strip /build/libcblite/lib/x86_64-pc-windows-gnu/cblite.dll -o /build/libcblite/lib/x86_64-pc-windows-gnu/cblite.stripped.dll
25+
26+
FROM scratch AS strip
27+
COPY --from=strip-stage /build/libcblite/ .
28+
COPY --from=strip-stage /build/libcblite/ .

README.md

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,34 @@ In addition to [Rust][RUST], you'll need to install LLVM and Clang, which are re
2020
[bindgen][BINDGEN] tool that generates Rust FFI APIs from C headers.
2121
Installation instructions are [here][BINDGEN_INSTALL].
2222

23-
### 2. Get Couchbase Lite For C
23+
### 2. Couchbase Lite For C
24+
25+
The Couchbase Lite For C shared library and headers ([Git repo][CBL_C]) are already embedded in this repo.
26+
To upgrade the version, start by replacing all the necessary files in the folder libcblite-3.0.3
27+
28+
For Android there is an extra step: stripping the libraries.
29+
Place your terminal to the root of this repo, then follow the instructions below.
30+
31+
Run Docker:
32+
``$ docker run --rm --platform linux/amd64 -it -v $(PWD):/build archlinux``
33+
Install strip:
34+
``$ pacman -Sy base-devel``
35+
Strip:
36+
``$ cd /build/libcblite-3.0.3/lib/x86_64-linux-android
37+
$ strip libcblite.so -o libcblite.stripped.so
38+
$ cd /build/libcblite-3.0.3/lib/i686-linux-android
39+
$ strip libcblite.so -o libcblite.stripped.so``
40+
41+
Run docker:
42+
``$ docker run --rm --platform linux/arm64 -it -v $(PWD):/build debian``
43+
Install strip:
44+
``$ apt update && apt install binutils -y``
45+
Strip:
46+
``$ cd /build/libcblite-3.0.3/lib/aarch64-linux-android
47+
$ strip libcblite.so -o libcblite.stripped.so
48+
$ cd /build/libcblite-3.0.3/lib/armv7-linux-androideabi
49+
$ strip libcblite.so -o libcblite.stripped.so``
2450

25-
Next you need the Couchbase Lite For C shared library and headers. You can download them from Couchbase, or build them yourself from the [Git repo][CBL_C].
2651

2752
### 3. Fix The Skanky Hardcoded Paths
2853

@@ -39,10 +64,20 @@ This tells the crate where to find Couchbase Lite's headers and library, and the
3964
counting the number of extant Couchbase Lite objects before and after it runs, and failing if the
4065
number increases. That works only if a single test runs at a time.
4166

42-
$ cargo test -- --test-threads 1
67+
$ LEAK_CHECK=y cargo test -- --test-threads 1
4368

44-
The library itself has no thread-safety problems; if you want to run the tests multi-threaded, just
45-
edit `tests/simple_tests.rs` and change the value of `LEAK_CHECKS` to `false`.
69+
### 6. Sanitizer
70+
71+
$ LSAN_OPTIONS=suppressions=san.supp RUSTFLAGS="-Zsanitizer=address" cargo +nightly test
72+
73+
**To diag flaky test**
74+
75+
$ LSAN_OPTIONS=suppressions=san.supp RUSTFLAGS="-Zsanitizer=address" cargo +nightly test --verbose --features=flaky-test flaky
76+
77+
### 7. Strip libraries
78+
```
79+
DOCKER_BUILDKIT=1 docker build --file Dockerfile -t strip --output libcblite .
80+
```
4681

4782
## Learning
4883

0 commit comments

Comments
 (0)