georust / proj

Rust bindings for the latest stable release of PROJ
https://docs.rs/proj
Apache License 2.0
137 stars 45 forks source link

add support of vcpkg with msvc toolchain #79

Open lapoigne opened 3 years ago

lapoigne commented 3 years ago

I added the support of vcpkg libraries in proj-sys. This allow to build proj-sys on windows with msvc without pkg-config.

To use vcpkg libraries on your rust program, you need:

To build, run

cargo install cargo-vcpkg
cargo vcpkg build
cargo build

I'm new to rust, I hope this isn't to ugly in my implementation.

michaelkirk commented 3 years ago

AFAIK none of the main contributors are using windows, so it'd be good to test this setup in CI.

Do you have any experience with using windows containers in GH actions? Would you be willing to add a job to https://github.com/georust/proj/blob/master/.github/workflows/test.yml?

urschrei commented 3 years ago

Hi @lapoigne, apologies for the delay. As @michaelkirk says, we don't have anyone available to locally test this, but we're certainly interested in anything that improves the Windows experience for these crates.

lapoigne commented 3 years ago

I will look closer to add CI for windows platform.

lapoigne commented 3 years ago

I added windows in CI file. The 32bit platform is commented because we loose precision in floating number and the test fail. Maybe you just want remove this architecture. I edited some test because I get some insignificant change in some value like 1450880.2910605008 for 1450880.2910605003

michaelkirk commented 3 years ago

bors try

Sorry to let this sit for so long. Thanks for adding the ci integration, let's try it out.

michaelkirk commented 3 years ago

bors try

bors[bot] commented 3 years ago

try

Already running a review

michaelkirk commented 3 years ago

bors r-

michaelkirk commented 3 years ago

bors retry

michaelkirk commented 3 years ago

bors r+

one last try bors.

michaelkirk commented 3 years ago

Bors is crashing, I'm going to follow up with some bors peeps.

update: done here https://forum.bors.tech/t/bors-crashing-resource-not-accessible-by-integration/571/3

update 2: looking into similarly errors reported, it seems like "editing the workflow file" is a common source of crashes between bors and gh

bors[bot] commented 3 years ago

try

Build succeeded:

wlinna commented 1 year ago

Using opus-rs as a starting point, I was able to compile proj https://github.com/rust-av/opus-rs/commit/9f04ec13880ae1c72ee3f0548a8f6fd45475d9c7

Given these assumptions.. :

These commands should work fine. At least I was able to build my project on Windows :

  1. chocolatey install pkgconfiglite (requires elevated privileges)
  2. Open PowerShell in C:\src\vcpkg
  3. .\vcpkg.exe install proj:x64-windows
  4. cargo init
  5. cargo add proj
  6. cargo build

(NOTE: I don't know whether or not this alone will result in linking with a release build of proj C++-library.)

I'm just thinking that maybe instead of referring to vcpkg directly in build.rs and Cargo configurations, georust/proj could consider requiring pkgconfiglite on Windows just like it requires pkg-config on other platforms (?). Of course the process would have to be documented.

I guess one advantage of this approach would be that it might not actually depend on vcpkg since developers can choose their own method for compiling proj C++-library (or so I believe).

I hope this helps

michaelkirk commented 1 year ago

Hi @wlinna! To clarify — it sounds like you were able to build with the unmodified proj release using the instructions you provided.

Is that right? Or did you have to modify the proj/proj-sys crate in some way?

wlinna commented 1 year ago

That's right, all unmodified :) . Rust, cargo are also installed with default options. All I had to do was to install software and set env variables according to the steps I provided.

On Thursday, November 10, 2022, Michael Kirk @.***> wrote:

Hi @wlinna https://github.com/wlinna! To clarify — it sounds like you were able to build with the unmodified proj release using the instructions you provided.

Is that right? Or did you have to modify the proj/proj-sys crate in some way?

— Reply to this email directly, view it on GitHub https://github.com/georust/proj/pull/79#issuecomment-1309109547, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALHXLQZT7FROKWN3KATO4DWHPOW5ANCNFSM4YQYDIOQ . You are receiving this because you were mentioned.Message ID: @.***>

kylebarron commented 1 year ago

This is amazing! Thanks for the hint about pkgconfiglite @wlinna. I was able to get proj building on CI for Python in https://github.com/geopolars/geopolars/pull/174