-
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.
pkgs/epicsSetupHook: init to specify EPICS build instructions
This uses the setup hook system, which is mostly bash, which should be easier to understand.
- Loading branch information
1 parent
4c6be40
commit e86d78f
Showing
3 changed files
with
144 additions
and
0 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 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