Skip to content

Commit ad11d0f

Browse files
committed
Re #6531 Add --stack-args
1 parent 36ea8b5 commit ad11d0f

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

.github/workflows/integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ jobs:
217217
# (Note that the online documentation for '--docker-stack-exe image'
218218
# specifies that the host Stack and image Stack must have the same
219219
# version number.)
220-
/usr/local/bin/stack etc/scripts/release.hs build --alpine --build-args --docker-stack-exe=image
220+
/usr/local/bin/stack etc/scripts/release.hs build --alpine --stack-args --docker-stack-exe=image
221221
222222
- name: Upload bindist
223223
if: needs.configuration.outputs.test-arm64 == 'true'

etc/scripts/release.hs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ main = shakeArgsWith
7676
gTestHaddocks = True
7777
gProjectRoot = "" -- Set to real value below.
7878
gBuildArgs = ["--flag", "stack:-developer-mode"]
79+
gStackArgs = []
7980
gCertificateName = Nothing
8081
global0 = foldl
8182
(flip id)
@@ -90,6 +91,7 @@ main = shakeArgsWith
9091
, gBinarySuffix
9192
, gTestHaddocks
9293
, gBuildArgs
94+
, gStackArgs
9395
, gCertificateName
9496
}
9597
flags
@@ -131,13 +133,22 @@ options =
131133
g { gBuildArgs =
132134
gBuildArgs g
133135
++ [ "--flag=stack:static"
134-
, "--docker"
136+
]
137+
, gStackArgs =
138+
gStackArgs g
139+
++ [ "--docker"
135140
, "--system-ghc"
136141
, "--no-install-ghc"
137142
]
138143
}
139144
)
140-
"Build a statically linked binary using an Alpine Docker image."
145+
"Build a statically-linked binary using an Alpine Linux Docker image."
146+
, Option "" [stackArgsOptName]
147+
( ReqArg
148+
(\v -> Right $ \g -> g{gStackArgs = gStackArgs g ++ words v})
149+
"\"ARG1 ARG2 ...\""
150+
)
151+
"Additional arguments to pass to 'stack'."
141152
, Option "" [buildArgsOptName]
142153
( ReqArg
143154
(\v -> Right $ \g -> g{gBuildArgs = gBuildArgs g ++ words v})
@@ -234,7 +245,13 @@ rules global args = do
234245
releaseDir </> binaryExeFileName %> \out -> do
235246
need [releaseBinDir </> binaryName </> stackExeFileName]
236247
(Stdout versionOut) <-
237-
cmd (releaseBinDir </> binaryName </> stackExeFileName) "--version"
248+
cmd
249+
stackProgName -- Use the platform's Stack
250+
global.gStackArgs -- Possibly to set up a Docker container
251+
["exec"] -- To execute the target Stack and get its version info
252+
(releaseBinDir </> binaryName </> stackExeFileName)
253+
["--"]
254+
["--version"]
238255
when (not global.gAllowDirty && "dirty" `isInfixOf` lower versionOut) $
239256
error
240257
( "Refusing continue because 'stack --version' reports dirty. Use --"
@@ -295,10 +312,12 @@ rules global args = do
295312
releaseBinDir </> binaryName </> stackExeFileName %> \out -> do
296313
alwaysRerun
297314
actionOnException
298-
( cmd stackProgName
315+
( cmd
316+
stackProgName -- Use the platform's Stack
299317
(stackArgs global)
300318
["--local-bin-path=" ++ takeDirectory out]
301-
"install"
319+
global.gStackArgs -- Possibly to set up a Docker container
320+
"install" -- To build and install Stack to that local bin path
302321
global.gBuildArgs
303322
integrationTestFlagArgs
304323
"--pedantic"
@@ -438,6 +457,10 @@ binaryVariantOptName = "binary-variant"
438457
noTestHaddocksOptName :: String
439458
noTestHaddocksOptName = "no-test-haddocks"
440459

460+
-- | @--stack-args@ command-line option name.
461+
stackArgsOptName :: String
462+
stackArgsOptName = "stack-args"
463+
441464
-- | @--build-args@ command-line option name.
442465
buildArgsOptName :: String
443466
buildArgsOptName = "build-args"
@@ -472,6 +495,7 @@ data Global = Global
472495
, gBinarySuffix :: !String
473496
, gTestHaddocks :: !Bool
474497
, gBuildArgs :: [String]
498+
, gStackArgs :: [String]
475499
, gCertificateName :: !(Maybe String)
476500
}
477501
deriving Show

0 commit comments

Comments
 (0)