Skip to content

Commit

Permalink
Add frameworks option
Browse files Browse the repository at this point in the history
  • Loading branch information
dcharkes committed Jun 26, 2024
1 parent 77116c3 commit b3c2b67
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
17 changes: 17 additions & 0 deletions pkgs/native_toolchain_c/lib/src/cbuilder/cbuilder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ class CBuilder implements Builder {
/// Used to output the [BuildOutput.dependencies].
final List<String> includes;

/// Frameworks to link.
///
/// Only effective if [language] is [Language.objectiveC].
///
/// Defaults to `['Foundation']`.
///
/// Not used to output the [BuildOutput.dependencies], frameworks can be
/// mentioned by name if they are available on the system, so the file path
/// is not known. If you're depending on your own frameworks add them to
/// [BuildOutput.dependencies] manually.
final List<String> frameworks;

static const List<String> _defaultFrameworks = ['Foundation'];

/// The dart files involved in building this artifact.
///
/// Resolved against [BuildConfig.packageRoot].
Expand Down Expand Up @@ -162,6 +176,7 @@ class CBuilder implements Builder {
required this.assetName,
this.sources = const [],
this.includes = const [],
this.frameworks = _defaultFrameworks,
required this.dartBuildFiles,
@visibleForTesting this.installName,
this.flags = const [],
Expand All @@ -179,6 +194,7 @@ class CBuilder implements Builder {
required this.name,
this.sources = const [],
this.includes = const [],
this.frameworks = _defaultFrameworks,
required this.dartBuildFiles,
this.flags = const [],
this.defines = const {},
Expand Down Expand Up @@ -228,6 +244,7 @@ class CBuilder implements Builder {
logger: logger,
sources: sources,
includes: includes,
frameworks: frameworks,
dynamicLibrary: _type == _CBuilderType.library &&
linkMode == DynamicLoadingBundled()
? libUri
Expand Down
8 changes: 6 additions & 2 deletions pkgs/native_toolchain_c/lib/src/cbuilder/run_cbuilder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class RunCBuilder {
final Logger? logger;
final List<Uri> sources;
final List<Uri> includes;
final List<String> frameworks;
final Uri? executable;
final Uri? dynamicLibrary;
final Uri? staticLibrary;
Expand All @@ -47,6 +48,7 @@ class RunCBuilder {
this.logger,
this.sources = const [],
this.includes = const [],
required this.frameworks,
this.executable,
this.dynamicLibrary,
this.staticLibrary,
Expand Down Expand Up @@ -247,8 +249,10 @@ class RunCBuilder {
for (final include in includes) '-I${include.toFilePath()}',
...sourceFiles,
if (language == Language.objectiveC) ...[
'-framework',
'Foundation',
for (final framework in frameworks) ...[
'-framework',
framework,
],
],
if (executable != null) ...[
'-o',
Expand Down

0 comments on commit b3c2b67

Please sign in to comment.