@specs-feup/clava
Version:
A C/C++ source-to-source compiler written in Typescript
116 lines • 4.23 kB
TypeScript
import { JavaClasses } from "@specs-feup/lara/api/lara/util/JavaTypes.js";
import ProcessExecutor from "@specs-feup/lara/api/lara/util/ProcessExecutor.js";
import CMakerSources from "./CMakerSources.js";
import CMakerUtils from "./CMakerUtils.js";
import CMakeCompiler from "./compilers/CMakeCompiler.js";
import BenchmarkCompilationEngine from "@specs-feup/lara/api/lara/benchmark/BenchmarkCompilationEngine.js";
/**
* Builds CMake configurations.
*
* @example
* new Cmaker()
* .setMinimumVersion("3.0.2") // Could have a standard minimum version
* .addSources(Io.getPaths(srcFolder, "*.cpp"))
* .addCxxFlags("-O3", "-std=c++11")
* .addLibs("stdc++")
* .addIncludes(srcFolder);
* .setVariable(name, value)
* cmaker.getCMake()
* cmaker.build(Io.getPath(srcFolder, "build"));
*/
export default class CMaker extends BenchmarkCompilationEngine {
private static MINIMUM_VERSION;
private static EXE_VAR;
private static DEFAULT_BIN_FOLDER;
makeCommand: string;
generator: string | undefined;
minimumVersion: string;
cxxFlags: string[];
cFlags: string[];
libs: string[];
sources: CMakerSources;
includeFolders: Set<string>;
printToConsole: boolean;
lastMakeOutput: ProcessExecutor | undefined;
compiler: CMakeCompiler | undefined;
customCMakeCode: string | undefined;
constructor(name?: string, disableWeaving?: boolean);
/**
* Custom CMake code that will be appended to the end of the CMake file.
*
* @param customCMakeCode - The code to append at the end of the CMake file.
*/
setCustomCMakeCode(customCMakeCode: string): this;
copy(): CMaker;
/**
* @returns Object that can be used to specify the sources.
*/
getSources(): CMakerSources;
/**
* Sets the minimum version of the CMake file.
*
* @param version - String with minimum CMake version
*/
setMinimumVersion(version: string): this;
/**
* Sets the name of the executable.
*
* @param name - String with the name of the executable.
*/
setName(name: string): this;
setCompiler(compiler: Parameters<typeof CMakerUtils.getCompiler>[0] | CMakeCompiler): this;
/**
* Sets if output of external tools (e.g., cmake, make) should appear in the console. By default it is off.
*/
setPrintToolsOutput(printToolsOutput?: boolean): this;
setGenerator(generator: string): this;
setMakeCommand(makeCommand: string): this;
/**
* Adds a variable number of Strings, one for each flag.
*
*/
addCxxFlags(...args: string[]): this;
/**
* Adds a variable number of Strings, one for each flag.
*
*/
addCFlags(...args: string[]): this;
addFlags(...args: string[]): this;
/**
* Adds link-time libraries (e.g., m for math.h).
*
* @param arguments - a sequence of String with the name of the link-time libraries, as CMake would accept (e.g., "m").
*/
addLibs(...args: string[]): this;
getMakeOutput(): string | undefined;
/**
* @param includeFolder - String representing an include folder
*/
addIncludeFolder(includeFolder: string | JavaClasses.File): this;
addCurrentAst(): this;
/**
* @returns The name of the executable that will be generated
*/
private getExecutableName;
/**
* Builds the program currently defined in the CMaker object.
*
* @param cmakelistsFolder - The folder where the CMakeList files will be written
* @param builderFolder - The folder where the program will be built
* @param cmakeFlags - Additional flags that will be passed to CMake execution
*
* @returns File to the executable compiled by the build.
*/
build(cmakelistsFolder?: string | JavaClasses.File, builderFolder?: string | JavaClasses.File, cmakeFlags?: string): JavaClasses.File | undefined;
/*** CODE FUNCTIONS ***/
/**
* @returns The CMake corresponding to the current configuration
*/
getCode(): string;
private getProjectDirectoriesCode;
private getCxxFlagsCode;
private getCFlagsCode;
private getIncludeFoldersCode;
private addExtraIncludes;
}
//# sourceMappingURL=CMaker.d.ts.map