-
Notifications
You must be signed in to change notification settings - Fork 2
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
Use pkg-config to get dependencies #14
base: master
Are you sure you want to change the base?
Conversation
This uses an aggregate target with a Run Script and pkg-config to generate OTHER_CFLAGS, OTHER_LDFLAGS, HEADER_SEARCH_PATHS, and LIBRARY_SEARCH_PATHS instead of having them hardcoded in the plugin configuration.
pkg-config points directly to the pidgin/ include subfolder, so we need to change the imports to follow. This also removes the (no longer needed) GtkTree and GtkWindow defines.
Generating the xcconfig as a target meant having to run the project twice (once to generate the config and have the build fail, and another time to actually pull the config values and build properly). Running as a pre-action allows the config values to be pulled on the same build.
xcodebuild will fail if the file doesn't exist. It doesn't need to start with content, it just needs to exist.
Hi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manually works well but automated generation seems to be missing. A few small suggestions too.
HEADER_SEARCH_PATHS="$(pkg-config $PACKAGES --cflags-only-I | sed 's/^-I//g;s/ -I/ /g')" | ||
LIBRARY_SEARCH_PATHS="$(pkg-config $PACKAGES --libs-only-L | sed 's/^-L//g;s/ -L/ /g')" | ||
|
||
cat <<EOF > "${PROJECT_DIR}/Dependencies.xcconfig" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it should write to a file that is a part of the repository. That generated file should be in gitignore otherwise it makes fictional changes.
@@ -0,0 +1,26 @@ | |||
#!/usr/bin/env bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering that Apple has basically stopped supporting bash
on macOS either pure sh
or at least zsh
would be a better idea.
@@ -0,0 +1,26 @@ | |||
#!/usr/bin/env bash | |||
|
|||
HOMEBREW_BIN="${HOMEBREW_ROOT:-/opt/homebrew}/bin" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does modern homebrew installation set this variable? Mine (a few years old) definitely didn't.
Anyway why not use brew config | grep "HOMEBREW_PREFIX:" | awk -F ' ' '{print $2}'
or something similar to find it when env var is not set?
@@ -35,6 +35,7 @@ | |||
/* End PBXCopyFilesBuildPhase section */ | |||
|
|||
/* Begin PBXFileReference section */ | |||
9DFC539927488134005F0927 /* Dependencies.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Dependencies.xcconfig; sourceTree = "<group>"; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some kind of a Run Script
phase or similar config is missing - currently it doesn't run the script at all and that would be the expected behavior (and commits mention it).
After manually running the script with correct env vars (I can only hope that xcode sets correct project dir as of now) it builds correctly through both XCode and terminal command.
With this change, a pre-build script will get the library and header flags needed for dependencies from pkg-config instead of having them hardcoded. This has allowed for building on my system (
ARCH=arm64
) with xcodebuild and in Xcode.app.Xcode seems to have a version of pkg-config in its
$PATH
that doesn't check Homebrew pkgconfig directories. To get around that, the build takes an argumentHOMEBREW_ROOT
which defaults to /opt/homebrew (the current default path) and can be overrode in xcodebuild or by modifying the scheme's arguments.For some reason the pre-build script doesn't run by default on xcodebuild, and I had to explicitly define the scheme to get it to kick off consistently: