diff --git a/etc/scripts/release.hs b/etc/scripts/release.hs index 0782604ee9..0f64cefc3e 100644 --- a/etc/scripts/release.hs +++ b/etc/scripts/release.hs @@ -28,7 +28,7 @@ import Development.Shake ( Action, Change (..), pattern Chatty, CmdOption (..), Rules , ShakeOptions (..), Stdout (..), (%>), actionOnException , alwaysRerun, cmd, command_, copyFileChanged - , getDirectoryFiles, liftIO, need, phony, putNormal + , getDirectoryFiles, liftIO, need, phony, putInfo , removeFilesAfter, shakeArgsWith, shakeOptions, want ) import Development.Shake.FilePath @@ -72,10 +72,12 @@ main = shakeArgsWith let gAllowDirty = False Platform arch _ = buildPlatform gArch = arch + gTargetOS = platformOS gBinarySuffix = "" gTestHaddocks = True gProjectRoot = "" -- Set to real value below. gBuildArgs = ["--flag", "stack:-developer-mode"] + gStackArgs = [] gCertificateName = Nothing global0 = foldl (flip id) @@ -87,9 +89,11 @@ main = shakeArgsWith , gProjectRoot , gHomeDir , gArch + , gTargetOS , gBinarySuffix , gTestHaddocks , gBuildArgs + , gStackArgs , gCertificateName } flags @@ -131,13 +135,23 @@ options = g { gBuildArgs = gBuildArgs g ++ [ "--flag=stack:static" - , "--docker" + ] + , gStackArgs = + gStackArgs g + ++ [ "--docker" , "--system-ghc" , "--no-install-ghc" ] + , gTargetOS = Linux } ) - "Build a statically linked binary using an Alpine Docker image." + "Build a statically-linked binary using an Alpine Linux Docker image." + , Option "" [stackArgsOptName] + ( ReqArg + (\v -> Right $ \g -> g{gStackArgs = gStackArgs g ++ words v}) + "\"ARG1 ARG2 ...\"" + ) + "Additional arguments to pass to 'stack'." , Option "" [buildArgsOptName] ( ReqArg (\v -> Right $ \g -> g{gBuildArgs = gBuildArgs g ++ words v}) @@ -180,9 +194,13 @@ rules global args = do , show dirty ] () <- cmd + stackProgName + global.gStackArgs + ["exec"] [ global.gProjectRoot releaseBinDir binaryName stackExeFileName ] + ["--"] (stackArgs global) ["build"] global.gBuildArgs @@ -191,9 +209,8 @@ rules global args = do ["--haddock" | global.gTestHaddocks] ["stack"] () <- cmd - [ global.gProjectRoot releaseBinDir binaryName - stackExeFileName - ] + stackProgName + global.gStackArgs ["exec"] [ global.gProjectRoot releaseBinDir binaryName "stack-integration-test" @@ -202,7 +219,7 @@ rules global args = do releaseDir binaryPkgZipFileName %> \out -> do stageFiles <- getBinaryPkgStageFiles - putNormal $ "zip " ++ out + putInfo $ "zip " ++ out liftIO $ do entries <- forM stageFiles $ \stageFile -> do Zip.readEntry @@ -234,7 +251,13 @@ rules global args = do releaseDir binaryExeFileName %> \out -> do need [releaseBinDir binaryName stackExeFileName] (Stdout versionOut) <- - cmd (releaseBinDir binaryName stackExeFileName) "--version" + cmd + stackProgName + global.gStackArgs + ["exec"] + (releaseBinDir binaryName stackExeFileName) + ["--"] + ["--version"] when (not global.gAllowDirty && "dirty" `isInfixOf` lower versionOut) $ error ( "Refusing continue because 'stack --version' reports dirty. Use --" @@ -298,6 +321,7 @@ rules global args = do ( cmd stackProgName (stackArgs global) ["--local-bin-path=" ++ takeDirectory out] + global.gStackArgs "install" global.gBuildArgs integrationTestFlagArgs @@ -336,7 +360,7 @@ rules global args = do releaseBinDir = releaseDir "bin" binaryPkgFileNames = - case platformOS of + case global.gTargetOS of Windows -> [ binaryExeFileName , binaryPkgZipFileName @@ -357,7 +381,7 @@ rules global args = do , "-" , stackVersionStr global , "-" - , display platformOS + , display global.gTargetOS , "-" , display global.gArch , if null global.gBinarySuffix then "" else "-" ++ global.gBinarySuffix @@ -438,6 +462,10 @@ binaryVariantOptName = "binary-variant" noTestHaddocksOptName :: String noTestHaddocksOptName = "no-test-haddocks" +-- | @--stack-args@ command-line option name. +stackArgsOptName :: String +stackArgsOptName = "stack-args" + -- | @--build-args@ command-line option name. buildArgsOptName :: String buildArgsOptName = "build-args" @@ -469,9 +497,11 @@ data Global = Global , gProjectRoot :: !FilePath , gHomeDir :: !FilePath , gArch :: !Arch + , gTargetOS :: !OS , gBinarySuffix :: !String , gTestHaddocks :: !Bool , gBuildArgs :: [String] + , gStackArgs :: [String] , gCertificateName :: !(Maybe String) } deriving Show