Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Cabal
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Glasgow Haskell Compiler
Packages
Cabal
Commits
f657276d
Commit
f657276d
authored
3 years ago
by
Patrick Augusto
Committed by
mergify-bot
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Common stanzas for cabal init
parent
cb980245
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cabal-install/src/Distribution/Client/Init/FileCreators.hs
+2
-1
2 additions, 1 deletion
cabal-install/src/Distribution/Client/Init/FileCreators.hs
cabal-install/src/Distribution/Client/Init/Format.hs
+36
-3
36 additions, 3 deletions
cabal-install/src/Distribution/Client/Init/Format.hs
with
38 additions
and
4 deletions
cabal-install/src/Distribution/Client/Init/FileCreators.hs
+
2
−
1
View file @
f657276d
...
...
@@ -61,12 +61,13 @@ writeProject (ProjectSettings opts pkgDesc libTarget exeTarget testTarget)
writeChangeLog
opts
pkgDesc
let
pkgFields
=
mkPkgDescription
opts
pkgDesc
commonStanza
=
mkCommonStanza
opts
libStanza
<-
prepareLibTarget
opts
libTarget
exeStanza
<-
prepareExeTarget
opts
exeTarget
testStanza
<-
prepareTestTarget
opts
testTarget
writeCabalFile
opts
$
pkgFields
++
[
libStanza
,
exeStanza
,
testStanza
]
writeCabalFile
opts
$
pkgFields
++
[
commonStanza
,
libStanza
,
exeStanza
,
testStanza
]
when
(
null
$
_pkgSynopsis
pkgDesc
)
$
message
opts
"
\n
Warning: no synopsis given. You should edit the .cabal file and add one."
...
...
This diff is collapsed.
Click to expand it.
cabal-install/src/Distribution/Client/Init/Format.hs
+
36
−
3
View file @
f657276d
...
...
@@ -20,6 +20,7 @@ module Distribution.Client.Init.Format
,
annNoComments
,
postProcessFieldLines
-- * stanza generation
,
mkCommonStanza
,
mkLibStanza
,
mkExeStanza
,
mkTestStanza
...
...
@@ -111,10 +112,28 @@ postProcessFieldLines ann
-- -------------------------------------------------------------------- --
-- Stanzas
-- The common stanzas are hardcoded for simplicity purposes,
-- see https://github.com/haskell/cabal/pull/7558#discussion_r693173846
mkCommonStanza
::
WriteOpts
->
PrettyField
FieldAnnotation
mkCommonStanza
opts
=
case
specHasCommonStanzas
$
_optCabalSpec
opts
of
NoCommonStanzas
->
PrettyEmpty
_
->
PrettySection
annNoComments
"common"
[
text
"warnings"
]
[
field
"ghc-options"
text
"-Wall"
[]
False
opts
]
mkLibStanza
::
WriteOpts
->
LibTarget
->
PrettyField
FieldAnnotation
mkLibStanza
opts
(
LibTarget
srcDirs
lang
expMods
otherMods
exts
deps
tools
)
=
PrettySection
annNoComments
(
toUTF8BS
"library"
)
[]
[
field
"exposed-modules"
formatExposedModules
(
toList
expMods
)
[
case
specHasCommonStanzas
$
_optCabalSpec
opts
of
NoCommonStanzas
->
PrettyEmpty
_
->
field
"import"
(
hsep
.
map
text
)
[
"warnings"
]
[
"Import common warning flags."
]
False
opts
,
field
"exposed-modules"
formatExposedModules
(
toList
expMods
)
[
"Modules exported by the library."
]
True
opts
...
...
@@ -153,7 +172,14 @@ mkLibStanza opts (LibTarget srcDirs lang expMods otherMods exts deps tools) =
mkExeStanza
::
WriteOpts
->
ExeTarget
->
PrettyField
FieldAnnotation
mkExeStanza
opts
(
ExeTarget
exeMain
appDirs
lang
otherMods
exts
deps
tools
)
=
PrettySection
annNoComments
(
toUTF8BS
"executable"
)
[
exeName
]
[
field
"main-is"
unsafeFromHs
exeMain
[
case
specHasCommonStanzas
$
_optCabalSpec
opts
of
NoCommonStanzas
->
PrettyEmpty
_
->
field
"import"
(
hsep
.
map
text
)
[
"warnings"
]
[
"Import common warning flags."
]
False
opts
,
field
"main-is"
unsafeFromHs
exeMain
[
".hs or .lhs file containing the Main module."
]
True
opts
...
...
@@ -194,7 +220,14 @@ mkExeStanza opts (ExeTarget exeMain appDirs lang otherMods exts deps tools) =
mkTestStanza
::
WriteOpts
->
TestTarget
->
PrettyField
FieldAnnotation
mkTestStanza
opts
(
TestTarget
testMain
dirs
lang
otherMods
exts
deps
tools
)
=
PrettySection
annNoComments
(
toUTF8BS
"test-suite"
)
[
suiteName
]
[
field
"default-language"
id
lang
[
case
specHasCommonStanzas
$
_optCabalSpec
opts
of
NoCommonStanzas
->
PrettyEmpty
_
->
field
"import"
(
hsep
.
map
text
)
[
"warnings"
]
[
"Import common warning flags."
]
False
opts
,
field
"default-language"
id
lang
[
"Base language which the package is written in."
]
True
opts
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment