Skip to content

Commit

Permalink
[native_toolchain_c] Pass in archiver from environment in test - take…
Browse files Browse the repository at this point in the history
… 2 (#1461)
  • Loading branch information
dcharkes authored Aug 26, 2024
1 parent 6eeb6d9 commit ec292a8
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ void main() {
targetOS: OS.current,
linkModePreference: LinkModePreference.dynamic,
buildMode: BuildMode.release,
cCompiler: CCompilerConfig(
compiler: cc,
envScript: envScript,
envScriptArgs: envScriptArgs,
),
cCompiler: cCompiler,
linkingEnabled: false,
);
final buildOutput = BuildOutput();
Expand Down
48 changes: 8 additions & 40 deletions pkgs/native_toolchain_c/test/cbuilder/cbuilder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ void main() {
buildMode: buildMode,
// Ignored by executables.
linkModePreference: LinkModePreference.dynamic,
cCompiler: CCompilerConfig(
compiler: cc,
envScript: envScript,
envScriptArgs: envScriptArgs,
),
cCompiler: cCompiler,
linkingEnabled: false,
);
final buildOutput = BuildOutput();
Expand Down Expand Up @@ -132,11 +128,7 @@ void main() {
targetOS: OS.current,
buildMode: BuildMode.release,
linkModePreference: LinkModePreference.dynamic,
cCompiler: CCompilerConfig(
compiler: cc,
envScript: envScript,
envScriptArgs: envScriptArgs,
),
cCompiler: cCompiler,
linkingEnabled: false,
);
final buildOutput = BuildOutput();
Expand Down Expand Up @@ -226,11 +218,7 @@ void main() {
buildMode: BuildMode.release,
// Ignored by executables.
linkModePreference: LinkModePreference.dynamic,
cCompiler: CCompilerConfig(
compiler: cc,
envScript: envScript,
envScriptArgs: envScriptArgs,
),
cCompiler: cCompiler,
linkingEnabled: false,
);
final buildOutput = BuildOutput();
Expand Down Expand Up @@ -284,11 +272,7 @@ void main() {
targetOS: OS.current,
buildMode: BuildMode.release,
linkModePreference: LinkModePreference.dynamic,
cCompiler: CCompilerConfig(
compiler: cc,
envScript: envScript,
envScriptArgs: envScriptArgs,
),
cCompiler: cCompiler,
linkingEnabled: false,
);
final buildOutput = BuildOutput();
Expand Down Expand Up @@ -330,11 +314,7 @@ void main() {
targetOS: OS.current,
buildMode: BuildMode.release,
linkModePreference: LinkModePreference.dynamic,
cCompiler: CCompilerConfig(
compiler: cc,
envScript: envScript,
envScriptArgs: envScriptArgs,
),
cCompiler: cCompiler,
linkingEnabled: false,
);
final buildOutput = BuildOutput();
Expand Down Expand Up @@ -390,11 +370,7 @@ void main() {
targetOS: OS.current,
// Ignored by executables.
linkModePreference: LinkModePreference.dynamic,
cCompiler: CCompilerConfig(
compiler: cc,
envScript: envScript,
envScriptArgs: envScriptArgs,
),
cCompiler: cCompiler,
linkingEnabled: false,
);
final buildOutput = BuildOutput();
Expand Down Expand Up @@ -455,11 +431,7 @@ void main() {
targetOS: OS.current,
// Ignored by executables.
linkModePreference: LinkModePreference.dynamic,
cCompiler: CCompilerConfig(
compiler: cc,
envScript: envScript,
envScriptArgs: envScriptArgs,
),
cCompiler: cCompiler,
linkingEnabled: false,
);
final buildOutput = BuildOutput();
Expand Down Expand Up @@ -527,11 +499,7 @@ Future<void> testDefines({
buildMode: buildMode,
// Ignored by executables.
linkModePreference: LinkModePreference.dynamic,
cCompiler: CCompilerConfig(
compiler: cc,
envScript: envScript,
envScriptArgs: envScriptArgs,
),
cCompiler: cCompiler,
linkingEnabled: false,
);
final buildOutput = BuildOutput();
Expand Down
6 changes: 1 addition & 5 deletions pkgs/native_toolchain_c/test/cbuilder/objective_c_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ void main() {
targetArchitecture: Architecture.current,
targetOS: OS.current,
linkModePreference: LinkModePreference.dynamic,
cCompiler: CCompilerConfig(
compiler: cc,
envScript: envScript,
envScriptArgs: envScriptArgs,
),
cCompiler: cCompiler,
linkingEnabled: false,
);
final buildOutput = BuildOutput();
Expand Down
6 changes: 1 addition & 5 deletions pkgs/native_toolchain_c/test/clinker/build_testfiles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ Future<Uri> buildTestArchive(
targetOS: os,
buildMode: BuildMode.release,
linkModePreference: LinkModePreference.dynamic,
cCompiler: CCompilerConfig(
compiler: cc,
envScript: envScript,
envScriptArgs: envScriptArgs,
),
cCompiler: cCompiler,
linkingEnabled: false,
);
final buildOutput = BuildOutput();
Expand Down
11 changes: 3 additions & 8 deletions pkgs/native_toolchain_c/test/clinker/objects_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Future<void> main() async {
final tempUri = await tempDirForTest();

final uri = await buildTestArchive(tempUri, os, architecture);

final linkConfig = LinkConfig.build(
outputDirectory: tempUri,
packageName: 'testpackage',
Expand All @@ -41,14 +40,10 @@ Future<void> main() async {
buildMode: BuildMode.debug,
linkModePreference: LinkModePreference.dynamic,
assets: [],
cCompiler: CCompilerConfig(
compiler: cc,
archiver: ar,
linker: ld,
envScript: envScript,
envScriptArgs: envScriptArgs,
),
cCompiler: cCompiler,
);
printOnFailure(linkConfig.cCompiler.toString());
printOnFailure(Platform.environment.keys.toList().toString());
await CLinker.library(
name: name,
assetName: '',
Expand Down
3 changes: 3 additions & 0 deletions pkgs/native_toolchain_c/test/clinker/treeshake_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ Future<void> runTests(List<Architecture> architectures) async {
buildMode: BuildMode.release,
linkModePreference: LinkModePreference.dynamic,
assets: [],
cCompiler: cCompiler,
);
printOnFailure(config.cCompiler.toString());
printOnFailure(Platform.environment.keys.toList().toString());
await clinker.linker([testArchive.toFilePath()]).run(
config: config,
output: linkOutput,
Expand Down
25 changes: 18 additions & 7 deletions pkgs/native_toolchain_c/test/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,31 +123,42 @@ String unparseKey(String key) => key.replaceAll('.', '__').toUpperCase();
/// Archiver provided by the environment.
///
/// Provided on Dart CI.
final Uri? ar = Platform.environment[unparseKey('c_compiler.ar')]?.asFileUri();
final Uri? _ar = Platform.environment[unparseKey('c_compiler.ar')]?.asFileUri();

/// Compiler provided by the environment.
///
/// Provided on Dart CI.
final Uri? cc = Platform.environment[unparseKey('c_compiler.cc')]?.asFileUri();
final Uri? _cc = Platform.environment[unparseKey('c_compiler.cc')]?.asFileUri();

/// Linker provided by the environment.
///
/// Provided on Dart CI.
final Uri? ld = Platform.environment[unparseKey('c_compiler.ld')]?.asFileUri();
final Uri? _ld = Platform.environment[unparseKey('c_compiler.ld')]?.asFileUri();

/// Path to script that sets environment variables for [cc], [ld], and [ar].
/// Path to script that sets environment variables for [_cc], [_ld], and [_ar].
///
/// Provided on Dart CI.
final Uri? envScript =
final Uri? _envScript =
Platform.environment[unparseKey('c_compiler.env_script')]?.asFileUri();

/// Arguments for [envScript] provided by environment.
/// Arguments for [_envScript] provided by environment.
///
/// Provided on Dart CI.
final List<String>? envScriptArgs = Platform
final List<String>? _envScriptArgs = Platform
.environment[unparseKey('c_compiler.env_script_arguments')]
?.split(' ');

/// Configuration for the native toolchain.
///
/// Provided on Dart CI.
final cCompiler = CCompilerConfig(
compiler: _cc,
archiver: _ar,
linker: _ld,
envScript: _envScript,
envScriptArgs: _envScriptArgs,
);

extension on String {
Uri asFileUri() => Uri.file(this);
}
Expand Down

0 comments on commit ec292a8

Please sign in to comment.