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

Allow redirection of the downloads folder with an environment variable. #4883

Merged
merged 7 commits into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

Vcpkg helps you manage C and C++ libraries on Windows, Linux and MacOS. This tool and ecosystem are constantly evolving; your involvement are vital to its success!

- [Installing and Using Packages Example: sqlite](examples/installing-and-using-packages.md)

### Examples

- [Installing and Using Packages Example: sqlite](examples/installing-and-using-packages.md)
Expand All @@ -15,6 +13,7 @@ Vcpkg helps you manage C and C++ libraries on Windows, Linux and MacOS. This too

- [Integration with build systems](users/integration.md)
- [Triplet files](users/triplets.md)
- [Configuration and Environment](users/config-environment.md)

### Maintainer help

Expand All @@ -24,6 +23,7 @@ Vcpkg helps you manage C and C++ libraries on Windows, Linux and MacOS. This too
### Specifications

- [Export](specifications/export-command.md)
- [Feature Packages](specifications/feature-packages.md)

### Blog posts
- [Announcing a single C++ library manager for Linux, macOS and Windows: Vcpkg](https://blogs.msdn.microsoft.com/vcblog/2018/04/24/announcing-a-single-c-library-manager-for-linux-macos-and-windows-vcpkg/)
Expand Down
41 changes: 22 additions & 19 deletions docs/users/triplets.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,6 @@ Valid options include any CMake system name, such as:
- `Darwin` (Mac OSX)
- `Linux` (Linux)

### VCPKG_PLATFORM_TOOLSET
Specifies the VS-based C/C++ compiler toolchain to use.

This can be set to `v141`, `v140`, or left blank. If left blank, we select the latest compiler toolset available on your machine.

Visual Studio 2015 platform toolset is `v140`
Visual Studio 2017 platform toolset is `v141`

### VCPKG_VISUAL_STUDIO_PATH
Specifies the Visual Studio installation to use.

When unspecified, a Visual Studio instance is selected automatically, preferring Stable 2017, then Preview 2017, then 2015.

The path should be absolute, formatted with backslashes, and have no trailing slash:
```cmake
set(VCPKG_VISUAL_STUDIO_PATH "C:\\Program Files (x86)\\Microsoft Visual Studio\\Preview\\Community")
```

### VCPKG_CHAINLOAD_TOOLCHAIN_FILE
Specifies an alternate CMake Toolchain file to use.

Expand All @@ -69,7 +51,28 @@ This option also has forms for configuration-specific and C flags:
- `VCPKG_C_FLAGS_DEBUG`
- `VCPKG_C_FLAGS_RELEASE`

## macOS Variables
## Windows Variables

### VCPKG_PLATFORM_TOOLSET
Specifies the VS-based C/C++ compiler toolchain to use.

This can be set to `v141`, `v140`, or left blank. If left blank, we select the latest compiler toolset available on your machine.

Visual Studio 2015 platform toolset is `v140`
Visual Studio 2017 platform toolset is `v141`

<a name="VCPKG_VISUAL_STUDIO_PATH"></a>
### VCPKG_VISUAL_STUDIO_PATH
Specifies the Visual Studio installation to use.

When unspecified, a Visual Studio instance is selected automatically, preferring Stable 2017, then Preview 2017, then 2015.

The path should be absolute, formatted with backslashes, and have no trailing slash:
```cmake
set(VCPKG_VISUAL_STUDIO_PATH "C:\\Program Files (x86)\\Microsoft Visual Studio\\Preview\\Community")
```

## MacOS Variables

### VCPKG_INSTALL_NAME_DIR
Sets the install name used when building macOS dynamic libraries. Default value is `@rpath`. See the CMake documentation for [CMAKE_INSTALL_NAME_DIR](https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_NAME_DIR.html) for more information.
Expand Down
11 changes: 10 additions & 1 deletion scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@ while [ "$vcpkgRootDir" != "/" ] && ! [ -e "$vcpkgRootDir/.vcpkg-root" ]; do
vcpkgRootDir="$(dirname "$vcpkgRootDir")"
done

downloadsDir="$vcpkgRootDir/downloads"
if [ -z ${VCPKG_DOWNLOADS+x} ]; then
downloadsDir="$vcpkgRootDir/downloads"
else
downloadsDir="$VCPKG_DOWNLOADS"
if [ ! -d "$VCPKG_DOWNLOADS" ]; then
echo "VCPKG_DOWNLOADS was set to '$VCPKG_DOWNLOADS', but that was not a directory."
exit 1
fi

fi

extractStringBetweenDelimiters()
{
Expand Down
3 changes: 2 additions & 1 deletion toolsrc/src/vcpkg/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ namespace vcpkg::Build
{"TARGET_TRIPLET", spec.triplet().canonical_name()},
{"VCPKG_PLATFORM_TOOLSET", toolset.version.c_str()},
{"VCPKG_USE_HEAD_VERSION",
Util::Enum::to_bool(config.build_package_options.use_head_version) ? "1" : "0"},
Util::Enum::to_bool(config.build_package_options.use_head_version) ? "1" : "0"},
{"DOWNLOADS", paths.downloads},
{"_VCPKG_NO_DOWNLOADS", !Util::Enum::to_bool(config.build_package_options.allow_downloads) ? "1" : "0"},
{"_VCPKG_DOWNLOAD_TOOL", to_string(config.build_package_options.download_tool)},
{"GIT", git_exe_path},
Expand Down
27 changes: 26 additions & 1 deletion toolsrc/src/vcpkg/vcpkgpaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,32 @@ namespace vcpkg

paths.packages = paths.root / "packages";
paths.buildtrees = paths.root / "buildtrees";
paths.downloads = paths.root / "downloads";

const auto overriddenDownloadsPath = System::get_environment_variable("VCPKG_DOWNLOADS");
if (auto odp = overriddenDownloadsPath.get())
{
auto asPath = fs::u8path(*odp);
if (!fs::stdfs::is_directory(asPath))
{
Metrics::g_metrics.lock()->track_property("error", "Invalid VCPKG_DOWNLOADS override directory.");
Checks::exit_with_message(
VCPKG_LINE_INFO,
"Invalid downloads override directory: %s; "
"create that directory or unset VCPKG_DOWNLOADS to use the default downloads location.",
asPath.u8string());
}

paths.downloads = fs::stdfs::canonical(std::move(asPath), ec);
if (ec)
{
return ec;
}
}
else
{
paths.downloads = paths.root / "downloads";
}

paths.ports = paths.root / "ports";
paths.installed = paths.root / "installed";
paths.triplets = paths.root / "triplets";
Expand Down