-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Labels
bugSomething isn't workingSomething isn't working
Description
The docc plugin should be able to generate docs for libraries, like SwiftJava which need to pass -I in order to include the necessary libraries that they're wrapping.
For example, for such target:
.target(
name: "JavaKit",
dependencies: [
"JavaRuntime",
"JavaKitMacros",
"JavaTypes",
"JavaKitConfigurationShared", // for Configuration reading at runtime
],
exclude: ["swift-java.config"],
swiftSettings: [
.swiftLanguageMode(.v5),
.unsafeFlags([
"-I\(javaIncludePath)",
"-I\(javaPlatformIncludePath)"
],
.when(platforms: [.macOS, .linux, .windows]))
],
linkerSettings: [
.unsafeFlags(
[
"-L\(javaHome)/lib/server",
"-Xlinker", "-rpath",
"-Xlinker", "\(javaHome)/lib/server",
],
.when(platforms: [.linux, .macOS])
),
.unsafeFlags(
[
"-L\(javaHome)/lib"
],
.when(platforms: [.windows])),
.linkedLibrary(
"jvm",
.when(platforms: [.linux, .macOS, .windows])
),
]
),
Expected behavior
The generated command should carry along all -I options from the target that was built.
Expected command for SwiftJava for example:
/Users/ktoso/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/bin/swift-symbolgraph-extract -module-name JavaKit -target arm64-apple-macosx15.0 -module-cache-path /Users/ktoso/code/swift-java/.build/arm64-apple-macosx/debug/ModuleCache -I /Users/ktoso/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift/macosx/testing -L /Users/ktoso/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift/macosx/testing -plugin-path /Users/ktoso/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift/host/plugins/testing -sdk /Library/Developer/CommandLineTools/SDKs/MacOSX14.5.sdk -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -Xcc -fmodule-map-file=/Users/ktoso/code/swift-java/Sources/JavaRuntime/include/module.modulemap -Xcc -I -Xcc /Users/ktoso/code/swift-java/Sources/JavaRuntime/include -I /Users/ktoso/code/swift-java/.build/arm64-apple-macosx/debug/Modules -minimum-access-level public -skip-inherited-docs -emit-extension-block-symbols -output-dir /Users/ktoso/code/swift-java/.build/arm64-apple-macosx/extracted-symbols/swift-java/JavaKit \
-I (THE "-I\(javaIncludePath)" FROM PACKAGE.SWIFT FOR THIS TARGET) \
-I (THE "-I\(javaPlatformIncludePath)" FROM PACKAGE.SWIFT FOR THIS TARGET) \
note the last two lines
Actual behavior
The plugin generates
/Users/ktoso/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/bin/swift-symbolgraph-extract -module-name JavaKit -target arm64-apple-macosx15.0 -module-cache-path /Users/ktoso/code/swift-java/.build/arm64-apple-macosx/debug/ModuleCache -I /Users/ktoso/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift/macosx/testing -L /Users/ktoso/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift/macosx/testing -plugin-path /Users/ktoso/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift/host/plugins/testing -sdk /Library/Developer/CommandLineTools/SDKs/MacOSX14.5.sdk -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -Xcc -fmodule-map-file=/Users/ktoso/code/swift-java/Sources/JavaRuntime/include/module.modulemap -Xcc -I -Xcc /Users/ktoso/code/swift-java/Sources/JavaRuntime/include -I /Users/ktoso/code/swift-java/.build/arm64-apple-macosx/debug/Modules -minimum-access-level public -skip-inherited-docs -emit-extension-block-symbols -output-dir /Users/ktoso/code/swift-java/.build/arm64-apple-macosx/extracted-symbols/swift-java/JavaKit
which is missing necessary include paths, and therefore fails to build:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "JavaRuntime.h"
^
/Users/ktoso/code/swift-java/Sources/JavaRuntime/include/JavaRuntime.h:18:10: error: 'jni.h' file not found
#include <jni.h> 🔥🔥🔥
^
<unknown>:0: error: could not build Objective-C module 'JavaRuntime'
Error: Failed to load the module 'JavaKit'. Are you missing build dependencies or include/framework directories?
See the previous error messages for details. Aborting.
Steps to Reproduce
git clone https://github.com/swiftlang/swift-java
cd swift-java
swift package --allow-writing-to-directory .docs generate-documentation --output-path .docs --target JavaKit
In case the JavaKit target was renamed it may already be named SwiftJNI, ping me if confused.
Swift-DocC Plugin Version Information
Swift-DocC plugin version: latest head at 7935a77
Swift Compiler version:
-> % swift -version
Apple Swift version 6.1.2 (swift-6.1.2-RELEASE)
Target: arm64-apple-macosx14.0
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working