ProtoDef-io / protodefc

Compiler for protodef written in Rust
11 stars 3 forks source link

Make WebAssembly compatible #18

Open ghost opened 6 years ago

ghost commented 6 years ago
Full tree output using cargo tree
├── Inflector v0.10.0
│   ├── lazy_static v0.2.8
│   └── regex v0.2.1
│       ├── aho-corasick v0.6.3
│       │   └── memchr v1.0.1
│       │       └── libc v0.2.22
│       ├── memchr v1.0.1 (*)
│       ├── regex-syntax v0.4.0
│       ├── thread_local v0.3.3
│       │   ├── thread-id v3.0.0
│       │   │   └── libc v0.2.22 (*)
│       │   └── unreachable v0.1.1
│       │       └── void v1.0.2
│       └── utf8-ranges v1.0.0
├── clap v2.23.3
│   ├── ansi_term v0.9.0
│   ├── atty v0.2.2
│   │   └── libc v0.2.22 (*)
│   ├── bitflags v0.8.2
│   ├── strsim v0.6.0
│   ├── term_size v0.3.0
│   │   └── libc v0.2.22 (*)
│   ├── unicode-segmentation v1.1.0
│   ├── unicode-width v0.1.4
│   └── vec_map v0.7.0
├── error-chain v0.10.0
│   └── backtrace v0.3.0
│       ├── backtrace-sys v0.1.10
│       │   └── libc v0.2.22 (*)
│       │   [build-dependencies]
│       │   └── gcc v0.3.45
│       ├── cfg-if v0.1.0
│       ├── dbghelp-sys v0.2.0
│       │   └── winapi v0.2.8
│       │   [build-dependencies]
│       │   └── winapi-build v0.1.1
│       ├── kernel32-sys v0.2.2
│       │   └── winapi v0.2.8 (*)
│       │   [build-dependencies]
│       │   └── winapi-build v0.1.1 (*)
│       ├── libc v0.2.22 (*)
│       ├── rustc-demangle v0.1.4
│       └── winapi v0.2.8 (*)
├── itertools v0.5.10
│   └── either v1.1.0
├── json v0.11.6
├── lazy_static v0.2.8 (*)
├── matches v0.1.4
├── nom v2.2.1
├── num-bigint v0.1.37
│   ├── num-integer v0.1.34
│   │   └── num-traits v0.1.37
│   ├── num-traits v0.1.37 (*)
│   ├── rand v0.3.15
│   │   └── libc v0.2.22 (*)
│   └── rustc-serialize v0.3.24
├── regex v0.2.1 (*)
├── rustache v0.1.0
│   ├── regex v0.1.80
│   │   ├── aho-corasick v0.5.3
│   │   │   └── memchr v0.1.11
│   │   │       └── libc v0.2.22 (*)
│   │   ├── memchr v0.1.11 (*)
│   │   ├── regex-syntax v0.3.9
│   │   ├── thread_local v0.2.7
│   │   │   └── thread-id v2.0.0
│   │   │       ├── kernel32-sys v0.2.2 (*)
│   │   │       └── libc v0.2.22 (*)
│   │   └── utf8-ranges v0.1.3
│   └── rustc-serialize v0.3.24 (*)
├── serde_json v1.0.1
│   ├── dtoa v0.4.1
│   ├── itoa v0.3.1
│   ├── num-traits v0.1.37 (*)
│   └── serde v1.0.2
└── toml v0.4.0
    └── serde v1.0.2 (*)
[build-dependencies]
└── peg v0.5.2
    └── quote v0.3.15

When compiling using rustc 1.25.0-nightly (b1f8e6fb0 2018-02-22) w/ cargo build --target wasm32-unknown-unknown, these packages seem to be an issue:

Then everything that uses libc is also broken.

@hansihe, what is the best approach here. WebAssembly is the 'next step' for this project (in terms of real world usage). The only things I can think of are:

Or, I mean, we could fallback to prebuilt dependencies and asm.js (I really, really don't want to do this, especially with the Rust community making WebAssembly such a big deal)

ghost commented 6 years ago

Ok, so as a good starting point, rustache isn't even needed at all.

ghost commented 6 years ago

Alright, it seems I have overlooked something important: the wasm32-unknown-emscripten target. I am going to attempt building ProtoDefc using this target. In the mean time though, I had made removed rustache, and made clap an optional dependency (as it's only used for the CLI). I will continue cracking away at this, until the point where I hit a wall, where I will turn to the emscripten target.

ghost commented 6 years ago

I was able to do it! #19