Skip to content

Commit 371dea4

Browse files
committed
Fix windows launcher
1 parent 2140cc9 commit 371dea4

File tree

8 files changed

+204
-57
lines changed

8 files changed

+204
-57
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jdk:
1515
before_install:
1616
- docker pull mmhelloworld/idris:1.0
1717
- mkdir -p $HOME/bin/idris-packages $HOME/bin/idris-jvm
18-
- wget https://github.com/mmhelloworld/idris-jvm/releases/download/1.0-SNAPSHOT-20170702/idris-jvm-1.0-SNAPSHOT-20170702.zip
19-
- unzip -o idris-jvm-*.zip -d $HOME/bin/idris-jvm
18+
- wget https://github.com/mmhelloworld/idris-jvm/releases/download/1.0-SNAPSHOT-20170704.beta/idris-jvm-1.0-SNAPSHOT-20170704.beta.zip
19+
- unzip -o idris-jvm-*.zip -d $HOME/bin
2020
- export PATH=`pwd`/bin/travis:$HOME/bin/idris-jvm/codegen/bin:$HOME/.local/bin:$PATH
2121
- export PROJECT_ROOT=`pwd`
2222
- docker run --name idris mmhelloworld/idris:1.0 idris -v && docker cp idris:/root/.stack/snapshots/x86_64-linux/lts-8.18/8.0.2/share/x86_64-linux-ghc-8.0.2/idris-1.0/libs/. $HOME/bin/idris-packages && docker rm idris

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ JVM bytecode backend for Idris
1111

1212
## Install
1313
1. Download and extract JVM bytecode backend from [here](https://github.com/mmhelloworld/idris-jvm/releases).
14-
1. From the extracted directory, run `bin/install` to install Idris packages for idris-jvm.
15-
1. Add `<IDRIS_JVM_EXTRACTED_DIRECTORY>/codegen/bin` to `PATH`.
14+
1. From the extracted directory, run `idris-jvm/bin/install` to install Idris packages for idris-jvm.
15+
1. Add `<IDRIS_JVM_EXTRACTED_DIRECTORY>/idris-jvm/codegen/bin` to `PATH`.
1616

1717
## Example
1818

@@ -29,7 +29,7 @@ JVM bytecode backend for Idris
2929
main = print (pythag 50)
3030
```
3131
32-
* `$ idris --portable-codegen jvm pythag.idr -o target`
32+
* `$ idris --portable-codegen jvm pythag.idr -o target` (For Windows: `idris --portable-codegen jvm.bat pythag.idr -o target`)
3333
* `$ java -cp <IDRIS_JVM_EXTRACTED_DIR>/idris-jvm-runtime.jar:target main.Main`
3434
3535
## Status

bin/stack.yaml

-6
This file was deleted.

idris-jvm-codegen-launcher/pom.xml

+3-39
Original file line numberDiff line numberDiff line change
@@ -30,48 +30,12 @@
3030
<build>
3131
<plugins>
3232
<plugin>
33-
<artifactId>maven-dependency-plugin</artifactId>
33+
<groupId>org.springframework.boot</groupId>
34+
<artifactId>spring-boot-maven-plugin</artifactId>
3435
<executions>
3536
<execution>
36-
<id>copy</id>
37-
<phase>package</phase>
38-
<goals>
39-
<goal>copy</goal>
40-
</goals>
41-
<configuration>
42-
<stripVersion>true</stripVersion>
43-
<artifactItems>
44-
<artifactItem>
45-
<artifactId>idris-jvm-server</artifactId>
46-
<groupId>io.github.mmhelloworld</groupId>
47-
<version>${project.version}</version>
48-
<outputDirectory>${assemble.dir}</outputDirectory>
49-
</artifactItem>
50-
</artifactItems>
51-
</configuration>
52-
</execution>
53-
</executions>
54-
</plugin>
55-
56-
<plugin>
57-
<groupId>org.codehaus.mojo</groupId>
58-
<artifactId>appassembler-maven-plugin</artifactId>
59-
<configuration>
60-
<assembleDirectory>${assemble.dir}</assembleDirectory>
61-
<repositoryName>lib</repositoryName>
62-
<programs>
63-
<program>
64-
<mainClass>io.github.mmhelloworld.idrisjvm.codegen.launcher.IdrisJvmCodegenLauncher
65-
</mainClass>
66-
<id>idris-codegen-jvm</id>
67-
</program>
68-
</programs>
69-
</configuration>
70-
<executions>
71-
<execution>
72-
<phase>package</phase>
7337
<goals>
74-
<goal>assemble</goal>
38+
<goal>repackage</goal>
7539
</goals>
7640
</execution>
7741
</executions>

idris-jvm-codegen-launcher/src/assembly/bin.xml

+15-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
44
<id>bin</id>
5-
<includeBaseDirectory>false</includeBaseDirectory>
5+
<baseDirectory>idris-jvm</baseDirectory>
66
<formats>
77
<format>zip</format>
88
</formats>
@@ -18,6 +18,10 @@
1818
<exclude>**/*.ibc</exclude>
1919
</excludes>
2020
</fileSet>
21+
<fileSet>
22+
<directory>${project.basedir}/src/bin</directory>
23+
<outputDirectory>codegen/bin</outputDirectory>
24+
</fileSet>
2125
<fileSet>
2226
<directory>${project.basedir}/../bin</directory>
2327
<outputDirectory>bin</outputDirectory>
@@ -32,5 +36,15 @@
3236
<outputDirectory/>
3337
<destName>idris-jvm-runtime.jar</destName>
3438
</file>
39+
<file>
40+
<source>${project.basedir}/../idris-jvm-server/target/idris-jvm-server-${project.version}.jar</source>
41+
<outputDirectory>codegen</outputDirectory>
42+
<destName>idris-jvm-server.jar</destName>
43+
</file>
44+
<file>
45+
<source>${project.build.directory}/idris-jvm-codegen-launcher-${project.version}.jar</source>
46+
<outputDirectory>codegen</outputDirectory>
47+
<destName>idris-jvm-codegen-launcher.jar</destName>
48+
</file>
3549
</files>
3650
</assembly>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/sh
2+
3+
# resolve links - $0 may be a softlink
4+
PRG="$0"
5+
6+
while [ -h "$PRG" ]; do
7+
ls=`ls -ld "$PRG"`
8+
link=`expr "$ls" : '.*-> \(.*\)$'`
9+
if expr "$link" : '/.*' > /dev/null; then
10+
PRG="$link"
11+
else
12+
PRG=`dirname "$PRG"`/"$link"
13+
fi
14+
done
15+
16+
PRGDIR=`dirname "$PRG"`
17+
BASEDIR=`cd "$PRGDIR/.." >/dev/null; pwd`
18+
19+
# OS specific support. $var _must_ be set to either true or false.
20+
cygwin=false;
21+
darwin=false;
22+
case "`uname`" in
23+
CYGWIN*) cygwin=true ;;
24+
Darwin*) darwin=true
25+
if [ -z "$JAVA_VERSION" ] ; then
26+
JAVA_VERSION="CurrentJDK"
27+
else
28+
echo "Using Java version: $JAVA_VERSION"
29+
fi
30+
if [ -z "$JAVA_HOME" ]; then
31+
if [ -x "/usr/libexec/java_home" ]; then
32+
JAVA_HOME=`/usr/libexec/java_home`
33+
else
34+
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home
35+
fi
36+
fi
37+
;;
38+
esac
39+
40+
if [ -z "$JAVA_HOME" ] ; then
41+
if [ -r /etc/gentoo-release ] ; then
42+
JAVA_HOME=`java-config --jre-home`
43+
fi
44+
fi
45+
46+
# For Cygwin, ensure paths are in UNIX format before anything is touched
47+
if $cygwin ; then
48+
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
49+
fi
50+
51+
# If a specific java binary isn't specified search for the standard 'java' binary
52+
if [ -z "$JAVACMD" ] ; then
53+
if [ -n "$JAVA_HOME" ] ; then
54+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
55+
# IBM's JDK on AIX uses strange locations for the executables
56+
JAVACMD="$JAVA_HOME/jre/sh/java"
57+
else
58+
JAVACMD="$JAVA_HOME/bin/java"
59+
fi
60+
else
61+
JAVACMD=`which java`
62+
fi
63+
fi
64+
65+
if [ ! -x "$JAVACMD" ] ; then
66+
echo "Error: JAVA_HOME is not defined correctly." 1>&2
67+
echo " We cannot execute $JAVACMD" 1>&2
68+
exit 1
69+
fi
70+
71+
# For Cygwin, switch paths to Windows format before running java
72+
if $cygwin; then
73+
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
74+
[ -n "$HOME" ] && HOME=`cygpath --path --windows "$HOME"`
75+
[ -n "$BASEDIR" ] && BASEDIR=`cygpath --path --windows "$BASEDIR"`
76+
fi
77+
78+
exec "$JAVACMD" $JAVA_OPTS \
79+
-Dapp.name="idris-codegen-jvm" \
80+
-Dapp.pid="$$" \
81+
-Dapp.home="$BASEDIR" \
82+
-Dbasedir="$BASEDIR" \
83+
-jar \
84+
$BASEDIR/idris-jvm-codegen-launcher.jar \
85+
"$@"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
@echo off
2+
3+
set ERROR_CODE=0
4+
setlocal enabledelayedexpansion enableextensions
5+
6+
:init
7+
@REM Decide how to startup depending on the version of windows
8+
9+
@REM -- Win98ME
10+
if NOT "%OS%"=="Windows_NT" goto Win9xArg
11+
12+
@REM set local scope for the variables with windows NT shell
13+
if "%OS%"=="Windows_NT" @setlocal
14+
15+
@REM -- 4NT shell
16+
if "%eval[2+2]" == "4" goto 4NTArgs
17+
18+
@REM -- Regular WinNT shell
19+
set CMD_LINE_ARGS=%*
20+
goto WinNTGetScriptDir
21+
22+
@REM The 4NT Shell from jp software
23+
:4NTArgs
24+
set CMD_LINE_ARGS=%$
25+
goto WinNTGetScriptDir
26+
27+
:Win9xArg
28+
@REM Slurp the command line arguments. This loop allows for an unlimited number
29+
@REM of arguments (up to the command line limit, anyway).
30+
set CMD_LINE_ARGS=
31+
:Win9xApp
32+
if %1a==a goto Win9xGetScriptDir
33+
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
34+
shift
35+
goto Win9xApp
36+
37+
:Win9xGetScriptDir
38+
set SAVEDIR=%CD%
39+
%0\
40+
cd %0\..\..
41+
set BASEDIR=%CD%
42+
cd %SAVEDIR%
43+
set SAVE_DIR=
44+
goto repoSetup
45+
46+
:WinNTGetScriptDir
47+
set BASEDIR=%~dp0\..
48+
49+
if "%JAVACMD%"=="" set JAVACMD=java
50+
51+
for /f %%i in ('where idris-codegen-jvm.bat') do set codegen_path=%%i
52+
53+
call :dir_name_from_path bindir !codegen_path!
54+
pushd %bindir%\..
55+
set BASEDIR=%CD%
56+
popd
57+
goto :end_dir_name_from_path
58+
59+
:dir_name_from_path <resultVar> <pathVar>
60+
(
61+
set "%~1=%~dp2"
62+
exit /b
63+
)
64+
:end_dir_name_from_path
65+
66+
@REM Reaching here means variables are defined and arguments have been captured
67+
:endInit
68+
69+
%JAVACMD% %JAVA_OPTS% -Dapp.name="idris-codegen-jvm" -Dapp.home="%BASEDIR%" -Dbasedir="%BASEDIR%" -jar %BASEDIR%\idris-jvm-codegen-launcher.jar %CMD_LINE_ARGS%
70+
if %ERRORLEVEL% NEQ 0 goto error
71+
goto end
72+
73+
:error
74+
if "%OS%"=="Windows_NT" @endlocal
75+
set ERROR_CODE=%ERRORLEVEL%
76+
77+
:end
78+
@REM set local scope for the variables with windows NT shell
79+
if "%OS%"=="Windows_NT" goto endNT
80+
81+
@REM For old DOS remove the set variables from ENV - we assume they were not set
82+
@REM before we started - at least we don't leave any baggage around
83+
set CMD_LINE_ARGS=
84+
goto postExec
85+
86+
:endNT
87+
@REM If error code is set to 1 then the endlocal was done already in :error.
88+
if %ERROR_CODE% EQU 0 @endlocal
89+
90+
:postExec
91+
92+
if "%FORCE_EXIT_ON_ERROR%" == "on" (
93+
if %ERROR_CODE% NEQ 0 exit %ERROR_CODE%
94+
)
95+
96+
exit /B %ERROR_CODE%

pom.xml

-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
<maven-surefire-plugin.version>2.20</maven-surefire-plugin.version>
3131
<exec-maven-plugin.version>1.5.0</exec-maven-plugin.version>
3232
<maven-assembly-plugin.version>3.0.0</maven-assembly-plugin.version>
33-
<appassembler-maven-plugin.version>1.10</appassembler-maven-plugin.version>
3433
<spring-boot-dependencies.version>1.5.3.RELEASE</spring-boot-dependencies.version>
3534
</properties>
3635

@@ -72,11 +71,6 @@
7271
<artifactId>exec-maven-plugin</artifactId>
7372
<version>${exec-maven-plugin.version}</version>
7473
</plugin>
75-
<plugin>
76-
<groupId>org.codehaus.mojo</groupId>
77-
<artifactId>appassembler-maven-plugin</artifactId>
78-
<version>${appassembler-maven-plugin.version}</version>
79-
</plugin>
8074
<plugin>
8175
<artifactId>maven-compiler-plugin</artifactId>
8276
<version>${maven-compiler-plugin.version}</version>

0 commit comments

Comments
 (0)