Skip to content

Commit

Permalink
sharedlib target for windows (#1235)
Browse files Browse the repository at this point in the history
* added sharedlib support for windows

(cherry picked from commit 08d6bdb)

* applied pr comments
  • Loading branch information
ennerf authored Nov 16, 2023
1 parent 992e31e commit a62c01b
Showing 1 changed file with 37 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2022, Gluon
* Copyright (c) 2019, 2023, Gluon
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down 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(getSharedLibPath());
}

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

}

0 comments on commit a62c01b

Please sign in to comment.