darwin.bootstrap_cmds: convert to Meson and use mkAppleDerivation
This commit is contained in:
parent
94b14746e0
commit
c5c276b6cb
@ -1,43 +0,0 @@
|
||||
{ lib, appleDerivation, stdenv, bison, flex }:
|
||||
|
||||
let
|
||||
|
||||
# Hard to get CC to pull this off without infinite recursion
|
||||
targetTargetPrefix = lib.optionalString
|
||||
(with stdenv; hostPlatform != targetPlatform)
|
||||
(stdenv.targetPlatform.config + "-");
|
||||
|
||||
in
|
||||
|
||||
appleDerivation {
|
||||
nativeBuildInputs = [ bison flex ];
|
||||
|
||||
buildPhase = ''
|
||||
cd migcom.tproj
|
||||
|
||||
# redundant file, don't know why apple not removing it.
|
||||
rm handler.c
|
||||
|
||||
yacc -d parser.y
|
||||
flex --header-file=lexxer.yy.h -o lexxer.yy.c lexxer.l
|
||||
|
||||
$CC -std=gnu99 -Os -dead_strip -DMIG_VERSION=\"$pname-$version\" -I. -o migcom *.c
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin $out/libexec $out/share/man/man1
|
||||
|
||||
chmod +x mig.sh
|
||||
cp mig.sh $out/bin/mig
|
||||
cp migcom $out/libexec
|
||||
ln -s $out/libexec/migcom $out/bin/migcom
|
||||
cp mig.1 $out/share/man/man1
|
||||
cp migcom.1 $out/share/man/man1
|
||||
|
||||
substituteInPlace $out/bin/mig \
|
||||
--replace 'arch=`/usr/bin/arch`' 'arch=${stdenv.targetPlatform.darwinArch}' \
|
||||
--replace '/usr/bin/' "" \
|
||||
--replace '/bin/rmdir' "rmdir" \
|
||||
--replace 'C=''${MIGCC}' "C=${targetTargetPrefix}cc"
|
||||
'';
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
# Build settings based on the upstream Xcode project.
|
||||
# See: https://github.com/apple-oss-distributions/bootstrap_cmds/blob/main/mig.xcodeproj/project.pbxproj
|
||||
|
||||
# Project settings
|
||||
project('bootstrap_cmds', 'c', version : '@version@')
|
||||
|
||||
|
||||
# Dependencies
|
||||
cc = meson.get_compiler('c')
|
||||
|
||||
|
||||
# Generators
|
||||
bison_bin = find_program('bison', required : true)
|
||||
flex_bin = find_program('flex', required : true)
|
||||
|
||||
bison = generator(
|
||||
bison_bin,
|
||||
arguments : ['@INPUT@', '--header=@OUTPUT0@', '--output=@OUTPUT1@'],
|
||||
output : [ '@BASENAME@.tab.h', '@BASENAME@.tab.c'],
|
||||
)
|
||||
|
||||
flex = generator(
|
||||
flex_bin,
|
||||
arguments : ['--header-file=@OUTPUT0@', '--outfile=@OUTPUT1@', '@INPUT@'],
|
||||
output : ['@BASENAME@.yy.h', '@BASENAME@.yy.c'],
|
||||
)
|
||||
|
||||
|
||||
# Binaries
|
||||
executable(
|
||||
'migcom',
|
||||
c_args: ['-DMIG_VERSION="migcom-@version@"'],
|
||||
include_directories : 'migcom.tproj',
|
||||
install : true,
|
||||
install_dir : get_option('libexecdir'),
|
||||
sources : [
|
||||
'migcom.tproj/error.c',
|
||||
'migcom.tproj/global.c',
|
||||
# Redundant file that’s not actually used. Trying to compile it results in compile errors.
|
||||
# 'migcom.tproj/handler.c',
|
||||
'migcom.tproj/header.c',
|
||||
'migcom.tproj/mig.c',
|
||||
'migcom.tproj/routine.c',
|
||||
'migcom.tproj/server.c',
|
||||
'migcom.tproj/statement.c',
|
||||
'migcom.tproj/string.c',
|
||||
'migcom.tproj/type.c',
|
||||
'migcom.tproj/user.c',
|
||||
'migcom.tproj/utils.c',
|
||||
bison.process('migcom.tproj/parser.y'),
|
||||
flex.process('migcom.tproj/lexxer.l'),
|
||||
],
|
||||
)
|
||||
install_data(
|
||||
'migcom.tproj/mig.sh',
|
||||
install_dir : get_option('bindir'),
|
||||
)
|
||||
install_man(
|
||||
'migcom.tproj/mig.1',
|
||||
'migcom.tproj/migcom.1',
|
||||
)
|
@ -0,0 +1,84 @@
|
||||
{
|
||||
lib,
|
||||
apple-sdk,
|
||||
apple-sdk_12,
|
||||
bison,
|
||||
buildPackages,
|
||||
flex,
|
||||
meson,
|
||||
mkAppleDerivation,
|
||||
replaceVars,
|
||||
stdenv,
|
||||
stdenvNoCC,
|
||||
}:
|
||||
|
||||
let
|
||||
Libc = apple-sdk.sourceRelease "Libc";
|
||||
|
||||
# Older versions of xnu are missing required headers. The one for the 11.3 SDK doesn’t define a needed function
|
||||
# that was added in 11.3. This version of xnu has everything that’s needed.
|
||||
xnu = apple-sdk_12.sourceRelease "xnu";
|
||||
|
||||
privateHeaders = stdenvNoCC.mkDerivation {
|
||||
name = "adv_cmds-deps-private-headers";
|
||||
|
||||
buildCommand = ''
|
||||
install -D -t "$out/include/os" \
|
||||
'${Libc}/os/assumes.h' \
|
||||
'${xnu}/libkern/os/base_private.h'
|
||||
'';
|
||||
};
|
||||
|
||||
# bootstrap_cmds is used to build libkrb5, which is a transitive dependency of Meson due to OpenLDAP.
|
||||
# This causes an infinite recursion unless Meson’s tests are disabled.
|
||||
mkAppleDerivation' = mkAppleDerivation.override {
|
||||
meson = meson.overrideAttrs { doInstallCheck = false; };
|
||||
};
|
||||
in
|
||||
mkAppleDerivation' {
|
||||
releaseName = "bootstrap_cmds";
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"man"
|
||||
];
|
||||
|
||||
xcodeHash = "sha256-N28WLkFo8fXiQqqpmRmOBE3BzqXHIy94fhZIxEkmOw4=";
|
||||
xcodeProject = "mig.xcodeproj";
|
||||
|
||||
patches = [
|
||||
# Make sure that `mig` in nixpkgs uses the correct clang
|
||||
(replaceVars ./patches/0001-Specify-MIGCC-for-use-with-substitute.patch {
|
||||
clang = "${lib.getBin buildPackages.targetPackages.clang}/bin/${buildPackages.targetPackages.clang.targetPrefix}clang";
|
||||
})
|
||||
# `mig` by default only removes the working directory at the end of the script.
|
||||
# If an error happens, it is left behind. Always clean it up.
|
||||
./patches/0002-Always-remove-working-directory.patch
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
# Fix the name to something Meson will like.
|
||||
substituteInPlace migcom.tproj/lexxer.l \
|
||||
--replace-fail 'y.tab.h' 'parser.tab.h'
|
||||
'';
|
||||
|
||||
env.NIX_CFLAGS_COMPILE = "-I${privateHeaders}/include";
|
||||
|
||||
nativeBuildInputs = [
|
||||
bison
|
||||
flex
|
||||
];
|
||||
|
||||
postInstall = ''
|
||||
mv "$out/bin/mig.sh" "$out/bin/mig"
|
||||
chmod a+x "$out/bin/mig"
|
||||
patchShebangs --build "$out/bin/mig"
|
||||
|
||||
substituteInPlace "$out/bin/mig" \
|
||||
--replace-fail 'arch=`/usr/bin/arch`' 'arch=${stdenv.targetPlatform.darwinArch}' \
|
||||
--replace-fail '/usr/bin/mktemp' '${lib.getBin buildPackages.coreutils}/bin/mktemp' \
|
||||
--replace-fail '/usr/bin/xcrun' '${buildPackages.xcbuild.xcrun}/bin/xcrun'
|
||||
'';
|
||||
|
||||
meta.description = "Contains mig command for generating headers from definitions";
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
diff --git a/migcom.tproj/mig.sh b/migcom.tproj/mig.sh
|
||||
index 3f6b0b544a..f91f1a0112 100644
|
||||
--- a/migcom.tproj/mig.sh
|
||||
+++ b/migcom.tproj/mig.sh
|
||||
@@ -47,6 +47,8 @@
|
||||
# the rights to redistribute these changes.
|
||||
#
|
||||
|
||||
+MIGCC=@clang@
|
||||
+
|
||||
realpath()
|
||||
{
|
||||
local FILE="$1"
|
@ -0,0 +1,19 @@
|
||||
diff --git a/migcom.tproj/mig.sh b/migcom.tproj/mig.sh
|
||||
index f91f1a0112..191eee0461 100644
|
||||
--- a/migcom.tproj/mig.sh
|
||||
+++ b/migcom.tproj/mig.sh
|
||||
@@ -101,6 +101,7 @@
|
||||
echo "Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
+trap 'rm -rf -- "$WORKTMP"' EXIT
|
||||
|
||||
# parse out the arguments until we hit plain file name(s)
|
||||
|
||||
@@ -232,6 +233,5 @@
|
||||
rm -f "${temp}.c"
|
||||
done
|
||||
|
||||
-/bin/rmdir "${WORKTMP}"
|
||||
exit 0
|
||||
|
@ -16,7 +16,7 @@ Security = applePackage' "Security" "59754.41.1" "macos-11.0.1" "0jq70mnwkvrrhws
|
||||
adv_cmds = applePackage' "adv_cmds" "176" "macos-11.0.1" "0sskwl3jc7llbrlyd1i7qlb03yhm1xkbxd1k9xhh7f9wqhlzq31j" {};
|
||||
architecture = applePackage' "architecture" "279" "macos-11.0.1" "19s93rqr9r98qh0rlndf7kv3v4n1ifh9i539mbpsx6kbixcx8vvp" {};
|
||||
basic_cmds = applePackage' "basic_cmds" "55" "macos-11.0.1" "1913pzk376zfap2fwmrb233rkn4h4l2c65nd7s8ixvrz1r7cz0q5" {};
|
||||
bootstrap_cmds = applePackage' "bootstrap_cmds" "121" "macos-11.0.1" "0qgbgwijv7xqmm9gn74jibyw2dh516xpj7h1grj2j1i80m3b16bl" {};
|
||||
bootstrap_cmds = callPackage ./bootstrap_cmds/package.nix { };
|
||||
configd = applePackage' "configd" "1109.40.9" "macos-11.0.1" "024ny63lpwzgnm8g28hh8dldvmmislmrl298n721rm0blqjhahz5" {};
|
||||
copyfile = applePackage' "copyfile" "173.40.2" "macos-11.0.1" "1j20909inn2iw8n51b8vk551wznfi3bhfziy8nbv08qj5lk50m04" {};
|
||||
diskdev_cmds = applePackage' "diskdev_cmds" "667.40.1" "macos-11.0.1" "0wr60vyvgkbc4wyldnsqas0xss2k1fgmbdk3vnhj6v6jqa98l1ny" {};
|
||||
|
@ -10,5 +10,9 @@
|
||||
"basic_cmds": {
|
||||
"hash": "sha256-BYPPTg4/7x6RPs0WwwQlkNiZxxArV+7EVe6bM+a/I6Q=",
|
||||
"version": "55"
|
||||
},
|
||||
"bootstrap_cmds": {
|
||||
"hash": "sha256-dJmwRgUoBilkfgEeebsJBTbB/YqSHPtSrbifLSN/62E=",
|
||||
"version": "121"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user