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

Fix parsing of target architecture flags with values that include arm64 #1751

Merged
merged 3 commits into from
Apr 8, 2021
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
13 changes: 12 additions & 1 deletion src/cpptools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,15 @@ function parseTargetArch(target: string): Architecture {
case 'amd64':
case 'x86_64':
return 'x64';
case 'aarch64':
case 'arm64':
return 'arm64';
case 'arm':
return 'arm';
}
// Check triple target value
if (target.indexOf('aarch64') >= 0 || target.indexOf('armv8-a') >= 0 || target.indexOf('armv8.') >= 0) {
if (target.indexOf('aarch64') >= 0 || target.indexOf('arm64') >= 0
|| target.indexOf('armv8-a') >= 0 || target.indexOf('armv8.') >= 0) {
return 'arm64';
} else if (target.indexOf('arm') >= 0 || is_arm_32(target)) {
return 'arm';
Expand Down Expand Up @@ -247,6 +253,11 @@ export function getIntelliSenseMode(cptVersion: cpt.Version, compiler_path: stri
case 'x86':
return 'gcc-x86';
case 'x64':
return 'gcc-x64';
case 'arm64':
return can_use_arm ? 'gcc-arm64' : 'gcc-x64';
case 'arm':
return can_use_arm ? 'gcc-arm' : 'gcc-x86';
default:
return 'gcc-x64';
}
Expand Down
12 changes: 12 additions & 0 deletions test/unit-tests/cpptools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,18 @@ suite('CppTools tests', () => {
// Parse target architecture
info = parseCompileFlags(cpptoolsVersion4, ['--target=aarch64-arm-none-eabi']);
expect(info.targetArch).to.eql('arm64');
info = parseCompileFlags(cpptoolsVersion4, ['-target', 'arm64-arm-none-eabi']);
expect(info.targetArch).to.eql('arm64');
info = parseCompileFlags(cpptoolsVersion4, ['-target', 'arm-arm-none-eabi']);
expect(info.targetArch).to.eql('arm');
info = parseCompileFlags(cpptoolsVersion4, ['-arch=x86_64']);
expect(info.targetArch).to.eql('x64');
info = parseCompileFlags(cpptoolsVersion4, ['-arch', 'aarch64']);
expect(info.targetArch).to.eql('arm64');
info = parseCompileFlags(cpptoolsVersion4, ['-arch', 'arm64']);
expect(info.targetArch).to.eql('arm64');
info = parseCompileFlags(cpptoolsVersion4, ['-arch', 'arm']);
expect(info.targetArch).to.eql('arm');
info = parseCompileFlags(cpptoolsVersion4, ['-arch', 'i686']);
expect(info.targetArch).to.eql('x86');
info = parseCompileFlags(cpptoolsVersion4, ['/arch:x86_64']);
Expand Down Expand Up @@ -77,10 +83,16 @@ suite('CppTools tests', () => {
expect(mode).to.eql('clang-arm');
mode = getIntelliSenseMode(cpptoolsVersion4, 'clang', 'x64');
expect(mode).to.eql('clang-x64');
mode = getIntelliSenseMode(cpptoolsVersion4, 'clang', 'arm64');
expect(mode).to.eql('clang-arm64');
mode = getIntelliSenseMode(cpptoolsVersion4, 'clang', 'arm');
expect(mode).to.eql('clang-arm');
mode = getIntelliSenseMode(cpptoolsVersion4, 'gcc', undefined);
expect(mode).to.eql('gcc-x64');
mode = getIntelliSenseMode(cpptoolsVersion4, 'gcc', 'arm64');
expect(mode).to.eql('gcc-arm64');
mode = getIntelliSenseMode(cpptoolsVersion4, 'gcc', 'arm');
expect(mode).to.eql('gcc-arm');
mode = getIntelliSenseMode(cpptoolsVersion4, 'g++', 'x86');
expect(mode).to.eql('gcc-x86');
mode = getIntelliSenseMode(cpptoolsVersion4, 'arm-none-eabi-g++', undefined);
Expand Down