Add triplet IntelliSense modes to support cross-compilation (#6745)

This commit is contained in:
Michelle Matias 2021-01-13 15:05:30 -08:00 коммит произвёл GitHub
Родитель 1bf090238d
Коммит 46e6b87d13
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
40 изменённых файлов: 426 добавлений и 97 удалений

33
Extension/bin/common.json Normal file
Просмотреть файл

@ -0,0 +1,33 @@
{
"defaults": [
"cpfe",
"--wchar_t_keyword",
"--no_warnings",
"--rtti",
"--edge",
"--exceptions",
"--error_limit",
"25000",
"-D_EDG_COMPILER",
"-D_USE_DECLSPECS_FOR_SAL=1"
],
"source_file_format": "-f %s",
"expressions": [
{
"match": "^/I(.*)",
"replace": "-I\n$1"
},
{
"match": "^/D(.*)",
"replace": "-D$1"
},
{
"match": "^/AI(.*)",
"replace": "--using_directory\n$1"
},
{
"match": "^/dE--header_only_fallback",
"replace": "--header_only_fallback"
}
]
}

Просмотреть файл

@ -0,0 +1,15 @@
{
"defaults": [
"--pack_alignment",
"8",
"-Dunix=1",
"-D__unix__=1",
"-D__linux__=1",
"-D__arm__=1",
"-D__ARM_32BIT_STATE=1",
"-D__PTRDIFF_TYPE__=int",
"-D__SIZE_TYPE__=unsigned int",
"-D__WCHAR_TYPE__=long int"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -0,0 +1,15 @@
{
"defaults": [
"--pack_alignment",
"8",
"-Dunix=1",
"-D__unix__=1",
"-D__linux__=1",
"-D__aarch64__=1",
"-D__ARM_64BIT_STATE=1",
"-D__PTRDIFF_TYPE__=long int",
"-D__SIZE_TYPE__=long unsigned int",
"-D__WCHAR_TYPE__=int"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -0,0 +1,15 @@
{
"defaults": [
"--pack_alignment",
"8",
"-Dunix=1",
"-D__unix__=1",
"-D__linux__=1",
"-D__x86_64=1",
"-D__x86_64__=1",
"-D__PTRDIFF_TYPE__=long int",
"-D__SIZE_TYPE__=long unsigned int",
"-D__WCHAR_TYPE__=int"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -0,0 +1,15 @@
{
"defaults": [
"--pack_alignment",
"8",
"-Dunix=1",
"-D__unix__=1",
"-D__linux__=1",
"-D__i386=1",
"-D__i386__=1",
"-D__PTRDIFF_TYPE__=int",
"-D__SIZE_TYPE__=unsigned int",
"-D__WCHAR_TYPE__=long int"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -0,0 +1,15 @@
{
"defaults": [
"--pack_alignment",
"8",
"-Dunix=1",
"-D__unix__=1",
"-D__linux__=1",
"-D__arm__=1",
"-D__ARM_32BIT_STATE=1",
"-D__PTRDIFF_TYPE__=int",
"-D__SIZE_TYPE__=unsigned int",
"-D__WCHAR_TYPE__=long int"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -0,0 +1,15 @@
{
"defaults": [
"--pack_alignment",
"8",
"-Dunix=1",
"-D__unix__=1",
"-D__linux__=1",
"-D__aarch64__=1",
"-D__ARM_64BIT_STATE=1",
"-D__PTRDIFF_TYPE__=long int",
"-D__SIZE_TYPE__=long unsigned int",
"-D__WCHAR_TYPE__=int"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -0,0 +1,15 @@
{
"defaults": [
"--pack_alignment",
"8",
"-Dunix=1",
"-D__unix__=1",
"-D__linux__=1",
"-D__x86_64=1",
"-D__x86_64__=1",
"-D__PTRDIFF_TYPE__=long int",
"-D__SIZE_TYPE__=long unsigned int",
"-D__WCHAR_TYPE__=int"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -0,0 +1,15 @@
{
"defaults": [
"--pack_alignment",
"8",
"-Dunix=1",
"-D__unix__=1",
"-D__linux__=1",
"-D__i386=1",
"-D__i386__=1",
"-D__PTRDIFF_TYPE__=int",
"-D__SIZE_TYPE__=unsigned int",
"-D__WCHAR_TYPE__=long int"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -0,0 +1,14 @@
{
"defaults": [
"--pack_alignment",
"8",
"-D__APPLE__=1",
"-D__MACH__=1",
"-D__arm__=1",
"-D__ARM_32BIT_STATE=1",
"-D__PTRDIFF_TYPE__=int",
"-D__SIZE_TYPE__=unsigned int",
"-D__WCHAR_TYPE__=long int"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -0,0 +1,14 @@
{
"defaults": [
"--pack_alignment",
"8",
"-D__APPLE__=1",
"-D__MACH__=1",
"-D__aarch64__=1",
"-D__ARM_64BIT_STATE=1",
"-D__PTRDIFF_TYPE__=long int",
"-D__SIZE_TYPE__=long unsigned int",
"-D__WCHAR_TYPE__=int"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -0,0 +1,14 @@
{
"defaults": [
"--pack_alignment",
"8",
"-D__APPLE__=1",
"-D__MACH__=1",
"-D__x86_64=1",
"-D__x86_64__=1",
"-D__PTRDIFF_TYPE__=long int",
"-D__SIZE_TYPE__=long unsigned int",
"-D__WCHAR_TYPE__=int"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -0,0 +1,14 @@
{
"defaults": [
"--pack_alignment",
"8",
"-D__APPLE__=1",
"-D__MACH__=1",
"-D__i386=1",
"-D__i386__=1",
"-D__PTRDIFF_TYPE__=int",
"-D__SIZE_TYPE__=unsigned int",
"-D__WCHAR_TYPE__=long int"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -0,0 +1,14 @@
{
"defaults": [
"--pack_alignment",
"8",
"-D__APPLE__=1",
"-D__MACH__=1",
"-D__arm__=1",
"-D__ARM_32BIT_STATE=1",
"-D__PTRDIFF_TYPE__=int",
"-D__SIZE_TYPE__=unsigned int",
"-D__WCHAR_TYPE__=long int"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -0,0 +1,14 @@
{
"defaults": [
"--pack_alignment",
"8",
"-D__APPLE__=1",
"-D__MACH__=1",
"-D__aarch64__=1",
"-D__ARM_64BIT_STATE=1",
"-D__PTRDIFF_TYPE__=long int",
"-D__SIZE_TYPE__=long unsigned int",
"-D__WCHAR_TYPE__=int"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -0,0 +1,14 @@
{
"defaults": [
"--pack_alignment",
"8",
"-D__APPLE__=1",
"-D__MACH__=1",
"-D__x86_64=1",
"-D__x86_64__=1",
"-D__PTRDIFF_TYPE__=long int",
"-D__SIZE_TYPE__=long unsigned int",
"-D__WCHAR_TYPE__=int"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -0,0 +1,14 @@
{
"defaults": [
"--pack_alignment",
"8",
"-D__APPLE__=1",
"-D__MACH__=1",
"-D__i386=1",
"-D__i386__=1",
"-D__PTRDIFF_TYPE__=int",
"-D__SIZE_TYPE__=unsigned int",
"-D__WCHAR_TYPE__=long int"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -1,33 +0,0 @@
{
"defaults": [
"cpfe",
"--wchar_t_keyword",
"--no_warnings",
"--rtti",
"--edge",
"--exceptions",
"--error_limit",
"25000",
"-D_EDG_COMPILER",
"-D_USE_DECLSPECS_FOR_SAL=1"
],
"source_file_format": "-f %s",
"expressions": [
{
"match": "^/I(.*)",
"replace": "-I\n$1"
},
{
"match": "^/D(.*)",
"replace": "-D$1"
},
{
"match": "^/AI(.*)",
"replace": "--using_directory\n$1"
},
{
"match": "^/dE--header_only_fallback",
"replace": "--header_only_fallback"
}
]
}

Просмотреть файл

@ -1,7 +0,0 @@
{
"defaults": [
"--pack_alignment",
"8"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -1,7 +0,0 @@
{
"defaults": [
"--pack_alignment",
"8"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -1,7 +0,0 @@
{
"defaults": [
"--pack_alignment",
"8"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -1,7 +0,0 @@
{
"defaults": [
"--pack_alignment",
"8"
],
"defaults_op" : "merge"
}

Просмотреть файл

@ -0,0 +1,7 @@
{
"defaults": [
"--pack_alignment",
"8"
],
"defaults_op": "merge"
}

Просмотреть файл

@ -0,0 +1,7 @@
{
"defaults": [
"--pack_alignment",
"8"
],
"defaults_op": "merge"
}

Просмотреть файл

Просмотреть файл

@ -0,0 +1,7 @@
{
"defaults": [
"--pack_alignment",
"8"
],
"defaults_op": "merge"
}

Просмотреть файл

@ -0,0 +1,7 @@
{
"defaults": [
"--pack_alignment",
"8"
],
"defaults_op": "merge"
}

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -90,9 +90,37 @@
}
},
"intelliSenseMode": {
"description": "The IntelliSense mode to use that maps to an architecture-specific variant of MSVC, gcc, or Clang. If not set or if set to ${default}, the extension will choose the default for that platform. Windows defaults to msvc-x64, Linux defaults to gcc-x64, and macOS defaults to clang-x64.",
"description": "The IntelliSense mode to use that maps to a platform and architecture variant of MSVC, gcc, or Clang. If not set or if set to ${default}, the extension will choose the default for that platform. Windows defaults to windows-msvc-x64, Linux defaults to linux-gcc-x64, and macOS defaults to macos-clang-x64.",
"type": "string",
"enum": [
"macos-clang-x86",
"macos-clang-x64",
"macos-clang-arm",
"macos-clang-arm64",
"macos-gcc-x86",
"macos-gcc-x64",
"macos-gcc-arm",
"macos-gcc-arm64",
"linux-clang-x86",
"linux-clang-x64",
"linux-clang-arm",
"linux-clang-arm64",
"linux-gcc-x86",
"linux-gcc-x64",
"linux-gcc-arm",
"linux-gcc-arm64",
"windows-clang-x86",
"windows-clang-x64",
"windows-clang-arm",
"windows-clang-arm64",
"windows-gcc-x86",
"windows-gcc-x64",
"windows-gcc-arm",
"windows-gcc-arm64",
"windows-msvc-x86",
"windows-msvc-x64",
"windows-msvc-arm",
"windows-msvc-arm64",
"clang-x86",
"clang-x64",
"clang-arm",

Просмотреть файл

@ -927,6 +927,34 @@
"type": "string",
"enum": [
"",
"macos-clang-x86",
"macos-clang-x64",
"macos-clang-arm",
"macos-clang-arm64",
"macos-gcc-x86",
"macos-gcc-x64",
"macos-gcc-arm",
"macos-gcc-arm64",
"linux-clang-x86",
"linux-clang-x64",
"linux-clang-arm",
"linux-clang-arm64",
"linux-gcc-x86",
"linux-gcc-x64",
"linux-gcc-arm",
"linux-gcc-arm64",
"windows-clang-x86",
"windows-clang-x64",
"windows-clang-arm",
"windows-clang-arm64",
"windows-gcc-x86",
"windows-gcc-x64",
"windows-gcc-arm",
"windows-gcc-arm64",
"windows-msvc-x86",
"windows-msvc-x64",
"windows-msvc-arm",
"windows-msvc-arm64",
"clang-x86",
"clang-x64",
"clang-arm",

Просмотреть файл

@ -440,10 +440,7 @@ export class CppProperties {
const resolvedCompilerPath: string = this.resolvePath(configuration.compilerPath, true);
const compilerPathAndArgs: util.CompilerPathAndArgs = util.extractCompilerPathAndArgs(resolvedCompilerPath);
// Valid compiler + IntelliSenseMode combinations:
// 1. compiler is cl/clang-cl and IntelliSenseMode is MSVC
// 2. compiler is not cl/clang-cl and IntelliSenseMode is not MSVC
const isValid: boolean = compilerPathAndArgs.compilerName.endsWith("cl.exe") === configuration.intelliSenseMode.startsWith("msvc");
const isValid: boolean = (compilerPathAndArgs.compilerName.toLowerCase() === "cl.exe") === configuration.intelliSenseMode.includes("msvc");
if (isValid) {
return "";
} else {
@ -1153,7 +1150,7 @@ export class CppProperties {
const compilerPathAndArgs: util.CompilerPathAndArgs = util.extractCompilerPathAndArgs(resolvedCompilerPath);
if (resolvedCompilerPath &&
// Don't error cl.exe paths because it could be for an older preview build.
!(isWindows && compilerPathAndArgs.compilerName === "cl.exe")) {
compilerPathAndArgs.compilerName.toLowerCase() !== "cl.exe") {
resolvedCompilerPath = resolvedCompilerPath.trim();
// Error when the compiler's path has spaces without quotes but args are used.
@ -1443,7 +1440,7 @@ export class CppProperties {
if (isCompilerPath) {
resolvedPath = resolvedPath.trim();
const compilerPathAndArgs: util.CompilerPathAndArgs = util.extractCompilerPathAndArgs(resolvedPath);
if (isWindows && compilerPathAndArgs.compilerName === "cl.exe") {
if (compilerPathAndArgs.compilerName.toLowerCase() === "cl.exe") {
continue; // Don't squiggle invalid cl.exe paths because it could be for an older preview build.
}
if (compilerPathAndArgs.compilerPath === undefined) {

Просмотреть файл

@ -154,7 +154,7 @@ export class CppBuildTaskProvider implements TaskProvider {
private getTask: (compilerPath: string, appendSourceToName: boolean, compilerArgs?: string[], definition?: CppBuildTaskDefinition, detail?: string) => Task = (compilerPath: string, appendSourceToName: boolean, compilerArgs?: string[], definition?: CppBuildTaskDefinition, detail?: string) => {
const compilerPathBase: string = path.basename(compilerPath);
const isCl: boolean = compilerPathBase === "cl.exe";
const isCl: boolean = compilerPathBase.toLowerCase() === "cl.exe";
// Double-quote the command if it is not already double-quoted.
let resolvedcompilerPath: string = isCl ? compilerPathBase : compilerPath;
if (resolvedcompilerPath && !resolvedcompilerPath.startsWith("\"") && resolvedcompilerPath.includes(" ")) {

Просмотреть файл

@ -544,19 +544,35 @@ export async function checkInstallBinariesExist(): Promise<boolean> {
export async function checkInstallJsonsExist(): Promise<boolean> {
let installJsonsExist: boolean = true;
const jsonFiles: string[] = [
"bin/msvc.arm32.clang.json",
"bin/msvc.arm32.gcc.json",
"bin/msvc.arm32.msvc.json",
"bin/msvc.arm64.clang.json",
"bin/msvc.arm64.gcc.json",
"bin/msvc.arm64.msvc.json",
"bin/msvc.json",
"bin/msvc.x64.clang.json",
"bin/msvc.x64.gcc.json",
"bin/msvc.x64.msvc.json",
"bin/msvc.x86.clang.json",
"bin/msvc.x86.gcc.json",
"bin/msvc.x86.msvc.json",
"bin/common.json",
"bin/linux.clang.arm.json",
"bin/linux.clang.arm64.json",
"bin/linux.clang.x64.json",
"bin/linux.clang.x86.json",
"bin/linux.gcc.arm.json",
"bin/linux.gcc.arm64.json",
"bin/linux.gcc.x64.json",
"bin/linux.gcc.x86.json",
"bin/macos.clang.arm.json",
"bin/macos.clang.arm64.json",
"bin/macos.clang.x64.json",
"bin/macos.clang.x86.json",
"bin/macos.gcc.arm.json",
"bin/macos.gcc.arm64.json",
"bin/macos.gcc.x64.json",
"bin/macos.gcc.x86.json",
"bin/windows.clang.arm.json",
"bin/windows.clang.arm64.json",
"bin/windows.clang.x64.json",
"bin/windows.clang.x86.json",
"bin/windows.gcc.arm.json",
"bin/windows.gcc.arm64.json",
"bin/windows.gcc.x64.json",
"bin/windows.gcc.x86.json",
"bin/windows.msvc.arm.json",
"bin/windows.msvc.arm64.json",
"bin/windows.msvc.x64.json",
"bin/windows.msvc.x86.json",
"debugAdapters/bin/cppdbg.ad7Engine.json"
];
await Promise.all(jsonFiles.map(async (file) => {
@ -897,6 +913,7 @@ export function downloadFileToStr(urlStr: string, headers?: OutgoingHttpHeaders)
});
}
/** CompilerPathAndArgs retains original casing of text input for compiler path and args */
export interface CompilerPathAndArgs {
compilerPath?: string;
compilerName: string;
@ -952,14 +969,13 @@ function extractArgs(argsString: string): string[] {
export function extractCompilerPathAndArgs(inputCompilerPath?: string, inputCompilerArgs?: string[]): CompilerPathAndArgs {
let compilerPath: string | undefined = inputCompilerPath;
const compilerPathLowercase: string | undefined = inputCompilerPath?.toLowerCase();
let compilerName: string = "";
let additionalArgs: string[] = [];
const isWindows: boolean = os.platform() === 'win32';
if (compilerPath) {
if (compilerPath.endsWith("\\cl.exe") || compilerPath.endsWith("/cl.exe") || compilerPath === "cl.exe") {
// Input is only compiler name, this is only for cl.exe
compilerName = path.basename(compilerPath);
if (compilerPath) {
if (compilerPathLowercase?.endsWith("\\cl.exe") || compilerPathLowercase?.endsWith("/cl.exe") || (compilerPathLowercase === "cl.exe")) {
compilerName = path.basename(compilerPath);
} else if (compilerPath.startsWith("\"")) {
// Input has quotes around compiler path
const endQuote: number = compilerPath.substr(1).search("\"") + 1;
@ -969,12 +985,16 @@ export function extractCompilerPathAndArgs(inputCompilerPath?: string, inputComp
compilerName = path.basename(compilerPath);
}
} else {
// Input has no quotes but can have a compiler path with spaces and args.
// Go from right to left checking if a valid path is to the left of a space.
// Input has no quotes around compiler path
let spaceStart: number = compilerPath.lastIndexOf(" ");
if (spaceStart !== -1 && (!isWindows || !compilerPath.endsWith("cl.exe")) && !checkFileExistsSync(compilerPath)) {
if (checkFileExistsSync(compilerPath)) {
// Get compiler name if there are no args but path is valid.
compilerName = path.basename(compilerPath);
} else if (spaceStart !== -1 && !checkFileExistsSync(compilerPath)) {
// Get compiler name if compiler path has spaces and args.
// Go from right to left checking if a valid path is to the left of a space.
let potentialCompilerPath: string = compilerPath.substr(0, spaceStart);
while ((!isWindows || !potentialCompilerPath.endsWith("cl.exe")) && !checkFileExistsSync(potentialCompilerPath)) {
while (!checkFileExistsSync(potentialCompilerPath)) {
spaceStart = potentialCompilerPath.lastIndexOf(" ");
if (spaceStart === -1) {
// Reached the start without finding a valid path. Use the original value.
@ -987,12 +1007,8 @@ export function extractCompilerPathAndArgs(inputCompilerPath?: string, inputComp
// Found a valid compilerPath and args.
additionalArgs = extractArgs(compilerPath.substr(spaceStart + 1));
compilerPath = potentialCompilerPath;
compilerName = path.basename(potentialCompilerPath);
}
compilerName = path.basename(compilerPath);
}
// Get compiler name if there are no args but path is valid or a valid path was found with args.
if (compilerPath === "cl.exe" || checkFileExistsSync(compilerPath)) {
compilerName = path.basename(compilerPath);
}
}
}

Просмотреть файл

@ -504,11 +504,39 @@
<div class="section">
<div class="section-title" data-loc-id="intellisense.mode">IntelliSense mode</div>
<div class="section-text">
<span data-loc-id="intellisense.mode.description">The IntelliSense mode to use that maps to an architecture-specific variant of MSVC, gcc, or Clang. If not set or if set to <code>${default}</code>, the extension will choose the default for that platform. Windows defaults to <code>msvc-x64</code>, Linux defaults to <code>gcc-x64</code>, and macOS defaults to <code>clang-x64</code>. Select a specific IntelliSense mode to override the <code>${default}</code> mode.</span>
<span data-loc-id="intellisense.mode.description">The IntelliSense mode to use that maps to a platform and architecture variant of MSVC, gcc, or Clang. If not set or if set to <code>${default}</code>, the extension will choose the default for that platform. Windows defaults to <code>windows-msvc-x64</code>, Linux defaults to <code>linux-gcc-x64</code>, and macOS defaults to <code>macos-clang-x64</code>. Select a specific IntelliSense mode to override the <code>${default}</code> mode.</span>
</div>
<div>
<select name="inputValue" id="intelliSenseMode" class="select-default">
<option value="${default}">${default}</option>
<option value="macos-clang-x86">macos-clang-x86</option>
<option value="macos-clang-x64">macos-clang-x64</option>
<option value="macos-clang-arm">macos-clang-arm</option>
<option value="macos-clang-arm64">macos-clang-arm64</option>
<option value="macos-gcc-x86">macos-gcc-x86</option>
<option value="macos-gcc-x64">macos-gcc-x64</option>
<option value="macos-gcc-arm">macos-gcc-arm</option>
<option value="macos-gcc-arm64">macos-gcc-arm64</option>
<option value="linux-clang-x86">linux-clang-x86</option>
<option value="linux-clang-x64">linux-clang-x64</option>
<option value="linux-clang-arm">linux-clang-arm</option>
<option value="linux-clang-arm64">linux-clang-arm64</option>
<option value="linux-gcc-x86">linux-gcc-x86</option>
<option value="linux-gcc-x64">linux-gcc-x64</option>
<option value="linux-gcc-arm">linux-gcc-arm</option>
<option value="linux-gcc-arm64">linux-gcc-arm64</option>
<option value="windows-clang-x86">windows-clang-x86</option>
<option value="windows-clang-x64">windows-clang-x64</option>
<option value="windows-clang-arm">windows-clang-arm</option>
<option value="windows-clang-arm64">windows-clang-arm64</option>
<option value="windows-gcc-x86">windows-gcc-x86</option>
<option value="windows-gcc-x64">windows-gcc-x64</option>
<option value="windows-gcc-arm">windows-gcc-arm</option>
<option value="windows-gcc-arm64">windows-gcc-arm64</option>
<option value="windows-msvc-x86">windows-msvc-x86</option>
<option value="windows-msvc-x64">windows-msvc-x64</option>
<option value="windows-msvc-arm">windows-msvc-arm</option>
<option value="windows-msvc-arm64">windows-msvc-arm64</option>
<option value="clang-x86">clang-x86</option>
<option value="clang-x64">clang-x64</option>
<option value="clang-arm">clang-arm</option>