coreos / cargo-vendor-filterer

Tool to `cargo vendor` with filtering
Apache License 2.0
37 stars 8 forks source link

Workspaces are not supported #41

Closed glandium closed 1 year ago

glandium commented 1 year ago

Taking a copy of the mozilla-central repository, and trying to run vendor-filterer on it yields the following:

$ cargo vendor-filterer
error: Executing cargo metadata (first run): Error during execution of `cargo metadata`: error: failed to parse manifest at `/tmp/gecko/Cargo.toml`

Caused by:
  missing field `name` for key `package`
cgwalters commented 1 year ago

Hmm, I don't get that particular error. I cloned https://github.com/mozilla/gecko-dev and the error I get instead is

$ error: Replacing with stub: cubeb-coreaudio: Executing cargo metadata: Error during execution of `cargo metadata`: error: failed to load manifest for dependency `coreaudio-sys-utils`

Caused by:
  failed to read `/var/srv/walters/src/github/mozilla/gecko-dev/vendor/cubeb-coreaudio/coreaudio-sys-utils/Cargo.toml`

Caused by:
  No such file or directory (os error 2)

Which looks like it's https://github.com/coreos/cargo-vendor-filterer/issues/32

What version are you using?

glandium commented 1 year ago

Oh, I know what gave me the error message: I was trying to add a [package.metadata.vendor-filter] for testing.

glandium commented 1 year ago

... but there is no package in the workspace Cargo.toml. So there is nowhere to attach the vendor filter to.

cgwalters commented 1 year ago

Ah right, duh. Easy fix: https://github.com/coreos/cargo-vendor-filterer/pull/42

(Also, thanks for all of your work on Firefox/Linux! Happy user here)

glandium commented 1 year ago

With #42, and the following addition to the top-level Cargo.toml

[workspace.metadata.vendor-filter]
platforms = ["*-linux-gnu*", "*-apple-darwin", "*-windows-msvc", "*-windows-gnu", "*-linux-android*"]

I'm now getting

error: Replacing with stub: uniffi-example-todolist: Executing cargo metadata: Error during execution of `cargo metadata`: error: failed to load manifest for dependency `uniffi`

Caused by:
  failed to read `/tmp/gecko/uniffi/Cargo.toml`

Caused by:
  No such file or directory (os error 2)

(after a bunch of Skipping entries that I'm not sure why they are skipped)

uniffi is one of the vendored crates, so I don't know why it's not trying to read its Cargo.toml from the vendor directory.

cgwalters commented 1 year ago

uniffi is one of the vendored crates, so I don't know why it's not trying to read its Cargo.toml from the vendor directory.

Will look at this as a distinct issue

cgwalters commented 1 year ago

OK trying this out with

diff --git a/Cargo.toml b/Cargo.toml
index 30fbfa8d2510..141ec2067d02 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -50,6 +50,9 @@ exclude = [
 # This is required for 'third_party/rust/wgpu-hal'
 resolver = "2"

+[workspace.metadata.vendor-filter]
+platforms = ["*-linux-gnu*", "*-apple-darwin", "*-windows-msvc", "*-windows-gnu", "*-linux-android*"]
+
 # Explicitly specify what our profiles use.  The opt-level setting here is
 # a total fiction; see the setup of MOZ_RUST_DEFAULT_FLAGS for what the
 # opt-level setting will be as a result of various other configure flags.

specifically, I get

error: Replacing with stub: cubeb-coreaudio: Executing cargo metadata: Error during execution of `cargo metadata`: error: failed to load manifest for dependency `coreaudio-sys-utils`

Caused by:
  failed to read `/var/srv/walters/src/github/mozilla/gecko-dev/vendor/cubeb-coreaudio/coreaudio-sys-utils/Cargo.toml`

Caused by:
  No such file or directory (os error 2)

Which looks like another duplicate of https://github.com/coreos/cargo-vendor-filterer/issues/32 because

$ grep sys-utils vendor/cubeb-coreaudio/Cargo.toml
coreaudio-sys-utils = { path = "coreaudio-sys-utils" }
cgwalters commented 1 year ago

@glandium https://github.com/coreos/cargo-vendor-filterer/pull/43 also gets us as far as generating a vendor/ directory for me with tip gecko-dev. But I didn't try compiling it:

$ git diff
diff --git a/Cargo.toml b/Cargo.toml
index 30fbfa8d2510..141ec2067d02 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -50,6 +50,9 @@ exclude = [
 # This is required for 'third_party/rust/wgpu-hal'
 resolver = "2"

+[workspace.metadata.vendor-filter]
+platforms = ["*-linux-gnu*", "*-apple-darwin", "*-windows-msvc", "*-windows-gnu", "*-linux-android*"]
+
 # Explicitly specify what our profiles use.  The opt-level setting here is
 # a total fiction; see the setup of MOZ_RUST_DEFAULT_FLAGS for what the
 # opt-level setting will be as a result of various other configure flags.
$ cargo vendor-filterer --all-features true
kipping mozversion
Skipping vcpkg
Skipping gecko-fuzz-targets
Skipping js-sys
Skipping rand
Skipping builtins-static
Skipping rust_minidump_writer_linux
Skipping binary_http
Skipping malloc_size_of
Skipping jog
Skipping oblivious_http
Skipping style_derive
Skipping marionette
Skipping defaultagent-static
Skipping selectors
Skipping unic-langid-ffi
Skipping gkrust_utils
Skipping mozurl
Skipping webrender_api
Skipping parking_lot
Skipping xpcom
Skipping cmake
Skipping wasi
Skipping mozrunner
Skipping swgl
Skipping smoosh
Skipping webdriver
Skipping wgpu_bindings
Skipping bench-collections-gtest
Skipping rure
Skipping peek-poke
Skipping to_shmem_derive
Skipping ipcclientcerts-static
Skipping moz_task
Skipping netwerk_helper
Skipping http3server
Skipping dap_ffi-gtest
Skipping mozdevice
Skipping xpcom_macros
Skipping web-sys
Skipping dom
Skipping xulstore
Skipping mozbuild
Skipping mozilla-central-workspace-hack
Skipping localization-ffi
Skipping tokio-util
Skipping uniffi-fixture-external-types
Skipping gecko-profiler
Skipping rsdparsa_capi
Skipping style
Skipping uniffi-bindgen-gecko-js
Skipping storage
Skipping detect_win32k_conflicts
Skipping autocfg
Skipping bits
Skipping uniffi-example-custom-types
Skipping webrender_bindings
Skipping geckodriver
Skipping nsstring
Skipping fog-gtest
Skipping fog_control
Skipping gluesmith
Skipping moz_asserts
Skipping qcms
Skipping peek-poke-derive
Skipping nserror
Skipping kvstore
Skipping bookmark_sync
Skipping xpcom-gtest
Skipping profiler_helper
Skipping http_sfv
Skipping static_prefs
Skipping memmap2
Skipping app_services_logger
Skipping dap_ffi
Skipping webext_storage_bridge
Skipping gkrust
Skipping mio
Skipping cascade_bloom_filter
Skipping mozwer_s
Skipping bitsdownload
Skipping style_traits
Skipping libudev-sys
Skipping mp4parse-gtest
Skipping bindgen
Skipping gkrust-gtest
Skipping jsrust_shared
Skipping l10nregistry-ffi
Skipping nsstring-gtest
Skipping mozprofile
Skipping neqo_glue
Skipping bits_client
Skipping cfg-if
Skipping stylo_tests
Skipping l10nregistry
Skipping prefs_parser
Skipping derive_common
Skipping redox_users
Skipping origin-trials-ffi
Skipping data-encoding-ffi
Skipping fluent-ffi
Skipping goblin
Skipping memoffset
Skipping golden_gate
Skipping encoding_glue
Skipping jsrust
Skipping wineventlog
Skipping geckoservo
Skipping mdns_service
Skipping uniffi_bindgen
Skipping env_logger
Skipping gkrust-shared
Skipping servo_arc
Skipping cert_storage
Skipping fog
Skipping midir_impl
Skipping profiler-macros
Skipping webrender
Skipping processtools
Skipping l10nregistry-ffi-gtest
Skipping wasm-bindgen
Skipping tinyvec
Skipping moz_task-gtest
Skipping storage_variant
Skipping gecko_logger
Skipping glsl-to-cxx
Skipping nix
Skipping rsclientcerts
Skipping mozglue-static
Skipping osclientcerts-static
Skipping webrender_build
Skipping fluent-langneg-ffi
Skipping wr_malloc_size_of
Skipping to_shmem
Generated: vendor
$

Does that set of omitted deps look right?

Let me know if you get a chance to test it out!

glandium commented 1 year ago

I tested it, and it finishes, but the generated directory still contains the same thing as cargo vendor does. I'd have expected things like redox_syscall to be skipped or replaced.

I don't know what the Skipping lines are about, but they don't seem right.

glandium commented 1 year ago

mmm actually, it sounds like the Skipping lines are about crates that are not part of the vendored set at all.