Skip to content

Commit

Permalink
Develop --> Main merge for 1.7.2 (#1840)
Browse files Browse the repository at this point in the history
* Fix typo in CMakePresets.json schema (#1809)

MinSizRel => MinSizeRel

* update version to 1.7.2

* Localize an error message

* Added counts for presets (#1819)

* override the locale when querying compiler versions (#1824)

* Adopt new localization process (#1831)

* Fix Operator Precedence when Getting Code Page (#1808)

The replacing should happen after the "??" operator.

Fixes #1615

Co-authored-by: Andreea Isac <48239328+andreeis@users.noreply.github.com>

* If we have both "-DCMAKE_GENERATOR:STRING=" and the generator from (#1753)

toolchain, prefre using "-DCMAKE_GENERATOR:STRING=", as
"-DCMAKE_GENERATOR:STRING=" can be defined by different cmake-variants.yaml

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>

Co-authored-by: Andreea Isac <48239328+andreeis@users.noreply.github.com>

* Use stricter type checks in presets expansion (#1818)

* Use stricter type checks in presets expansion

* Resolving comments

Co-authored-by: Andreea Isac <48239328+andreeis@users.noreply.github.com>

* Fix paths of target sources outside the workspace (#1816)

* Fix paths of target sources outside the workspace

For more details, see:
#1504

* Add test for source files outside of workspace root

Co-Authored-By: Elson Wei <elson.wei@gmail.com>

Co-authored-by: Elson Wei <elson.wei@gmail.com>
Co-authored-by: Bob Brown <bobbrow@users.noreply.github.com>

* CHANGELOG updates for 1.7.2 (#1837)

Co-authored-by: BlueC0re <bluec0re@users.noreply.github.com>
Co-authored-by: Bob Brown <bobbrow@users.noreply.github.com>
Co-authored-by: Bob Brown (DEVDIV) <bobbrow@microsoft.com>
Co-authored-by: xisui-MSFT <44103947+xisui-MSFT@users.noreply.github.com>
Co-authored-by: Colen Garoutte-Carson <49173979+Colengms@users.noreply.github.com>
Co-authored-by: Huang, Zhaoquan <zhaoquan2008@hotmail.com>
Co-authored-by: Yonggang Luo <luoyonggang@gmail.com>
Co-authored-by: Simon Leiner <sleiner@users.noreply.github.com>
Co-authored-by: Elson Wei <elson.wei@gmail.com>
  • Loading branch information
10 people authored May 6, 2021
1 parent 0a98967 commit d18f29f
Show file tree
Hide file tree
Showing 20 changed files with 301 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-vsix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ jobs:
with:
name: cmake-tools.vsix
path: ./cmake-tools.vsix
if-no-files-found: error
if-no-files-found: error
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# What's New?

## 1.7.2
Bug fixes:
- Fix paths of target sources outside the workspace. [#1504](https://github.com/microsoft/vscode-cmake-tools/issues/1504) [@sleiner](https://github.com/sleiner)
- Use stricter type checks in presets expansion. [#1815](https://github.com/microsoft/vscode-cmake-tools/issues/1815)
- Solve conflict between -DCMAKE_GENERAOR:STRING=Ninja versus -G "Visual Studio 16 2019" -A x64. [PR #1753](https://github.com/microsoft/vscode-cmake-tools/pull/1753) [@lygstate](https://github.com/lygstate)
- Fix operator precedence when getting code page. [#1615](https://github.com/microsoft/vscode-cmake-tools/issues/1615) [@taoyouh](https://github.com/taoyouh)
- Override the locale when querying compiler versions. [#1821](https://github.com/microsoft/vscode-cmake-tools/issues/1821)
- Fix typo in CMakePresets.json schema. [PR #1809](https://github.com/microsoft/vscode-cmake-tools/pull/1809) [@bluec0re](https://github.com/bluec0re)


## 1.7.1
Improvements:
- CppTools-API v5 integration. [#1624](https://github.com/microsoft/vscode-cmake-tools/issues/1624)
Expand Down
13 changes: 13 additions & 0 deletions jobs/loc/LocProject.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Projects": [
{
"LanguangeSet": "VS_Main_Languages",
"LocItems": [
{
"SourceFile": "vscode-extensions-localization-export\\vscode-extensions\\vscode-cmake-tools.xlf",
"Languages": "cs;de;es;fr;it;ja;ko;pl;pt-BR;ru;tr;zh-Hans;zh-Hant"
}
]
}
]
}
37 changes: 37 additions & 0 deletions jobs/loc/TranslationsExport.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# ==================================================================================
# Pipeline for VsCodeExtension-Localization build definition
# Runs OneLocBuild task to localize xlf file
# ==================================================================================

resources:
repositories:
- repository: self
clean: true

trigger: none
pr: none

pool:
vmImage: 'windows-latest'

steps:
- task: CmdLine@2
inputs:
script: 'yarn run translations-export'

- task: OneLocBuild@1
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
locProj: 'jobs/loc/LocProject.json'
outDir: '$(Build.ArtifactStagingDirectory)'
isCreatePrSelected: false
prSourceBranchPrefix: 'locfiles'
packageSourceAuth: 'patAuth'
patVariable: '$(OneLocBuildPat)'

- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
37 changes: 37 additions & 0 deletions jobs/loc/TranslationsImport.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# ==================================================================================
# Pipeline for VsCodeExtension-Localization build definition
# Gets translated files from VSCodeExt and creates a PR for vscode-cpptools
#
# Triggered only by daily schedule
# ==================================================================================

trigger: none
pr: none
schedules:
- cron: "0 7 * * *"
displayName: Daily 7 AM
branches:
include:
- main

pool:
vmImage: 'windows-latest'

steps:
- checkout: self
path: s/vscode-cmake-tools

- task: CmdLine@2
inputs:
script: 'git clone $(LocRepoUri) ..\VSCodeExt'
workingDirectory: '$(Build.SourcesDirectory)'

- task: CmdLine@2
inputs:
script: 'yarn install'
workingDirectory: '$(Build.SourcesDirectory)'

- task: CmdLine@2
inputs:
script: 'node ./translations_auto_pr.js microsoft vscode-cmake-tools cmake-tools csigs $(csigsPat) csigs csigs@users.noreply.github.com $(Build.SourcesDirectory)/../VSCodeExt'
workingDirectory: '$(Build.SourcesDirectory)'
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cmake-tools",
"displayName": "CMake Tools",
"description": "Extended CMake support in Visual Studio Code",
"version": "1.7.1",
"version": "1.7.2",
"publisher": "ms-vscode",
"repository": {
"type": "git",
Expand Down Expand Up @@ -79,7 +79,7 @@
"onCommand:cmake.outline.buildAll",
"workspaceContains:**/CMakeLists.txt",
"workspaceContains:.vscode/cmake-kits.json"
],
],
"main": "./dist/main",
"contributes": {
"commands": [
Expand Down Expand Up @@ -1807,7 +1807,7 @@
"default": true,
"description": "%cmake-tools.configuration.cmake.exportCompileCommandsFile.description%"
},
"cmake.useCMakePresets": {
"cmake.useCMakePresets": {
"type": "string",
"enum": [
"always",
Expand Down Expand Up @@ -1936,6 +1936,7 @@
"mocha": "^8.3.0",
"module-alias": "^2.2.2",
"node-loader": "^1.0.2",
"parse-git-config": "^3.0.0",
"sinon": "~9.2.4",
"ts-loader": "^8.0.17",
"ts-node": "^9.1.1",
Expand Down
4 changes: 2 additions & 2 deletions schemas/CMakePresets-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@
"Debug",
"Release",
"RelWithDebInfo",
"MinSizRel"
"MinSizeRel"
]
},
{
Expand Down Expand Up @@ -1060,4 +1060,4 @@
}
},
"additionalProperties": false
}
}
4 changes: 2 additions & 2 deletions src/code-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ async function _getWindowsCodePage(): Promise<string> {
log.error(localize('failed.to.execute', 'Failed to execute {0}', "chcp"), chcp_res.stderr);
return 'utf-8';
}
const numStr = chcp_res.stdout ?? ''.replace(/[^0-9]/ig, '');
const numStr = (chcp_res.stdout ?? '').replace(/[^0-9]/ig, '');
const cpNum = parseInt(numStr);
return getCodePageTable()[cpNum] || 'utf-8';
}
}
10 changes: 6 additions & 4 deletions src/drivers/cmakefileapi/api_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ function convertToAbsolutePath(input_path: string, base_path: string) {
return path.normalize(absolute_path);
}

function convertToExtCodeModelFileGroup(targetObject: index_api.CodeModelKind.TargetObject): CodeModelFileGroup[] {
function convertToExtCodeModelFileGroup(targetObject: index_api.CodeModelKind.TargetObject,
root_paths: index_api.CodeModelKind.PathInfo): CodeModelFileGroup[] {
const fileGroup: CodeModelFileGroup[] = !targetObject.compileGroups ? [] : targetObject.compileGroups.map(group => {
const compileFlags
= group.compileCommandFragments ? group.compileCommandFragments.map(frag => frag.fragment).join(' ') : '';
Expand All @@ -197,9 +198,10 @@ function convertToExtCodeModelFileGroup(targetObject: index_api.CodeModelKind.Ta
// Collection all without compilegroup like headers
const defaultIndex = fileGroup.push({sources: [], isGenerated: false} as CodeModelFileGroup) - 1;


const target_source_root = convertToAbsolutePath(targetObject.paths.source, root_paths.source);
targetObject.sources.forEach(sourcefile => {
const file_path = path.relative(targetObject.paths.source, sourcefile.path).replace('\\', '/');
const file_abs_path = convertToAbsolutePath(sourcefile.path, root_paths.source);
const file_path = path.relative(target_source_root, file_abs_path).replace('\\', '/');
if (sourcefile.compileGroupIndex !== undefined) {
fileGroup[sourcefile.compileGroupIndex].sources.push(file_path);
} else {
Expand All @@ -215,7 +217,7 @@ function convertToExtCodeModelFileGroup(targetObject: index_api.CodeModelKind.Ta
async function loadCodeModelTarget(root_paths: index_api.CodeModelKind.PathInfo, jsonfile: string) {
const targetObject = await loadTargetObject(jsonfile);

const fileGroups = convertToExtCodeModelFileGroup(targetObject);
const fileGroups = convertToExtCodeModelFileGroup(targetObject, root_paths);

// This implementation expects that there is only one sysroot in a target.
// The ServerAPI only has provided one sysroot. In the FileAPI,
Expand Down
8 changes: 7 additions & 1 deletion src/drivers/cmfileapi-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,13 @@ export class CMakeFileApiDriver extends codemodel.CodeModelDriver {
const bindir = util.lightNormalizePath(this.binaryDir);
args.push(`-B${bindir}`);
const gen = this.generator;
if (gen) {
let has_gen = false;
for (const arg of args) {
if (arg.startsWith("-DCMAKE_GENERATOR:STRING=")) {
has_gen = true;
}
}
if (!has_gen && gen) {
args.push('-G');
args.push(gen.name);
if (gen.toolset) {
Expand Down
30 changes: 30 additions & 0 deletions src/drivers/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,16 @@ export abstract class CMakeDriver implements vscode.Disposable {
return {name: allowedCompilerName, version};
}

private countHiddenPresets(presets: preset.Preset[]): number {
let count = 0;
for (const p of presets) {
if (p.hidden) {
count++;
}
}
return count;
}

async configure(trigger: ConfigureTrigger, extra_args: string[], consumer?: proc.OutputConsumer, withoutCmakeSettings:boolean = false): Promise<number> {
if (this.configRunning) {
await this.preconditionHandler(CMakePreconditionProblems.ConfigureIsAlreadyRunning);
Expand Down Expand Up @@ -1152,6 +1162,26 @@ export abstract class CMakeDriver implements vscode.Disposable {
const telemetryMeasures: telemetry.Measures = {
Duration: timeEnd - timeStart,
};
if (this.useCMakePresets && this.workspaceFolder) {
const configurePresets = preset.configurePresets(this.workspaceFolder);
const userConfigurePresets = preset.userConfigurePresets(this.workspaceFolder);
const buildPresets = preset.buildPresets(this.workspaceFolder);
const userBuildPresets = preset.userBuildPresets(this.workspaceFolder);
const testPresets = preset.testPresets(this.workspaceFolder);
const userTestPresets = preset.userTestPresets(this.workspaceFolder);
telemetryMeasures['ConfigurePresets'] = configurePresets.length;
telemetryMeasures['HiddenConfigurePresets'] = this.countHiddenPresets(configurePresets);
telemetryMeasures['UserConfigurePresets'] = userConfigurePresets.length;
telemetryMeasures['HiddenUserConfigurePresets'] = this.countHiddenPresets(userConfigurePresets);
telemetryMeasures['BuildPresets'] = buildPresets.length;
telemetryMeasures['HiddenBuildPresets'] = this.countHiddenPresets(buildPresets);
telemetryMeasures['UserBuildPresets'] = userBuildPresets.length;
telemetryMeasures['HiddenUserBuildPresets'] = this.countHiddenPresets(userBuildPresets);
telemetryMeasures['TestPresets'] = testPresets.length;
telemetryMeasures['HiddenTestPresets'] = this.countHiddenPresets(testPresets);
telemetryMeasures['UserTestPresets'] = userTestPresets.length;
telemetryMeasures['HiddenUserTestPresets'] = this.countHiddenPresets(userTestPresets);
}
if (consumer) {
if (consumer instanceof CMakeOutputConsumer) {
let errorCount: number = 0;
Expand Down
22 changes: 7 additions & 15 deletions src/kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,26 +153,18 @@ interface CompilerVersion {

export async function getCompilerVersion(vendor: CompilerVendorEnum, binPath: string): Promise<CompilerVersion|null> {
log.debug(localize('testing.compiler.binary', 'Testing {0} binary: {1}', vendor, binPath));
const exec = await proc.execute(binPath, ['-v']).result;
const exec = await proc.execute(binPath, ['-v'], undefined, { overrideLocale: true }).result;
if (exec.retc !== 0) {
log.debug(localize('bad.compiler.binary', 'Bad {0} binary ("-v" returns non-zero): {1}', vendor, binPath));
return null;
}
let version_re_loc: RegExp;
let version_re_en: RegExp;
const versionWord: string = localize("version.word", "version");
let version_re: RegExp;
let version_match_index;
if (vendor === 'Clang') {
const version_re_str_loc: string = `^(?:Apple LLVM|.*clang) ${versionWord} ([^\\s-]+)(?:[\\s-]|$)`;
const version_re_str_en: string = `^(?:Apple LLVM|.*clang) version ([^\\s-]+)(?:[\\s-]|$)`;
version_re_loc = RegExp(version_re_str_loc, "mgi");
version_re_en = RegExp(version_re_str_en, "mgi");
version_re = /^(?:Apple LLVM|.*clang) version ([^\s-]+)(?:[\s-]|$)/mgi;
version_match_index = 1;
} else {
const version_re_str_loc: string = `^gcc(-| )${versionWord} (.*?) .*`;
const version_re_str_en: string = `^gcc(-| )version (.*?) .*`;
version_re_loc = RegExp(version_re_str_loc, "mgi");
version_re_en = RegExp(version_re_str_en, "mgi");
version_re = /^gcc(-| )version (.*?) .*/mgi;
version_match_index = 2;
}

Expand All @@ -181,7 +173,7 @@ export async function getCompilerVersion(vendor: CompilerVendorEnum, binPath: st
let fullVersion: string = "";
const lines = exec.stderr.trim().split('\n');
for (const line of lines) {
const version_match = version_re_en.exec(line) || version_re_loc.exec(line);
const version_match = version_re.exec(line);
if (version_match !== null && version === '') {
version = version_match[version_match_index];
fullVersion = line;
Expand Down Expand Up @@ -940,7 +932,7 @@ async function scanDirForClangForMSVCKits(dir: string, vsInstalls: VSInstallatio
// Clang for MSVC ABI with GNU CLI (command line interface) is supported in CMake 3.15.0+
if (isClangGNUCLI) {
if (undefined === cmakeTools) {
log.error("failed.to.scan.for.kits", "Failed to scan for kits:", "cmakeTools is undefined");
log.error(localize("failed.to.scan.for.kits", "Failed to scan for kits: cmakeTools is undefined"));

return null;
} else {
Expand All @@ -965,7 +957,7 @@ async function scanDirForClangForMSVCKits(dir: string, vsInstalls: VSInstallatio

const clangArch = (vs_arch === "amd64") ? "x64\\" : "";
if (binPath.startsWith(`${vs.installationPath}\\VC\\Tools\\Llvm\\${clangArch}bin`) &&
util.checkFileExists(util.lightNormalizePath(binPath))) {
util.checkFileExists(util.lightNormalizePath(binPath))) {
clangKits.push({
name: `Clang ${version.version} ${clang_cli} (${install_name} - ${vs_arch})`,
visualStudio: kitVSName(vs),
Expand Down
13 changes: 8 additions & 5 deletions src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export interface ConfigurePreset extends Preset {
toolset?: string | ValueStrategy;
binaryDir?: string;
cmakeExecutable?: string;
cacheVariables?: { [key: string]: CacheVarType };
// Make the cache value to be possibly undefined for type checking
cacheVariables?: { [key: string]: CacheVarType | undefined };
warnings?: WarningOptions;
errors?: ErrorOptions;
debug?: DebugOptions;
Expand Down Expand Up @@ -369,7 +370,7 @@ function getVendorForConfigurePresetHelper(folder: string, preset: ConfigurePres
const parentVendor = getVendorForConfigurePresetImpl(folder, parent, allowUserPreset);
if (parentVendor) {
for (const key in parentVendor) {
if (!preset.vendor[key]) {
if (preset.vendor[key] === undefined) {
preset.vendor[key] = parentVendor[key];
}
}
Expand Down Expand Up @@ -448,7 +449,9 @@ export async function expandConfigurePreset(folder: string,
expandedPreset.cacheVariables = { };
for (const cacheVarName in preset.cacheVariables) {
const cacheVar = preset.cacheVariables[cacheVarName];
if (cacheVar && typeof cacheVar !== 'boolean') {
if (typeof cacheVar === 'boolean') {
expandedPreset.cacheVariables[cacheVarName] = cacheVar;
} else if (cacheVar) {
if (util.isString(cacheVar)) {
expandedPreset.cacheVariables[cacheVarName] = await expandString(cacheVar, expansionOpts);
} else if (util.isString(cacheVar.value)) {
Expand Down Expand Up @@ -527,7 +530,7 @@ async function expandConfigurePresetHelper(folder: string,
inheritedEnv = util.mergeEnvironment(parent.environment! as EnvironmentVariables, inheritedEnv as EnvironmentVariables);
// Inherit cache vars
for (const name in parent.cacheVariables) {
if (!preset.cacheVariables[name]) {
if (preset.cacheVariables[name] === undefined) {
preset.cacheVariables[name] = parent.cacheVariables[name];
}
}
Expand All @@ -550,7 +553,7 @@ async function expandConfigurePresetHelper(folder: string,
// [Windows Only] If CMAKE_CXX_COMPILER or CMAKE_C_COMPILER is set as 'cl' or 'cl.exe', but they are not on PATH,
// then set the env automatically
if (process.platform === 'win32') {
const getStringValueFromCacheVar = (variable: CacheVarType) => {
const getStringValueFromCacheVar = (variable?: CacheVarType) => {
if (util.isString(variable)) {
return variable;
} else if (variable && typeof variable === 'object') {
Expand Down
11 changes: 10 additions & 1 deletion src/proc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export interface ExecutionOptions {
encoding?: BufferEncoding;
outputEncoding?: string;
useTask?: boolean;
overrideLocale?: boolean;
}

export function buildCmdStr(command: string, args?: string[]): string {
Expand Down Expand Up @@ -114,7 +115,15 @@ export function execute(command: string,
if (!options) {
options = {};
}
const final_env = util.mergeEnvironment(process.env as EnvironmentVariables, options.environment || {});
const localeOverride: EnvironmentVariables = {
LANG: "C",
LC_ALL: "C"
};
const final_env = util.mergeEnvironment(
process.env as EnvironmentVariables,
options.environment || {},
options.overrideLocale ? localeOverride : {});

const spawn_opts: proc.SpawnOptions = {
env: final_env,
shell: !!options.shell,
Expand Down
Loading

0 comments on commit d18f29f

Please sign in to comment.