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

Implement depend-defaults #295

Closed

Conversation

ras0219-msft
Copy link
Contributor

@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

@BillyONeal BillyONeal closed this Nov 28, 2022
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