本文整理汇总了TypeScript中@cmt/cache.CMakeCache类的典型用法代码示例。如果您正苦于以下问题:TypeScript CMakeCache类的具体用法?TypeScript CMakeCache怎么用?TypeScript CMakeCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CMakeCache类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: test
test('Passing env-vars to CMake but not to the compiler', async () => {
// Set fake settings
testEnv.config.updatePartial({
configureEnvironment: {
_CONFIGURE_ENV: '${workspaceRootFolderName}',
},
});
// Configure
expect(await cmt.configure()).to.be.eq(0, '[configureEnvironment] configure failed');
expect(testEnv.projectFolder.buildDirectory.isCMakeCachePresent).to.eql(true, 'expected cache not present');
const cache = await CMakeCache.fromPath(await cmt.cachePath);
const cacheEntry = cache.get('configureEnvironment') as api.CacheEntry;
expect(cacheEntry.type).to.eq(api.CacheEntryType.String, '[configureEnvironment] unexpected cache entry type');
expect(cacheEntry.key).to.eq('configureEnvironment', '[configureEnvironment] unexpected cache entry key name');
expect(cacheEntry.as<string>())
.to.eq(path.basename(testEnv.projectFolder.location), '[configureEnvironment] substitution incorrect');
expect(typeof cacheEntry.value).to.eq('string', '[configureEnvironment] unexpected cache entry value type');
// Build
expect(await cmt.build()).to.be.eq(0, '[configureEnvironment] build failed');
const result = await testEnv.result.getResultAsJson();
expect(result['configure-env']).to.eq('', '[configureEnvironment] env-var got passed to compiler');
}).timeout(100000);
开发者ID:vector-of-bool,项目名称:vscode-cmake-tools,代码行数:25,代码来源:environment.test.ts
示例2: test
test('Check substitution for variant names', async () => {
// Define test keys and expected values
const testKeys = {buildType: 'debug-label', otherVariant: 'option1'};
// Update configure settings
const configSettings: {[key: string]: string} = {};
await Promise.all(Object.keys(testKeys).map(async key => configSettings[key] = `\${variant:${key}}`));
testEnv.config.updatePartial({configureSettings: configSettings});
// Configure and retrieve generated cache
expect(await cmt.configure()).to.be.eq(0, '[variant] configure failed');
expect(testEnv.projectFolder.buildDirectory.isCMakeCachePresent).to.eql(true, '[variant] cache not found');
const cache = await CMakeCache.fromPath(await cmt.cachePath);
// Helper function for checking test keys in a cmake cache
const checkTestKey = async (testKey: [string, string], testCache: CMakeCache) => {
const [key, expected] = testKey;
// Get cache entry for given test key
const cacheEntry = testCache.get(key) as api.CacheEntry;
// Check type and value of the retrieved cache entry
expect(cacheEntry.type).to.eq(api.CacheEntryType.String, `[variant:${key}] unexpected cache entry type`);
expect(cacheEntry.key).to.eql(key, `[variant:${key}] unexpected cache entry key name`);
expect(cacheEntry.as<string>()).to.eql(expected, `[variant:${key}] incorrect substitution`);
expect(typeof cacheEntry.value).to.eq('string', `[variant:${key}] unexpected cache entry value type`);
};
// Check test keys
await Promise.all(objectPairs(testKeys).map(async testKey => checkTestKey(testKey, cache)));
}).timeout(100000);
开发者ID:vector-of-bool,项目名称:vscode-cmake-tools,代码行数:31,代码来源:variable-substitution.test.ts
示例3: searchForCompilerPathInCache
function searchForCompilerPathInCache(cache: CMakeCache): string|null {
const languages = ['CXX', 'C', 'CUDA'];
for (const lang of languages) {
const entry = cache.get(`CMAKE_${lang}_COMPILER`);
if (!entry) {
continue;
}
return entry.value as string;
}
return null;
}
开发者ID:vector-of-bool,项目名称:vscode-cmake-tools,代码行数:11,代码来源:debugger.ts
示例4: async
const checkTestKey = async (testKey: [string, string], testCache: CMakeCache) => {
const [key, expected] = testKey;
// Get cache entry for given test key
const cacheEntry = testCache.get(key) as api.CacheEntry;
// Check type and value of the retrieved cache entry
expect(cacheEntry.type).to.eq(api.CacheEntryType.String, `[variant:${key}] unexpected cache entry type`);
expect(cacheEntry.key).to.eql(key, `[variant:${key}] unexpected cache entry key name`);
expect(cacheEntry.as<string>()).to.eql(expected, `[variant:${key}] incorrect substitution`);
expect(typeof cacheEntry.value).to.eq('string', `[variant:${key}] unexpected cache entry value type`);
};
开发者ID:vector-of-bool,项目名称:vscode-cmake-tools,代码行数:12,代码来源:variable-substitution.test.ts
示例5: getDebugConfigurationFromCache
export async function getDebugConfigurationFromCache(cache: CMakeCache, target: ExecutableTarget, platform: string):
Promise<Configuration|null> {
const entry = cache.get('CMAKE_LINKER');
if (entry !== null) {
const linker = entry.value as string;
const is_msvc_linker = linker.endsWith('link.exe');
if (is_msvc_linker) {
return createMSVCDebugConfiguration(target);
}
}
const compiler_path = searchForCompilerPathInCache(cache);
if (compiler_path === null) {
throw Error('No compiler found in cache file.'); // MSVC should be already found by CMAKE_LINKER
}
const clang_compiler_regex = /(clang[\+]{0,2})+(?!-cl)/gi;
// Look for lldb-mi
let clang_debugger_path = compiler_path.replace(clang_compiler_regex, 'lldb-mi');
if ((clang_debugger_path.search(new RegExp('lldb-mi')) != -1) && await checkDebugger(clang_debugger_path)) {
return createLLDBDebugConfiguration(clang_debugger_path, target);
} else {
// Look for gdb
clang_debugger_path = compiler_path.replace(clang_compiler_regex, 'gdb');
if ((clang_debugger_path.search(new RegExp('gdb')) != -1) && await checkDebugger(clang_debugger_path)) {
return createGDBDebugConfiguration(clang_debugger_path, target);
} else {
// Look for lldb
clang_debugger_path = compiler_path.replace(clang_compiler_regex, 'lldb');
if ((clang_debugger_path.search(new RegExp('lldb')) != -1) && await checkDebugger(clang_debugger_path)) {
return createLLDBDebugConfiguration(clang_debugger_path, target);
}
}
}
const debugger_name = platform == 'darwin' ? 'lldb' : 'gdb';
const description = DEBUG_GEN[debugger_name];
const gcc_compiler_regex = /([cg]\+\+|g?cc)+/gi;
const gdb_debugger_path = compiler_path.replace(gcc_compiler_regex, description.miMode);
if (gdb_debugger_path.search(new RegExp(description.miMode)) != -1) {
return description.createConfig(gdb_debugger_path, target);
}
const is_msvc_compiler = compiler_path.endsWith('cl.exe');
if (is_msvc_compiler) {
return createMSVCDebugConfiguration(target);
}
log.warning(`Unable to automatically determine debugger corresponding to compiler: ${compiler_path}`);
return null;
}
开发者ID:vector-of-bool,项目名称:vscode-cmake-tools,代码行数:51,代码来源:debugger.ts
示例6: test
test('Check substitution within toolchain kits', async () => {
// Configure
expect(await cmt.configure()).to.be.eq(0, '[toolchain] configure failed');
expect(testEnv.projectFolder.buildDirectory.isCMakeCachePresent).to.eql(true, 'expected cache not present');
const cache = await CMakeCache.fromPath(await cmt.cachePath);
const cacheEntry = cache.get('CMAKE_TOOLCHAIN_FILE') as api.CacheEntry;
// tslint:disable-next-line:no-unused-expression
expect(cacheEntry).to.not.be.null;
expect(cacheEntry.key).to.eq('CMAKE_TOOLCHAIN_FILE', '[toolchain] unexpected cache entry key name');
expect(platformNormalizePath(cacheEntry.as<string>()))
.to.eq(platformNormalizePath(testEnv.projectFolder.location.concat('/test-toolchain.cmake')),
'[toolchain] substitution incorrect');
}).timeout(100000);
开发者ID:vector-of-bool,项目名称:vscode-cmake-tools,代码行数:14,代码来源:toolchain.test.ts
示例7: test
test('Check for environment variables being passed to configure', async () => {
// Set fake settings
// Configure
expect(await cmt.configure()).to.be.eq(0, '[variantEnv] configure failed');
expect(testEnv.projectFolder.buildDirectory.isCMakeCachePresent).to.eql(true, 'expected cache not present');
const cache = await CMakeCache.fromPath(await cmt.cachePath);
const cacheEntry_ = cache.get('variantEnv');
expect(cacheEntry_).to.not.be.eq(null, '[variantEnv] Cache entry was not present');
const cacheEntry = cacheEntry_!;
expect(cacheEntry.type).to.eq(api.CacheEntryType.String, '[variantEnv] unexpected cache entry type');
expect(cacheEntry.key).to.eq('variantEnv', '[variantEnv] unexpected cache entry key name');
expect(typeof cacheEntry.value).to.eq('string', '[variantEnv] unexpected cache entry value type');
expect(cacheEntry.as<string>())
.to.eq('0cbfb6ae-f2ec-4017-8ded-89df8759c502', '[variantEnv] incorrect environment variable');
}).timeout(100000);
开发者ID:vector-of-bool,项目名称:vscode-cmake-tools,代码行数:16,代码来源:variant-envs.test.ts
注:本文中的@cmt/cache.CMakeCache类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论