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

Support usage of environment variables for toolchainFile in kits #626

Closed
wants to merge 3 commits into from

Conversation

blakehurd
Copy link

This changes kit handling to support environment variables (${SOME_ENV_VAR} pattern) for toolchainFile setting

The following changes are proposed:

  • Add a processKit method to post-process kits from the .json spec
  • Leverage processKit method to resolve environment variables used for the toolchainFile setting.
  • Add unit test to ensure it works.

The purpose of this change

Scratching one of my itches using this extension. I wanted to use an env var to specify where my vcpkg toolchain is installed, rather than hardcode it. This does what I want, but feel free to suggest a better way if you can think of one.

@rcdailey
Copy link

Why has this not been reviewed yet? I think this is a major issue. Android's NDK includes a CMake toolchain file with it, but all developers install the NDK to different locations. Hence it's important to be able to do something like this:

"toolchainFile": "${env:ANDROID_NDK}/cmake/android.toolchain.cmake",

@vector-of-bool Can you provide some feedback?

export function processKit(kit: Kit) {
if (kit.toolchainFile) {
// map ${foo} -> process.env[foo] to resolve corresponding environment variables
kit.toolchainFile = kit.toolchainFile.replace(/\$\{(\w+)\}/, (_str: string, p1: string, ..._args) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you checked whether case sensitivity is an issue here?
This here might be useful: https://github.com/vector-of-bool/vscode-cmake-tools/blob/develop/src/expand.ts

@bobbrow bobbrow requested review from itodirel and a team August 10, 2019 05:16
@bobbrow bobbrow added this to the 1.2.0 milestone Aug 10, 2019
@bobbrow bobbrow modified the milestones: 1.2.0, On Deck Sep 23, 2019
@bobbrow
Copy link
Member

bobbrow commented Dec 30, 2019

This PR was replaced by #991.

@bobbrow bobbrow closed this Dec 30, 2019
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants