Skip to content
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target
Cargo.lock
.idea/
20 changes: 2 additions & 18 deletions cargo-apk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,7 @@ $ cargo install --path cargo-apk/

## Crate configuration

Android and thus `cargo-apk` require the [Cargo Target] to be a Shared Library, corresponding to Rust's `cdylib` `crate-type`. For the sole library in a crate, configure this as follows in `Cargo.toml`:

```toml
[lib]
# Optionally supports a different library location using `path = "..."`
crate-type = ["cdylib"]
```

Example targets must be identified by their `name` or `path` in the list of `example`s:

```toml
[[example]]
name = "example_name" # Matching the filename in `examples/example_name.rs`, unless specified otherwise with `path = "..."`
crate-type = ["cdylib"]
```

[Cargo Target]: https://doc.rust-lang.org/cargo/reference/cargo-targets.html
Crate specific configuration is no longer required, you can just build it out of the box. Old configurations explicitly declaring the `crate-type` can be removed.

## Commands

Expand All @@ -57,7 +41,7 @@ Invoke `cargo apk help` for a more detailed overview of all available commands a

### Target selection

Like `cargo`, the above subcommands from `cargo apk` support selecting the target to build and/or run using `--package`/`-p` (which picks the library target inside the crate) or `--example`, as long as the Cargo Target is a `cdylib` as described above.
Like `cargo`, the above subcommands from `cargo apk` support selecting the target to build and/or run using `--package`/`-p` (which picks the library target inside the crate) or `--example`.

## Manifest

Expand Down
3 changes: 2 additions & 1 deletion cargo-apk/src/apk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ impl<'a> ApkBuilder<'a> {
self.min_sdk_version(),
self.cmd.target_dir(),
)?;
cargo.arg("build");
cargo.arg("rustc");
cargo.args(["--crate-type", "cdylib"]);
if self.cmd.target().is_none() {
cargo.arg("--target").arg(triple);
}
Expand Down
12 changes: 0 additions & 12 deletions ndk-examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,3 @@ ndk = { version = "0.9", features = ["api-level-23"] }
ndk-context = "0.1.1"
android_logger = "0.15"
android-activity = { version = "0.6", features = ["native-activity"] }

[[example]]
name = "hello_world"
crate-type = ["cdylib"]

[[example]]
name = "jni_audio"
crate-type = ["cdylib"]

[[example]]
name = "looper"
crate-type = ["cdylib"]
Loading