execute method
Execute this build step.
The context provides access to the build configuration and logger.
Returns a NativeStepResult containing any artifacts produced by this step.
Implementation
@override
Future<NativeStepResult> execute(
NativeBuildContext context,
ResolvedSource source,
) async {
final logger = context.logger;
logger?.info('[$id] Starting build step');
final r = runner ?? ProcessRunner(logger: logger);
final expandedBuildDirectory = expandRecipeValue(
buildDirectory,
context,
source,
);
final buildDir = p.isAbsolute(expandedBuildDirectory)
? expandedBuildDirectory
: p.join(source.directory.path, expandedBuildDirectory);
final args = <String>['--build', buildDir];
if (targets.isNotEmpty) {
for (final target in expandRecipeValues(targets, context, source)) {
args.addAll(['--target', target]);
}
}
if (parallel) {
args.addAll(['--parallel', Platform.numberOfProcessors.toString()]);
}
logger?.info('[$id] Running: cmake ${args.join(' ')}');
await r.runStreaming(
'cmake',
args,
workingDirectory: Directory(buildDir),
environment: environment == null
? null
: expandRecipeStringMap(environment!, context, source),
);
return const NativeStepResult();
}