Skip to content

Commit

Permalink
Also CCompilerConfig{,Impl} -> CCompilerConfig (now that CCompilerCon…
Browse files Browse the repository at this point in the history
…fig is a plain data class)
  • Loading branch information
mkustermann committed Sep 26, 2024
1 parent f542a1d commit 6ee53b3
Show file tree
Hide file tree
Showing 17 changed files with 66 additions and 223 deletions.
20 changes: 10 additions & 10 deletions pkgs/native_assets_builder/lib/src/build_runner/build_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class NativeAssetsBuildRunner {
required Target target,
required Uri workingDirectory,
required BuildMode buildMode,
CCompilerConfigImpl? cCompilerConfig,
CCompilerConfig? cCompilerConfig,
IOSSdk? targetIOSSdk,
int? targetIOSVersion,
int? targetMacOSVersion,
Expand Down Expand Up @@ -104,7 +104,7 @@ class NativeAssetsBuildRunner {
required Target target,
required Uri workingDirectory,
required BuildMode buildMode,
CCompilerConfigImpl? cCompilerConfig,
CCompilerConfig? cCompilerConfig,
IOSSdk? targetIOSSdk,
int? targetIOSVersion,
int? targetMacOSVersion,
Expand Down Expand Up @@ -142,7 +142,7 @@ class NativeAssetsBuildRunner {
required Target target,
required Uri workingDirectory,
required BuildMode buildMode,
CCompilerConfigImpl? cCompilerConfig,
CCompilerConfig? cCompilerConfig,
IOSSdk? targetIOSSdk,
int? targetIOSVersion,
int? targetMacOSVersion,
Expand All @@ -167,12 +167,12 @@ class NativeAssetsBuildRunner {
final env = Platform.environment;
String? lookup(String key) => env[unparseKey(key)];

final cc = lookup(CCompilerConfigImpl.ccConfigKeyFull);
final ar = lookup(CCompilerConfigImpl.arConfigKeyFull);
final ld = lookup(CCompilerConfigImpl.ldConfigKeyFull);
final envScript = lookup(CCompilerConfigImpl.envScriptConfigKeyFull);
final cc = lookup(CCompilerConfig.ccConfigKeyFull);
final ar = lookup(CCompilerConfig.arConfigKeyFull);
final ld = lookup(CCompilerConfig.ldConfigKeyFull);
final envScript = lookup(CCompilerConfig.envScriptConfigKeyFull);
final envScriptArgs =
lookup(CCompilerConfigImpl.envScriptArgsConfigKeyFull)
lookup(CCompilerConfig.envScriptArgsConfigKeyFull)
?.split(' ')
.map((arg) => arg.trim())
.where((arg) => arg.isNotEmpty)
Expand All @@ -185,7 +185,7 @@ class NativeAssetsBuildRunner {
ld != null ||
envScript != null ||
hasEnvScriptArgs) {
cCompilerConfig = CCompilerConfigImpl(
cCompilerConfig = CCompilerConfig(
archiver: ar != null ? Uri.file(ar) : null,
compiler: cc != null ? Uri.file(cc) : null,
envScript: envScript != null ? Uri.file(envScript) : null,
Expand Down Expand Up @@ -273,7 +273,7 @@ class NativeAssetsBuildRunner {
LinkModePreference linkModePreference,
DependencyMetadata? dependencyMetadata,
bool? linkingEnabled,
CCompilerConfigImpl? cCompilerConfig,
CCompilerConfig? cCompilerConfig,
IOSSdk? targetIOSSdk,
int? targetAndroidNdkApi,
int? targetIOSVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ void main() async {
String unparseKey(String key) =>
'DART_HOOK_TESTING_${key.replaceAll('.', '__').toUpperCase()}';

final arKey = unparseKey(CCompilerConfigImpl.arConfigKeyFull);
final ccKey = unparseKey(CCompilerConfigImpl.ccConfigKeyFull);
final ldKey = unparseKey(CCompilerConfigImpl.ldConfigKeyFull);
final envScriptKey = unparseKey(CCompilerConfigImpl.envScriptConfigKeyFull);
final arKey = unparseKey(CCompilerConfig.arConfigKeyFull);
final ccKey = unparseKey(CCompilerConfig.ccConfigKeyFull);
final ldKey = unparseKey(CCompilerConfig.ldConfigKeyFull);
final envScriptKey = unparseKey(CCompilerConfig.envScriptConfigKeyFull);
final envScriptArgsKey =
unparseKey(CCompilerConfigImpl.envScriptArgsConfigKeyFull);
unparseKey(CCompilerConfig.envScriptArgsConfigKeyFull);

final cc = Platform.environment[ccKey]?.fileUri;

Expand Down Expand Up @@ -54,7 +54,7 @@ void main() async {
logger,
dartExecutable,
// Manually pass in a compiler.
cCompilerConfig: CCompilerConfigImpl(
cCompilerConfig: CCompilerConfig(
archiver: Platform.environment[arKey]?.fileUri,
compiler: cc,
envScript: Platform.environment[envScriptKey]?.fileUri,
Expand Down
10 changes: 5 additions & 5 deletions pkgs/native_assets_builder/test/build_runner/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Future<BuildResult> build(
Logger logger,
Uri dartExecutable, {
LinkModePreference linkModePreference = LinkModePreference.dynamic,
CCompilerConfigImpl? cCompilerConfig,
CCompilerConfig? cCompilerConfig,
bool includeParentEnvironment = true,
List<String>? capturedLogs,
PackageLayout? packageLayout,
Expand Down Expand Up @@ -85,7 +85,7 @@ Future<LinkResult> link(
Logger logger,
Uri dartExecutable, {
LinkModePreference linkModePreference = LinkModePreference.dynamic,
CCompilerConfigImpl? cCompilerConfig,
CCompilerConfig? cCompilerConfig,
bool includeParentEnvironment = true,
List<String>? capturedLogs,
PackageLayout? packageLayout,
Expand Down Expand Up @@ -131,7 +131,7 @@ Future<(BuildResult, LinkResult)> buildAndLink(
Logger logger,
Uri dartExecutable, {
LinkModePreference linkModePreference = LinkModePreference.dynamic,
CCompilerConfigImpl? cCompilerConfig,
CCompilerConfig? cCompilerConfig,
bool includeParentEnvironment = true,
List<String>? capturedLogs,
PackageLayout? packageLayout,
Expand Down Expand Up @@ -223,7 +223,7 @@ Future<BuildDryRunResult> buildDryRun(
Logger logger,
Uri dartExecutable, {
LinkModePreference linkModePreference = LinkModePreference.dynamic,
CCompilerConfigImpl? cCompilerConfig,
CCompilerConfig? cCompilerConfig,
bool includeParentEnvironment = true,
List<String>? capturedLogs,
PackageLayout? packageLayout,
Expand Down Expand Up @@ -251,7 +251,7 @@ Future<LinkDryRunResult> linkDryRun(
Logger logger,
Uri dartExecutable, {
LinkModePreference linkModePreference = LinkModePreference.dynamic,
CCompilerConfigImpl? cCompilerConfig,
CCompilerConfig? cCompilerConfig,
bool includeParentEnvironment = true,
List<String>? capturedLogs,
PackageLayout? packageLayout,
Expand Down
12 changes: 6 additions & 6 deletions pkgs/native_assets_builder/test/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,41 +130,41 @@ String unparseKey(String key) =>
///
/// Provided on Dart CI.
final Uri? _ar = Platform
.environment[unparseKey(internal.CCompilerConfigImpl.arConfigKeyFull)]
.environment[unparseKey(internal.CCompilerConfig.arConfigKeyFull)]
?.asFileUri();

/// Compiler provided by the environment.
///
/// Provided on Dart CI.
final Uri? _cc = Platform
.environment[unparseKey(internal.CCompilerConfigImpl.ccConfigKeyFull)]
.environment[unparseKey(internal.CCompilerConfig.ccConfigKeyFull)]
?.asFileUri();

/// Linker provided by the environment.
///
/// Provided on Dart CI.
final Uri? _ld = Platform
.environment[unparseKey(internal.CCompilerConfigImpl.ldConfigKeyFull)]
.environment[unparseKey(internal.CCompilerConfig.ldConfigKeyFull)]
?.asFileUri();

/// Path to script that sets environment variables for [_cc], [_ld], and [_ar].
///
/// Provided on Dart CI.
final Uri? _envScript = Platform.environment[
unparseKey(internal.CCompilerConfigImpl.envScriptConfigKeyFull)]
unparseKey(internal.CCompilerConfig.envScriptConfigKeyFull)]
?.asFileUri();

/// Arguments for [_envScript] provided by environment.
///
/// Provided on Dart CI.
final List<String>? _envScriptArgs = Platform.environment[
unparseKey(internal.CCompilerConfigImpl.envScriptArgsConfigKeyFull)]
unparseKey(internal.CCompilerConfig.envScriptArgsConfigKeyFull)]
?.split(' ');

/// Configuration for the native toolchain.
///
/// Provided on Dart CI.
final cCompiler = internal.CCompilerConfigImpl(
final cCompiler = internal.CCompilerConfig(
compiler: _cc,
archiver: _ar,
linker: _ld,
Expand Down
3 changes: 2 additions & 1 deletion pkgs/native_assets_cli/lib/native_assets_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ library native_assets_cli;
export 'src/api/asset.dart'
show Asset, DataAsset, NativeCodeAsset, OSLibraryNaming;
export 'src/api/build.dart' show build;
export 'src/api/build_config.dart' show BuildConfig, CCompilerConfig;
export 'src/api/build_config.dart' show BuildConfig;
export 'src/api/build_output.dart' show BuildOutput, LinkOutput;
export 'src/api/builder.dart' show Builder;
export 'src/api/hook_config.dart' show HookConfig;
Expand All @@ -18,6 +18,7 @@ export 'src/api/link_config.dart' show LinkConfig;
export 'src/api/linker.dart' show Linker;
export 'src/architecture.dart' show Architecture;
export 'src/build_mode.dart' show BuildMode;
export 'src/c_compiler_config.dart' show CCompilerConfig;
export 'src/ios_sdk.dart' show IOSSdk;
export 'src/link_mode.dart'
show
Expand Down
2 changes: 1 addition & 1 deletion pkgs/native_assets_cli/lib/native_assets_cli_internal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ library native_assets_cli_internal;

export 'native_assets_cli.dart' hide build, link;
export 'src/api/asset.dart' show AssetImpl, DataAssetImpl, NativeCodeAssetImpl;
export 'src/api/build_config.dart' show BuildConfigImpl, CCompilerConfigImpl;
export 'src/api/build_config.dart' show BuildConfigImpl;
export 'src/api/build_output.dart' show HookOutputImpl;
export 'src/api/hook_config.dart' show HookConfigImpl;
export 'src/api/link_config.dart' show LinkConfigImpl;
Expand Down
5 changes: 2 additions & 3 deletions pkgs/native_assets_cli/lib/src/api/build_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:pub_semver/pub_semver.dart';
import '../architecture.dart';
import '../args_parser.dart';
import '../build_mode.dart';
import '../c_compiler_config.dart';
import '../ios_sdk.dart';
import '../json_utils.dart';
import '../link_mode_preference.dart';
Expand All @@ -26,8 +27,6 @@ import 'deprecation_messages.dart';
import 'hook_config.dart';

part '../model/build_config.dart';
part '../model/c_compiler_config.dart';
part 'c_compiler_config.dart';

/// The configuration for a build hook (`hook/build.dart`) invocation.
///
Expand Down Expand Up @@ -143,7 +142,7 @@ abstract final class BuildConfig implements HookConfig {
targetIOSVersion: targetIOSVersion,
targetMacOSVersion: targetMacOSVersion,
targetAndroidNdkApi: targetAndroidNdkApi,
cCompiler: cCompiler as CCompilerConfigImpl?,
cCompiler: cCompiler,
linkModePreference: linkModePreference,
dependencyMetadata: dependencyMetadata != null
? {
Expand Down
32 changes: 0 additions & 32 deletions pkgs/native_assets_cli/lib/src/api/c_compiler_config.dart

This file was deleted.

1 change: 1 addition & 0 deletions pkgs/native_assets_cli/lib/src/api/hook_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:pub_semver/pub_semver.dart';

import '../architecture.dart';
import '../build_mode.dart';
import '../c_compiler_config.dart';
import '../ios_sdk.dart';
import '../json_utils.dart';
import '../link_mode.dart';
Expand Down
3 changes: 2 additions & 1 deletion pkgs/native_assets_cli/lib/src/api/link_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:pub_semver/pub_semver.dart';
import '../architecture.dart';
import '../args_parser.dart';
import '../build_mode.dart';
import '../c_compiler_config.dart';
import '../ios_sdk.dart';
import '../json_utils.dart';
import '../link_mode_preference.dart';
Expand Down Expand Up @@ -68,7 +69,7 @@ abstract class LinkConfig implements HookConfig {
packageName: packageName,
packageRoot: packageRoot,
buildMode: buildMode,
cCompiler: cCompiler as CCompilerConfigImpl?,
cCompiler: cCompiler,
targetAndroidNdkApi: targetAndroidNdkApi,
targetArchitecture: targetArchitecture,
targetIOSSdk: targetIOSSdk,
Expand Down
1 change: 1 addition & 0 deletions pkgs/native_assets_cli/lib/src/api/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:yaml/yaml.dart';

import '../architecture.dart';
import '../build_mode.dart';
import '../c_compiler_config.dart';
import '../ios_sdk.dart';
import '../link_mode_preference.dart';
import '../os.dart';
Expand Down
95 changes: 0 additions & 95 deletions pkgs/native_assets_cli/lib/src/model/c_compiler_config.dart

This file was deleted.

Loading

0 comments on commit 6ee53b3

Please sign in to comment.