Added helper program for generating the Makefile rules in an automated way.

This commit is contained in:
LoRd_MuldeR 2020-09-28 13:47:33 +02:00
parent 5105236cf2
commit 8ebb6ae355
6 changed files with 183 additions and 39 deletions

View File

@ -17,14 +17,14 @@ There currently are two different ways to use Launch5j with your application cod
* ***Combine the launcher executable and the JAR file (“wrapping”)***
In order to combine the launcher executable (`launch5j.wrapped.exe`) and the JAR file to a *single* file, you can simply concatenate these files. The executable launcher must go before the JAR file content. There are many ways to achieve this, but one method is by running the following *copy* command-line in the terminal:
In order to combine the launcher executable (`launch5j_wrapped.exe`) and the JAR file to a *single* file, you can simply concatenate these files. The executable launcher must go before the JAR file content. There are many ways to achieve this, but one method is by running the following *copy* command-line in the terminal:
copy /B launch5j.wrapped.exe + my_program.jar my_program.exe
copy /B launch5j_wrapped.exe + my_program.jar my_program.exe
If you are building you application with Apache Ant, consider using the `concat` task like this:
<concat destfile="my_program.exe" binary="true">
<fileset file="launch5j.wrapped.exe"/>
<fileset file="launch5j_wrapped.exe"/>
<fileset file="my_program.jar"/>
</concat>
@ -42,15 +42,18 @@ Launch5j executables come in a number of variants, allowing you to pick the most
* **`registry`**
Tries to automatically detect the install path of the JRE from the Windows registry; default variant expects the JRE to be located in the `/runtime` path relative to the location of the executable launcher.
* **`java11`**
When detecting the JRE install path from the Windows registry, accepts only JRE version 11 or any newer JRE version; default variant accepts only JRE version 8 (1.8.0) or any newer JRE version.
* **`java<N>`**
When detecting the JRE install path from the Windows registry, accepts *only* JRE version **N.0** or any newer JRE version; default variant accepts *only* JRE version **8.0** (1.8.0) or any newer JRE version.
* **`nosplash`**
Does **not** display a splash screen while the application is launching; default variant *does* display a splash screen while the application is launching (will be hidden as soon as application window shows up).
* **`only[32|64]bit`**
When detecting the JRE install path from the Windows registry, accepts *only* 32-Bit (x86) or *only* 64-Bit (x64) JRE versions, respectively; default variant accepts 32-Bit *and* 64-Bit versions with a preference to 64-Bit.
* **`nowait`**
Does **not** keep the launcher executable alive while the application is running; default variant keeps the launcher executable alive until the application terminates and then forwards the application's exit code.
* **`nosplash`**
Does **not** display a splash screen while the application is launching; default variant *does* display a splash screen while the application is launching &ndash; will be hidden as soon as application window shows up.
# Customizations
Launch5j comes with a *default* executable icon and a *default* splash screen bitmap. These just server as an example and you probably want to replace them with your own *application-specific* graphics.

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,2 @@
/.settings
/bin

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>MakefileGenerator</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,116 @@
/************************************************************/
/* Launch5j, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* Java JAR wrapper for creating Windows native executables */
/* https://github.com/lordmulder/ */
/* */
/* This work has been released under the MIT license. */
/* Please see LICENSE.TXT for details! */
/* */
/* ACKNOWLEDGEMENT */
/* This project is partly inspired by the Launch4j project: */
/* https://sourceforge.net/p/launch4j/ */
/************************************************************/
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
/*
* Helper program to generate the Makefile rules for Launch5j
*/
public class MakefileGenerator {
public static void main(String[] args) throws UnsupportedEncodingException {
final List<String> filenNames = new ArrayList<String>();
final PrintStream out = new PrintStream(System.out, true, StandardCharsets.UTF_8.name());
out.println("build: init resources");
for(int wrapped = 0; wrapped < 2; ++wrapped) {
for(int registry = 0; registry < 2; ++registry) {
for(int requireJava = 8; requireJava < 12; ++requireJava) {
if(requireJava == 10) {
continue;
}
for(int requireBitness = 0; requireBitness < 65; requireBitness += 32) {
for(int stayAlive = 1; stayAlive > -1; --stayAlive) {
for(int enableSplash = 1; enableSplash > -1; --enableSplash) {
if((registry == 0) && ((requireJava != 8) || (requireBitness != 0))) {
continue;
}
out.println(generate(filenNames, wrapped, registry, requireJava, requireBitness, stayAlive, enableSplash));
}
}
}
}
}
}
out.println("\nstrip: build");
for(final String fileName : filenNames) {
out.printf("\tstrip %s\n", fileName);
}
}
private static String generate(final List<String> filenNames, final int wrapped, final int registry, final int requireJava, final int requireBitness, final int stayAlive, final int enableSplash)
{
final String fileName = String.format("bin/launch5j_$(CPU_ARCH)%s.exe",
generateNameSuffix(wrapped, registry, requireJava, requireBitness, stayAlive, enableSplash));
final StringBuilder cmdLine = new StringBuilder(String.format(
"\t$(CC) $(CFLAGS) "
+ "-DJAR_FILE_WRAPPED=%d "
+ "-DDETECT_REGISTRY=%d "
+ "-DREQUIRE_JAVA=%-2d "
+ "-DREQUIRE_BITNESS=%-2d "
+ "-DSTAY_ALIVE=%d "
+ "-DENABLE_SPLASH=%d "
+ "-o %s "
+ "src/head.c obj/version.$(CPU_ARCH).o obj/icon.$(CPU_ARCH).o",
wrapped,
registry,
requireJava,
requireBitness,
stayAlive,
enableSplash,
fileName));
if(enableSplash > 0) {
append(cmdLine, ' ', " obj/splash_screen.$(CPU_ARCH).o");
}
filenNames.add(fileName);
return cmdLine.toString();
}
private static String generateNameSuffix(final int wrapped, final int registry, final int requireJava, final int requireBitness, final int stayAlive, final int enableSplash) {
final StringBuilder builder = new StringBuilder();
if(wrapped > 0) {
append(builder, '_', "wrapped");
}
if(registry > 0) {
append(builder, '_', "registry");
}
if(requireJava != 8) {
append(builder, '_', String.format("java%d", requireJava));
}
if(requireBitness != 0) {
append(builder, '_', String.format("only%dbit", requireBitness));
}
if(stayAlive == 0) {
append(builder, '_', "nowait");
}
if(enableSplash == 0) {
append(builder, '_', "nosplash");
}
return (builder.length() > 0) ? builder.insert(0, '_').toString() : "";
}
private static void append(final StringBuilder builder, final char sep, final String string) {
if(builder.length() != 0) {
builder.append(sep);
}
builder.append(string);
}
}