Skip to content

Commit 12223d7

Browse files
authored
Merge pull request #9573 from cabalism/fix/gen-buildinfo-9186
Generate doc/buildinfo-fields-reference.rst
2 parents fe705cf + 5f1c443 commit 12223d7

File tree

7 files changed

+129
-69
lines changed

7 files changed

+129
-69
lines changed

.github/workflows/quick-jobs.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,36 @@ jobs:
9292
run: make doctest-install
9393
- name: Doctest
9494
run: make doctest
95+
buildinfo:
96+
name: Check Field Syntax Reference
97+
runs-on: ubuntu-latest
98+
steps:
99+
- name: Set PATH
100+
run: |
101+
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
102+
- uses: actions/cache@v3
103+
with:
104+
path: ~/.cabal/store
105+
key: linux-store-buildinfo-doc-diff
106+
# See https://github.com/haskell/cabal/pull/8739
107+
- name: Sudo chmod to permit ghcup to update its cache
108+
run: |
109+
if [[ "${{ runner.os }}" == "Linux" ]]; then
110+
sudo ls -lah /usr/local/.ghcup/cache
111+
sudo mkdir -p /usr/local/.ghcup/cache
112+
sudo ls -lah /usr/local/.ghcup/cache
113+
sudo chown -R $USER /usr/local/.ghcup
114+
sudo chmod -R 777 /usr/local/.ghcup
115+
fi
116+
- name: ghcup
117+
run: |
118+
ghcup --version
119+
ghcup config set cache true
120+
ghcup install ghc --set recommended
121+
ghcup install cabal --set latest
122+
- name: Update Hackage index
123+
run: cabal v2-update
124+
- uses: actions/checkout@v4
125+
- name: Are buildinfo docs up to date?
126+
run: make doc/buildinfo-fields-reference.rst
127+

Cabal-described/src/Distribution/Described.hs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE FlexibleInstances #-}
12
{-# LANGUAGE OverloadedStrings #-}
23
{-# LANGUAGE ScopedTypeVariables #-}
34
module Distribution.Described (
@@ -65,6 +66,7 @@ import Distribution.Utils.GrammarRegex
6566
-- Types
6667
import Distribution.Compat.Newtype
6768
import Distribution.Compiler (CompilerFlavor, CompilerId, knownCompilerFlavors)
69+
import Distribution.PackageDescription.FieldGrammar (CompatFilePath, CompatLicenseFile)
6870
import Distribution.FieldGrammar.Newtypes
6971
import Distribution.ModuleName (ModuleName)
7072
import Distribution.System (Arch, OS, knownArches, knownOSs)
@@ -95,6 +97,7 @@ import Distribution.Types.SourceRepo (RepoType)
9597
import Distribution.Types.TestType (TestType)
9698
import Distribution.Types.UnitId (UnitId)
9799
import Distribution.Types.UnqualComponentName (UnqualComponentName)
100+
import Distribution.Utils.Path (LicenseFile, PackageDir, SourceDir, SymbolicPath)
98101
import Distribution.Verbosity (Verbosity)
99102
import Distribution.Version (Version, VersionRange)
100103
import Language.Haskell.Extension (Extension, Language)
@@ -419,7 +422,7 @@ instance Described IncludeRenaming where
419422
mr = describe (Proxy :: Proxy ModuleRenaming)
420423

421424
instance Described Language where
422-
describe _ = REUnion ["Haskell98", "Haskell2010"]
425+
describe _ = REUnion ["GHC2021", "Haskell2010", "Haskell98"]
423426

424427
instance Described LegacyExeDependency where
425428
describe _ = RETodo
@@ -575,3 +578,15 @@ instance Described TestedWith where
575578

576579
instance Described FilePathNT where
577580
describe _ = describe ([] :: [Token])
581+
582+
instance Described (SymbolicPath PackageDir SourceDir) where
583+
describe _ = describe ([] :: [Token])
584+
585+
instance Described (SymbolicPath PackageDir LicenseFile) where
586+
describe _ = describe ([] :: [Token])
587+
588+
instance Described CompatLicenseFile where
589+
describe _ = describe ([] :: [Token])
590+
591+
instance Described CompatFilePath where
592+
describe _ = describe ([] :: [Token])

Makefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,15 @@ $(TEMPLATE_PATHS) : templates/Paths_pkg.template.hs cabal-dev-scripts/src/GenPat
5959
cabal run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-paths-module -- $< $@
6060

6161
# generated docs
62-
63-
buildinfo-fields-reference : phony
64-
cabal build --builddir=dist-newstyle-bi --project-file=cabal.project.buildinfo buildinfo-reference-generator
65-
$$(cabal list-bin --builddir=dist-newstyle-bi buildinfo-reference-generator) buildinfo-reference-generator/template.zinza | tee $@
62+
# Use cabal build before cabal run to avoid output of the build on stdout when running
63+
doc/buildinfo-fields-reference.rst : \
64+
$(wildcard Cabal-syntax/src/*/*.hs Cabal-syntax/src/*/*/*.hs Cabal-syntax/src/*/*/*/*.hs) \
65+
$(wildcard Cabal-described/src/Distribution/Described.hs Cabal-described/src/Distribution/Utils/*.hs) \
66+
buildinfo-reference-generator/src/Main.hs \
67+
buildinfo-reference-generator/template.zinza
68+
cabal build --project-file=cabal.project.buildinfo buildinfo-reference-generator
69+
cabal run --project-file=cabal.project.buildinfo buildinfo-reference-generator buildinfo-reference-generator/template.zinza | tee $@
70+
git diff --exit-code $@
6671

6772
# analyse-imports
6873
analyse-imports : phony

buildinfo-reference-generator/buildinfo-reference-generator.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ executable buildinfo-reference-generator
88
ghc-options: -Wall
99
main-is: Main.hs
1010
build-depends:
11-
, base ^>=4.12 || ^>=4.13
11+
, base >=4.11 && <4.20
1212
, Cabal
1313
, Cabal-described
1414
, containers

buildinfo-reference-generator/template.zinza

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Build info fields
157157
{# We show documentation link only for non deprecated fields #}
158158
{% if null field.deprecatedSince.fst %}
159159
{% if null field.removedIn.fst %}
160-
* Documentation of :pkg-field:`{{field.name}}`
160+
* Documentation of :pkg-field:`library:{{field.name}}`
161161
{% endif %}
162162
{% endif %}
163163
{% if notNull field.syntax %}

cabal.project.buildinfo

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ packages: Cabal-described
44
packages: buildinfo-reference-generator/
55
tests: False
66
optimization: False
7-
with-compiler: ghc-8.8.3
87

98
-- avoiding extra dependencies
109
constraints: rere -rere-cfg

0 commit comments

Comments
 (0)