summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lesot <jplesot@google.com>2015-04-01 17:00:34 +0200
committerJean-Philippe Lesot <jplesot@google.com>2015-04-01 18:07:52 +0200
commit011ec29c12763f9cc655933414b5c0a5c9a7b6ca (patch)
treecb92aea7a4539cb0c9cbc678143ca589e269f42d
parent98efb7bb82b1a2a3c5ada01c7b2265ecf408db82 (diff)
downloadtoolchain_jack-011ec29c12763f9cc655933414b5c0a5c9a7b6ca.zip
toolchain_jack-011ec29c12763f9cc655933414b5c0a5c9a7b6ca.tar.gz
toolchain_jack-011ec29c12763f9cc655933414b5c0a5c9a7b6ca.tar.bz2
Add local setting, add id url to Jack simple server
Change-Id: I8e4b2e51a271fe8e625c40daa13d07395981c2cf
-rw-r--r--jack-server/src/com/android/jack/server/JackSimpleServer.java28
-rw-r--r--jack-server/src/com/android/jack/server/Server.java6
-rw-r--r--jack-server/src/com/android/jack/server/ServerTask.java3
-rw-r--r--jack-server/src/com/android/jack/server/ServerTaskInsideVm.java7
-rw-r--r--jack-server/src/com/android/jack/server/ServerTaskSpawningVM.java7
-rwxr-xr-xjack/etc/jack46
6 files changed, 89 insertions, 8 deletions
diff --git a/jack-server/src/com/android/jack/server/JackSimpleServer.java b/jack-server/src/com/android/jack/server/JackSimpleServer.java
index fa2184c..e939de5 100644
--- a/jack-server/src/com/android/jack/server/JackSimpleServer.java
+++ b/jack-server/src/com/android/jack/server/JackSimpleServer.java
@@ -131,6 +131,12 @@ public class JackSimpleServer {
return rnd.nextInt(30);
}
+
+ @Override
+ @Nonnull
+ public String getVersion() {
+ return "0-0";
+ }
};
@Nonnull
@@ -210,6 +216,7 @@ public class JackSimpleServer {
router.addContainer(new PathParser("/jack"), new JackRun());
router.addContainer(new PathParser("/gc"), new JackGc());
router.addContainer(new PathParser("/stat"), new JackStat());
+ router.addContainer(new PathParser("/id"), new JackId());
ContainerSocketProcessor processor = new ContainerSocketProcessor(router, nbInstance);
connection = new SocketConnection(processor);
@@ -615,6 +622,27 @@ public class JackSimpleServer {
}
}
+ private static class JackId implements Container {
+ @Override
+ public void handle(@Nonnull Request request, @Nonnull Response response) {
+ try {
+ response.setStatus(Status.OK);
+ PrintStream printer = response.getPrintStream();
+
+ printer.println("server.version: 1");
+ printer.println("jack.version: " + service.getVersion());
+ } catch (IOException e) {
+ logger.log(Level.SEVERE, "Exception during IO: ", e);
+ } finally {
+ try {
+ response.close();
+ } catch (IOException e) {
+ logger.log(Level.SEVERE, "Exception during close: ", e);
+ }
+ }
+ }
+ }
+
static void printMemoryUsage(@Nonnull PrintStream printer, @Nonnull String suffix,
@CheckForNull MemoryUsage usage) {
if (usage != null) {
diff --git a/jack-server/src/com/android/jack/server/Server.java b/jack-server/src/com/android/jack/server/Server.java
index 8ab3153..483e301 100644
--- a/jack-server/src/com/android/jack/server/Server.java
+++ b/jack-server/src/com/android/jack/server/Server.java
@@ -76,6 +76,12 @@ public class Server {
return rnd.nextInt(30);
}
+
+ @Override
+ @Nonnull
+ public String getVersion() {
+ return "0-0";
+ }
};
@Nonnull
diff --git a/jack-server/src/com/android/jack/server/ServerTask.java b/jack-server/src/com/android/jack/server/ServerTask.java
index b89f76c..78eff36 100644
--- a/jack-server/src/com/android/jack/server/ServerTask.java
+++ b/jack-server/src/com/android/jack/server/ServerTask.java
@@ -29,4 +29,7 @@ import javax.annotation.Nonnull;
public interface ServerTask {
int run(@Nonnull PrintStream out, @Nonnull PrintStream err, @Nonnull File workingDir,
@Nonnull TokenIterator args);
+
+ @Nonnull
+ String getVersion();
} \ No newline at end of file
diff --git a/jack-server/src/com/android/jack/server/ServerTaskInsideVm.java b/jack-server/src/com/android/jack/server/ServerTaskInsideVm.java
index 7331c9e..47907c9 100644
--- a/jack-server/src/com/android/jack/server/ServerTaskInsideVm.java
+++ b/jack-server/src/com/android/jack/server/ServerTaskInsideVm.java
@@ -17,6 +17,7 @@
package com.android.jack.server;
import com.android.jack.CommandLine;
+import com.android.jack.Jack;
import com.android.jack.Main;
import com.android.jack.Options;
import com.android.sched.util.config.cli.TokenIterator;
@@ -92,4 +93,10 @@ public class ServerTaskInsideVm extends CommandLine implements ServerTask {
return runJack(err, options);
}
+
+ @Override
+ @Nonnull
+ public String getVersion() {
+ return Jack.getVersion().getReleaseCode() + "-" + Jack.getVersion().getSubReleaseCode();
+ }
}
diff --git a/jack-server/src/com/android/jack/server/ServerTaskSpawningVM.java b/jack-server/src/com/android/jack/server/ServerTaskSpawningVM.java
index a8ef6ab..c017d9e 100644
--- a/jack-server/src/com/android/jack/server/ServerTaskSpawningVM.java
+++ b/jack-server/src/com/android/jack/server/ServerTaskSpawningVM.java
@@ -16,6 +16,7 @@
package com.android.jack.server;
+import com.android.jack.Jack;
import com.android.jack.util.ExecuteFile;
import com.android.sched.util.config.cli.TokenIterator;
import com.android.sched.util.file.CannotReadException;
@@ -149,4 +150,10 @@ public class ServerTaskSpawningVM implements ServerTask {
return tokenizer;
}
+
+ @Override
+ @Nonnull
+ public String getVersion() {
+ return Jack.getVersion().getReleaseCode() + "-" + Jack.getVersion().getSubReleaseCode();
+ }
}
diff --git a/jack/etc/jack b/jack/etc/jack
index 3a69eb6..504d935 100755
--- a/jack/etc/jack
+++ b/jack/etc/jack
@@ -15,17 +15,48 @@
# limitations under the License.
#
set -o nounset
+umask 077
#
-# Default setting
+# Settings
#
+LOCAL_SETTING="$HOME/.jack"
TMPDIR=${TMPDIR:=/tmp}
-SERVER_PORT=${SERVER_PORT:=8072}
-SERVER_COUNT=${SERVER_COUNT:=1}
-SERVER_NB_COMPILE=${SERVER_NB_COMPILE:=4}
-SERVER_TIMEOUT=${SEVER_TIMEOUT:=60}
-SERVER_DIR=${SERVER_DIR:=$TMPDIR/jack-$USER}
-SERVER_LOG=${SERVER_LOG:=$SERVER_DIR/jack-$SERVER_PORT.log}
+SERVER_DIR=$TMPDIR/jack-$USER
+
+#
+# Create local settings if it does not exist
+#
+if [ ! -f "$LOCAL_SETTING" ]; then
+ echo "Writing local settings in " $LOCAL_SETTING
+ cat >"$LOCAL_SETTING.$$" <<-"EOT"
+ # Server settings
+ SERVER=true
+ SERVER_PORT=8072
+ SERVER_COUNT=1
+ SERVER_NB_COMPILE=4
+ SERVER_TIMEOUT=60
+ SERVER_LOG=$SERVER_DIR/jack-$SERVER_PORT.log
+ JACK_VM_COMMAND=${JACK_VM_COMMAND:=java}
+ # Internal, do not touch
+ SETTING_VERSION=1
+EOT
+ ln "$LOCAL_SETTING.$$" "$LOCAL_SETTING"
+ rm "$LOCAL_SETTING.$$"
+fi
+
+#
+# Load local settings
+#
+source "$LOCAL_SETTING"
+
+#
+# If not in server mode, exec jack
+#
+if [ "$SERVER" != "true" ]; then
+ exec $JACK_VM_COMMAND -jar $JACK_JAR "$@"
+ exit 255
+fi
#
# Static setting
@@ -42,7 +73,6 @@ JACK_CLI="$JACK_DIR/cli"
JACK_EXIT="$JACK_DIR/exit"
JACK_PWD="$PWD"
-umask 077
mkdir "$SERVER_DIR" 2>/dev/null
# Cleanup