Add a windows build

This commit is contained in:
Alexander Bantyev 2020-04-11 13:22:26 +03:00
parent df59d2c461
commit 76b7ae101b
No known key found for this signature in database
GPG Key ID: E081FF12ADCB4AD5
7 changed files with 43 additions and 12 deletions

View File

@ -9,6 +9,10 @@ steps:
label: Executable
artifact_paths:
- "result/bin/xrefcheck"
- command: nix-build --argstr platform windows
label: Windows executable
artifact_paths:
- "result/bin/*"
- command: nix run -f. -c xrefcheck
label: Xrefcheck itself
- command: nix run -f $(nix eval --raw '((import ./nix/sources.nix).nixpkgs)') reuse -c reuse lint

View File

@ -2,4 +2,6 @@
#
# SPDX-License-Identifier: MPL-2.0
(import ./xrefcheck.nix { static = true; }).components.exes.xrefcheck
{ platform ? "linux-static" }:
(import ./xrefcheck.nix { ${platform} = true; }).components.exes.xrefcheck

View File

@ -5,7 +5,7 @@
{ pkgs ? import (import ../nix/sources.nix).nixpkgs { } }:
let
executable =
(import ../xrefcheck.nix { static = true; }).components.exes.xrefcheck;
(import ../xrefcheck.nix { linux-static = true; }).components.exes.xrefcheck;
binOnly = pkgs.runCommand "xrefcheck-bin" { } ''
mkdir -p $out/bin
cp ${executable}/bin/xrefcheck $out/bin

View File

@ -68,6 +68,7 @@ dependencies:
- directory-tree
- directory
- filepath
- file-embed
- fmt
- Glob
- http-client

View File

@ -4,8 +4,26 @@
{ pkgs ? import (import ../nix/sources.nix).nixpkgs { }, timestamp }:
let
executable =
(import ../xrefcheck.nix { static = true; }).components.exes.xrefcheck;
xrefcheck-x86_64-linux =
(import ../xrefcheck.nix { linux-static = true; }).components.exes.xrefcheck;
xrefcheck-x86_64-windows =
(import ../xrefcheck.nix { windows = true; }).components.exes.xrefcheck;
mkZip = { name, paths, compression ? 5 }:
pkgs.stdenvNoCC.mkDerivation {
inherit name;
buildInputs = [ pkgs.zip ];
buildCommand = ''
mkdir -p "$out"
zip "$out/$name.zip" -jr ${toString paths} -${toString compression}
'';
};
xrefcheck-x86_64-windows-zip = mkZip {
name = "xrefcheck-x86_64-windows";
paths = [ "${xrefcheck-x86_64-windows}/bin" ];
};
releaseNotes = pkgs.writeText "release-notes.md" ''
Automatic release on ${timestamp}
@ -17,6 +35,10 @@ in pkgs.linkFarm "xrefcheck-release" [
}
{
name = "xrefcheck-x86_64-linux";
path = "${executable}/bin/xrefcheck";
path = "${xrefcheck-x86_64-linux}/bin/xrefcheck";
}
{
name = "xrefcheck-x86_64-windows.zip";
path = "${xrefcheck-x86_64-windows-zip}/xrefcheck-x86_64-windows.zip";
}
]

View File

@ -11,9 +11,11 @@ import Data.Aeson.Options (defaultOptions)
import Data.Aeson.TH (deriveFromJSON)
import Data.Yaml (FromJSON (..), decodeEither', prettyPrintParseException, withText)
import Instances.TH.Lift ()
import qualified Language.Haskell.TH.Syntax as TH
import System.FilePath ((</>))
import TH.RelativePaths (qReadFileBS)
-- FIXME: Use </> from System.FilePath
-- </> from Posix is used only because we cross-compile to Windows and \ doesn't work on Linux
import System.FilePath.Posix ((</>))
import Data.FileEmbed (embedFile)
import Time (KnownRatName, Second, Time, unitsP)
import Xrefcheck.System (RelGlobPattern)
@ -50,7 +52,7 @@ data VerifyConfig = VerifyConfig
-- would be lost.
defConfigText :: ByteString
defConfigText =
$(TH.lift =<< qReadFileBS ("src-files" </> "def-config.yaml"))
$(embedFile ("src-files" </> "def-config.yaml"))
defConfig :: HasCallStack => Config
defConfig =

View File

@ -2,18 +2,18 @@
#
# SPDX-License-Identifier: MPL-2.0
{ static ? false }:
{ linux ? false, linux-static ? false, windows ? false }:
let
sources = import ./nix/sources.nix;
nixpkgs = import sources.nixpkgs (import sources."haskell.nix" {}).nixpkgsArgs;
pkgs = if static then nixpkgs.pkgsCross.musl64 else nixpkgs;
pkgs = if linux-static then nixpkgs.pkgsCross.musl64 else if windows then nixpkgs.pkgsCross.mingwW64 else nixpkgs;
project = pkgs.haskell-nix.stackProject {
src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
modules = [{
packages.xrefcheck = {
package.ghcOptions = "-Werror";
configureFlags = with pkgs;
lib.optionals static [
lib.optionals linux-static [
"--ghc-option=-optl=-L${zlib.static}/lib"
"--ghc-option=-optl=-L${nixpkgs.pkgsStatic.numactl}/lib"
];