-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #2516: Support Packaging and Distribution #2524
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d3182f1
add packing and dotc/dotr
liufengyun dd9a473
add brew script for install on Mac
liufengyun dc2f558
fix separation in dotr
liufengyun 0dda9e1
move brew formula to lampepfl/homebrew-dotty
liufengyun c09e87e
refine sbt task for dist
liufengyun b8b6ee4
remove unsupported options
liufengyun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/usr/bin/env bash | ||
|
||
#/*-------------------------------------------------------------------------- | ||
# * Credits: This script is based on the script generated by sbt-pack. | ||
# *--------------------------------------------------------------------------*/ | ||
|
||
cygwin=false | ||
mingw=false | ||
darwin=false | ||
case "`uname`" in | ||
CYGWIN*) cygwin=true | ||
;; | ||
MINGW*) mingw=true | ||
;; | ||
Darwin*) darwin=true | ||
if [ -z "$JAVA_VERSION" ] ; then | ||
JAVA_VERSION="CurrentJDK" | ||
else | ||
echo "Using Java version: $JAVA_VERSION" 1>&2 | ||
fi | ||
if [ -z "$JAVA_HOME" ] ; then | ||
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home | ||
fi | ||
JAVA_OPTS="$JAVA_OPTS -Xdock:name=\"${PROG_NAME}\" -Xdock:icon=\"$PROG_HOME/icon-mac.png\" -Dapple.laf.useScreenMenuBar=true" | ||
JAVACMD="`which java`" | ||
;; | ||
esac | ||
|
||
# Resolve JAVA_HOME from javac command path | ||
if [ -z "$JAVA_HOME" ]; then | ||
javaExecutable="`which javac`" | ||
if [ -n "$javaExecutable" -a -f "$javaExecutable" -a ! "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then | ||
# readlink(1) is not available as standard on Solaris 10. | ||
readLink=`which readlink` | ||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then | ||
javaExecutable="`readlink -f \"$javaExecutable\"`" | ||
javaHome="`dirname \"$javaExecutable\"`" | ||
javaHome=`expr "$javaHome" : '\(.*\)/bin'` | ||
JAVA_HOME="$javaHome" | ||
export JAVA_HOME | ||
fi | ||
fi | ||
fi | ||
|
||
|
||
if [ -z "$JAVACMD" ] ; then | ||
if [ -n "$JAVA_HOME" ] ; then | ||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | ||
# IBM's JDK on AIX uses strange locations for the executables | ||
JAVACMD="$JAVA_HOME/jre/sh/java" | ||
else | ||
JAVACMD="$JAVA_HOME/bin/java" | ||
fi | ||
else | ||
JAVACMD="`which java`" | ||
fi | ||
fi | ||
|
||
if [ ! -x "$JAVACMD" ] ; then | ||
echo "Error: JAVA_HOME is not defined correctly." | ||
echo " We cannot execute $JAVACMD" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$JAVA_HOME" ] ; then | ||
echo "Warning: JAVA_HOME environment variable is not set." | ||
fi | ||
|
||
CLASSPATH_SUFFIX="" | ||
# Path separator used in EXTRA_CLASSPATH | ||
PSEP=":" | ||
|
||
# For Cygwin, switch paths to Windows-mixed format before running java | ||
if $cygwin; then | ||
[ -n "$PROG_HOME" ] && | ||
PROG_HOME=`cygpath -am "$PROG_HOME"` | ||
[ -n "$JAVA_HOME" ] && | ||
JAVA_HOME=`cygpath -am "$JAVA_HOME"` | ||
CLASSPATH_SUFFIX=";" | ||
PSEP=";" | ||
fi | ||
|
||
# For Migwn, ensure paths are in UNIX format before anything is touched | ||
if $mingw ; then | ||
[ -n "$PROG_HOME" ] && | ||
PROG_HOME="`(cd "$PROG_HOME"; pwd -W | sed 's|/|\\\\|g')`" | ||
[ -n "$JAVA_HOME" ] && | ||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd -W | sed 's|/|\\\\|g')`" | ||
CLASSPATH_SUFFIX=";" | ||
PSEP=";" | ||
fi | ||
|
||
#/*-------------------------------------------------- | ||
# * The code below is for Dotty | ||
# *-------------------------------------------------*/ | ||
|
||
for filename in $PROG_HOME/lib/*.jar; do | ||
[[ $filename =~ .*dotty-compiler.*.jar ]] && DOTTY_COMP=$filename | ||
[[ $filename =~ .*dotty-interfaces.*.jar ]] && DOTTY_INTF=$filename | ||
[[ $filename =~ .*dotty-library.*.jar ]] && DOTTY_LIB=$filename | ||
[[ $filename =~ .*scala-asm.*.jar ]] && SCALA_ASM=$filename | ||
[[ $filename =~ .*scala-library.*.jar ]] && SCALA_LIB=$filename | ||
[[ $filename =~ .*scala-xml.*.jar ]] && SCALA_XML=$filename | ||
[[ $filename =~ .*sbt-interface.*.jar ]] && SBT_INTF=$filename | ||
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ -z "$PROG_HOME" ] ; then | ||
## resolve links - $0 may be a link to PROG_HOME | ||
PRG="$0" | ||
|
||
# need this for relative symlinks | ||
while [ -h "$PRG" ] ; do | ||
ls=`ls -ld "$PRG"` | ||
link=`expr "$ls" : '.*-> \(.*\)$'` | ||
if expr "$link" : '/.*' > /dev/null; then | ||
PRG="$link" | ||
else | ||
PRG="`dirname "$PRG"`/$link" | ||
fi | ||
done | ||
|
||
saveddir=`pwd` | ||
|
||
PROG_HOME=`dirname "$PRG"`/.. | ||
|
||
# make it fully qualified | ||
PROG_HOME=`cd "$PROG_HOME" && pwd` | ||
|
||
cd "$saveddir" | ||
fi | ||
|
||
source "$PROG_HOME/bin/common" | ||
|
||
default_java_opts="-Xmx768m -Xms768m" | ||
bootcp=true | ||
|
||
CompilerMain=dotty.tools.dotc.Main | ||
FromTasty=dotty.tools.dotc.FromTasty | ||
ReplMain=dotty.tools.dotc.repl.Main | ||
|
||
PROG_NAME=$CompilerMain | ||
|
||
addJava () { | ||
java_args+=("$1") | ||
} | ||
addScala () { | ||
scala_args+=("$1") | ||
} | ||
addResidual () { | ||
residual_args+=("$1") | ||
} | ||
|
||
classpathArgs () { | ||
# echo "dotty-compiler: $DOTTY_COMP" | ||
# echo "dotty-interface: $DOTTY_INTF" | ||
# echo "dotty-library: $DOTTY_LIB" | ||
# echo "scala-asm: $SCALA_ASM" | ||
# echo "scala-lib: $SCALA_LIB" | ||
# echo "scala-xml: $SCALA_XML" | ||
# echo "sbt-intface: $SBT_INTF" | ||
|
||
toolchain="" | ||
toolchain+="$SCALA_LIB$PSEP" | ||
toolchain+="$DOTTY_LIB$PSEP" | ||
toolchain+="$SCALA_ASM$PSEP" | ||
toolchain+="$SBT_INTF$PSEP" | ||
toolchain+="$DOTTY_INTF$PSEP" | ||
toolchain+="$DOTTY_LIB$PSEP" | ||
toolchain+="$DOTTY_COMP" | ||
|
||
if [[ -n "$bootcp" ]]; then | ||
jvm_cp_args="-Xbootclasspath/a:$toolchain" | ||
else | ||
jvm_cp_args="-classpath $toolchain" | ||
fi | ||
} | ||
|
||
while [[ $# -gt 0 ]]; do | ||
case "$1" in | ||
--) shift; for arg; do addResidual "$arg"; done; set -- ;; | ||
-h|-help) help=true && shift ;; | ||
-v|-verbose) verbose=true && shift ;; | ||
-debug) debug=true && shift ;; | ||
-q|-quiet) quiet=true && shift ;; | ||
|
||
# Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222 | ||
-Oshort) addJava "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" && shift ;; | ||
-repl) PROG_NAME="$ReplMain" && shift ;; | ||
-tasty) PROG_NAME="$FromTasty" && shift ;; | ||
-compile) PROG_NAME="$CompilerMain" && shift ;; | ||
-run) PROG_NAME="$ReplMain" && shift ;; | ||
-bootcp) bootcp=true && shift ;; | ||
-nobootcp) unset bootcp && shift ;; | ||
-colors) colors=true && shift ;; | ||
-no-colors) unset colors && shift ;; | ||
|
||
# break out -D and -J options and add them to JAVA_OPTS as well | ||
# so they reach the JVM in time to do some good. The -D options | ||
# will be available as system properties. | ||
-D*) addJava "$1" && addScala "$1" && shift ;; | ||
-J*) addJava "${1:2}" && addScala "$1" && shift ;; | ||
*) addResidual "$1" && shift ;; | ||
esac | ||
done | ||
|
||
classpathArgs | ||
|
||
eval exec "\"$JAVACMD\"" \ | ||
${JAVA_OPTS:-$default_java_opts} \ | ||
"${java_args[@]}" \ | ||
"$jvm_cp_args" \ | ||
-Dscala.usejavacp=true \ | ||
"$PROG_NAME" \ | ||
"${scala_args[@]}" \ | ||
"${residual_args[@]}" | ||
exit $? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Try to autodetect real location of the script | ||
|
||
if [ -z "$PROG_HOME" ] ; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment here. |
||
## resolve links - $0 may be a link to PROG_HOME | ||
PRG="$0" | ||
|
||
# need this for relative symlinks | ||
while [ -h "$PRG" ] ; do | ||
ls=`ls -ld "$PRG"` | ||
link=`expr "$ls" : '.*-> \(.*\)$'` | ||
if expr "$link" : '/.*' > /dev/null; then | ||
PRG="$link" | ||
else | ||
PRG="`dirname "$PRG"`/$link" | ||
fi | ||
done | ||
|
||
saveddir=`pwd` | ||
|
||
PROG_HOME=`dirname "$PRG"`/.. | ||
|
||
# make it fully qualified | ||
PROG_HOME=`cd "$PROG_HOME" && pwd` | ||
|
||
cd "$saveddir" | ||
fi | ||
|
||
source "$PROG_HOME/bin/common" | ||
|
||
CLASS_PATH="-classpath .$PSEP$DOTTY_LIB$PSEP$SCALA_LIB" | ||
|
||
first_arg="$1" | ||
|
||
if [ -z "$1" ]; then | ||
echo "Starting dotty REPL..." | ||
eval "$PROG_HOME/bin/dotc -repl" | ||
elif [[ ${first_arg:0:1} == "-" ]]; then | ||
eval "$PROG_HOME/bin/dotc -repl $@" | ||
else | ||
eval exec "\"$JAVACMD\"" $CLASS_PATH $@ | ||
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot of copy paste and re-implementation for the current
bin/dotc
script.I propose we merge the two, otherwise it will be hard to maintain and we'll be using different scripts from the ones our users do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DarkDimius I agree there's a potential to merge the two. But I think we can delay the merge after the Copenhagen release -- as the
bin/dotc
andbin/dotr
have something special to the development of the compiler, such as switch between bootstrap and unbootstrap versions. We can make the decision later.