Skip to content

Conversation

@dcoutts
Copy link
Contributor

@dcoutts dcoutts commented Sep 1, 2017

Add CLI target support for package names. Ultimately this will be able to be used for referring to out-of-project packages, or packages that are deps of things in the project.

At the moment there is nothing except for syntax support.

For the moment, when used, it will report:

cabal: Cannot build the package foobar, it is not in this project
(either directly or indirectly). If you want to add it to the
project then edit the cabal.project file.

This is also intended to help @fgaz with his work. It may make sense to rebase the wip/extra-packages on these changes.

The integration-tests2 cover the new syntax to the extent that it checks ambiguity. What is missing is positive tests for the new syntax.

In addition this PR includes two simple clean-up patches.

Consolodate the three copies of it.
@mention-bot
Copy link

@dcoutts, thanks for your PR! By analyzing the history of the files in this pull request, we identified @grayjay, @RyanGlScott and @hvr to be potential reviewers.


None errs
| TargetStringFileStatus1 str _ <- targetStrStatus
, validPackageName str -> Right (TargetPackageName (mkPackageName str))
Copy link
Member

@fgaz fgaz Sep 1, 2017

Choose a reason for hiding this comment

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

[obsolete]
In my tests we only fall here when i run
cabal new-build some-package-not-in-the-project
while if I run
cabal new-build some-extra-package
we fall in the Unambiguous target case.

I don't understand if

  1. it should match the extra package
  2. it should match any other package (ex. from hackage)

If (1): this doesn't work and we probably need to re-add syntaxForm1Name and filter out extra packages in syntaxForm1Package.

If (2): Well, until now i thought we were dealing with the first case... I'll have to think abou this.

@BardurArantsson BardurArantsson removed their request for review September 1, 2017 11:37
There is nothing except for syntax support, but this is a first step
towards proper support for targets refering to dependencies or to out of
project packages.

For the moment, when used, it will report:

    cabal: Cannot build the package foobar, it is not in this project
    (either directly or indirectly). If you want to add it to the
    project then edit the cabal.project file.

Also update the test output for an integration test.
It's currently in the old Targets module, but we'll need it in the
new-build code too soon, and it's not really that closely related to
targets, so it makes sense to have it live in the common Types module.
That is, any package name within the install plan. This allows
targeting a dependency of a package that is local to the project.
So you can now add `extra-packages: foo` to the cabal.projct file and
then `cabal (new-)build foo`. The extra packages are included into the
install plan and they are also resolved as build targets.

Currently this only uses the "any valid package name" target syntax
which means you can use `foo` but not `foo:tests` or any of the other
variations.
@dcoutts dcoutts force-pushed the target-package-names branch from cd500ab to e002ad4 Compare September 2, 2017 17:42
@dcoutts
Copy link
Contributor Author

dcoutts commented Sep 2, 2017

FYI, I'm trying to improve the target parser further to make this more flexible. So I appreciate review already but hold off merging for now.

Copy link
Member

@23Skidoo 23Skidoo left a comment

Choose a reason for hiding this comment

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

LGTM modulo minor bikeshedding. Any chance we can get some test cases?

-- resolve to a dependency of a local package or to a package from
-- hackage. Either way, it requires further processing to resolve.
--
| TargetPackageName PackageName
Copy link
Member

Choose a reason for hiding this comment

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

Maybe call it TargetExtraPackageName or TargetUnknownPackage to highlight the connection to extra-packages and make the distinction between it and TargetPackage more clear?

@fgaz
Copy link
Member

fgaz commented Sep 19, 2017

@23Skidoo New-install will indirectly test it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants