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

Puts invalid pkg-config package names into Cargo.toml (dashes replaced with underscores) #1020

Closed
deanleggo opened this issue Dec 9, 2020 · 9 comments · Fixed by #1022
Closed

Comments

@deanleggo
Copy link
Contributor

Following the Gir Tutorial and continuing from the discussion on GNOME's Discourse. I am unable to build tracker-sys. On discourse I referenced the test/abi.rs file, but this file is (of course) not ran during the build step.

This time I built Tracker from source and placed the generated gir file in tracker-sys/gir-files along with the required librarys from /usr/share/gir-1.0/ on Fedora 33. The code I have is on my Gitlab - tracker-rs.

During the build process, it is trying to find the package tracker_sparql_3_0 but the name should be tracker-sparql-3.0. For some reason the builder is modifying the package name found inside the tracker gir file when searching pkg-config for the package.

error: failed to run custom build command for `tracker-sys v0.0.1 (/home/dean/Projects/tracker-rs/tracker-sys)`

Caused by:
  process didn't exit successfully: `/home/dean/Projects/tracker-rs/tracker-sys/target/debug/build/tracker-sys-52e25f5b766c5977/build-script-build` (exit code: 1)
  --- stdout
  cargo:rerun-if-env-changed=TRACKER_SPARQL_3_0_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=TRACKER_SPARQL_3_0_STATIC
  cargo:rerun-if-env-changed=TRACKER_SPARQL_3_0_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  `"pkg-config" "--libs" "--cflags" "tracker_sparql_3_0" "tracker_sparql_3_0 >= 3.0"` did not exit successfully: exit code: 1
  --- stderr
  Package tracker_sparql_3_0 was not found in the pkg-config search path.
  Perhaps you should add the directory containing `tracker_sparql_3_0.pc'
  to the PKG_CONFIG_PATH environment variable
  Package 'tracker_sparql_3_0', required by 'virtual:world', not found
  Package 'tracker_sparql_3_0', required by 'virtual:world', not found
@sdroege
Copy link
Member

sdroege commented Dec 9, 2020

You can edit the Cargo.toml of the -sys crates for this, and the changes are preserved whenever you regenerate (otherwise that would be a bug). See for example what I do for GStreamer here. That's basically the same problem: switching dashes and underscores.

@deanleggo
Copy link
Contributor Author

Thanks that works. I've now moved to the next step of the tutorial.
Should the name be added for every generated Cargo.toml file?
If not, would it be possible to add a note in the tutorial?

@sdroege
Copy link
Member

sdroege commented Dec 9, 2020

Should the name be added for every generated Cargo.toml file?

Which name?

But yes, the pkg-config stuff that confused you here should definitely be added to the tutorial. If you want, can you create a PR for https://github.com/gtk-rs/gtk-rs.github.io to add a paragraph or two about that?

@deanleggo
Copy link
Contributor Author

I can create the PR

I was referring to the link you provided earlier.

[package.metadata.system-deps.gstreamer_1_0]
name = "gstreamer-1.0"
version = "1.8"

I think this name comes directly from the package field in the gir file. But that depends if the current behaviour is the standard way to provide names for pkg-config names and this issue is rare.

@sdroege
Copy link
Member

sdroege commented Dec 9, 2020

I think it would be useful for gir to do something more clever here about the dashes/underscores. I mean, in the .gir file the name is correct...

@gdesmott What do you think? Why do we change the name to begin with?

@gdesmott
Copy link
Contributor

gdesmott commented Dec 9, 2020

Because toml keys cannot contains - so we have to use _ instead. :\

@sdroege
Copy link
Member

sdroege commented Dec 9, 2020

Right, but I assume we could directly provide it in the correct way with name = "name-with-dashes" in the autogenerated Cargo.toml or is there something making that difficult?

@gdesmott
Copy link
Contributor

gdesmott commented Dec 9, 2020

It's already supposed to do it actually: https://github.com/gtk-rs/gir/blob/master/src/codegen/sys/cargo_toml.rs#L120

That should be debugged if it didn't work.

@sdroege
Copy link
Member

sdroege commented Dec 9, 2020

Thanks, so something to fix here in gir instead :)

@sdroege sdroege changed the title Failure to generate library for Tracker 3 Puts invalid pkg-config package names into Cargo.toml (dashes replaced with underscores) Dec 9, 2020
@sdroege sdroege linked a pull request Dec 11, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants