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

Investigation of pkg-config, brew / vcpkg on GHA #35

Closed
robo9k opened this issue Oct 3, 2023 · 2 comments
Closed

Investigation of pkg-config, brew / vcpkg on GHA #35

robo9k opened this issue Oct 3, 2023 · 2 comments

Comments

@robo9k
Copy link
Owner

robo9k commented Oct 3, 2023

In order to see how viable #1 is I've tested this with GitHub Actions on their shared runners.

At the time of writing:

ubuntu-22.04

  • pkg-config 0.29.2-1ubuntu3
  • libmagic1 1:5.41-3ubuntu0.1
  • libmagig-dev 1:5.41-3ubuntu0.1
  • build static with "-lmagic -llzma -lbz2 -lz"

macos-12

  • pkg-config 0.29.2_3
  • libmagic 5.45
  • brew 4.1.14
  • build static with "-I/usr/local/Cellar/libmagic/5.45/include -L/usr/local/Cellar/libmagic/5.45/lib -lmagic -llzma -lbz2 -lz"

windows-2022

  • libmagic 5.40#2
  • vcpkg 2023-09-15-ac02a9f660977426b8ec6392919fbb1d51b10998
  • build static with ??? (needs vcpkg triplet selection iiuc)
on:
  workflow_dispatch: 

jobs:
  ubuntu:
    runs-on: ubuntu-22.04

    steps:
      - run: |
          sudo apt-get update
          sudo apt-get install libmagic1 libmagic-dev pkg-config

      - run: |
          which pkg-config
          pkg-config --version

      - run: ls $(pkg-config --variable=libdir libmagic)/libmagic*

      - run: pkg-config --debug --validate libmagic

      - run: |
          pkg-config --static --libs --cflags libmagic
          pkg-config --libs --cflags libmagic
  macos:
    runs-on: macos-12

    steps:
      - run: |
          brew update
          brew install libmagic pkg-config

      - run: |
          which pkg-config
          pkg-config --version
          brew --version

      - run: ls $(pkg-config --variable=libdir libmagic)/libmagic*

      - run: pkg-config --debug --validate libmagic

      - run: |
          pkg-config --static --libs --cflags libmagic
          pkg-config --libs --cflags libmagic

  windows:
      runs-on: windows-2022
      env:
        VCPKG_BINARY_SOURCES: clear;x-gha,readwrite

      steps:
        - uses: actions/github-script@v6
          with:
            script: |
              core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
              core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');

        - run: |
            vcpkg update
            vcpkg install libmagic

        - run: |
            vcpkg version

        - run: |
            vcpkg search libmagic
            vcpkg depend-info libmagic

While this did not actually test a build of magic-sys (with neither pkg-config nor (cargo) vcpkg, it looks like at least GHA should be able to build with a hard requirement on

  • pkg-config (on Linux, macOS)
  • vcpkg (on Windows)
  • libmagic >= 5.39
@robo9k
Copy link
Owner Author

robo9k commented Oct 3, 2023

Looking at the static build flags explains missing symbols in #30 (comment) and #34 (comment)

It doesn't help explain #37 (comment) so that needs further investigation.
There was another vcpkg workaround in #16 (comment)

In general I believe the current way of building with the MAGIC_DIR, MAGIC_STATIC env is too simplistic in that it makes half-baked assumptions about the installed libmagic library.
Instead we should lean in fully on pkg-config and vcpkg, so that users will have to configure those crates/binaries instead.
Maybe we could keep a MAGIC_LINK env with auto|dynamic|static which attempts to detect a sensible default for auto or else passes dynamic/static to pkg-config & vcpkg.

This would mean a change in requirements (see #5 ) and thus in supported systems. I'll do some more research in #36

I'm still not sold entirely on #4 as I'd rather not pull in a whole submodule and possibly autotools (crate) dependency.
Using apt-get, brew, vcpkg is probably enough for the common cases.

@robo9k
Copy link
Owner Author

robo9k commented Oct 8, 2023

See #39 (comment) for a series of pull requests that implement builds with GHA for this repo now

@robo9k robo9k closed this as completed Oct 8, 2023
@robo9k robo9k unpinned this issue Oct 8, 2023
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

No branches or pull requests

1 participant