lukka / run-vcpkg

The GitHub Action to setup vcpkg for your C++ based projects. Stores built ports using Binary Caching backed onto GH Cache.
MIT License
193 stars 26 forks source link

Issues when trying to use the action #179

Open 4JX opened 1 year ago

4JX commented 1 year ago

I want to use this action since it significantly cuts down the build times thanks to the caching, but I cannot seem to get it to work in place of manually calling vcpkg.

If I use the action, the build scripts of my dependencies cannot seem to find the installed packages https://github.com/4JX/L5P-Keyboard-RGB/actions/runs/3999069155

However, if I revert to manually using vcpkg they are found just fine. https://github.com/4JX/L5P-Keyboard-RGB/actions/runs/4008777116

Reading the logs the most prominent difference would be the place vcpkg is installed, but I do not believe that to be the issue.

lukka commented 1 year ago

@4JX i think you spot already the issue: run-vcpkg by default puts the installed directory using --x-install-root,/home/runner/work/L5P-Keyboard-RGB/b/vcpkg_installed, while your build is trying to pull them from the $VCPKG_ROOT/installed:

2023-01-24T18:08:31.0955971Z   cargo:rustc-link-search=/home/runner/work/L5P-Keyboard-RGB/L5P-Keyboard-RGB/vcpkg/installed/x64-linux/lib
2023-01-24T18:08:31.0956681Z   cargo:include=/home/runner/work/L5P-Keyboard-RGB/L5P-Keyboard-RGB/vcpkg/installed/x64-linux/include

You can either customize the installed directory location in run-vcpkg by modifying the value of the env var VCPKG_INSTALLED_DIR which is then used when running vcpkg (see https://github.com/lukka/run-vcpkg/blob/main/action.yml#L53). Or you can instruct your build system to pull them from the <root>/b/vcpkg_installed directory.

Let me know if this helps.

4JX commented 1 year ago

i think you spot already the issue

I was thinking about where vcpkg itself is installed, as I assumed that it (in tandem with VCPKG_ROOT) would determine the location of the installed packages.

Should I be manually creating the installed directory?

I tried setting it as VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg/installed but it fails with "invalid directory" https://github.com/4JX/L5P-Keyboard-RGB/actions/runs/4038536445/jobs/6942641088#step:5:78

lukka commented 1 year ago

@4JX thanks a lot for trying this out! In the last failing run the root cause of the failure is that a vcpkg.json file was not found, hence the action does not know what to do and fails. Follow ups:

lukka commented 1 year ago

@4JX Let me know if your workflow runs correctly. I plan to add a new workflow to validate your scenario ('cargo'+'vcpkg'), and to improve run-vcpkg error reporting as well. I added a basic workflow, all it needs to be added is that the rust code should reference and link symbols pulled from packages installed by vcpkg, you may contribute as well to add the missing pieces in a PR, thanks!

4JX commented 1 year ago

the root cause of the failure is that a vcpkg.json file was not found

Completely forgot about re-adding the file, compiles fine now!

Spoke too soon, the windows build had yet to make an attempt at recompiling while linking https://github.com/4JX/L5P-Keyboard-RGB/actions/runs/4067795449/jobs/7006243710.

Seems like vcpkg gets set up in D:\a\L5P-Keyboard-RGB\L5P-Keyboard-RGB\vcpkg while the build scrip tries to go through -L 'C:\vcpkg\installed\x64-windows-static\lib' -L 'C:\vcpkg\installed\x64-windows-static\lib' for some reason?

Magically worked again https://github.com/4JX/L5P-Keyboard-RGB/actions/runs/4087432025/jobs/7047932976 (while also linking to the downloaded deps in the correct directory specified by $VCPKG_ROOT), no idea why the other would've failed.

I added a basic workflow

[package.metadata.vcpkg.target] comes from a different tool, currently building a minimal example over at https://github.com/4JX/vcpkg-action-test

It seems to be mostly working, but when using run-vcpkg it fails on MacOS due to these lines, which search for files inside of (if I'm not mistaken) $VCPKG_ROOT/installed/vcpkg/updates.

Is it correct to assume that such a directory will exist? Manually using vcpkg update && vcpkg install vpx finishes correctly.

lukka commented 1 year ago

@4JX it is great to see a sample for cargo+vcpkg! I'll look into it to make it working on macOS and let you know. Let me know if everything works fine for you as well!

lukka commented 1 year ago

@4JX the sample of using vcpkg+cargo with run-vcpkg is properly working, take a look to the tip of the main branch: https://github.com/lukka/vcpkg-action-test/tree/ab6dd1bf5a9c2571f16f80afddd06ede3b84c8c0

This is the workflow run: https://github.com/lukka/vcpkg-action-test/actions/runs/4100509958

I am looking forward to add the scenario to the set of validation tests of run-vcpkg, thanks for creating a small test case!

4JX commented 1 year ago

Great! Thanks for the support provided on getting this working.

lukka commented 1 year ago

@4JX are you currently using run-vcpkg and cargo on GitHub workflows? If so, I think the libvpx build is broken for Windows, and wonder which vcpkg commit id are you currently using. Last run worked for macos, failed for Wndows, and for some unkown reason for Linux wont start: https://github.com/lukka/vcpkg-action-test/actions/runs/4581758239/jobs/8091515087

4JX commented 1 year ago

Had that just happen, updating to a more recent commit (and using v11) seems to have fixed it https://github.com/4JX/L5P-Keyboard-RGB/actions/runs/4746484205/jobs/8430188222#step:5:1 (Ignore the otherwise failed build, run-vcpkg worked just fine for the linux one) https://github.com/4JX/L5P-Keyboard-RGB/actions/runs/4746596729/jobs/8430436744#step:5:1 (for windows)

lukka commented 1 year ago

@4JX I think that I could reference your project as a sample that shows how to integrate vcpkg with cargo in the documentation of run-vcpkg.