Skip to content

Commit 3d66d94

Browse files
committed
Add a LibraryReference item allowing linking of static/shared native libraries.
1 parent e3cabf0 commit 3d66d94

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

doc/configuration/items.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ are used by the Zig SDK:
66

77
* `Compile`: Source code files passed to the Zig compiler. By default, the Zig
88
SDK will populate this item type according to the project type.
9-
* `IncludeDirectory`: Header include directories passed to the compiler with the
10-
`-I` flag. Note that this applies to Zig as well, not just C/C++.
119
* `PreludeHeader`: C/C++ header files that will be automatically `#include`d in
1210
every C/C++ source file by way of Clang's `-include` flag.
11+
* `IncludeDirectory`: Header include directories passed to the compiler with the
12+
`-I` flag. Note that this applies to Zig as well, not just C/C++.
13+
* `LibraryReference`: Native libraries that should be linked to. These can be
14+
either static or dynamic. For multi-platform projects, additions to this item
15+
should be conditioned on the value of `RuntimeIdentifier` (or similar).
1316
* `CHeader`: Prepopulated by the Zig SDK with all files in the project directory
1417
ending in `.h`.
1518
* `CSource`: Prepopulated by the Zig SDK with all files in the project directory

src/sdk/ZigCompile.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ public string Configuration
6969
[Required]
7070
public string LanguageStandard { get; set; } = null!;
7171

72+
[Required]
73+
public ITaskItem[] LibraryReferences { get; set; } = null!;
74+
7275
[Required]
7376
public bool LinkTimeOptimization { get; set; }
7477

@@ -564,6 +567,7 @@ void TryAppendWarningSwitch(string name)
564567
// TODO: https://github.com/vezel-dev/zig-sdk/issues/8
565568

566569
builder.AppendFileNamesIfNotNull(Sources, " ");
570+
builder.AppendFileNamesIfNotNull(LibraryReferences, " ");
567571
builder.AppendSwitchIfNotNull(isZig ? "-femit-bin=" : "-o ", OutputBinary);
568572

569573
if (!isZig)

src/sdk/build/Vezel.Zig.Sdk.Build.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
FastMath="$(FastMath)"
5959
IncludeDirectories="@(IncludeDirectory)"
6060
LanguageStandard="$(LanguageStandard)"
61+
LibraryReferences="@(LibraryReference)"
6162
LinkTimeOptimization="$(LinkTimeOptimization)"
6263
MicrosoftExtensions="$(MicrosoftExtensions)"
6364
NullabilityAnalysis="$(NullabilityAnalysis)"

src/sdk/build/Vezel.Zig.Sdk.Test.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
FastMath="$(FastMath)"
3535
IncludeDirectories="@(IncludeDirectory)"
3636
LanguageStandard="$(LanguageStandard)"
37+
LibraryReferences="@(LibraryReference)"
3738
LinkTimeOptimization="$(LinkTimeOptimization)"
3839
MicrosoftExtensions="$(MicrosoftExtensions)"
3940
NullabilityAnalysis="$(NullabilityAnalysis)"

0 commit comments

Comments
 (0)