Skip to content

Commit

Permalink
Custom build for bindings_wasm (#1148)
Browse files Browse the repository at this point in the history
* add an xtask for building bindings_wasm

* include fix for gen_kotlin
  • Loading branch information
insipx authored Oct 17, 2024
1 parent 79904ae commit 18ca7b7
Show file tree
Hide file tree
Showing 11 changed files with 484 additions and 28 deletions.
133 changes: 122 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ members = [
"bindings_wasm",
"bindings_node",
"bindings_ffi",
"xtask"
]

# Make the feature resolver explicit.
Expand Down
52 changes: 38 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# LibXMTP

![https://github.com/xmtp/libxmtp/actions/workflows/test.yml/badge.svg](https://github.com/xmtp/libxmtp/actions/workflows/test.yml/badge.svg) ![https://github.com/xmtp/libxmtp/actions/workflows/lint.yml/badge.svg](https://github.com/xmtp/libxmtp/actions/workflows/lint.yml/badge.svg) ![Status](https://img.shields.io/badge/Project_status-Alpha-orange)
![https://github.com/xmtp/libxmtp/actions/workflows/test.yml/badge.svg](https://github.com/xmtp/libxmtp/actions/workflows/test.yml/badge.svg)
![https://github.com/xmtp/libxmtp/actions/workflows/lint.yml/badge.svg](https://github.com/xmtp/libxmtp/actions/workflows/lint.yml/badge.svg)
![Status](https://img.shields.io/badge/Project_status-Alpha-orange)

LibXMTP is a shared library encapsulating the core functionality of the XMTP messaging protocol, such as cryptography, networking, and language bindings.
LibXMTP is a shared library encapsulating the core functionality of the XMTP
messaging protocol, such as cryptography, networking, and language bindings.

> **Important**
> This software is in **alpha** status and ready for you to start experimenting with. However, we do not recommend using alpha software in production apps. Expect frequent changes as we add features and iterate based on feedback.
> **Important** This software is in **alpha** status and ready for you to start
> experimenting with. However, we do not recommend using alpha software in
> production apps. Expect frequent changes as we add features and iterate based
> on feedback.
## Requirements

- Install [Rustup](https://rustup.rs/)
- Install [Docker](https://www.docker.com/get-started/)
- Install [Foundry](https://book.getfoundry.sh/getting-started/installation#using-foundryup)
- Install
[Foundry](https://book.getfoundry.sh/getting-started/installation#using-foundryup)

## Development

Expand All @@ -30,10 +36,19 @@ Start Docker Desktop.
```
dev/test
```
- To run WebAssembly tests headless:
```
dev/test-wasm
```
- To run WebAssembly tests interactively for a package, for example, `xmtp_mls`:
```
dev/test-wasm-interactive xmtp_mls
```

## Quick Start (Dev Containers)

This project supports containerized development. From Visual Studio Code Dev Containers extension specify the Dockerfile as the target:
This project supports containerized development. From Visual Studio Code Dev
Containers extension specify the Dockerfile as the target:

`Reopen in Container`

Expand All @@ -49,27 +64,36 @@ docker build . -t libxmtp:1

libxmtp/

[`bindings_ffi`](./bindings_ffi): FFI bindings for Android and iOS (in progress)
[`bindings_ffi`](./bindings_ffi): FFI bindings for Android and iOS (in
progress)

[`bindings_wasm`](./bindings_wasm): Wasm bindings (in progress)

├ examples/

│ ├ [`android/xmtpv3_example`](./examples/android/xmtpv3_example): Example Android app (in progress)
│ ├ [`android/xmtpv3_example`](./examples/android/xmtpv3_example): Example
Android app (in progress)

│ └ [`cli`](./examples/cli): Example XMTP console client. Use the CLI to try out sending double ratchet messages on the XMTP `dev` network.
│ └ [`cli`](./examples/cli): Example XMTP console client. Use the CLI to try out
sending double ratchet messages on the XMTP `dev` network.

[`xmtp_api_grpc`](./xmtp_api_grpc): API client for XMTP's gRPC API, using code from `xmtp_proto`
[`xmtp_api_grpc`](./xmtp_api_grpc): API client for XMTP's gRPC API, using code
from `xmtp_proto`

[`xmtp_api_http`](./xmtp_api_http): API client for XMTP's gRPC Gateway API, using code from `xmtp_proto`
[`xmtp_api_http`](./xmtp_api_http): API client for XMTP's gRPC Gateway API,
using code from `xmtp_proto`

[`xmtp_cryptography`](./xmtp_cryptography): Cryptographic operations

[`xmtp_mls`](./xmtp_mls): Version 3 of XMTP which implements [Messaging Layer Security](https://messaginglayersecurity.rocks/).
[`xmtp_mls`](./xmtp_mls): Version 3 of XMTP which implements
[Messaging Layer Security](https://messaginglayersecurity.rocks/).

[`xmtp_proto`](./xmtp_proto): Generated code for handling XMTP protocol buffers
[`xmtp_proto`](./xmtp_proto): Generated code for handling XMTP protocol
buffers

[`xmtp_v2`](./xmtp_v2): Version 2 of XMTP which uses a [user key bundle](https://xmtp.org/docs/concepts/key-generation-and-usage) to encrypt and exchange messages.
[`xmtp_v2`](./xmtp_v2): Version 2 of XMTP which uses a
[user key bundle](https://xmtp.org/docs/concepts/key-generation-and-usage) to
encrypt and exchange messages.

### Run the benchmarks

Expand Down
2 changes: 1 addition & 1 deletion bindings_ffi/gen_kotlin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WORKSPACE_PATH="$(dirname $WORKSPACE_MANIFEST)"
BINDINGS_MANIFEST="$WORKSPACE_PATH/bindings_ffi/Cargo.toml"
BINDINGS_PATH="$(dirname $BINDINGS_MANIFEST)"
TARGET_DIR="$WORKSPACE_PATH/target"
XMTP_ANDROID="${1:-../xmtp_android}"
XMTP_ANDROID="${1:-../../xmtp-android}"

if [ ! -d $XMTP_ANDROID ]; then
echo "${RED}xmtp-android directory not detected${NC}"
Expand Down
2 changes: 1 addition & 1 deletion bindings_wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"scripts": {
"build": "npm run clean && npm run build:node && npm run clean:gitignore",
"build:node": "wasm-pack build --target web --no-pack --release --out-dir ./dist",
"build:node": "cargo xtask build BindingsWasm --out-dir ./dist -- --release",
"clean": "rm -rf ./dist",
"clean:gitignore": "rm -f ./dist/**/.gitignore",
"prepublishOnly": "npm run build",
Expand Down
13 changes: 12 additions & 1 deletion dev/test-wasm
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
#!/bin/bash
set -eou pipefail

WASM_BINDGEN_TEST_ONLY_WEB=1 WASM_BINDGEN_TEST_TIMEOUT=120 CHROMEDRIVER="chromedriver" cargo test --target wasm32-unknown-unknown --release -p xmtp_mls -p xmtp_id -p xmtp_api_http -- --skip xmtp_mls::subscriptions --skip xmtp_mls::groups::subscriptions --skip xmtp_mls::storage::encrypted_store::group_message::tests::it_cannot_insert_message_without_group --skip xmtp_mls::groups::tests::process_messages_abort_on_retryable_error --skip xmtp_mls::storage::encrypted_store::group::tests::test_find_groups --skip xmtp_mls::storage::encrypted_store::group::tests::test_installations_last_checked_is_updated
WASM_BINDGEN_SPLIT_LINKED_MODULES=1 \
WASM_BINDGEN_TEST_ONLY_WEB=1 \
WASM_BINDGEN_TEST_TIMEOUT=120 \
CHROMEDRIVER="chromedriver" \
cargo test --target wasm32-unknown-unknown --release \
-p xmtp_mls -p xmtp_id -p xmtp_api_http -- \
--skip xmtp_mls::subscriptions \
--skip xmtp_mls::groups::subscriptions \
--skip xmtp_mls::storage::encrypted_store::group_message::tests::it_cannot_insert_message_without_group \
--skip xmtp_mls::groups::tests::process_messages_abort_on_retryable_error \
--skip xmtp_mls::storage::encrypted_store::group::tests::test_find_groups \
--skip xmtp_mls::storage::encrypted_store::group::tests::test_installations_last_checked_is_updated
Loading

0 comments on commit 18ca7b7

Please sign in to comment.