Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use --message-format=json for getting the location of the generated files #333

Closed
konstin opened this issue Sep 21, 2018 · 1 comment
Closed
Labels
to-do stuff that needs to happen, so plz do it k thx

Comments

@konstin
Copy link
Contributor

konstin commented Sep 21, 2018

💡 Feature description

Currently, wasm-pack tries to guess the location of the asset from the Cargo.toml. With --message-format=json we can get the location directly from cargo.

This should also fix #252.

💻 Basic example

{
  "features": [],
  "filenames": [
    "/home/konsti/pyo3-pack/points/target/debug/libpoints.so"
  ],
  "fresh": true,
  "package_id": "points 0.1.0 (path+file:///home/konsti/pyo3-pack/points)",
  "profile": {
    "debug_assertions": true,
    "debuginfo": 2,
    "opt_level": "0",
    "overflow_checks": true,
    "test": false
  },
  "reason": "compiler-artifact",
  "target": {
    "crate_types": [
      "cdylib"
    ],
    "edition": "2015",
    "kind": [
      "cdylib"
    ],
    "name": "points",
    "src_path": "/home/konsti/pyo3-pack/points/src/lib.rs"
  }
}

Implementation in pyo3-pack: https://github.com/PyO3/pyo3-pack/blob/2f0c8a926bf1b607c48589a2393604de322f7f40/src/compile.rs#L221-L232

cargo-metadata has a pending pull request which wraps cargo's messages in a nice api we could use.

@ashleygwilliams ashleygwilliams added this to the 0.6.0 milestone Sep 21, 2018
@ashleygwilliams ashleygwilliams added the to-do stuff that needs to happen, so plz do it k thx label Sep 21, 2018
konstin added a commit to konstin/wasm-pack that referenced this issue Sep 23, 2018
konstin added a commit to konstin/wasm-pack that referenced this issue Sep 23, 2018
konstin added a commit to konstin/wasm-pack that referenced this issue Sep 24, 2018
konstin added a commit to konstin/wasm-pack that referenced this issue Sep 27, 2018
konstin added a commit to konstin/wasm-pack that referenced this issue Oct 1, 2018
@alexcrichton
Copy link
Contributor

I think unfortunately we won't be able to switch to doing this in the near future because when Cargo is placed in json message mode it also places the compiler in json message mode. We don't have a great way to rerender an error message as desired by rustc later on which means we wouldn't be able to render rustc's error messages faithfully to the console.

I think, though, that with recent improvements and bug fixes we should be pretty good to go here. Cargo should always produce predictable output for a package so long as we hook up the directories and such correctly. For now we'll have to implement that logic manually, but perhaps in the future we can also add a feature to Cargo to have cargo emit json messages and have rustc still emit normal error messages!

@ashleygwilliams ashleygwilliams removed this from the 0.6.0 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to-do stuff that needs to happen, so plz do it k thx
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants