-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #234 from minijackson/epicsSetupHook
Switch to setup-hook based EPICS builds
- Loading branch information
Showing
7 changed files
with
208 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
makeSetupHook, | ||
stdenv, | ||
epnixLib, | ||
}: | ||
makeSetupHook { | ||
name = "epics-setup-hook"; | ||
|
||
substitutions = { | ||
# Note that since the setup hook is going into 'nativeBuildInputs', | ||
# the platforms are "shifted", | ||
# which means from the point of view of the setup hook, | ||
# the host platform is the end package's build platform, | ||
# and the target platform is the end package's host platform. | ||
|
||
# "build" as in Nix terminology (the build machine) | ||
build_arch = epnixLib.toEpicsArch stdenv.hostPlatform; | ||
# "host" as in Nix terminology (the machine which will run the generated code) | ||
host_arch = epnixLib.toEpicsArch stdenv.targetPlatform; | ||
}; | ||
|
||
meta = { | ||
description = "Instructions for building EPICS tops"; | ||
maintainers = with epnixLib.maintainers; [minijackson]; | ||
hidden = true; | ||
}; | ||
} | ||
./epics-setup-hook.sh |
114 changes: 114 additions & 0 deletions
114
pkgs/build-support/epics-setup-hook/epics-setup-hook.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
epicsConfigurePhase() { | ||
runHook preConfigure | ||
|
||
if ! [[ -v enableParallelBuilding ]]; then | ||
enableParallelBuilding=1 | ||
fi | ||
|
||
appendToVar makeFlags "INSTALL_LOCATION=$out" | ||
|
||
stripDebugList+=("bin/@host_arch@" "lib/@host_arch@") | ||
|
||
# Ensure reproducibility when running Perl scripts that generate files, | ||
# during the build. | ||
export PERL_HASH_SEED=0 | ||
|
||
# This variable is used as a default version revision if no VCS is found. | ||
# | ||
# Since fetchgit and related fetchers remove the .git directory for | ||
# reproducibility, EPICS fallsback to either the GENVERSIONDEFAULT variable | ||
# if set (not the default), or the current date/time, which isn't | ||
# reproducible. | ||
echo 'GENVERSIONDEFAULT="EPNix"' >configure/CONFIG_SITE.local | ||
|
||
# This prevents EPICS from detecting installed libraries on the host | ||
# system, for when Nix is compiling without sandbox (e.g.: WSL2) | ||
echo 'GNU_DIR="/var/empty"' >>configure/CONFIG_SITE.local | ||
|
||
if [[ "@build_arch@" != "@host_arch@" ]]; then | ||
stripDebugList+=("bin/@build_arch@" "lib/@build_arch@") | ||
|
||
# Tell EPICS we are compiling to the given architecture. | ||
# "host" as in Nix terminology (the machine which will run the generated code) | ||
echo 'CROSS_COMPILER_TARGET_ARCHS="@host_arch@"' >>configure/CONFIG_SITE.local | ||
fi | ||
|
||
echo "${local_config_site-}" >>configure/CONFIG_SITE.local | ||
|
||
# Undefine the SUPPORT variable here, since there is no single "support" | ||
# directory and this variable is a source of conflicts between RELEASE files | ||
echo "undefine SUPPORT" >configure/RELEASE.local | ||
|
||
echo "${local_release-}" >>configure/RELEASE.local | ||
|
||
# set to empty if unset | ||
: "''${EPICS_COMPONENTS=}" | ||
|
||
# For each EPICS-specific package (e.g. asyn, StreamDevice), | ||
# add it to the 'configure/RELEASE.local' file | ||
IFS=: read -ra components <<<"$EPICS_COMPONENTS" | ||
for component in "${components[@]}"; do | ||
echo "$component" >>configure/RELEASE.local | ||
done | ||
|
||
echo "==============================" | ||
echo "CONFIG_SITE.local" | ||
echo "------------------------------" | ||
cat "configure/CONFIG_SITE.local" | ||
echo "==============================" | ||
echo "RELEASE.local" | ||
echo "------------------------------" | ||
cat "configure/RELEASE.local" | ||
echo "------------------------------" | ||
|
||
runHook postConfigure | ||
} | ||
|
||
if [ -z "${dontUseEpicsConfigure-}" ] && [ -z "${configurePhase-}" ]; then | ||
configurePhase=epicsConfigurePhase | ||
fi | ||
|
||
epicsInstallPhase() { | ||
runHook preInstall | ||
|
||
# Don't do a manual `make install`, `make` already installs | ||
# everything into `INSTALL_LOCATION`. | ||
|
||
runHook postInstall | ||
} | ||
|
||
if [ -z "${dontUseEpicsInstall-}" ] && [ -z "${installPhase-}" ]; then | ||
installPhase=epicsInstallPhase | ||
fi | ||
|
||
# Automatically create binaries directly in `bin/` that calls the ones that | ||
# are in `bin/linux-x86_64/` | ||
# TODO: we should probably do the same for libraries | ||
epicsInstallProgramsHook() { | ||
echo "Installing programs in 'bin/@host_arch@' to 'bin'..." | ||
if [[ -d "$out/bin/@host_arch@" ]]; then | ||
for file in "$out/bin/@host_arch@/"*; do | ||
[[ -x "$file" ]] || continue | ||
|
||
echo "Installing program '$(basename "$file")' to 'bin'" | ||
makeWrapper "$file" "$out/bin/$(basename "$file")" | ||
done | ||
fi | ||
} | ||
|
||
if [ -z "${dontInstallPrograms-}" ]; then | ||
postInstallHooks+=(epicsInstallProgramsHook) | ||
fi | ||
|
||
epicsInstallIocBootHook() { | ||
if [[ -d iocBoot ]]; then | ||
echo "Installing 'iocBoot' folder..." | ||
cp -rafv iocBoot -t "$out" | ||
else | ||
echo "No 'iocBoot' folder found, skipping" | ||
fi | ||
} | ||
|
||
if [ -z "${dontInstallIocBoot-}" ]; then | ||
postInstallHooks+=(epicsInstallIocBootHook) | ||
fi |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
stdenv, | ||
lib, | ||
makeWrapper, | ||
perl, | ||
epnix, | ||
buildPackages, | ||
readline, | ||
... | ||
}: { | ||
pname, | ||
varname, | ||
local_config_site ? {}, | ||
local_release ? {}, | ||
isEpicsBase ? false, | ||
depsBuildBuild ? [], | ||
nativeBuildInputs ? [], | ||
buildInputs ? [], | ||
... | ||
} @ attrs: let | ||
# remove non standard attributes that cannot be coerced to strings | ||
overridable = builtins.removeAttrs attrs ["local_config_site" "local_release"]; | ||
generateConf = (buildPackages.epnixLib.formats.make {}).generate; | ||
in | ||
stdenv.mkDerivation (overridable | ||
// { | ||
strictDeps = true; | ||
|
||
# When cross-compiling, | ||
# epics will build every project twice, | ||
# once "build -> build", and once "build -> host", | ||
# so we need a compiler for the "build -> build" compilation. | ||
depsBuildBuild = depsBuildBuild ++ [buildPackages.stdenv.cc]; | ||
|
||
nativeBuildInputs = | ||
nativeBuildInputs | ||
++ [ | ||
makeWrapper | ||
perl | ||
readline | ||
epnix.epicsSetupHook | ||
]; | ||
|
||
# Also add perl into the non-native build inputs | ||
# so that shebangs gets patched | ||
buildInputs = | ||
buildInputs | ||
++ [perl readline] | ||
++ (lib.optional (!isEpicsBase) epnix.epics-base); | ||
|
||
setupHook = ./setup-hook.sh; | ||
|
||
local_config_site = generateConf local_config_site; | ||
local_release = generateConf local_release; | ||
|
||
doCheck = attrs.doCheck or true; | ||
checkTarget = "runtests"; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Export this package in a EPNix specific "EPICS_COMPONENTS" environment variable, | ||
# so that we are able to list every EPICS-specific packages, | ||
# to add them in the 'configure/RELEASE.local' file | ||
# in dependent packages. | ||
export "EPICS_COMPONENTS=${EPICS_COMPONENTS:+${EPICS_COMPONENTS}:}@varname@=@out@" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters