- Notifications
You must be signed in to change notification settings - Fork0
More work on vcpkg toolchain, combining cmake and vcpkg toolchains#71
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
3 changes: 3 additions & 0 deletions.gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -157,3 +157,6 @@ hatch_cpp/labextension | ||
| # Rust | ||
| target | ||
| vcpkg | ||
| vcpkg_installed | ||
31 changes: 26 additions & 5 deletionshatch_cpp/config.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletionhatch_cpp/tests/test_project_cmake_vcpkg/vcpkg.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletionhatch_cpp/tests/test_project_pybind_vcpkg/vcpkg.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
16 changes: 15 additions & 1 deletionhatch_cpp/toolchains/cmake.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletionshatch_cpp/toolchains/common.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
50 changes: 42 additions & 8 deletionshatch_cpp/toolchains/vcpkg.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,64 @@ | ||
| from __future__ import annotations | ||
| from pathlib import Path | ||
| from platform import machine as platform_machine | ||
| from sys import platform as sys_platform | ||
| from typing importLiteral,Optional | ||
| from pydantic import BaseModel, Field | ||
| __all__ = ("HatchCppVcpkgConfiguration",) | ||
| VcpkgTriplet = Literal[ | ||
| "x64-android", | ||
| "x64-osx", | ||
| "x64-linux", | ||
| "x64-uwp", | ||
| "x64-windows", | ||
| "x64-windows-release", | ||
| "x64-windows-static", | ||
| "x64-windows-static-md", | ||
| "x86-windows", | ||
| "arm-neon-android", | ||
| "arm64-android", | ||
| "arm64-osx", | ||
| "arm64-uwp", | ||
| "arm64-windows", | ||
| "arm64-windows-static-md", | ||
| ] | ||
| VcpkgPlatformDefaults = { | ||
| ("linux", "x86_64"): "x64-linux", | ||
| # ("linux", "arm64"): "", | ||
| ("darwin", "x86_64"): "x64-osx", | ||
| ("darwin", "arm64"): "arm64-osx", | ||
| ("win32", "x86_64"): "x64-windows-static-md", | ||
| ("win32", "arm64"): "arm64-windows-static-md", | ||
| } | ||
| class HatchCppVcpkgConfiguration(BaseModel): | ||
| vcpkg: Optional[str] = Field(default="vcpkg.json") | ||
| vcpkg_root: Optional[Path] = Field(default=Path("vcpkg")) | ||
| vcpkg_repo: Optional[str] = Field(default="https://github.com/microsoft/vcpkg.git") | ||
| vcpkg_triplet: Optional[VcpkgTriplet] = Field(default=None) | ||
| # TODO: overlay | ||
| def generate(self, config): | ||
| commands = [] | ||
| if self.vcpkg_triplet is None: | ||
| self.vcpkg_triplet = VcpkgPlatformDefaults.get((sys_platform, platform_machine())) | ||
| if self.vcpkg_triplet is None: | ||
| raise ValueError(f"Could not determine vcpkg triplet for platform {sys_platform} and architecture {platform_machine()}") | ||
| if self.vcpkg and Path(self.vcpkg).exists(): | ||
| if not Path(self.vcpkg_root).exists(): | ||
| commands.append(f"git clone {self.vcpkg_repo} {self.vcpkg_root}") | ||
| commands.append( | ||
| f"./{self.vcpkg_root / 'bootstrap-vcpkg.sh' if sys_platform != 'win32' else self.vcpkg_root / 'sbootstrap-vcpkg.bat'}" | ||
| ) | ||
| commands.append(f"./{self.vcpkg_root / 'vcpkg'} install --triplet {self.vcpkg_triplet}") | ||
| return commands |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.