macvim: switch to building with the nixpkgs SDK
This uses the nixpkgs SDK to build, which means we can get rid of a lot of our build hacks. This does mean we're now assuming that Xcode is in `/Applications/Xcode.app` instead of letting xcode-select find it, though this is configurable. Reenable python3 support since using the nixpkgs SDK fixes the incompatibility there. Switch lua/perl/python/ruby/tcl support away from dynamic since vim isn't finding the right libraries anymore, for some reason. Remove some of the other old stuff like bits of the patchfile that don't seem to be needed anymore.
This commit is contained in:
@@ -7,7 +7,7 @@ index 7481870..6355242 100644
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/zsh;
|
||||
- shellScript = "# Copy the runtime files to the app bundle, under Resources/vim/runtime folder.\n# We cannot do a direct copy of the runtime folder as it contains misc test\n# scripts and also man pages and we should use the Vim's defined rules to\n# install them properly.\n\n# Note that this will also install man pages, under a \"man\" folder. This is\n# useful if the user really wants to point their man page to MacVim's verison\n# instead of builtin Vim, using MANPATH=/Applications/MacVim.app/Contents/man).\n\n# prefix: Reset to empty as it's set to /Applications for fallback rt-folder\n# VIMNAME: Use the default \"vim\" to make sure man pages use that instead of \"Vim\"\n# VIMRTDIR: Make sure to use \"runtime\" as by default it uses a \"vim90\" style folder which is mostly a relic.\n\ncd \"${SRCROOT}\"/..\nmake \\\n DESTDIR=\"${TARGET_BUILD_DIR}\" \\\n prefix= \\\n VIMNAME=vim \\\n VIMRTDIR=/runtime \\\n macvim-install-runtime\n\n# Also add man pages for \"mvim\"\nfor curdir in \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH\"/man/**/man1; do\n (cd $curdir; ln -f -s gvim.1 mvim.1)\ndone\n";
|
||||
+ shellScript = "# Copy the runtime files to the app bundle, under Resources/vim/runtime folder.\n# We cannot do a direct copy of the runtime folder as it contains misc test\n# scripts and also man pages and we should use the Vim's defined rules to\n# install them properly.\n\n# Note that this will also install man pages, under a \"man\" folder. This is\n# useful if the user really wants to point their man page to MacVim's verison\n# instead of builtin Vim, using MANPATH=/Applications/MacVim.app/Contents/man).\n\n# prefix: Reset to empty as it's set to /Applications for fallback rt-folder\n# VIMNAME: Use the default \"vim\" to make sure man pages use that instead of \"Vim\"\n# VIMRTDIR: Make sure to use \"runtime\" as by default it uses a \"vim90\" style folder which is mostly a relic.\n\ncd \"${SRCROOT}\"/..\nfor x in ${(k)parameters}; do if [[ $x = *_DEPLOYMENT_TARGET ]]; then [[ $x = MACOSX_DEPLOYMENT_TARGET ]] || unset $x; fi; done\nmake \\\n DESTDIR=\"${TARGET_BUILD_DIR}\" \\\n prefix= \\\n VIMNAME=vim \\\n VIMRTDIR=/runtime \\\n macvim-install-runtime\n\n# Also add man pages for \"mvim\"\nfor curdir in \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH\"/man/**/man1; do\n (cd $curdir; ln -f -s gvim.1 mvim.1)\ndone\n";
|
||||
+ shellScript = "# Copy the runtime files to the app bundle, under Resources/vim/runtime folder.\n# We cannot do a direct copy of the runtime folder as it contains misc test\n# scripts and also man pages and we should use the Vim's defined rules to\n# install them properly.\n\n# Note that this will also install man pages, under a \"man\" folder. This is\n# useful if the user really wants to point their man page to MacVim's verison\n# instead of builtin Vim, using MANPATH=/Applications/MacVim.app/Contents/man).\n\n# prefix: Reset to empty as it's set to /Applications for fallback rt-folder\n# VIMNAME: Use the default \"vim\" to make sure man pages use that instead of \"Vim\"\n# VIMRTDIR: Make sure to use \"runtime\" as by default it uses a \"vim90\" style folder which is mostly a relic.\n\nset -e\n\ncd \"${SRCROOT}\"/..\nfor x in ${(k)parameters}; do if [[ $x = *_DEPLOYMENT_TARGET ]]; then [[ $x = MACOSX_DEPLOYMENT_TARGET ]] || unset $x; fi; done\nmake --jobs=1 \\\n DESTDIR=\"${TARGET_BUILD_DIR}\" \\\n prefix= \\\n VIMNAME=vim \\\n VIMRTDIR=/runtime \\\n macvim-install-runtime\n\n# Also add man pages for \"mvim\"\nfor curdir in \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH\"/man/**/man1; do\n (cd $curdir; ln -f -s gvim.1 mvim.1)\ndone\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
90C052E1251E889500E2D81E /* Copy vimtutor */ = {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
lib,
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
runCommand,
|
||||
apple-sdk_14,
|
||||
ncurses,
|
||||
gettext,
|
||||
pkg-config,
|
||||
@@ -11,30 +11,17 @@
|
||||
tcl,
|
||||
perl,
|
||||
luajit,
|
||||
darwin,
|
||||
libiconv,
|
||||
python3,
|
||||
enablePython ? false,
|
||||
rcodesign,
|
||||
# Setting withXcodePath makes it use that instead of the system-default Xcode.
|
||||
# This can be set to one of the `darwin.xcode_*` packages as well.
|
||||
# If set, this should be a path to Xcode.app, e.g. `"/Applications/Xcode.app"`.
|
||||
withXcodePath ? null,
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib) optional optionals optionalString;
|
||||
in
|
||||
|
||||
# Try to match MacVim's documented script interface compatibility
|
||||
let
|
||||
# Ruby 3.4
|
||||
ruby = ruby_3_4;
|
||||
|
||||
# Building requires a few system tools to be in PATH.
|
||||
# Some of these we could patch into the relevant source files (such as xcodebuild and
|
||||
# qlmanage) but some are used by Xcode itself and we have no choice but to put them in PATH.
|
||||
# Symlinking them in this way is better than just putting all of /usr/bin in there.
|
||||
buildSymlinks = runCommand "macvim-build-symlinks" { } ''
|
||||
mkdir -p $out/bin
|
||||
ln -s /usr/bin/xcrun /usr/bin/xcodebuild /usr/bin/tiffutil /usr/bin/qlmanage $out/bin
|
||||
'';
|
||||
in
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
@@ -53,10 +40,12 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkg-config
|
||||
buildSymlinks
|
||||
]
|
||||
++ optional stdenv.isAarch64 rcodesign;
|
||||
];
|
||||
buildInputs = [
|
||||
# MacVim references up to MAC_OS_VERSION_14_0 in its source
|
||||
# Update this SDK if it adds APIs that use newer versions
|
||||
# (check both MAC_OS_VERSION_* and MAC_OS_X_VERSION_*)
|
||||
apple-sdk_14
|
||||
gettext
|
||||
ncurses
|
||||
cscope
|
||||
@@ -64,17 +53,52 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
ruby
|
||||
tcl
|
||||
perl
|
||||
]
|
||||
++ optional enablePython python3;
|
||||
python3
|
||||
];
|
||||
|
||||
patches = [
|
||||
./macvim.patch
|
||||
# Xcode 26.0 sets *_DEPLOYMENT_TARGET env vars for all platforms in shell script build phases.
|
||||
# This breaks invocations of clang in those phases, as they target the wrong platform.
|
||||
# Note: The shell script build phase in question uses /bin/zsh.
|
||||
# This also adds --jobs=1 to the shell script build phase invocation of `make` as running in
|
||||
# parallel is causing the gvim.1 manpage to go missing.
|
||||
./macvim-xcode26.patch
|
||||
];
|
||||
|
||||
# Fix clang version detection in configure script, it's getting tripped up
|
||||
# because the InstalledDir matches the same pattern
|
||||
postPatch = ''
|
||||
substituteInPlace src/auto/configure \
|
||||
--replace-fail /usr/bin/grep grep \
|
||||
--replace-fail '$CC --version 2>/dev/null |' '$CC --version 2>/dev/null | head -1 |'
|
||||
''
|
||||
# Remove $(VIMTARGET) from the installrtbase rule deps. MacVim already comments out the usage of
|
||||
# this executable in this rule, and for some reason Xcode is deleting it after copying it into
|
||||
# MacVim.app/Contents/MacOS/, so this is getting rebuilt unnecessarily and causing issues.
|
||||
+ ''
|
||||
substituteInPlace src/Makefile \
|
||||
--replace-fail \
|
||||
'installrtbase: $(HELPSOURCE)/vim.1 $(DEST_VIM) $(VIMTARGET) $(DEST_RT)' \
|
||||
'installrtbase: $(HELPSOURCE)/vim.1 $(DEST_VIM) $(DEST_RT)'
|
||||
''
|
||||
# Patch in the xcode path we want
|
||||
+ ''
|
||||
xcodebuildPath=${
|
||||
if withXcodePath == null then
|
||||
"$(DEVELOPER_DIR= /usr/bin/xcrun -find xcodebuild)"
|
||||
else
|
||||
lib.escapeShellArg "${withXcodePath}/Contents/Developer/usr/bin/xcodebuild"
|
||||
}
|
||||
substituteInPlace src/Makefile \
|
||||
--replace-fail xcodebuild "$xcodebuildPath"
|
||||
''
|
||||
# QuickLookStephen calls `qlmanage -r` in a shell script phase
|
||||
+ ''
|
||||
substituteInPlace src/MacVim/qlstephen/QuickLookStephen.xcodeproj/project.pbxproj \
|
||||
--replace-fail qlmanage /usr/bin/qlmanage
|
||||
'';
|
||||
|
||||
configureFlags = [
|
||||
"--enable-cscope"
|
||||
"--enable-fail-if-missing"
|
||||
@@ -82,23 +106,15 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
"--enable-gui=macvim"
|
||||
"--enable-multibyte"
|
||||
"--enable-nls"
|
||||
"--enable-luainterp=dynamic"
|
||||
]
|
||||
++ optionals enablePython [
|
||||
"--enable-python3interp=dynamic"
|
||||
]
|
||||
++ [
|
||||
"--enable-perlinterp=dynamic"
|
||||
"--enable-rubyinterp=dynamic"
|
||||
"--enable-luainterp=yes"
|
||||
"--enable-python3interp=yes"
|
||||
"--enable-perlinterp=yes"
|
||||
"--enable-rubyinterp=yes"
|
||||
"--enable-tclinterp=yes"
|
||||
"--without-local-dir"
|
||||
"--with-luajit"
|
||||
"--with-lua-prefix=${luajit}"
|
||||
]
|
||||
++ optionals enablePython [
|
||||
"--with-python3-command=${python3}/bin/python3"
|
||||
]
|
||||
++ [
|
||||
"--with-ruby-command=${ruby}/bin/ruby"
|
||||
"--with-tclsh=${tcl}/bin/tclsh"
|
||||
"--with-tlib=ncurses"
|
||||
@@ -106,75 +122,34 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
"--disable-sparkle"
|
||||
];
|
||||
|
||||
# This is unfortunate, but we need to use the same compiler as Xcode, but Xcode doesn't provide a
|
||||
# way to configure the compiler. We also need to pull in lib/include paths for some of our build
|
||||
# inputs since we don't have cc-wrapper to do that for us.
|
||||
preConfigure =
|
||||
let
|
||||
# ideally we'd recurse, but we don't need that right now
|
||||
inputs = [ ncurses ] ++ perl.propagatedBuildInputs;
|
||||
ldflags = map (drv: "-L${lib.getLib drv}/lib") inputs ++ [ "-headerpad_max_install_names" ];
|
||||
cppflags = map (drv: "-isystem ${lib.getDev drv}/include") inputs;
|
||||
in
|
||||
''
|
||||
unset DEVELOPER_DIR # Use the system Xcode not the nixpkgs SDK.
|
||||
|
||||
CC=/usr/bin/clang
|
||||
|
||||
DEV_DIR=$(/usr/bin/xcode-select -print-path)/Platforms/MacOSX.platform/Developer
|
||||
configureFlagsArray+=(
|
||||
--with-developer-dir="$DEV_DIR"
|
||||
LDFLAGS=${lib.escapeShellArg ldflags}
|
||||
CPPFLAGS=${lib.escapeShellArg cppflags}
|
||||
CFLAGS="-Wno-error=implicit-function-declaration"
|
||||
)
|
||||
''
|
||||
# For some reason having LD defined causes PSMTabBarControl to fail at link-time as it
|
||||
# passes arguments to ld that it meant for clang.
|
||||
+ ''
|
||||
unset LD
|
||||
''
|
||||
# When building with nix-daemon, we need to pass -derivedDataPath or else it tries to use
|
||||
# a folder rooted in /var/empty and fails. Unfortunately we can't just pass -derivedDataPath
|
||||
# by itself as this flag requires the use of -scheme or -xctestrun (not sure why), but MacVim
|
||||
# by default just runs `xcodebuild -project src/MacVim/MacVim.xcodeproj`, relying on the default
|
||||
# behavior to build the first target in the project. Experimentally, there seems to be a scheme
|
||||
# called MacVim, so we'll explicitly select that. We also need to specify the configuration too
|
||||
# as the scheme seems to have the wrong default.
|
||||
+ ''
|
||||
configureFlagsArray+=(
|
||||
XCODEFLAGS="-scheme MacVim -derivedDataPath $NIX_BUILD_TOP/derivedData LDFLAGS='\$(inherited) -headerpad_max_install_names' ENABLE_CODE_COVERAGE=NO"
|
||||
--with-xcodecfg="Release"
|
||||
)
|
||||
'';
|
||||
|
||||
# Because we're building with system clang, this means we're building against Xcode's SDK and
|
||||
# linking against system libraries. The configure script is picking up Nix Libsystem (via ruby)
|
||||
# so we need to patch that out or we'll get linker issues. The MacVim binary built by Xcode links
|
||||
# against the system anyway so it doesn't really matter that the Vim binary will too. If we
|
||||
# decide that matters, we can always patch it back to the Nix libsystem post-build.
|
||||
# It also picks up libiconv, libunwind, and objc4 from Nix. These seem relatively harmless but
|
||||
# let's strip them out too.
|
||||
#
|
||||
# Note: If we do add a post-build install_name_tool patch, we need to add the
|
||||
# "LDFLAGS=-headerpad_max_install_names" flag to configureFlags and either patch it into the
|
||||
# Xcode project or pass it as a flag to xcodebuild as well.
|
||||
postConfigure = ''
|
||||
substituteInPlace src/auto/config.mk \
|
||||
--replace-warn " -L${stdenv.cc.libc}/lib" "" \
|
||||
--replace-warn " -L${darwin.libunwind}/lib" "" \
|
||||
--replace-warn " -L${libiconv}/lib" ""
|
||||
|
||||
# All the libraries we stripped have -osx- in their name as of this time.
|
||||
# Assert now that this pattern no longer appears in config.mk.
|
||||
( # scope variable
|
||||
while IFS="" read -r line; do
|
||||
if [[ "$line" == LDFLAGS*-osx-* ]]; then
|
||||
echo "WARNING: src/auto/config.mk contains reference to Nix osx library" >&2
|
||||
fi
|
||||
done <src/auto/config.mk
|
||||
preConfigure = ''
|
||||
configureFlagsArray+=(
|
||||
--with-developer-dir="$DEVELOPER_DIR"
|
||||
CFLAGS="-Wno-error=implicit-function-declaration"
|
||||
)
|
||||
''
|
||||
# Having `$LD` set causes Xcode to invoke `ld` instead of `clang` as the linker, but it still
|
||||
# passes flags intended for clang.
|
||||
+ ''
|
||||
unset LD
|
||||
''
|
||||
# When building with nix-daemon, we need to pass -derivedDataPath or else it tries to use
|
||||
# a folder rooted in /var/empty and fails. Unfortunately we can't just pass -derivedDataPath
|
||||
# by itself as this flag requires the use of -scheme or -xctestrun (not sure why), but MacVim
|
||||
# by default just runs `xcodebuild -project src/MacVim/MacVim.xcodeproj`, relying on the default
|
||||
# behavior to build the first target in the project. Experimentally, there seems to be a scheme
|
||||
# called MacVim, so we'll explicitly select that. We also need to specify the configuration too
|
||||
# as the scheme seems to have the wrong default.
|
||||
# Passing ENABLE_CODE_COVERAGE=NO because it's defaulting on for some reason.
|
||||
# Passing ONLY_ACTIVE_ARCH=YES because QuickLookStephen.xcodeproj is building Universal by default.
|
||||
+ ''
|
||||
configureFlagsArray+=(
|
||||
XCODEFLAGS="-scheme MacVim -derivedDataPath $NIX_BUILD_TOP/derivedData ENABLE_CODE_COVERAGE=NO ONLY_ACTIVE_ARCH=YES"
|
||||
--with-xcodecfg="Release"
|
||||
)
|
||||
'';
|
||||
|
||||
postConfigure = ''
|
||||
substituteInPlace src/MacVim/vimrc --subst-var-by CSCOPE ${cscope}/bin/cscope
|
||||
'';
|
||||
|
||||
@@ -198,28 +173,15 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
mkdir -p $out/share
|
||||
ln -s $out/Applications/MacVim.app/Contents/man $out/share/man
|
||||
|
||||
# Fix rpaths
|
||||
exe="$out/Applications/MacVim.app/Contents/MacOS/Vim"
|
||||
libperl=$(dirname $(find ${perl} -name "libperl.dylib"))
|
||||
install_name_tool -add_rpath ${luajit}/lib $exe
|
||||
install_name_tool -add_rpath ${tcl}/lib $exe
|
||||
''
|
||||
+ optionalString enablePython ''
|
||||
install_name_tool -add_rpath ${python3}/lib $exe
|
||||
''
|
||||
+ ''
|
||||
install_name_tool -add_rpath $libperl $exe
|
||||
install_name_tool -add_rpath ${ruby}/lib $exe
|
||||
|
||||
# Remove manpages from tools we aren't providing
|
||||
find $out/Applications/MacVim.app/Contents/man \( -name evim.1 -or -name eview.1 \) -delete
|
||||
rm $out/Applications/MacVim.app/Contents/man/man1/mvim.1
|
||||
''
|
||||
+ optionalString stdenv.isAarch64 ''
|
||||
# Resign the binary and set the linker-signed flag.
|
||||
rcodesign sign --code-signature-flags linker-signed $exe
|
||||
'';
|
||||
|
||||
# macvim obj-c log macro triggers -Wformat-security (seems like a bug? it's a string literal!)
|
||||
hardeningDisable = [ "format" ];
|
||||
# os_log also enables -Werror,-Wformat by default
|
||||
env.NIX_CFLAGS_COMPILE = "-DOS_LOG_FORMAT_WARNINGS";
|
||||
|
||||
# We rely on the user's Xcode install to build. It may be located in an arbitrary place, and
|
||||
# it's not clear what system-level components it may require, so for now we'll just allow full
|
||||
# filesystem access. This way the package still can't access the network.
|
||||
|
||||
@@ -50,19 +50,6 @@ index 162af04..4322049 100644
|
||||
+set cscopeprg=@CSCOPE@
|
||||
|
||||
" vim: sw=2 ts=2 et
|
||||
diff --git a/src/Makefile b/src/Makefile
|
||||
index d89756f..184354d 100644
|
||||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -1293,7 +1293,7 @@ MACVIMGUI_SRC = gui.c gui_beval.c MacVim/gui_macvim.m MacVim/MMBackend.m \
|
||||
MacVim/MacVim.m
|
||||
MACVIMGUI_OBJ = objects/gui.o objects/gui_beval.o \
|
||||
objects/gui_macvim.o objects/MMBackend.o objects/MacVim.o
|
||||
-MACVIMGUI_DEFS = -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe
|
||||
+MACVIMGUI_DEFS = -DMACOS_X_DARWIN -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe
|
||||
MACVIMGUI_IPATH =
|
||||
MACVIMGUI_LIBS_DIR =
|
||||
MACVIMGUI_LIBS1 =
|
||||
diff --git a/src/auto/configure b/src/auto/configure
|
||||
index d4ead96..299988f 100755
|
||||
--- a/src/auto/configure
|
||||
@@ -177,25 +164,3 @@ index d4ead96..299988f 100755
|
||||
fi
|
||||
|
||||
if test "X$librubyarg" != "X"; then
|
||||
diff --git a/src/vim.h b/src/vim.h
|
||||
index feaa685..fe34d99 100644
|
||||
--- a/src/vim.h
|
||||
+++ b/src/vim.h
|
||||
@@ -277,17 +277,6 @@
|
||||
# define SUN_SYSTEM
|
||||
#endif
|
||||
|
||||
-// If we're compiling in C++ (currently only KVim), the system
|
||||
-// headers must have the correct prototypes or nothing will build.
|
||||
-// Conversely, our prototypes might clash due to throw() specifiers and
|
||||
-// cause compilation failures even though the headers are correct. For
|
||||
-// a concrete example, gcc-3.2 enforces exception specifications, and
|
||||
-// glibc-2.2.5 has them in their system headers.
|
||||
-#if !defined(__cplusplus) && defined(UNIX) \
|
||||
- && !defined(MACOS_X) // MACOS_X doesn't yet support osdef.h
|
||||
-# include "auto/osdef.h" // bring missing declarations in
|
||||
-#endif
|
||||
-
|
||||
#ifdef AMIGA
|
||||
# include "os_amiga.h"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user