icanwalkonwater / libaria2-rs

Rust bindings to libaria2.
Apache License 2.0
11 stars 2 forks source link

First version #8

Open icanwalkonwater opened 2 years ago

icanwalkonwater commented 2 years ago

As stated in #7 I have made it easier to contribute by providing a roadmap and goals of the project in view of the first release (v0.1.0)

TODO list for first release:

icanwalkonwater commented 2 years ago

@nyurik If you are up for it, I think a first contribution to get you started can be to (has you mentionned initialy) to improve support for other platforms. It currently uses pkg-config to find aria2, which is linux-only. It is used here.

nyurik commented 2 years ago

I did a first preliminary step so far - made a few improvements to the aria2 windows build docker file - https://github.com/aria2/aria2/pull/1867 - hopefully the maintainers will accept the changes. This should help simplify the Windows build process - we can simply use that docker file as one of the build steps compiling the rust wrapper, or at least help with testing/CI. Will hack on it a bit further soon.

nyurik commented 2 years ago

Update: The https://github.com/aria2/aria2/pull/1867 has been substantially changed in the past few days, adding a number of cleanups and features. The docker will now export aria2.h and all of the *.a lib files (I wasn't able to generate .dll file for some reason). My current approach at building libaria2-rs for Windows is in https://github.com/icanwalkonwater/libaria2-rs/compare/main...nyurik:win

This is the tentative Windows build approach.

export GITHUB_REPO='nyurik/aria2'
export GIT_TAG='win'
curl https://raw.githubusercontent.com/${GITHUB_REPO}/${GIT_TAG}/Dockerfile.mingw \
  | docker build -t aria2-mingw --build-arg GITHUB_REPO --build-arg GIT_TAG --build-arg LIBARIA2=enable --build-arg HOST=x86_64-w64-mingw32 -

# Copy results to the ./native
cd ...path_to_libaria2-rs_clone...
docker run --rm -v $PWD/native:/output aria2-mingw
export LIBARIA2_DIR=native/
cargo build --target=x86_64-pc-windows-gnu --example add-uri

This has not been fully verified, i'll post further updates soon.

icanwalkonwater commented 2 years ago

I didn't realized building for windows will be such a pain.

Reading through some *-sys crate it seems that everyone is building from source then statically linking instead of dynamically linking like I did.

Since it is basically what is required anyway for windows, maybe it can be easier to just build aria2 from source and link it, regardless of the platform, that will certainly remove any version problems, make for more predictable builds and make for a cleaner build.rs.

What do you think ?

nyurik commented 2 years ago

Well, that's what I was kind of doing too, except that I was doing it half way in a docker, and the rest on the host. Instead, I think we can just build the whole thing in docker using mingw target. My biggest concern is the need to link to some win core libs, as well as proper testing