Skip to content

Commit

Permalink
add linkWith flag
Browse files Browse the repository at this point in the history
this is required for linking with libraries on Windows msvc. Hope to port to
other platforms as well.

dart-lang#1221
  • Loading branch information
Rich Young committed Oct 16, 2024
1 parent c638d9f commit 54d3198
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkgs/native_toolchain_c/lib/src/cbuilder/cbuilder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class CBuilder extends CTool implements Builder {
super.assetName,
super.sources = const [],
super.includes = const [],
super.linkWith = const [],
super.frameworks = CTool.defaultFrameworks,
@Deprecated(
'Newer Dart and Flutter SDKs automatically add the Dart hook '
Expand All @@ -73,6 +74,7 @@ class CBuilder extends CTool implements Builder {
required super.name,
super.sources = const [],
super.includes = const [],
super.linkWith = const [],
super.frameworks = CTool.defaultFrameworks,
@Deprecated(
'Newer Dart and Flutter SDKs automatically add the Dart hook '
Expand Down Expand Up @@ -135,6 +137,7 @@ class CBuilder extends CTool implements Builder {
logger: logger,
sources: sources,
includes: includes,
linkWith: linkWith,
frameworks: frameworks,
dynamicLibrary:
type == OutputType.library && linkMode == DynamicLoadingBundled()
Expand Down
4 changes: 4 additions & 0 deletions pkgs/native_toolchain_c/lib/src/cbuilder/ctool.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ abstract class CTool {
/// Used to output the [LinkOutput.dependencies].
final List<String> includes;

/// Libraries to link with the target (Windows/DLL only)
final List<String> linkWith;

/// Frameworks to link.
///
/// Only effective if [language] is [Language.objectiveC].
Expand Down Expand Up @@ -123,6 +126,7 @@ abstract class CTool {
required this.assetName,
required this.sources,
required this.includes,
required this.linkWith,
required this.frameworks,
required this.installName,
required this.flags,
Expand Down
3 changes: 3 additions & 0 deletions pkgs/native_toolchain_c/lib/src/cbuilder/run_cbuilder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class RunCBuilder {
final Logger? logger;
final List<Uri> sources;
final List<Uri> includes;
final List<String> linkWith;
final List<String> frameworks;
final Uri? executable;
final Uri? dynamicLibrary;
Expand All @@ -51,6 +52,7 @@ class RunCBuilder {
this.logger,
this.sources = const [],
this.includes = const [],
this.linkWith = const [],
required this.frameworks,
this.executable,
this.dynamicLibrary,
Expand Down Expand Up @@ -335,6 +337,7 @@ class RunCBuilder {
if (dynamicLibrary != null) ...[
...sources.map((e) => e.toFilePath()),
'/link',
...linkWith,
'/DLL',
'/out:${outDir.resolveUri(dynamicLibrary!).toFilePath()}',
],
Expand Down

0 comments on commit 54d3198

Please sign in to comment.