Streamline status-go Nix expressions
Signed-off-by: Pedro Pombeiro <pombeirp@users.noreply.github.com>
This commit is contained in:
parent
69b9847c5f
commit
a753be4ab9
|
@ -2,6 +2,8 @@
|
|||
{ buildGoPackage, go, xcodeWrapper, pkgs, stdenv }:
|
||||
|
||||
{ owner, repo, rev, version, goPackagePath, src, host,
|
||||
|
||||
# desktop-only arguments
|
||||
goBuildFlags, goBuildLdFlags,
|
||||
outputFileName,
|
||||
hostSystem } @ args':
|
||||
|
@ -9,36 +11,24 @@
|
|||
with stdenv;
|
||||
|
||||
let
|
||||
args = removeAttrs args' [ "goBuildFlags" "goBuildLdFlags" "outputFileName" "hostSystem" ];
|
||||
buildStatusGo = pkgs.callPackage ./build-status-go.nix { inherit buildGoPackage go xcodeWrapper; };
|
||||
|
||||
args = removeAttrs args' [ "goBuildFlags" "goBuildLdFlags" "outputFileName" "hostSystem" ]; # Remove desktop-only arguments from args
|
||||
buildStatusGoDesktopLib = buildStatusGo (args // {
|
||||
buildMessage = "Building desktop library";
|
||||
#GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build ${goBuildFlags} -buildmode=c-archive -o $out/${outputFileName} ./lib
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
runHook renameImports
|
||||
|
||||
pushd "$NIX_BUILD_TOP/go/src/${goPackagePath}" >/dev/null
|
||||
|
||||
echo
|
||||
echo "Building desktop library"
|
||||
echo
|
||||
#GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build ${goBuildFlags} -buildmode=c-archive -o $out/${outputFileName} ./lib
|
||||
go build -o $out/${outputFileName} ${goBuildFlags} -buildmode=c-archive ${goBuildLdFlags} ./lib
|
||||
|
||||
popd >/dev/null
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/lib/${hostSystem} $out/include
|
||||
mv $out/${outputFileName} $out/lib/${hostSystem}
|
||||
mv $out/libstatus.h $out/include
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
outputs = [ "out" ];
|
||||
|
|
|
@ -2,29 +2,25 @@
|
|||
{ buildGoPackage, go, gomobile, openjdk, xcodeWrapper, pkgs, stdenv }:
|
||||
|
||||
{ owner, repo, rev, version, goPackagePath, src, host,
|
||||
|
||||
# mobile-only arguments
|
||||
goBuildFlags, goBuildLdFlags,
|
||||
config } @ args':
|
||||
|
||||
with stdenv;
|
||||
|
||||
let
|
||||
args = removeAttrs args' [ "config" "goBuildFlags" "goBuildLdFlags" ];
|
||||
targetConfig = config;
|
||||
buildStatusGo = pkgs.callPackage ./build-status-go.nix { inherit buildGoPackage go xcodeWrapper; };
|
||||
|
||||
args = removeAttrs args' [ "config" "goBuildFlags" "goBuildLdFlags" ]; # Remove mobile-only arguments from args
|
||||
buildStatusGoMobileLib = buildStatusGo (args // {
|
||||
nativeBuildInputs = [ gomobile ] ++ lib.optional (targetConfig.name == "android") openjdk;
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
runHook renameImports
|
||||
|
||||
buildMessage = "Building mobile library for ${targetConfig.name}";
|
||||
# Build mobile libraries
|
||||
# TODO: Manage to pass -s -w to -ldflags. Seems to only accept a single flag
|
||||
echo
|
||||
echo "Building mobile library for ${targetConfig.name}"
|
||||
echo
|
||||
buildPhase = ''
|
||||
GOPATH=${gomobile.dev}:$GOPATH \
|
||||
PATH=${lib.makeBinPath [ gomobile.bin ]}:$PATH \
|
||||
${lib.concatStringsSep " " targetConfig.envVars} \
|
||||
|
@ -32,17 +28,11 @@ let
|
|||
-o ${targetConfig.outputFileName} \
|
||||
${goBuildLdFlags} \
|
||||
${goPackagePath}/mobile
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/lib
|
||||
mv ${targetConfig.outputFileName} $out/lib/
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
outputs = [ "out" ];
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
{ owner, repo, rev, version, goPackagePath, src, host,
|
||||
nativeBuildInputs ? [],
|
||||
buildPhase,
|
||||
buildPhase, buildMessage,
|
||||
installPhase ? "",
|
||||
postInstall ? "",
|
||||
outputs, meta } @ args:
|
||||
outputs, meta } @ args':
|
||||
|
||||
with stdenv;
|
||||
|
||||
|
@ -13,6 +13,7 @@ let
|
|||
removeReferences = [ go ];
|
||||
removeExpr = refs: ''remove-references-to ${lib.concatMapStrings (ref: " -t ${ref}") refs}'';
|
||||
|
||||
args = removeAttrs args' [ "buildMessage" ]; # Remove our arguments from args before passing them on to buildGoPackage
|
||||
buildStatusGo = buildGoPackage (args // {
|
||||
name = "${repo}-${version}-${host}";
|
||||
|
||||
|
@ -44,6 +45,27 @@ let
|
|||
xcrun xcodebuild -version
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
runHook renameImports
|
||||
|
||||
echo
|
||||
echo "${buildMessage}"
|
||||
echo
|
||||
${buildPhase}
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
${installPhase}
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
# remove hardcoded paths to go package in /nix/store, otherwise Nix will fail the build
|
||||
preFixup = ''
|
||||
find $out -type f -exec ${removeExpr removeReferences} '{}' + || true
|
||||
|
|
Loading…
Reference in New Issue