ffdec-cli as separate executable, project

ffdec executable on linux
This commit is contained in:
Jindra Petřík
2024-01-15 23:17:45 +01:00
parent 06ea0c2dff
commit 4e63384f56
28 changed files with 515 additions and 164 deletions

2
.gitattributes vendored
View File

@@ -33,6 +33,8 @@
# Batch files
*.sh text eol=lf
ffdec text eol=lf
ffdec-cli text eol=lf
*.bat text eol=crlf
# PHP scripts

7
.gitignore vendored
View File

@@ -96,3 +96,10 @@ exported1.all.bin
/libsrc/miterstroke/nbproject/private/
/libsrc/miterstroke/build/
/libsrc/miterstroke/dist/
/libsrc/ffdec_cli/build/
/libsrc/ffdec_cli/nbproject/private/
/libsrc/ffdec_cli/javadoc/
/libsrc/ffdec_cli/coverage/
/libsrc/ffdec_cli/reports/
/libsrc/ffdec_cli/dist/
/libsrc/ffdec_cli/coverage.ec

View File

@@ -77,6 +77,7 @@ Key Features: \n \
app.installer.dir = mac/installer
app.bundle.dir = mac/bundle
cli.script = libsrc/ffdec_cli/build.xml
#------------- COMMMON SCRIPT PROPERTIES, supposed not to change -------------

View File

@@ -558,6 +558,8 @@
<target name="res">
<copy todir="${dist.dir}">
<fileset dir="${resources.dir}" includes="**/*.*"/>
<fileset dir="${resources.dir}" includes="ffdec"/>
<fileset dir="${resources.dir}" includes="ffdec-cli"/>
</copy>
<copy todir="${dist.dir}" file="${changelog.file}"/>
<fixcrlf srcdir="${dist.dir}" includes="**/*.md" eol="crlf" preservelastmodified="true" />
@@ -701,6 +703,7 @@
<attribute name="Class-Path" value="${manifestClassPath}"/>
</manifest>
</jar>
<antcall target="build_cli"></antcall>
</target>
<target name="run" depends="build">
@@ -962,6 +965,10 @@
</exec>
</target>
<target name="build_cli">
<ant antfile="${cli.script}" target="build" inheritAll="false" usenativebasedir="true"/>
</target>
<target name="github-newversion" depends="-git-required,-git-checkout-master,-github-newversion-input,rename-unreleased-section,update-changelog-md,update-metainfo">
<exec executable="git" failonerror="true">
<arg value="add"/>

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,36 @@
run.params =
builder = jpexs
project.name = FFDec_Cli
prefix.filename = ffdec-cli
target.java = 1.8
src.dir = src
test.dir = test
test.lib.dir = testlib
test.result.dir = reports/tests
coverage.result.dir = reports/coverage
dist.dir = dist
compile.dir = build/classes
coverage.dir = coverage
compile.test.dir = build/test
lib.dir = ../../lib
liblib.dir = lib
releases.dir = releases
properties.name = project.properties
dist.lib.dirname = lib
javadoc.dir = javadoc
lexers.dir = lexers
ant.lib.dir = antlib
version_info = version.properties
#for run task (MB):
max.heap.size.run = 8094
main.class = com.jpexs.decompiler.flash.cli.CommandlineInterface
app.dir = ../../dist
app.lib.dir = ../../dist/lib

175
libsrc/ffdec_cli/build.xml Normal file
View File

@@ -0,0 +1,175 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="FFDec CLI" basedir="." default="build" xmlns:jacoco="antlib:org.jacoco.ant">
<description>Builds project FFDec CLI</description>
<loadproperties srcfile="build.properties" />
<path id="ant.lib.classpath">
<fileset dir="${ant.lib.dir}" includes="**/*.jar"/>
</path>
<taskdef name="testng" classname="org.testng.TestNGAntTask" classpathref="ant.lib.classpath" />
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpathref="ant.lib.classpath" />
<property name="jar.filename" value="${prefix.filename}"/>
<description>Builds project</description>
<property name="dist.lib.dir" value="${dist.dir}/${dist.lib.dirname}"/>
<patternset id="compiler.resources">
<include name="**/?*.properties"/>
<include name="**/?*.bin"/>
<include name="**/?*.xml"/>
<include name="**/?*.txt"/>
<include name="**/?*.gif"/>
<include name="**/?*.png"/>
<include name="**/?*.jpeg"/>
<include name="**/?*.jpg"/>
<include name="**/?*.html"/>
<include name="**/?*.dtd"/>
<include name="**/?*.tld"/>
<include name="**/?*.mid"/>
<include name="**/?*.wav"/>
<include name="**/?*.js"/>
<include name="**/?*.css"/>
</patternset>
<target name="compile">
<mkdir dir="${compile.dir}"/>
<mkdir dir="${lib.dir}"/>
<copy todir="${lib.dir}">
<fileset dir="${liblib.dir}">
<type type="file"/>
</fileset>
</copy>
<mkdir dir="${app.lib.dir}"/>
<copy todir="${app.lib.dir}">
<fileset dir="${liblib.dir}">
<type type="file"/>
</fileset>
</copy>
<javac srcdir="${src.dir}" destdir="${compile.dir}" includes="**/*.java" target="${target.java}" source="${target.java}" debug="true"
debuglevel="lines,vars,source" includeantruntime="false" encoding="utf-8">
<compilerarg line="-Xlint:unchecked -Xlint:deprecation"/> <!-- For Java 8: -Xdiags:verbose -->
<classpath>
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</classpath>
</javac>
<copy todir="${compile.dir}">
<fileset dir="${src.dir}">
<patternset refid="compiler.resources"/>
<type type="file"/>
</fileset>
</copy>
</target>
<target name="compile-tests">
<delete dir="${compile.test.dir}"/>
<mkdir dir="${compile.test.dir}"/>
<javac srcdir="${test.dir}" destdir="${compile.test.dir}" includes="**/*.java" target="${target.java}" source="${target.java}" debug="true" includeantruntime="false" encoding="utf-8">
<classpath>
<pathelement path="${compile.dir}"/>
<fileset dir="${lib.dir}" includes="**/*.jar"/>
<fileset dir="${test.lib.dir}" includes="**/*.jar"/>
</classpath>
</javac>
</target>
<target name="-test-sethalt" depends="">
<property name="test.halt" value="true" />
</target>
<target name="-test-setnohalt" unless="test.halt">
<property name="test.halt" value="false" />
</target>
<target name="testhalt" depends="-test-sethalt,test">
</target>
<target name="test" depends="-test-setnohalt,compile,compile-tests">
<delete dir="${test.result.dir}"/>
<mkdir dir="${test.result.dir}"/>
<mkdir dir="${test.result.dir}/raw/"/>
<mkdir dir="${coverage.dir}" />
<jacoco:coverage destfile="${coverage.dir}/jacoco.exec">
<testng
outputDir="${test.result.dir}"
haltOnFailure="${test.halt}" verbose="2" workingDir="${basedir}" >
<classpath>
<pathelement path="${compile.test.dir}"/>
<pathelement path="${compile.dir}"/>
<fileset dir="${lib.dir}" includes="**/*.jar"/>
<fileset dir="${test.lib.dir}" includes="**/*.jar"/>
</classpath>
<jvmarg value="-noverify" />
<classfileset dir="${compile.test.dir}" includes="**/*.class" />
</testng>
</jacoco:coverage>
<!-- Coverage report -->
<mkdir dir="${coverage.result.dir}"/>
<jacoco:report>
<executiondata>
<file file="${coverage.dir}/jacoco.exec" />
</executiondata>
<structure name="${project.name}">
<classfiles>
<fileset dir="${compile.dir}" />
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${src.dir}" />
</sourcefiles>
</structure>
<html destdir="${coverage.result.dir}" />
</jacoco:report>
</target>
<target name="build" depends="compile">
<mkdir dir="${dist.dir}"/>
<pathconvert pathsep=" " property="manifestClassPath">
<fileset dir="${basedir}" includes="${dist.lib.dirname}/**/*.*"/>
<chainedmapper>
<flattenmapper/>
<globmapper from="*" to="${dist.lib.dirname}/*"/>
</chainedmapper>
</pathconvert>
<jar destfile="${dist.dir}/${jar.filename}.jar" basedir="${compile.dir}">
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
<attribute name="Class-Path" value="${manifestClassPath}"/>
</manifest>
</jar>
<copy file="${dist.dir}/${jar.filename}.jar" tofile="${app.dir}/${jar.filename}.jar" />
</target>
<target name="javadoc">
<mkdir dir="${javadoc.dir}"/>
<javadoc sourcepath="${src.dir}" destdir="${javadoc.dir}" windowtitle="${project.name}"
useexternalfile="yes">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath>
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</classpath>
</javadoc>
</target>
<target name="clean">
<delete dir="${dist.dir}"/>
<delete dir="${compile.test.dir}"/>
<delete dir="${compile.dir}"/>
<delete dir="${coverage.dir}"/>
<delete dir="${test.result.dir}"/>
<delete dir="${coverage.result.dir}"/>
<delete dir="${javadoc.dir}"/>
</target>
<target name="run" depends="build">
<java jar="${app.dir}/${jar.filename}.jar" fork="true">
<env key="VLC_VERBOSE" value="-1" />
<jvmarg value="-Xmx${max.heap.size.run}m" />
<jvmarg value="-Djava.net.preferIPv4Stack=true" />
<arg line="${run.params}" />
</java>
</target>
</project>

Binary file not shown.

View File

@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.ant.freeform</type>
<configuration>
<general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
<!-- Do not use Project Properties customizer when editing this file manually.
To prevent the customizer from showing, create nbproject/project.properties file and enter
auxiliary.show.customizer=false
property there. Adding
auxiliary.show.customizer.message=<message>
will show your customized message when someone attempts to open the customizer. -->
<name>FFDec CLI</name>
<properties/>
<folders>
<source-folder>
<label>src</label>
<type>java</type>
<location>src</location>
</source-folder>
</folders>
<ide-actions>
<action name="build">
<target>build</target>
</action>
<action name="clean">
<target>clean</target>
</action>
<action name="javadoc">
<target>javadoc</target>
</action>
<action name="run">
<target>run</target>
</action>
<action name="test">
<target>test</target>
</action>
<action name="rebuild">
<target>clean</target>
<target>build</target>
</action>
</ide-actions>
<export>
<type>folder</type>
<location>build/classes</location>
<build-target>build</build-target>
</export>
<view>
<items>
<source-folder style="packages">
<label>src</label>
<location>src</location>
</source-folder>
<source-file>
<location>build.xml</location>
</source-file>
</items>
<context-menu>
<ide-action name="build"/>
<ide-action name="rebuild"/>
<ide-action name="clean"/>
<ide-action name="javadoc"/>
<ide-action name="run"/>
<ide-action name="test"/>
</context-menu>
</view>
</general-data>
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/4">
<compilation-unit>
<package-root>src</package-root>
<classpath mode="compile">lib/jansi-2.4.0.jar;../../lib/ffdec_lib.jar</classpath>
<built-to>build/classes</built-to>
<source-level>1.8</source-level>
</compilation-unit>
</java-data>
</configuration>
</project>

View File

@@ -14,9 +14,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.console;
package com.jpexs.decompiler.flash.cli;
import com.jpexs.decompiler.flash.console.commands.Main;
import com.jpexs.decompiler.flash.cli.commands.Main;
import org.fusesource.jansi.AnsiConsole;
import picocli.CommandLine;
@@ -24,7 +24,7 @@ import picocli.CommandLine;
*
* @author JPEXS
*/
public class NewCommandLine {
public class CommandlineInterface {
public static void main(String[] args) {
AnsiConsole.systemInstall();

View File

@@ -14,13 +14,13 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.console.commands;
import com.jpexs.decompiler.flash.console.commands.types.ConfigConverter;
import com.jpexs.decompiler.flash.console.commands.types.ExportObject;
import com.jpexs.decompiler.flash.console.commands.types.ExportObjectFormat;
import com.jpexs.decompiler.flash.console.commands.types.ExportObjectFormatConverter;
import com.jpexs.decompiler.flash.console.commands.types.Selection;
import com.jpexs.decompiler.flash.console.commands.types.SelectionConverter;
package com.jpexs.decompiler.flash.cli.commands;
import com.jpexs.decompiler.flash.cli.commands.types.ConfigConverter;
import com.jpexs.decompiler.flash.cli.commands.types.ExportObject;
import com.jpexs.decompiler.flash.cli.commands.types.ExportObjectFormat;
import com.jpexs.decompiler.flash.cli.commands.types.ExportObjectFormatConverter;
import com.jpexs.decompiler.flash.cli.commands.types.Selection;
import com.jpexs.decompiler.flash.cli.commands.types.SelectionConverter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

View File

@@ -14,9 +14,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.console.commands;
package com.jpexs.decompiler.flash.cli.commands;
import com.jpexs.decompiler.flash.ApplicationInfo;
import com.jpexs.decompiler.flash.console.commands.types.ConfigConverter;
import com.jpexs.decompiler.flash.cli.commands.types.ConfigConverter;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
@@ -32,7 +32,7 @@ import picocli.CommandLine.ScopeType;
*
* @author JPEXS
*/
@Command(name="<ffdec>",
@Command(name="ffdec-cli",
mixinStandardHelpOptions = true,
versionProvider = VersionProvider.class,
subcommands = {
@@ -43,18 +43,13 @@ import picocli.CommandLine.ScopeType;
optionListHeading = "%n@|bold,underline Options|@:%n",
parameterListHeading = "%n@|bold,underline Parameters|@:%n",
synopsisHeading = "@|bold,underline Usage|@:",
customSynopsis = {"<ffdec> [@|fg(yellow) FILE|@...]",
/*customSynopsis = {"<ffdec> [@|fg(yellow) FILE|@...]",
" or <ffdec> [@|fg(yellow) -hV|@]",
" or <ffdec> @|fg(yellow) --cli|@ [COMMAND]"},
description = {"JPEXS Free Flash Decompiler commandline interface",
"",
"@|bold,underline Executable|@:",
" <ffdec> ffdec.sh on Linux/MacOs, ffdec.bat on Windows",
" or 'java -jar ffdec.jar' on all java"
},
commandListHeading = "%n@|bold,underline Commands|@:%n"
" or <ffdec> @|fg(yellow) --cli|@ [COMMAND]"},*/
description = {"JPEXS Free Flash Decompiler commandline interface"},
commandListHeading = "%n@|bold,underline Commands|@:%n"
)
public class Main implements Runnable {
public class Main {
@Option(names = "--config",
paramLabel = "<key>=<value>[,<key>=<value>...]",
@@ -67,19 +62,9 @@ public class Main implements Runnable {
)
private Map<String, String> configs = new HashMap<>();
@Parameters(paramLabel = "FILE", description = "one or more files to open in GUI")
private File[] files;
@Option(names = "--cli",
required = true,
description = "Use new commandline mode",
scope = ScopeType.INHERIT)
private boolean cli = false;
@Override
public void run() {
System.out.println("Main command");
}
/*@Parameters(paramLabel = "FILE", description = "one or more files to open in GUI")
private File[] files; */
}
class VersionProvider implements IVersionProvider {

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.console.commands.types;
package com.jpexs.decompiler.flash.cli.commands.types;
import com.jpexs.decompiler.flash.configuration.Configuration;
import java.lang.reflect.Field;

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.console.commands.types;
package com.jpexs.decompiler.flash.cli.commands.types;
import com.jpexs.decompiler.flash.exporters.modes.BinaryDataExportMode;
import com.jpexs.decompiler.flash.exporters.modes.ButtonExportMode;

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.console.commands.types;
package com.jpexs.decompiler.flash.cli.commands.types;
/**
*

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.console.commands.types;
package com.jpexs.decompiler.flash.cli.commands.types;
import java.util.ArrayList;
import java.util.List;

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.console.commands.types;
package com.jpexs.decompiler.flash.cli.commands.types;
/**
*

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.console.commands.types;
package com.jpexs.decompiler.flash.cli.commands.types;
import java.util.ArrayList;
import java.util.List;

View File

@@ -14,10 +14,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.console.commands.types;
package com.jpexs.decompiler.flash.cli.commands.types;
import com.jpexs.decompiler.flash.console.CommandLineArgumentParser;
import static com.jpexs.decompiler.flash.console.CommandLineArgumentParser.badArguments;
import java.util.ArrayList;
import java.util.List;
import picocli.CommandLine;

View File

@@ -27,6 +27,12 @@
<location>test</location>
<encoding>UTF-8</encoding>
</source-folder>
<source-folder>
<label>libsrc\ffdec_cli\src</label>
<type>java</type>
<location>libsrc/ffdec_cli/src</location>
<encoding>UTF-8</encoding>
</source-folder>
<source-folder>
<label>libsrc\ffdec_lib\src</label>
<type>java</type>
@@ -237,6 +243,10 @@
<label>test</label>
<location>test</location>
</source-folder>
<source-folder style="packages">
<label>libsrc\ffdec_cli\src</label>
<location>libsrc/ffdec_cli/src</location>
</source-folder>
<source-folder style="packages">
<label>libsrc\ffdec_lib\src</label>
<location>libsrc/ffdec_lib/src</location>
@@ -340,6 +350,10 @@
<built-to>build/test</built-to>
<source-level>1.8</source-level>
</compilation-unit>
<compilation-unit>
<package-root>libsrc/ffdec_cli/src</package-root>
<source-level>1.8</source-level>
</compilation-unit>
<compilation-unit>
<package-root>libsrc/ffdec_lib/src</package-root>
<source-level>1.8</source-level>

17
resources/ffdec Normal file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# This is a comment, it starts with "#".
# Uncomment following and set it to higher value if you want more memory
# You need 64 bit OS and 64 bit java to set it to higher values
# FFDEC_MEMORY=1024m
# Uncomment following when you encounter StackOverFlowErrors.
# If the app then terminates with OutOfMemory you can experiment with lower value.
# FFDEC_STACK_SIZE=32m
# Hide VLC error output
export VLC_VERBOSE=-1
export FFDEC_JARFILENAME=ffdec.jar
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
exec $SCRIPT_DIR/run-java.sh "$@"

17
resources/ffdec-cli Normal file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# This is a comment, it starts with "#".
# Uncomment following and set it to higher value if you want more memory
# You need 64 bit OS and 64 bit java to set it to higher values
# FFDEC_MEMORY=1024m
# Uncomment following when you encounter StackOverFlowErrors.
# If the app then terminates with OutOfMemory you can experiment with lower value.
# FFDEC_STACK_SIZE=32m
# Hide VLC error output
export VLC_VERBOSE=-1
export FFDEC_JARFILENAME=ffdec-cli.jar
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
exec $SCRIPT_DIR/run-java.sh "$@"

BIN
resources/ffdec-cli.exe Normal file

Binary file not shown.

View File

@@ -12,121 +12,6 @@
# Hide VLC error output
export VLC_VERBOSE=-1
# Based on Freerapid Downloader startup script - created by Petris 2009
# FFDec requires Oracle Java 8
# Look for java in these directories
LOOKUP_JRE_DIRS="/usr/lib/jvm/* /opt/java* /opt/jre*"
# Required version
REQ_JVER1=1
REQ_JVER2=8
REQ_JVER3=0
REQ_JVER4=0
search_jar_file() {
JAR_FILE_CANDIDATES='./ffdec.jar ../dist/ffdec.jar /usr/share/java/ffdec.jar /usr/share/java/ffdec/ffdec.jar /usr/share/java/jpexs-decompiler/ffdec.jar'
for f in $JAR_FILE_CANDIDATES ; do
[ -r "$f" ] && JAR_FILE="$f" && return 0
done
echo Unable to find ffdec.jar in the following locations:
echo "${JAR_FILE_CANDIDATES// /$'\n'}"
return 1
}
check_java_version () {
JVER1=$(echo $JAVA_VERSION_OUTPUT | sed 's/java version "\([0-9]*\)\.[0-9]*\.[0-9]*\(_[0-9]*\)\?".*/\1/')
JVER2=$(echo $JAVA_VERSION_OUTPUT | sed 's/java version "[0-9]*\.\([0-9]*\)\.[0-9]*\(_[0-9]*\)\?".*/\1/')
JVER3=$(echo $JAVA_VERSION_OUTPUT | sed 's/java version "[0-9]*\.[0-9]*\.\([0-9]*\)\(_[0-9]*\)\?".*/\1/')
JVER4=$(echo $JAVA_VERSION_OUTPUT | sed 's/java version "[0-9]*\.[0-9]*\.[0-9]*\(_\([0-9]*\)\)\?".*/\2/' | sed 's/^$/0/')
if [ "$JVER1" -gt $REQ_JVER1 ]; then
return 0
elif [ "$JVER1" -lt $REQ_JVER1 ]; then
return 1
fi
if [ "$JVER2" -gt $REQ_JVER2 ]; then
return 0
elif [ "$JVER2" -lt $REQ_JVER2 ]; then
return 1
fi
if [ "$JVER3" -gt $REQ_JVER3 ]; then
return 0
elif [ "$JVER3" -lt $REQ_JVER3 ]; then
return 1
fi
if [ "$JVER4" -lt $REQ_JVER4 ]; then
return 1
fi
return 0
}
# Handle symlinks
PROGRAM="$0"
while [ -L "$PROGRAM" ]; do
PROGRAM=$(readlink -f "$PROGRAM")
done
pushd "$(dirname "$PROGRAM")" > /dev/null
search_jar_file || exit 1
if [ "${JAR_FILE:0:1}" != '/' ] ; then
JAR_FILE=$(pwd)/$JAR_FILE
fi
popd > /dev/null
if [ -z ${FFDEC_MEMORY+x} ]; then
FFDEC_MEMORY=1024m
fi
STACK_SIZE_PARAM=""
MEMORY_PARAM=""
if [ -n "$FFDEC_STACK_SIZE" ]; then
STACK_SIZE_PARAM=" -Xss$FFDEC_STACK_SIZE"
fi
if [ -n "$FFDEC_MEMORY" ]; then
MEMORY_PARAM=" -Xmx$FFDEC_MEMORY"
fi
args=(-Djava.net.preferIPv4Stack=true${MEMORY_PARAM}${STACK_SIZE_PARAM} -jar $JAR_FILE "$@")
if [ "$(uname)" = "Darwin" ]; then
args=(-Xdock:name=FFDec -Xdock:icon=icon.png "${args[@]}")
fi
# Check default java
if [ -x "$(which java)" ]; then
JAVA_VERSION_OUTPUT=$(java -version 2>&1)
JAVA_VERSION_OUTPUT=$(echo $JAVA_VERSION_OUTPUT | sed 's/openjdk version/java version/')
check_java_version && exec java "${args[@]}"
fi
# Test other possible Java locations
for JRE_PATH in $LOOKUP_JRE_DIRS; do
if [ -x "$JRE_PATH/bin/java" ]; then
JAVA_VERSION_OUTPUT=$("$JRE_PATH/bin/java" -version 2>&1)
JAVA_VERSION_OUTPUT=`echo $JAVA_VERSION_OUTPUT | sed 's/openjdk version/java version/'`
check_java_version && {
export JRE_PATH
exec "$JRE_PATH/bin/java" "${args[@]}"
}
fi
done
# Failed
if [ -x "$(which xmessage)" ]; then
xmessage -nearmouse -file - <<EOF
Failed to find a suitable java version.
Required: $REQ_JVER1.$REQ_JVER2.$REQ_JVER3.$REQ_JVER4 or newer.
EOF
else
echo Failed to find a suitable java version.
echo Required: $REQ_JVER1.$REQ_JVER2.$REQ_JVER3.$REQ_JVER4 or newer.
fi
exit 1
export FFDEC_JARFILENAME=ffdec.jar
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
exec $SCRIPT_DIR/run-java.sh "$@"

132
resources/run-java.sh Normal file
View File

@@ -0,0 +1,132 @@
#!/usr/bin/env bash
# This is a comment, it starts with "#".
# Uncomment following and set it to higher value if you want more memory
# You need 64 bit OS and 64 bit java to set it to higher values
# FFDEC_MEMORY=1024m
# Uncomment following when you encounter StackOverFlowErrors.
# If the app then terminates with OutOfMemory you can experiment with lower value.
# FFDEC_STACK_SIZE=32m
# FFDec requires Oracle Java 8
# Look for java in these directories
LOOKUP_JRE_DIRS="/usr/lib/jvm/* /opt/java* /opt/jre*"
# Required version
REQ_JVER1=1
REQ_JVER2=8
REQ_JVER3=0
REQ_JVER4=0
if [ -z ${FFDEC_JARFILENAME+x} ]; then
FFDEC_JARFILENAME=ffdec.jar
fi
search_jar_file() {
JAR_FILE_CANDIDATES="./${FFDEC_JARFILENAME} ../dist/${FFDEC_JARFILENAME} /usr/share/java/${FFDEC_JARFILENAME} /usr/share/java/ffdec/${FFDEC_JARFILENAME} /usr/share/java/jpexs-decompiler/${FFDEC_JARFILENAME}"
for f in $JAR_FILE_CANDIDATES ; do
[ -r "$f" ] && JAR_FILE="$f" && return 0
done
echo Unable to find ${FFDEC_JARFILE} in the following locations:
echo "${JAR_FILE_CANDIDATES// /$'\n'}"
return 1
}
check_java_version () {
JVER1=$(echo $JAVA_VERSION_OUTPUT | sed 's/java version "\([0-9]*\)\.[0-9]*\.[0-9]*\(_[0-9]*\)\?".*/\1/')
JVER2=$(echo $JAVA_VERSION_OUTPUT | sed 's/java version "[0-9]*\.\([0-9]*\)\.[0-9]*\(_[0-9]*\)\?".*/\1/')
JVER3=$(echo $JAVA_VERSION_OUTPUT | sed 's/java version "[0-9]*\.[0-9]*\.\([0-9]*\)\(_[0-9]*\)\?".*/\1/')
JVER4=$(echo $JAVA_VERSION_OUTPUT | sed 's/java version "[0-9]*\.[0-9]*\.[0-9]*\(_\([0-9]*\)\)\?".*/\2/' | sed 's/^$/0/')
if [ "$JVER1" -gt $REQ_JVER1 ]; then
return 0
elif [ "$JVER1" -lt $REQ_JVER1 ]; then
return 1
fi
if [ "$JVER2" -gt $REQ_JVER2 ]; then
return 0
elif [ "$JVER2" -lt $REQ_JVER2 ]; then
return 1
fi
if [ "$JVER3" -gt $REQ_JVER3 ]; then
return 0
elif [ "$JVER3" -lt $REQ_JVER3 ]; then
return 1
fi
if [ "$JVER4" -lt $REQ_JVER4 ]; then
return 1
fi
return 0
}
# Handle symlinks
PROGRAM="$0"
while [ -L "$PROGRAM" ]; do
PROGRAM=$(readlink -f "$PROGRAM")
done
pushd "$(dirname "$PROGRAM")" > /dev/null
search_jar_file || exit 1
if [ "${JAR_FILE:0:1}" != '/' ] ; then
JAR_FILE=$(pwd)/$JAR_FILE
fi
popd > /dev/null
if [ -z ${FFDEC_MEMORY+x} ]; then
FFDEC_MEMORY=1024m
fi
STACK_SIZE_PARAM=""
MEMORY_PARAM=""
if [ -n "$FFDEC_STACK_SIZE" ]; then
STACK_SIZE_PARAM=" -Xss$FFDEC_STACK_SIZE"
fi
if [ -n "$FFDEC_MEMORY" ]; then
MEMORY_PARAM=" -Xmx$FFDEC_MEMORY"
fi
args=(-Djava.net.preferIPv4Stack=true${MEMORY_PARAM}${STACK_SIZE_PARAM} -jar $JAR_FILE "$@")
if [ "$(uname)" = "Darwin" ]; then
args=(-Xdock:name=FFDec -Xdock:icon=icon.png "${args[@]}")
fi
# Check default java
if [ -x "$(which java)" ]; then
JAVA_VERSION_OUTPUT=$(java -version 2>&1)
JAVA_VERSION_OUTPUT=$(echo $JAVA_VERSION_OUTPUT | sed 's/openjdk version/java version/')
check_java_version && exec java "${args[@]}"
fi
# Test other possible Java locations
for JRE_PATH in $LOOKUP_JRE_DIRS; do
if [ -x "$JRE_PATH/bin/java" ]; then
JAVA_VERSION_OUTPUT=$("$JRE_PATH/bin/java" -version 2>&1)
JAVA_VERSION_OUTPUT=`echo $JAVA_VERSION_OUTPUT | sed 's/openjdk version/java version/'`
check_java_version && {
export JRE_PATH
exec "$JRE_PATH/bin/java" "${args[@]}"
}
fi
done
# Failed
if [ -x "$(which xmessage)" ]; then
xmessage -nearmouse -file - <<EOF
Failed to find a suitable java version.
Required: $REQ_JVER1.$REQ_JVER2.$REQ_JVER3.$REQ_JVER4 or newer.
EOF
else
echo Failed to find a suitable java version.
echo Required: $REQ_JVER1.$REQ_JVER2.$REQ_JVER3.$REQ_JVER4 or newer.
fi
exit 1

View File

@@ -44,7 +44,6 @@ import com.jpexs.decompiler.flash.configuration.SwfSpecificConfiguration;
import com.jpexs.decompiler.flash.configuration.SwfSpecificCustomConfiguration;
import com.jpexs.decompiler.flash.console.CommandLineArgumentParser;
import com.jpexs.decompiler.flash.console.ContextMenuTools;
import com.jpexs.decompiler.flash.console.NewCommandLine;
import com.jpexs.decompiler.flash.exporters.modes.ExeExportMode;
import com.jpexs.decompiler.flash.gfx.GfxConvertor;
import com.jpexs.decompiler.flash.gui.debugger.DebugAdapter;