Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sharedlib target for windows #1235

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
ennerf marked this conversation as resolved.
Show resolved Hide resolved
}

@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());
}

}
Loading