Skip to content

Commit e00ac09

Browse files
committed
ios/feature: it compiles for iOS, but don't work yet
1 parent e6bb6e3 commit e00ac09

File tree

4 files changed

+74
-8
lines changed

4 files changed

+74
-8
lines changed

.github/workflows/main.yml

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ jobs:
2626
RUSTUP_MAX_RETRIES: 10
2727
CARGO_NET_RETRY: 10
2828
steps:
29-
3029
- uses: actions/checkout@v2
3130
with:
3231
submodules: 'recursive'
@@ -67,12 +66,56 @@ jobs:
6766
cd $GITHUB_WORKSPACE
6867
python ci/build_and_run_tests.py --rust-only
6968
shell: bash
69+
ios-tests:
70+
name: Check work with iOS
71+
runs-on:
72+
strategy:
73+
fail-fast: true
74+
matrix:
75+
os: [macos-latest]
76+
rust: [stable, beta]
77+
env:
78+
RUSTUP_MAX_RETRIES: 10
79+
CARGO_NET_RETRY: 10
80+
steps:
81+
- uses: actions/checkout@v2
82+
with:
83+
submodules: 'recursive'
84+
- name: Install Rust toolchain
85+
uses: actions-rs/toolchain@v1
86+
with:
87+
toolchain: ${{ matrix.rust }}
88+
profile: minimal
89+
override: true
90+
target: "aarch64-apple-ios"
91+
- uses: actions/setup-python@v2
92+
with:
93+
python-version: '3.8.2'
94+
- uses: jwlawson/actions-setup-cmake@v1.0
95+
with:
96+
cmake-version: '3.15.4'
97+
github-api-token: ${{ secrets.GITHUB_TOKEN }}
98+
- name: Check versions
99+
run: |
100+
set -e
101+
cargo --version
102+
rustc --version
103+
python --version
104+
cmake --version
105+
echo "end of versions checking"
106+
shell: bash
107+
- name: Run tests
108+
run: |
109+
set -e
110+
cd $GITHUB_WORKSPACE
111+
python ci/build_and_run_tests.py --rust-ios-only
112+
shell: bash
113+
# Rebuild C++ part here, because of in build.rs we don't build unit tests
70114
cpp-tests:
71115
name: C++ tests
72116
runs-on: ${{ matrix.os }}
73117
strategy:
74118
fail-fast: false
75-
76119
matrix:
77120
os: [ubuntu-latest, macos-latest]
78121
steps:

ci/build_and_run_tests.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,35 @@ def build_and_test_rust_part(src_root: str):
4646
check_call(["cargo", "test", "--all", "-vv"], cwd = src_root)
4747
print("running tests in release mode")
4848
check_call(["cargo", "test", "--all", "--release", "-vv"], cwd = src_root)
49+
check_call(["cargo", "build", "-p", "chat-demo"], cwd = src_root)
50+
51+
@show_timing
52+
def build_and_test_rust_part_for_ios(src_root: str):
53+
print("build for iOS")
54+
check_call(["cargo", "build", "--target=aarch64-apple-ios", "-p", "chat-demo"], cwd = src_root)
4955

5056
@show_timing
5157
def main():
5258
ci_dir = Path(get_src_root_path(sys.argv[0]))
5359
src_root = ci_dir.parent
5460
CPP_TESTS = "cpp"
5561
RUST_TESTS = "rust"
62+
RUST_IOS_TESTS = "rust-ios"
5663
tests = set([CPP_TESTS, RUST_TESTS])
57-
if len(sys.argv) >= 2 and sys.argv[1] == "--rust-only":
58-
tests = set([RUST_TESTS])
59-
if len(sys.argv) >= 2 and sys.argv[1] == "--cpp-only":
60-
tests = set([CPP_TESTS])
64+
if len(sys.argv) >= 2:
65+
if sys.argv[1] == "--rust-only":
66+
tests = set([RUST_TESTS])
67+
elif sys.argv[1] == "--cpp-only":
68+
tests = set([CPP_TESTS])
69+
elif sys.argv[1] == "--rust-ios-only":
70+
tests = set([RUST_IOS_TESTS])
71+
6172
if CPP_TESTS in tests:
6273
build_and_test_cpp_part(src_root)
6374
if RUST_TESTS in tests:
6475
build_and_test_rust_part(src_root)
76+
if RUST_IOS_TESTS in tests:
77+
build_and_test_rust_part_for_ios(src_root)
6578

6679
if __name__ == "__main__":
6780
main()

couchbase-lite-core-sys/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ edition = "2018"
77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

99
[build-dependencies]
10-
cmake = "0.1.42"
10+
cmake = "=0.1.43"
1111
bindgen = "0.53.2"
12-
cc = "1.0.53"
12+
cc = "1.0.53"
13+
env_logger = "0.7"

couchbase-lite-core-sys/build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::{
77
};
88

99
fn main() {
10+
env_logger::init();
1011
let dst = cmake::Config::new(Path::new("couchbase-lite-core"))
1112
.define("DISABLE_LTO_BUILD", "True")
1213
.define("SANITIZE_FOR_DEBUG_ENABLED", "False")
@@ -170,6 +171,14 @@ fn run_bindgen_for_c_headers<P: AsRef<Path>>(
170171
.prepend_enum_name(true)
171172
.size_t_is_usize(true)
172173
.rustfmt_bindings(false);
174+
175+
//see https://github.com/rust-lang/rust-bindgen/issues/1211
176+
bindings = if target == "aarch64-apple-ios" {
177+
bindings.clang_arg("--target=arm64-apple-ios")
178+
} else {
179+
bindings
180+
};
181+
173182
bindings = include_dirs.iter().fold(bindings, |acc, x| {
174183
acc.clang_arg("-I".to_string() + x.as_ref().to_str().unwrap())
175184
});

0 commit comments

Comments
 (0)