Skip to content

Commit 04a26ae

Browse files
committed
fixup! feat: support generated cmm-sources
1 parent 5134617 commit 04a26ae

File tree

6 files changed

+226
-232
lines changed

6 files changed

+226
-232
lines changed

Cabal-syntax/src/Distribution/PackageDescription/FieldGrammar.hs

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ packageDescriptionFieldGrammar =
139139
-- * Files
140140
<*> monoidalFieldAla "data-files" (alaList' VCat RelativePathNT) L.dataFiles
141141
<*> optionalFieldDefAla "data-dir" CompatDataDir L.dataDir sameDirectory
142-
^^^ fmap (\x -> if null (getSymbolicPath x) then sameDirectory else x) -- map empty directories to "."
143-
<*> monoidalFieldAla "extra-source-files" formatExtraSourceFiles L.extraSrcFiles
144-
<*> monoidalFieldAla "extra-tmp-files" (alaList' VCat RelativePathNT) L.extraTmpFiles
145-
<*> monoidalFieldAla "extra-doc-files" formatExtraSourceFiles L.extraDocFiles
146-
<*> monoidalFieldAla "extra-files" formatExtraSourceFiles L.extraFiles
147-
^^^ availableSince CabalSpecV3_14 []
142+
^^^ fmap (\x -> if null (getSymbolicPath x) then sameDirectory else x) -- map empty directories to "."
143+
<*> monoidalFieldAla "extra-source-files" formatExtraSourceFiles L.extraSrcFiles
144+
<*> monoidalFieldAla "extra-tmp-files" (alaList' VCat RelativePathNT) L.extraTmpFiles
145+
<*> monoidalFieldAla "extra-doc-files" formatExtraSourceFiles L.extraDocFiles
146+
<*> monoidalFieldAla "extra-files" formatExtraSourceFiles L.extraFiles
147+
^^^ availableSince CabalSpecV3_14 []
148148
where
149149
packageIdentifierGrammar =
150150
PackageIdentifier
@@ -158,7 +158,7 @@ packageDescriptionFieldGrammar =
158158
-- and license-files when more
159159
<$> monoidalFieldAla "license-file" CompatLicenseFile L.licenseFiles
160160
<*> monoidalFieldAla "license-files" (alaList' FSep RelativePathNT) L.licenseFiles
161-
^^^ hiddenField
161+
^^^ hiddenField
162162

163163
-------------------------------------------------------------------------------
164164
-- Library
@@ -195,10 +195,10 @@ libraryFieldGrammar n =
195195
<$> monoidalFieldAla "exposed-modules" formatExposedModules L.exposedModules
196196
<*> monoidalFieldAla "reexported-modules" (alaList CommaVCat) L.reexportedModules
197197
<*> monoidalFieldAla "signatures" (alaList' VCat MQuoted) L.signatures
198-
^^^ availableSince CabalSpecV2_0 []
199-
<*> booleanFieldDef "exposed" L.libExposed True
200-
<*> visibilityField
201-
<*> blurFieldGrammar L.libBuildInfo buildInfoFieldGrammar
198+
^^^ availableSince CabalSpecV2_0 []
199+
<*> booleanFieldDef "exposed" L.libExposed True
200+
<*> visibilityField
201+
<*> blurFieldGrammar L.libBuildInfo buildInfoFieldGrammar
202202
where
203203
visibilityField = case n of
204204
-- nameless/"main" libraries are public
@@ -291,8 +291,8 @@ executableFieldGrammar n =
291291
-- main-is is optional as conditional blocks don't have it
292292
<$> optionalFieldDefAla "main-is" RelativePathNT L.modulePath (modulePath mempty)
293293
<*> optionalFieldDef "scope" L.exeScope ExecutablePublic
294-
^^^ availableSince CabalSpecV2_0 ExecutablePublic
295-
<*> blurFieldGrammar L.buildInfo buildInfoFieldGrammar
294+
^^^ availableSince CabalSpecV2_0 ExecutablePublic
295+
<*> blurFieldGrammar L.buildInfo buildInfoFieldGrammar
296296
{-# SPECIALIZE executableFieldGrammar :: UnqualComponentName -> ParsecFieldGrammar' Executable #-}
297297
{-# SPECIALIZE executableFieldGrammar :: UnqualComponentName -> PrettyFieldGrammar' Executable #-}
298298

@@ -367,7 +367,7 @@ testSuiteFieldGrammar =
367367
<*> optionalField "test-module" testStanzaTestModule
368368
<*> blurFieldGrammar testStanzaBuildInfo buildInfoFieldGrammar
369369
<*> monoidalFieldAla "code-generators" (alaList' CommaFSep Token) testStanzaCodeGenerators
370-
^^^ availableSince CabalSpecV3_8 []
370+
^^^ availableSince CabalSpecV3_8 []
371371

372372
validateTestSuite :: CabalSpecVersion -> Position -> TestSuiteStanza -> ParseResult TestSuite
373373
validateTestSuite cabalSpecVersion pos stanza = case testSuiteType of
@@ -388,8 +388,8 @@ validateTestSuite cabalSpecVersion pos stanza = case testSuiteType of
388388
parseFailure pos (missingField "main-is" tt)
389389
pure emptyTestSuite
390390
Just file -> do
391-
when (isJust (_testStanzaTestModule stanza))
392-
$ parseWarning pos PWTExtraBenchmarkModule (extraField "test-module" tt)
391+
when (isJust (_testStanzaTestModule stanza)) $
392+
parseWarning pos PWTExtraBenchmarkModule (extraField "test-module" tt)
393393
pure
394394
basicTestSuite
395395
{ testInterface = TestSuiteExeV10 ver file
@@ -399,8 +399,8 @@ validateTestSuite cabalSpecVersion pos stanza = case testSuiteType of
399399
parseFailure pos (missingField "test-module" tt)
400400
pure emptyTestSuite
401401
Just module_ -> do
402-
when (isJust (_testStanzaMainIs stanza))
403-
$ parseWarning pos PWTExtraMainIs (extraField "main-is" tt)
402+
when (isJust (_testStanzaMainIs stanza)) $
403+
parseWarning pos PWTExtraMainIs (extraField "main-is" tt)
404404
pure
405405
basicTestSuite
406406
{ testInterface = TestSuiteLibV09 ver module_
@@ -412,8 +412,7 @@ validateTestSuite cabalSpecVersion pos stanza = case testSuiteType of
412412
guard (cabalSpecVersion >= CabalSpecV3_8)
413413

414414
testTypeExe <$ _testStanzaMainIs stanza
415-
<|> testTypeLib
416-
<$ _testStanzaTestModule stanza
415+
<|> testTypeLib <$ _testStanzaTestModule stanza
417416

418417
missingField name tt =
419418
"The '"
@@ -539,8 +538,8 @@ validateBenchmark cabalSpecVersion pos stanza = case benchmarkStanzaType of
539538
parseFailure pos (missingField "main-is" tt)
540539
pure emptyBenchmark
541540
Just file -> do
542-
when (isJust (_benchmarkStanzaBenchmarkModule stanza))
543-
$ parseWarning pos PWTExtraBenchmarkModule (extraField "benchmark-module" tt)
541+
when (isJust (_benchmarkStanzaBenchmarkModule stanza)) $
542+
parseWarning pos PWTExtraBenchmarkModule (extraField "benchmark-module" tt)
544543
pure
545544
emptyBenchmark
546545
{ benchmarkInterface = BenchmarkExeV10 ver file
@@ -709,9 +708,9 @@ hsSourceDirsGrammar =
709708
(++)
710709
<$> monoidalFieldAla "hs-source-dirs" formatHsSourceDirs L.hsSourceDirs
711710
<*> monoidalFieldAla "hs-source-dir" (alaList' FSep SymbolicPathNT) wrongLens
712-
--- https://github.com/haskell/cabal/commit/49e3cdae3bdf21b017ccd42e66670ca402e22b44
713-
^^^ deprecatedSince CabalSpecV1_2 "Please use 'hs-source-dirs'"
714-
^^^ removedIn CabalSpecV3_0 "Please use 'hs-source-dirs' field."
711+
--- https://github.com/haskell/cabal/commit/49e3cdae3bdf21b017ccd42e66670ca402e22b44
712+
^^^ deprecatedSince CabalSpecV1_2 "Please use 'hs-source-dirs'"
713+
^^^ removedIn CabalSpecV3_0 "Please use 'hs-source-dirs' field."
715714
where
716715
-- TODO: make pretty printer aware of CabalSpecVersion
717716
wrongLens :: Functor f => LensLike' f BuildInfo [SymbolicPath Pkg (Dir Source)]
@@ -762,9 +761,9 @@ profSharedOptionsFieldGrammar
762761
profSharedOptionsFieldGrammar =
763762
PerCompilerFlavor
764763
<$> monoidalFieldAla "ghc-prof-shared-options" (alaList' NoCommaFSep Token') (extract GHC)
765-
^^^ availableSince CabalSpecV3_14 []
766-
<*> monoidalFieldAla "ghcjs-prof-shared-options" (alaList' NoCommaFSep Token') (extract GHCJS)
767-
^^^ availableSince CabalSpecV3_14 []
764+
^^^ availableSince CabalSpecV3_14 []
765+
<*> monoidalFieldAla "ghcjs-prof-shared-options" (alaList' NoCommaFSep Token') (extract GHCJS)
766+
^^^ availableSince CabalSpecV3_14 []
768767
where
769768
extract :: CompilerFlavor -> ALens' BuildInfo [String]
770769
extract flavor = L.profSharedOptions . lookupLens flavor
@@ -874,8 +873,8 @@ instance Newtype (SymbolicPath Pkg (Dir DataDir)) CompatDataDir
874873
instance Parsec CompatDataDir where
875874
parsec = do
876875
token <- parsecToken
877-
when (null token)
878-
$ parsecWarning PWTEmptyFilePath "empty FilePath"
876+
when (null token) $
877+
parsecWarning PWTEmptyFilePath "empty FilePath"
879878
return (CompatDataDir $ makeSymbolicPath token)
880879

881880
instance Pretty CompatDataDir where
@@ -909,19 +908,19 @@ _syntaxFieldNames =
909908
sequence_
910909
[ BS8.putStrLn $ " \\ " <> n
911910
| n <-
912-
nub
913-
$ sort
914-
$ mconcat
915-
[ fieldGrammarKnownFieldList packageDescriptionFieldGrammar
916-
, fieldGrammarKnownFieldList $ libraryFieldGrammar LMainLibName
917-
, fieldGrammarKnownFieldList $ executableFieldGrammar "exe"
918-
, fieldGrammarKnownFieldList $ foreignLibFieldGrammar "flib"
919-
, fieldGrammarKnownFieldList testSuiteFieldGrammar
920-
, fieldGrammarKnownFieldList benchmarkFieldGrammar
921-
, fieldGrammarKnownFieldList $ flagFieldGrammar (error "flagname")
922-
, fieldGrammarKnownFieldList $ sourceRepoFieldGrammar (error "repokind")
923-
, fieldGrammarKnownFieldList $ setupBInfoFieldGrammar True
924-
]
911+
nub $
912+
sort $
913+
mconcat
914+
[ fieldGrammarKnownFieldList packageDescriptionFieldGrammar
915+
, fieldGrammarKnownFieldList $ libraryFieldGrammar LMainLibName
916+
, fieldGrammarKnownFieldList $ executableFieldGrammar "exe"
917+
, fieldGrammarKnownFieldList $ foreignLibFieldGrammar "flib"
918+
, fieldGrammarKnownFieldList testSuiteFieldGrammar
919+
, fieldGrammarKnownFieldList benchmarkFieldGrammar
920+
, fieldGrammarKnownFieldList $ flagFieldGrammar (error "flagname")
921+
, fieldGrammarKnownFieldList $ sourceRepoFieldGrammar (error "repokind")
922+
, fieldGrammarKnownFieldList $ setupBInfoFieldGrammar True
923+
]
925924
]
926925

927926
_syntaxExtensions :: IO ()
@@ -935,8 +934,8 @@ _syntaxExtensions =
935934
]
936935
where
937936
es =
938-
nub
939-
$ sort
937+
nub $
938+
sort
940939
[ prettyShow e
941940
| e <- [minBound .. maxBound]
942941
, e `notElem` [Safe, Unsafe, Trustworthy]

Cabal/src/Distribution/Simple/Build.hs

Lines changed: 55 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -168,17 +168,16 @@ build_setupHooks
168168
checkSemaphoreSupport verbosity (compiler lbi) flags
169169
targets <- readTargetInfos verbosity pkg_descr lbi (buildTargets flags)
170170
let componentsToBuild = neededTargetsInBuildOrder' pkg_descr lbi (map nodeKey targets)
171-
info verbosity
172-
$ "Component build order: "
173-
++ intercalate
174-
", "
175-
( map
176-
(showComponentName . componentLocalName . targetCLBI)
177-
componentsToBuild
178-
)
171+
info verbosity $
172+
"Component build order: "
173+
++ intercalate
174+
", "
175+
( map
176+
(showComponentName . componentLocalName . targetCLBI)
177+
componentsToBuild
178+
)
179179

180-
when (null targets)
181-
$
180+
when (null targets) $
182181
-- Only bother with this message if we're building the whole package
183182
setupMessage verbosity "Building" (packageId pkg_descr)
184183

@@ -253,8 +252,8 @@ build_setupHooks
253252
checkSemaphoreSupport
254253
:: Verbosity -> Compiler -> BuildFlags -> IO ()
255254
checkSemaphoreSupport verbosity comp flags = do
256-
unless (jsemSupported comp || (isNothing (flagToMaybe (buildUseSemaphore flags))))
257-
$ dieWithException verbosity CheckSemaphoreSupport
255+
unless (jsemSupported comp || (isNothing (flagToMaybe (buildUseSemaphore flags)))) $
256+
dieWithException verbosity CheckSemaphoreSupport
258257

259258
-- | Write available build information for 'LocalBuildInfo' to disk.
260259
--
@@ -280,14 +279,14 @@ dumpBuildInfo verbosity distPref dumpBuildInfoFlag pkg_descr lbi flags = do
280279
-- Changing this line might break consumers of the dumped build info.
281280
-- Announce changes on mailing lists!
282281
let activeTargets = allTargetsInBuildOrder' pkg_descr lbi
283-
info verbosity
284-
$ "Dump build information for: "
285-
++ intercalate
286-
", "
287-
( map
288-
(showComponentName . componentLocalName . targetCLBI)
289-
activeTargets
290-
)
282+
info verbosity $
283+
"Dump build information for: "
284+
++ intercalate
285+
", "
286+
( map
287+
(showComponentName . componentLocalName . targetCLBI)
288+
activeTargets
289+
)
291290

292291
(compilerProg, _) <- case flavorToProgram (compilerFlavor (compiler lbi)) of
293292
Nothing ->
@@ -297,10 +296,10 @@ dumpBuildInfo verbosity distPref dumpBuildInfoFlag pkg_descr lbi flags = do
297296
wdir <- absoluteWorkingDirLBI lbi
298297
let (warns, json) = mkBuildInfo wdir pkg_descr lbi flags (compilerProg, compiler lbi) activeTargets
299298
buildInfoText = renderJson json
300-
unless (null warns)
301-
$ warn verbosity
302-
$ "Encountered warnings while dumping build-info:\n"
303-
++ unlines warns
299+
unless (null warns) $
300+
warn verbosity $
301+
"Encountered warnings while dumping build-info:\n"
302+
++ unlines warns
304303
LBS.writeFile buildInfoFile buildInfoText
305304

306305
when (not shouldDumpBuildInfo) $ do
@@ -366,14 +365,14 @@ repl_setupHooks
366365
[target] -> return target
367366
_ -> dieWithException verbosity $ NoMultipleTargets
368367
let componentsToBuild = neededTargetsInBuildOrder' pkg_descr lbi [nodeKey target]
369-
debug verbosity
370-
$ "Component build order: "
371-
++ intercalate
372-
", "
373-
( map
374-
(showComponentName . componentLocalName . targetCLBI)
375-
componentsToBuild
376-
)
368+
debug verbosity $
369+
"Component build order: "
370+
++ intercalate
371+
", "
372+
( map
373+
(showComponentName . componentLocalName . targetCLBI)
374+
componentsToBuild
375+
)
377376

378377
internalPackageDB <- createInternalPackageDB verbosity lbi distPref
379378

@@ -451,11 +450,11 @@ buildComponent
451450
-> SymbolicPath Pkg (Dir Dist)
452451
-> IO (Maybe InstalledPackageInfo)
453452
buildComponent flags _ _ _ _ (CTest TestSuite{testInterface = TestSuiteUnsupported tt}) _ _ =
454-
dieWithException (fromFlag $ buildVerbosity flags)
455-
$ NoSupportBuildingTestSuite tt
453+
dieWithException (fromFlag $ buildVerbosity flags) $
454+
NoSupportBuildingTestSuite tt
456455
buildComponent flags _ _ _ _ (CBench Benchmark{benchmarkInterface = BenchmarkUnsupported tt}) _ _ =
457-
dieWithException (fromFlag $ buildVerbosity flags)
458-
$ NoSupportBuildingBenchMark tt
456+
dieWithException (fromFlag $ buildVerbosity flags) $
457+
NoSupportBuildingBenchMark tt
459458
buildComponent
460459
flags
461460
numJobs
@@ -533,12 +532,12 @@ buildComponent
533532
lib' =
534533
lib
535534
{ libBuildInfo =
536-
flip addExtraAsmSources extras
537-
$ flip addExtraCmmSources extras
538-
$ flip addExtraCxxSources extras
539-
$ flip addExtraCSources extras
540-
$ flip addExtraJsSources extras
541-
$ libbi
535+
flip addExtraAsmSources extras $
536+
flip addExtraCmmSources extras $
537+
flip addExtraCxxSources extras $
538+
flip addExtraCSources extras $
539+
flip addExtraJsSources extras $
540+
libbi
542541
}
543542

544543
buildLib flags numJobs pkg_descr lbi lib' clbi
@@ -627,8 +626,7 @@ generateCode codeGens nm pdesc bi lbi clbi verbosity = do
627626
tgtDir = buildDir lbi </> makeRelativePathEx (nm' </> nm' ++ "-gen")
628627
go :: String -> IO [ModuleName.ModuleName]
629628
go codeGenProg =
630-
fmap fromString
631-
. lines
629+
fmap fromString . lines
632630
<$> getDbProgramOutputCwd
633631
verbosity
634632
mbWorkDir
@@ -948,9 +946,9 @@ addInternalBuildTools pkg lbi bi progs =
948946
| toolName <- getAllInternalToolDependencies pkg bi
949947
, let toolName' = unUnqualComponentName toolName
950948
, let toolLocation =
951-
interpretSymbolicPathLBI lbi
952-
$ buildDir lbi
953-
</> makeRelativePathEx (toolName' </> toolName' <.> exeExtension (hostPlatform lbi))
949+
interpretSymbolicPathLBI lbi $
950+
buildDir lbi
951+
</> makeRelativePathEx (toolName' </> toolName' <.> exeExtension (hostPlatform lbi))
954952
]
955953
mbWorkDir = mbWorkDirLBI lbi
956954
rawDataDir = dataDir pkg
@@ -1168,10 +1166,10 @@ builtinAutogenFiles
11681166
-> ComponentLocalBuildInfo
11691167
-> Map AutogenFile AutogenFileContents
11701168
builtinAutogenFiles pkg lbi clbi =
1171-
Map.insert pathsFile pathsContents
1172-
$ Map.insert packageInfoFile packageInfoContents
1173-
$ Map.insert cppHeaderFile cppHeaderContents
1174-
$ emptySignatureModules clbi
1169+
Map.insert pathsFile pathsContents $
1170+
Map.insert packageInfoFile packageInfoContents $
1171+
Map.insert cppHeaderFile cppHeaderContents $
1172+
emptySignatureModules clbi
11751173
where
11761174
pathsFile = AutogenModule (autogenPathsModuleName pkg) (Suffix "hs")
11771175
pathsContents = toUTF8LBS $ generatePathsModule pkg lbi clbi
@@ -1202,12 +1200,12 @@ emptySignatureModules clbi =
12021200
where
12031201
emptyHsigFile :: ModuleName -> AutogenFileContents
12041202
emptyHsigFile modName =
1205-
toUTF8LBS
1206-
$ "{-# OPTIONS_GHC -w #-}\n"
1207-
++ "{-# LANGUAGE NoImplicitPrelude #-}\n"
1208-
++ "signature "
1209-
++ prettyShow modName
1210-
++ " where"
1203+
toUTF8LBS $
1204+
"{-# OPTIONS_GHC -w #-}\n"
1205+
++ "{-# LANGUAGE NoImplicitPrelude #-}\n"
1206+
++ "signature "
1207+
++ prettyShow modName
1208+
++ " where"
12111209

12121210
data AutogenFile
12131211
= AutogenModule !ModuleName !Suffix

Cabal/src/Distribution/Simple/GHC/Build.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ build numJobs pkg_descr pbci = do
138138
let (hsMainFile, nonHsMainFile) =
139139
case mbMainFile of
140140
Just mainFile
141-
| PD.package pkg_descr
142-
== fakePackageId
141+
| PD.package pkg_descr == fakePackageId
143142
|| isHaskell (getSymbolicPath mainFile) ->
144143
(Just mainFile, Nothing)
145144
| otherwise ->

0 commit comments

Comments
 (0)