Skip to content

Implement depend-defaults#295

Closed
ras0219-msft wants to merge 5 commits intomicrosoft:mainfrom
ras0219-msft:dev/roschuma/depends-defaults
Closed

Implement depend-defaults#295
ras0219-msft wants to merge 5 commits intomicrosoft:mainfrom
ras0219-msft:dev/roschuma/depends-defaults

Conversation

@ras0219-msft
Copy link
Collaborator

@ras0219-msft ras0219-msft commented Dec 7, 2021

This manifest property implements two highly requested features:

  1. Sets the default for "default-features" in the current manifest to false, meaning a simple dependency list of strings will not imply dependency upon default features. The vast majority of dependencies should not require defaults, so this avoids the boilerplate of explicitly qualifying every dependency as "default-features": false.

  2. If used in the top level manifest, disables automatic addition of defaults for transitive unnamed dependencies. This enables easier testing of the "minimum set" of dependencies and has been commonly requested by advanced users of vcpkg.

Edit:

During the implementation of this feature, I ran into an issue where the code reuses Dependency both as a context sensitive parse tree as well as a context-free representation of dependence in the version resolver algorithm. I've chosen to resolve this in the simplest way possible for now (inject the context in the SourceControlFile parser), however the more correct long-term approach is to introduce a separate representation for the context-free form (that has an InternalFeatureSet, etc).

@autoantwort
Copy link
Contributor

Port test1:

{
  "name": "test1",
  "version": "1.0.0",
  "default-features": ["foo"],
  "features":{
    "foo": {
      "description": "bar"
    }
  }
}

Main vcpkg.json:

{
  "name": "root",
  "version": "1.0.0",
  "depend-defaults": false,
  "dependencies": [
    {
      "name": "test1",
      "default-features": true
    }
  ]
}

Results in

➜  vcpkg git:(master) ✗ vcpkg install  --triplet=x64-osx --host-triplet=x64-osx --enforce-port-checks 
Detecting compiler hash for triplet x64-osx...
The following packages will be built and installed:
    test1[core]:x64-osx -> 1.0.0
Restored 1 packages from /Users/leanderSchulten/.cache/vcpkg/archives in 15.07 ms. Use --debug to see more details.
Starting package 1/1: test1:x64-osx
Installing package test1[core]:x64-osx...
Elapsed time for package test1:x64-osx: 1.583 ms

Total elapsed time: 2.843 s

Imho it should install test1[foo]

@autoantwort
Copy link
Contributor

autoantwort commented Dec 7, 2021

The problem is that the vcpkg.json parser only parses "default-features" as true or false, and not as true, false or Nothing. I had the same problem in #177. If you want you can use the corresponding code from there to parse it as Yes, No,DontCare.

@BillyONeal
Copy link
Member

Can you merge with main?

@BillyONeal
Copy link
Member

Are you still working on this? If not I think we should close the PR.

@autoantwort
Copy link
Contributor

I have completed this PR in #538.

One thing: The features vector now always contains "core" which seems a little bit unnecessary.

@BillyONeal
Copy link
Member

Closing this in favor of #538

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.

3 participants