co-authored by
Colin
parent
3297bf3ba6
commit
b0fcfa88cf
@@ -46,6 +46,10 @@
|
||||
|
||||
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
|
||||
|
||||
- `hareHook` has been added as the language framework for Hare. From now on, it,
|
||||
not the `hare` package, should be added to `nativeBuildInputs` when building
|
||||
Hare programs.
|
||||
|
||||
- To facilitate dependency injection, the `imgui` package now builds a static archive using vcpkg' CMake rules.
|
||||
The derivation now installs "impl" headers selectively instead of by a wildcard.
|
||||
Use `imgui.src` if you just want to access the unpacked sources.
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
{
|
||||
hare,
|
||||
lib,
|
||||
makeSetupHook,
|
||||
makeWrapper,
|
||||
runCommand,
|
||||
stdenv,
|
||||
writeShellApplication,
|
||||
}:
|
||||
let
|
||||
arch = stdenv.targetPlatform.uname.processor;
|
||||
harePropagationInputs = builtins.attrValues { inherit (hare) harec qbe; };
|
||||
hareWrappedScript = writeShellApplication {
|
||||
# `name` MUST be `hare`, since its role is to replace the hare binary.
|
||||
name = "hare";
|
||||
runtimeInputs = [ hare ];
|
||||
excludeShellChecks = [ "SC2086" ];
|
||||
# ''${cmd:+"$cmd"} is used on the default case to keep the same behavior as
|
||||
# the hare binary: If "$cmd" is passed directly and it's empty, the hare
|
||||
# binary will treat it as an unrecognized command.
|
||||
text = ''
|
||||
readonly cmd="$1"
|
||||
shift
|
||||
case "$cmd" in
|
||||
"test"|"run"|"build") exec hare "$cmd" $NIX_HAREFLAGS "$@" ;;
|
||||
*) exec hare ''${cmd:+"$cmd"} "$@"
|
||||
esac
|
||||
'';
|
||||
};
|
||||
hareWrapper = runCommand "hare-wrapper" { nativeBuildInputs = [ makeWrapper ]; } ''
|
||||
mkdir -p $out/bin
|
||||
install ${lib.getExe hareWrappedScript} $out/bin/hare
|
||||
makeWrapper ${lib.getExe hare} $out/bin/hare-native \
|
||||
--inherit-argv0 \
|
||||
--unset AR \
|
||||
--unset LD \
|
||||
--unset CC
|
||||
'';
|
||||
in
|
||||
makeSetupHook {
|
||||
name = "hare-hook";
|
||||
# The propagation of `qbe` and `harec` (harePropagationInputs) is needed for
|
||||
# build frameworks like `haredo`, which set the HAREC and QBE env vars to
|
||||
# `harec` and `qbe` respectively. We use the derivations from the `hare`
|
||||
# package to assure that there's no different behavior between the `hareHook`
|
||||
# and `hare` packages.
|
||||
propagatedBuildInputs = [ hareWrapper ] ++ harePropagationInputs;
|
||||
substitutions = {
|
||||
hare_unconditional_flags = "-q -a${arch}";
|
||||
hare_stdlib = "${hare}/src/hare/stdlib";
|
||||
};
|
||||
meta = {
|
||||
description = "A setup hook for the Hare compiler";
|
||||
inherit (hare.meta) badPlatforms platforms;
|
||||
};
|
||||
} ./setup-hook.sh
|
||||
@@ -130,13 +130,6 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
scdoc
|
||||
];
|
||||
|
||||
# Needed for build frameworks like `haredo`, which set the HAREC and QBE env vars to `harec` and
|
||||
# `qbe` respectively.
|
||||
propagatedBuildInputs = [
|
||||
harec
|
||||
qbe
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
harec
|
||||
qbe
|
||||
@@ -171,8 +164,6 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
ln -s configs/${platform}.mk config.mk
|
||||
'';
|
||||
|
||||
setupHook = ./setup-hook.sh;
|
||||
|
||||
passthru = {
|
||||
updateScript = gitUpdater { };
|
||||
tests =
|
||||
@@ -182,6 +173,8 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
// lib.optionalAttrs (stdenv.buildPlatform.canExecute stdenv.hostPlatform) {
|
||||
mimeModule = callPackage ./mime-module-test.nix { hare = finalAttrs.finalPackage; };
|
||||
};
|
||||
# To be propagated by `hareHook`.
|
||||
inherit harec qbe;
|
||||
};
|
||||
|
||||
meta = {
|
||||
|
||||
@@ -1,9 +1,36 @@
|
||||
addHarepath () {
|
||||
for haredir in third-party stdlib; do
|
||||
if [[ -d "$1/src/hare/$haredir" ]]; then
|
||||
addToSearchPath HAREPATH "$1/src/hare/$haredir"
|
||||
fi
|
||||
done
|
||||
# shellcheck disable=SC2154,SC2034,SC2016
|
||||
|
||||
addHarepath() {
|
||||
local -r thirdparty="${1-}/src/hare/third-party"
|
||||
if [[ -d "$thirdparty" ]]; then
|
||||
addToSearchPath HAREPATH "$thirdparty"
|
||||
fi
|
||||
}
|
||||
|
||||
# Hare's stdlib should come after its third party libs, since the latter may
|
||||
# expand or shadow the former.
|
||||
readonly hareSetStdlibPhase='
|
||||
addToSearchPath HAREPATH "@hare_stdlib@"
|
||||
'
|
||||
readonly hareInfoPhase='
|
||||
echoCmd "HARECACHE" "$HARECACHE"
|
||||
echoCmd "HAREPATH" "$HAREPATH"
|
||||
echoCmd "hare" "$(command -v hare)"
|
||||
echoCmd "hare-native" "$(command -v hare-native)"
|
||||
'
|
||||
prePhases+=("hareSetStdlibPhase" "hareInfoPhase")
|
||||
|
||||
readonly hare_unconditional_flags="@hare_unconditional_flags@"
|
||||
case "${hareBuildType:-"release"}" in
|
||||
"release") export NIX_HAREFLAGS="-R $hare_unconditional_flags" ;;
|
||||
"debug") export NIX_HAREFLAGS="$hare_unconditional_flags" ;;
|
||||
*)
|
||||
printf -- 'Invalid hareBuildType: "%s"\n' "${hareBuildType-}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
HARECACHE="$(mktemp -d)"
|
||||
export HARECACHE
|
||||
|
||||
addEnvHooks "$hostOffset" addHarepath
|
||||
|
||||
@@ -25196,6 +25196,10 @@ with pkgs;
|
||||
|
||||
leaps = callPackage ../development/tools/leaps { };
|
||||
|
||||
### DEVELOPMENT / HARE
|
||||
|
||||
hareHook = callPackage ../by-name/ha/hare/hook.nix { };
|
||||
|
||||
### DEVELOPMENT / JAVA MODULES
|
||||
|
||||
javaPackages = recurseIntoAttrs (callPackage ./java-packages.nix { });
|
||||
|
||||
Reference in New Issue
Block a user