cpubench: init, add template rendering

This commit is contained in:
2024-07-09 14:02:13 +08:00
parent ad0c451f29
commit bcaa03233c
2 changed files with 128 additions and 0 deletions

16
src/cpubench/index.ts Normal file
View File

@@ -0,0 +1,16 @@
import fs from 'fs';
import { projectRoot } from 'lyc/environment';
import path from 'path';
const cpubenchTemplate = fs.readFileSync(path.resolve(projectRoot, 'assets', 'CPUBenchTemplate.ini')).toString('utf-8');
export interface CPUBenchConfigOptions {
llvmInstall: string;
optimize: string[];
}
export function renderConfig({ llvmInstall, optimize }: CPUBenchConfigOptions) {
return `# Rendered from TypeScript ${new Date().toLocaleString()}, do not edit!\n` + cpubenchTemplate
.replace('@@LLVM_INSTALL@@', llvmInstall)
.replace('@@OPTIMIZE@@', optimize.join(' '));
}