Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 1.7 KB

README.md

File metadata and controls

48 lines (33 loc) · 1.7 KB

rust-proc-macro-expander

Build Status Build Status

This utility is capable of calling compiled Rust custom derive dynamic libraries on arbitrary code.

IMPORTANT: compiler API, used in this utility, is not in stable rustc build. Use nightly rustc version to build it.

Usage

IMPORTANT: should be built with RUSTFLAGS='--cfg procmacro2_semver_exempt' as stated here.

Expander launches as CLI tool and accepts json array of expansion tasks from stdin.

Assuming you have expansion_task.json in current directory, and compiled procedural macro id_macro somewhere:

[
  {
    "macro_body": "struct S {}", 
    "macro_name": "id_macro",
    "libs": [ "path/to/libid_macro.so" ]
  }
]

you can launch proc_macro_expander like this:

> cat expansion_task.json | ./proc_macro_expander

[ {"type": "success", "expansion": "struct S { }"} ]

Testing

You can launch tests with this command:

> RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo +nightly-2019-04-01 test

Current stable and nighly builds are having incompatible ABIs due to this PR. That is why nightly-2019-04-01 is used. As soon as changes from this PR make it into the stable branch, tests should be able to run on current nightly.