Skip to content

Commit 9d4d45a

Browse files
authored
New update script & Documentation cleanup (#21)
Updating to a new version of Couchbase Lite C is still done by hand, which is time consuming and error prone. There was a script `download.sh` that could be used to download the different releases locally, but many manual actions were still required afterwards. This PR introduces a new script, `update_cblite_c.sh`, that can: 1. Download all the needed releases from Couchbase Lite C in a temporary directory 2. Unzip all the packages in a temporary directory 3. Recreate the `libcblite` folder in a temporary directory 4. Replace the `libcblite` folder in the local repository with the one created 5. Strip the libraries This should greatly help the release of new Couchbase Lite C versions.
1 parent 4530fdc commit 9d4d45a

File tree

166 files changed

+1098
-857
lines changed

Some content is hidden

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

166 files changed

+1098
-857
lines changed

.DS_Store

-8 KB
Binary file not shown.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
Cargo.lock
33

44
.vscode
5+
6+
# MacOS directory conf
7+
.DS_Store

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @doctolib/bics
1+
* @doctolib/bicson

README.md

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,57 @@
22

33
This is a Rust API of [Couchbase Lite][CBL], an embedded NoSQL document database engine with sync.
44

5+
The crate wraps the [couchbase-lite-C][CBL_C] releases with an idiomatic Rust API.
6+
57
## Disclaimer
68

7-
This library is **NOT SUPPORTED BY COUCHBASE**, it was forked from Couchbase Labs' repo [couchbase-lite-rust][CBL_RUST]
8-
and finalized.
9-
It is currently used and maintained by Doctolib.
9+
This library is **NOT SUPPORTED BY COUCHBASE**, it was forked from Couchbase Labs' repo [couchbase-lite-rust][CBL_RUST] and finalized.
10+
It is currently used and maintained by [Doctolib][DOCTOLIB] ([GitHub][DOCTOLIB_GH]).
11+
1012
The supported platforms are Windows, macOS, Linux, Android and iOS.
1113

1214
## Building
1315

1416
### 1. Install LLVM/Clang
1517

16-
In addition to [Rust][RUST], you'll need to install LLVM and Clang, which are required by the
17-
[bindgen][BINDGEN] tool that generates Rust FFI APIs from C headers.
18+
In addition to [Rust][RUST], you'll need to install LLVM and Clang, which are required by the [bindgen][BINDGEN] tool that generates Rust FFI APIs from C headers.
1819
Installation instructions are [here][BINDGEN_INSTALL].
1920

20-
### 2. Couchbase Lite For C
21+
### 2. Build!
22+
23+
```shell
24+
$ cargo build
25+
```
26+
27+
## Maintaining
28+
29+
### Couchbase Lite For C
2130

2231
The Couchbase Lite For C shared library and headers ([Git repo][CBL_C]) are already embedded in this repo.
23-
To upgrade the version, start by replacing all the necessary files in the folder libcblite-3.0.3
32+
They are present in the directory `libcblite`.
2433

25-
For Android there is an extra step: stripping the libraries.
26-
Place your terminal to the root of this repo, then follow the instructions below.
34+
### Upgrade Couchbase Lite C
2735

28-
### 2.1. Download
29-
```shell
30-
$ ./download.sh
31-
```
36+
The different releases can be found in [this page][CBL_DOWNLOAD_PAGE].
3237

33-
### 2.2 Strip
38+
When a new C release is available, a new Rust release must be created. Running the following script will download and setup the libraries locally:
3439

3540
```shell
36-
$ DOCKER_BUILDKIT=1 docker build --file Dockerfile -t strip --output libcblite .
41+
$ ./update_cblite_c.sh -v 3.2.1
3742
```
3843

39-
### 3. Fix The Skanky Hardcoded Paths
40-
41-
Now edit the file `CouchbaseLite/build.rs` and edit the hardcoded paths on lines 32-37.
42-
This tells the crate where to find Couchbase Lite's headers and library, and the Clang libraries.
43-
44-
### 4. Build!
44+
If the script fails on MacOS, you might need to install wget or a recent bash version:
4545

4646
```shell
47-
$ cargo build
47+
$ brew install wget
48+
$ brew install bash
4849
```
4950

50-
### 5. Test
51+
After that, fix the compilation & tests and you can create a pull request.
52+
53+
New C features should also be added to the Rust API at some point.
54+
55+
### Test
5156

5257
**The unit tests must be run single-threaded.** This is because each test case checks for leaks by
5358
counting the number of extant Couchbase Lite objects before and after it runs, and failing if the
@@ -57,7 +62,7 @@ number increases. That works only if a single test runs at a time.
5762
$ LEAK_CHECK=y cargo test -- --test-threads 1
5863
```
5964

60-
### 6. Sanitizer
65+
### Sanitizer
6166

6267
```shell
6368
$ LSAN_OPTIONS=suppressions=san.supp RUSTFLAGS="-Zsanitizer=address" cargo +nightly test
@@ -71,31 +76,32 @@ $ LSAN_OPTIONS=suppressions=san.supp RUSTFLAGS="-Zsanitizer=address" cargo +nigh
7176

7277
## Learning
7378

74-
I've copied the doc-comments from the C API into the Rust files. But Couchbase Lite is fairly
75-
complex, so if you're not already familiar with it, you'll want to start by reading through
76-
the [official documentation][CBLDOCS].
79+
[Official Couchbase Lite documentation][CBL_DOCS]
7780

78-
The Rust API is mostly method-for-method compatible with the languages documented there, except
79-
down at the document property level (dictionaries, arrays, etc.) where I haven't yet written
80-
compatible bindings. For those APIs you can check out the document "[Using Fleece][FLEECE]".
81-
82-
(FYI, if you want to see what bindgen's Rust translation of the C API looks like, it's in the file `bindings.rs` in
83-
`build/couchbase-lite-*/out`, where "`*`" will be some hex string. This is super unlikely to be useful unless you want
84-
to work on improving the high-level bindings themselves.)
81+
[C API reference][CBL_API_REFERENCE]
8582

83+
[Using Fleece][FLEECE]
8684

8785
[RUST]: https://www.rust-lang.org
8886

8987
[CBL]: https://www.couchbase.com/products/lite
9088

89+
[CBL_DOWNLOAD_PAGE]: https://www.couchbase.com/downloads/?family=couchbase-lite
90+
9191
[CBL_C]: https://github.com/couchbase/couchbase-lite-C
9292

9393
[CBL_RUST]: https://github.com/couchbaselabs/couchbase-lite-rust
9494

95-
[CBLDOCS]: https://docs.couchbase.com/couchbase-lite/current/introduction.html
95+
[CBL_DOCS]: https://docs.couchbase.com/couchbase-lite/current/introduction.html
96+
97+
[CBL_API_REFERENCE]: https://docs.couchbase.com/mobile/3.2.1/couchbase-lite-c/C/html/modules.html
9698

9799
[FLEECE]: https://github.com/couchbaselabs/fleece/wiki/Using-Fleece
98100

99101
[BINDGEN]: https://rust-lang.github.io/rust-bindgen/
100102

101103
[BINDGEN_INSTALL]: https://rust-lang.github.io/rust-bindgen/requirements.html
104+
105+
[DOCTOLIB]: https://www.doctolib.fr/
106+
107+
[DOCTOLIB_GH]: https://github.com/doctolib

build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ use std::path::PathBuf;
3232
use std::process::Command;
3333
use fs_extra::dir;
3434

35-
static CBL_INCLUDE_DIR: &str = "libcblite-3.0.3/include";
36-
static CBL_LIB_DIR: &str = "libcblite-3.0.3/lib";
35+
static CBL_INCLUDE_DIR: &str = "libcblite/include";
36+
static CBL_LIB_DIR: &str = "libcblite/lib";
3737

3838
fn main() -> Result<(), Box<dyn Error>> {
3939
generate_bindings()?;

download.sh

Lines changed: 0 additions & 70 deletions
This file was deleted.

libcblite

Lines changed: 0 additions & 1 deletion
This file was deleted.

libcblite-3.0.3/.DS_Store

-8 KB
Binary file not shown.

0 commit comments

Comments
 (0)