yoshuawuyts/crossgen

Generate library templates using --lib

Open

#11 opened on Sep 13, 2018

View on GitHub
 (6 comments) (1 reaction) (0 assignees)Rust (5 forks)github user discovery
enhancementhelp wanted

Repository metrics

Stars
 (20 stars)
PR merge metrics
 (PR metrics pending)

Description

Feature Request

Summary

In addition to building binaries, we should be able to build libraries too.

Motivation

This is useful for targeting non-cargo targets such as Android, iOS, and WASM. An example use case for this was brought up in https://github.com/datrs/hypercore/issues/36#issuecomment-420861424, where we're trying to build .so files targeting Android.

Guide-level explanation

When someone wants to use crossgen to build libraries, they can run:

$ crossgen --lib

And it'll setup a base version of crossgen, targeting most common platforms.

Reference-level explanation

  1. We should add a lib: bool flag to the CLI.
  2. We should create separate travis templates for CLI
  3. We should create a separate generator method for lib; giving us a choice of gen_bin() and gen_lib() from the lib.rs interface.
  4. main.rs should choose between the gen_bin() and gen_lib() based on the lib: bool flag.

Drawbacks

None.

Rationale and alternatives

  • crossgen --lib was chosen to be compatible with cargo init --lib and cargo init, which target binaries by default, and libraries with a flag.
  • a separate subcommand could be chosen too, but that would be less consistent with cargo, and possibly the wider rust ecosystem.

Unresolved Questions

This does not address setting up individual targets. For example there is currently no way to indicate you want Android support, but not WASM. This must be removed manually after crossgen has run.

Contributor guide