Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove show-build-info command and generate build-info as a side-effect of 'build' #7498

Merged
merged 10 commits into from
Sep 8, 2021

Conversation

fendor
Copy link
Collaborator

@fendor fendor commented Jul 27, 2021

This is the first step for implementing Approach 3 of #7489.
Mainly extracted from #7478

In particular, add a flag --enable-build-info to configure of Setup.hs and generate build-info.json right next to setup-config.

Readable by tooling.

  • Cabal Tests using build-type: Simple
  • Cabal Tests using build-type: Custom
  • Optional: Add cabal configure --enable-dump-buildinfo (e.g. enable/disable the generation)
  • Add buildInfoJson to plan.json output
  • Guard against older Cabal versions

@fendor fendor force-pushed the feature/sbi-build-sideeffect branch 4 times, most recently from 9567d55 to 7744fe4 Compare July 28, 2021 10:52
@fendor fendor requested review from Mikolaj, fgaz, jneira and emilypi and removed request for Mikolaj July 29, 2021 11:52
@fendor fendor force-pushed the feature/sbi-build-sideeffect branch 2 times, most recently from 535591f to 500d0bd Compare July 30, 2021 10:35
@fendor fendor force-pushed the feature/sbi-build-sideeffect branch 3 times, most recently from 3c7272f to f9844d6 Compare July 30, 2021 13:15
@@ -67,6 +67,10 @@ srcPref distPref = distPref </> "src"
hscolourPref :: HaddockTarget -> FilePath -> PackageDescription -> FilePath
hscolourPref = haddockPref

-- | Build info json file, generated in every build
buildInfoPref :: FilePath -> FilePath
buildInfoPref distPref = distPref </> "build-info.json"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible inconsistency, file name is build-info but other flags are buildinfo. Any preferences?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I'm concerned buildinfo is a word.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I also find "buildinfo" more natural I found some precedent on the cmdline: --enable-debug-info is a thing so maybe we should be consistent with that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I choose consistency with debug-info, everything will be renamed to build-info

@fendor fendor force-pushed the feature/sbi-build-sideeffect branch 2 times, most recently from 4fc7f04 to bda7743 Compare July 30, 2021 14:02
@@ -556,6 +564,17 @@ configureOptions showOrParseArgs =
"Don't emit debug info"
]

, multiOption "dump-buildinfo"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why conditionally? Is there a reason not to write it always?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not want to change the default behaviour, but it would be indeed better if it was always generated. Subject to bikeshed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

performance is not a problem I suppose

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I woudn't be so sure that performance couldn't be a problem, best to err on the side of caution when people with pitchforks are sure to follow if build speed regresses ;)

If it turns out to be unproblematic it's an easy default to change: just ignore the flag going forward, but the other way around isn't so easy since tooling would break if we introduce a flag.

Lastly my understanding is that hie-bios currently always does at least one (implicit) build call anyway though the repl command so we're just maintaining the status quo if it has to do one with a special flag to get the buildinfo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lastly my understanding is that hie-bios currently always does at least one (implicit) build call anyway though the repl command so we're just maintaining the status quo if it has to do one with a special flag to get the buildinfo.

yeah but it would be nice if we get to make no one if possible, though

Copy link
Collaborator

@DanielG DanielG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking pretty good. I'm super excited that we figured out how to roll this into build rather than introducing a new command.

Apart from nits and bikeshedding the only real points that need addressing are the non-nullability of the compiler "path", the nullability of "build-info" in plan.json or an alternate mechanism for downstreams to detect if the "lib:Cabal too old" case is happening and as always moar docs ;)

Cabal/src/Distribution/Simple/Build.hs Outdated Show resolved Hide resolved
Cabal/src/Distribution/Simple/Setup.hs Outdated Show resolved Hide resolved
Cabal/src/Distribution/Simple/Setup.hs Outdated Show resolved Hide resolved
@@ -67,6 +67,10 @@ srcPref distPref = distPref </> "src"
hscolourPref :: HaddockTarget -> FilePath -> PackageDescription -> FilePath
hscolourPref = haddockPref

-- | Build info json file, generated in every build
buildInfoPref :: FilePath -> FilePath
buildInfoPref distPref = distPref </> "build-info.json"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I also find "buildinfo" more natural I found some precedent on the cmdline: --enable-debug-info is a thing so maybe we should be consistent with that?

@@ -2,7 +2,7 @@
-- This module defines a simple JSON-based format for exporting basic
-- information about a Cabal package and the compiler configuration Cabal
-- would use to build it. This can be produced with the
-- @cabal new-show-build-info@ command.
-- @cabal build --enable-dump-buildinfo@ command.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing that one would pass the (configure) enable flag to build like this makes me wonder if --dump-buildinfo should imply --enable-buildinfo on the build cmdline? cabal build --enable-buildinfo --dump-buildinfo=PATH seems quite redundant.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no flag --dump-buildinfo exists yet, I would leave that to a follow-up PR, unless someone objects

Cabal/src/Distribution/Simple/ShowBuildInfo.hs Outdated Show resolved Hide resolved
flags_3_5_0 = flags_latest {
-- Cabal < 3.5 does not understand --dump-build-info
configDumpBuildInfo = NoFlag
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we ought to emit a warning about this somewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure but where?

cabal-install/src/Distribution/Client/ProjectPlanOutput.hs Outdated Show resolved Hide resolved
Copy link
Collaborator

@DanielG DanielG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just another per-commit review pass. Something seems off about the commit messages not being in sync with the diffs.

Cabal/src/Distribution/Simple/BuildTarget.hs Outdated Show resolved Hide resolved
Cabal/Cabal.cabal Outdated Show resolved Hide resolved
Cabal/src/Distribution/Simple/Utils/Json.hs Outdated Show resolved Hide resolved
@fendor fendor force-pushed the feature/sbi-build-sideeffect branch 8 times, most recently from 53de4fb to 38f189f Compare August 1, 2021 18:21
@fendor fendor force-pushed the feature/sbi-build-sideeffect branch from e03c434 to 7a9f973 Compare September 4, 2021 12:13
doc/setup-commands.rst Outdated Show resolved Hide resolved
on how to build an individual component, such as compiler version, modules of a component and
how to compile the component.

The output format is in json, and the exact location can be discovered from ``plan.json``.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still doesn't seem to mention what the field name in plan.json is or where that field can be found like I suggested above.

cabal-install/src/Distribution/Client/ProjectPlanOutput.hs Outdated Show resolved Hide resolved
Cabal/src/Distribution/Simple/Setup.hs Outdated Show resolved Hide resolved
Copy link
Collaborator

@DanielG DanielG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add some comments to make sure code, json schema and docs stay in sync in the face of other people changing this code in the future.

doc/setup-commands.rst Show resolved Hide resolved
doc/json-schemas/build-info.schema.json Show resolved Hide resolved
Adds missing file information for test and benchmark stanzas.
Removes 'show-build-info' command from 'lib:Cabal' and replaces it
by generating build-info whenever a build happens.

Add flag '--dump-buildinfo' to signal the build step to dump
build information for the package/component we are currently building.
@fendor fendor force-pushed the feature/sbi-build-sideeffect branch 4 times, most recently from c26077d to 9b56d10 Compare September 7, 2021 16:21
@fendor fendor force-pushed the feature/sbi-build-sideeffect branch from 9b56d10 to 0702193 Compare September 7, 2021 16:25
@jneira
Copy link
Member

jneira commented Sep 8, 2021

are you scared of pressing the button? 😝

@fendor
Copy link
Collaborator Author

fendor commented Sep 8, 2021

Well, someone else should press the merge button :)

@DanielG DanielG merged commit c66a126 into haskell:master Sep 8, 2021
@DanielG
Copy link
Collaborator

DanielG commented Sep 8, 2021

Alright then, been eyeing that button all day :D

@andreasabel
Copy link
Member

andreasabel commented Sep 11, 2021

@fendor @DanielG Commit 024c060 of this PR broke make users-guide:

doc/developing-packages.rst:259: WARNING: Unknown target name: "common stanzas".

doc/developing-packages.rst:351: WARNING: Unknown target name: "package versioning policy".

doc/setup-commands.rst:1057: WARNING: Unexpected indentation.
doc/setup-commands.rst:1060: WARNING: Block quote ends without a blank line; unexpected unindent.
doc/setup-commands.rst:1062: WARNING: Unexpected indentation.
doc/setup-commands.rst:1067: WARNING: Unexpected indentation.
doc/setup-commands.rst:1068: WARNING: Block quote ends without a blank line; unexpected unindent.
doc/setup-commands.rst:1070: WARNING: Unexpected indentation.
doc/setup-commands.rst:1071: WARNING: Block quote ends without a blank line; unexpected unindent.
doc/setup-commands.rst:1073: WARNING: Unexpected indentation.
doc/setup-commands.rst:1074: WARNING: Block quote ends without a blank line; unexpected unindent.
doc/setup-commands.rst:1076: WARNING: Unexpected indentation.
doc/setup-commands.rst:1077: WARNING: Block quote ends without a blank line; unexpected unindent.
doc/setup-commands.rst:1081: WARNING: Block quote ends without a blank line; unexpected unindent.
doc/setup-commands.rst:1082: WARNING: Definition list ends without a blank line; unexpected unindent.

doc/setup-commands.rst:1084: WARNING: Unknown directive type "jsonschema".

.. jsonschema:: ./json-schemas/build-info.schema.json

@Mikolaj
Copy link
Member

Mikolaj commented Sep 11, 2021

Uhoh. We do need make users-guide in CI.

@DanielG
Copy link
Collaborator

DanielG commented Sep 11, 2021

Indeed fendor seems to have forgotten to add the jsonschema extension to conf.py, but the users-guide target was already broken before the merge AFAICT :]

According to my bisect 0f041b6 is to blame originally.

@Mikolaj
Copy link
Member

Mikolaj commented Sep 11, 2021

See #7637.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants