Skip to content

Commit

Permalink
added sharedlib support for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ennerf committed Nov 9, 2023
1 parent c685783 commit 08d6bdb
Showing 1 changed file with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ List<String> getTargetSpecificLinkOutputFlags() {
@Override
String getLinkOutputName() {
String appName = projectConfiguration.getAppName();
return appName + ".exe";
return appName + (projectConfiguration.isSharedLibrary() ? ".dll" : ".exe");
}

@Override
Expand All @@ -160,9 +160,16 @@ List<String> getTargetSpecificLinkFlags(boolean useJavaFX, boolean usePrismSW) {
List<String> flags = new ArrayList<>();
flags.add("/NODEFAULTLIB:libcmt.lib");

if (projectConfiguration.isSharedLibrary()) {
flags.add("/DLL");
}

if (useJavaFX) {
flags.add("/SUBSYSTEM:WINDOWS");
flags.add("/ENTRY:mainCRTStartup");

if (!projectConfiguration.isSharedLibrary()) {
flags.add("/SUBSYSTEM:WINDOWS");
flags.add("/ENTRY:mainCRTStartup");
}

flags.addAll(asListOfLibraryLinkFlags(javaFxWindowsLibs));
flags.addAll(asListOfLibraryLinkFlags(staticJavaFxLibs));
Expand Down Expand Up @@ -296,4 +303,30 @@ private String findCacheFlag() throws IOException, InterruptedException {
}
return flag;
}

@Override
List<String> getAdditionalSourceFiles() {
if (projectConfiguration.isSharedLibrary()) {
return List.of();
}
return super.getAdditionalSourceFiles();
}

@Override
public boolean createSharedLib() throws IOException, InterruptedException {
if (!compile()) {
Logger.logSevere("Error building a shared image: error compiling the native image");
return false;
}
if (!link()) {
Logger.logSevere("Error building a shared image: error linking the native image");
return false;
}
return Files.exists(getLinkOutputFile());
}

Path getLinkOutputFile() {
return paths.getAppPath().resolve(getLinkOutputName());
}

}

0 comments on commit 08d6bdb

Please sign in to comment.