harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r480847 - in /harmony/enhanced/jdktools/trunk/modules/samsa: ./ make/ src/ src/main/ src/main/native/ src/main/native/samsa/ src/main/native/samsa/linux/
Date Thu, 30 Nov 2006 06:09:22 GMT
Author: geirm
Date: Wed Nov 29 22:09:18 2006
New Revision: 480847

URL: http://svn.apache.org/viewvc?view=rev&rev=480847
Log:
first whack at the launcher-launcher called 'samsa'
(after Kafka's Gregor Samsa) that is the core
code in jdk/bin for javac, javap, javah, etc

Right now, this is for linux only.  I'll continue
tomorrow


Added:
    harmony/enhanced/jdktools/trunk/modules/samsa/
    harmony/enhanced/jdktools/trunk/modules/samsa/build.xml   (with props)
    harmony/enhanced/jdktools/trunk/modules/samsa/make/
    harmony/enhanced/jdktools/trunk/modules/samsa/make/hyproperties.xml   (with props)
    harmony/enhanced/jdktools/trunk/modules/samsa/src/
    harmony/enhanced/jdktools/trunk/modules/samsa/src/main/
    harmony/enhanced/jdktools/trunk/modules/samsa/src/main/native/
    harmony/enhanced/jdktools/trunk/modules/samsa/src/main/native/samsa/
    harmony/enhanced/jdktools/trunk/modules/samsa/src/main/native/samsa/linux/
    harmony/enhanced/jdktools/trunk/modules/samsa/src/main/native/samsa/linux/makefile
    harmony/enhanced/jdktools/trunk/modules/samsa/src/main/native/samsa/samsa.c   (with props)

Added: harmony/enhanced/jdktools/trunk/modules/samsa/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/samsa/build.xml?view=auto&rev=480847
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/samsa/build.xml (added)
+++ harmony/enhanced/jdktools/trunk/modules/samsa/build.xml Wed Nov 29 22:09:18 2006
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+  
+       http://www.apache.org/licenses/LICENSE-2.0
+  
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<project name="Samsa Build" default="build" basedir=".">
+    <description>Build for samsa program</description>
+
+    <!-- import common properties -->
+    <property name="hy.hdk" location="${basedir}/../../deploy" />
+    <import file="../../make/properties.xml" />
+
+    <!-- set global properties for this build. -->
+    <xmlproperty file="make/hyproperties.xml" semanticAttributes="true" />
+
+    <property file="../../make/depends.properties" />
+
+    <target name="build-native" depends="build"/>
+    <target name="clean-native" depends="clean"/>
+
+    <target name="build" >
+
+        <echo>Launcher : ${hy.drlvm}  ${harmony.jdktools} </echo>
+            
+        <!-- Build launcher executables -->
+        <make dir="${hy.samsa.src.main.native}/samsa/${hy.os}" />
+
+        <!-- Copy across the built executables -->
+        <copy todir="${hy.jdk}/bin" overwrite="yes">
+            <fileset dir="${hy.samsa.src.main.native}/samsa/${hy.os}">
+                <patternset includes="samsa${exe.suffix}" />
+            </fileset>
+        </copy>
+
+        <!-- now make copies for the tools -->
+            
+        <copy file="${hy.jdk}/bin/samsa${exe.suffix}" tofile="${hy.jdk}/bin/javac${exe.suffix}"
/>
+        <chmod file="${hy.jdk}/bin/javac${exe.suffix}" perm="ugo+x" />
+        <copy file="${hy.jdk}/bin/samsa${exe.suffix}" tofile="${hy.jdk}/bin/javap${exe.suffix}"
/>
+        <chmod file="${hy.jdk}/bin/javap${exe.suffix}" perm="ugo+x" />
+        <copy file="${hy.jdk}/bin/samsa${exe.suffix}" tofile="${hy.jdk}/bin/javah${exe.suffix}"
/>
+        <chmod file="${hy.jdk}/bin/javah${exe.suffix}" perm="ugo+x" />
+
+        <delete file="${hy.jdk}/bin/samsa${exe.suffix}"/>
+
+    </target>
+
+    <!-- Clean natives -->
+    <target name="clean">
+        <echo>
+Cleaning launcher natives
+        </echo>
+        <make dir="${hy.samsa.src.main.native}/samsa/${hy.os}"
+              target="clean" />
+    </target>
+
+</project>

Propchange: harmony/enhanced/jdktools/trunk/modules/samsa/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/samsa/make/hyproperties.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/samsa/make/hyproperties.xml?view=auto&rev=480847
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/samsa/make/hyproperties.xml (added)
+++ harmony/enhanced/jdktools/trunk/modules/samsa/make/hyproperties.xml Wed Nov 29 22:09:18
2006
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+
+<hy>
+   <samsa location=".">
+      <src>
+         <main>
+            <java location="src/main/java" />
+            <native location="src/main/native" />
+        	<resources location="src/main/resources" />
+         </main>
+         <test location="src/test">
+            <resources location="src/test/resources" />
+         </test>
+         <natives location="src/natives" />
+      </src>
+      <bin>
+        <main location="bin/main" />
+        <test location="bin/test" />
+      </bin>
+      <packaging>
+        <jarname>luni</jarname>
+      </packaging>
+   </samsa>
+
+   <hdk location="../../deploy" />
+   <jdk location="../../deploy/jdk" />
+   <build location="../../build/classes" />
+
+   <tests>
+      <reports location="../../build/test_report" />
+      <support>
+          <bin location="../../build/tests" />
+      </support>
+   </tests>
+</hy>

Propchange: harmony/enhanced/jdktools/trunk/modules/samsa/make/hyproperties.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/samsa/src/main/native/samsa/linux/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/samsa/src/main/native/samsa/linux/makefile?view=auto&rev=480847
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/samsa/src/main/native/samsa/linux/makefile (added)
+++ harmony/enhanced/jdktools/trunk/modules/samsa/src/main/native/samsa/linux/makefile Wed
Nov 29 22:09:18 2006
@@ -0,0 +1,26 @@
+#  Licensed to the Apache Software Foundation (ASF) under one or more
+#  contributor license agreements.  See the NOTICE file distributed with
+#  this work for additional information regarding copyright ownership.
+#  The ASF licenses this file to You under the Apache License, Version 2.0
+#  (the "License"); you may not use this file except in compliance with
+#  the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+#
+# Makefile for 'samsa'
+#
+
+include $(HY_JDKTOOLS)/make/makefile.include
+
+BUILDFILES = ../samsa.o
+
+EXENAME = samsa
+
+include $(HY_JDKTOOLS)/make/rules.mk

Added: harmony/enhanced/jdktools/trunk/modules/samsa/src/main/native/samsa/samsa.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/samsa/src/main/native/samsa/samsa.c?view=auto&rev=480847
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/samsa/src/main/native/samsa/samsa.c (added)
+++ harmony/enhanced/jdktools/trunk/modules/samsa/src/main/native/samsa/samsa.c Wed Nov 29
22:09:18 2006
@@ -0,0 +1,173 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <limits.h>
+
+#define EXE_POSTFIX   "/jre/bin/java"
+#define LIB_POSTFIX   "/lib/"
+#define TOOL_JAR      "tools.jar"
+#define ECJ_JAR       "ecj_3.2.jar"
+#define CLASSPATH_SEP ":"
+#define CLASS_PREFIX  "org.apache.harmony.tools."
+#define CLASS_POSTFIX ".Main"
+
+char *cleanToolName(const char *);
+char *getExeDir();
+char *getJDKRoot();
+
+
+int main (int argc, char **argv, char **envp)
+{
+    int myArgvCount = argc + 4;
+    char **myArgv = (char **) malloc(sizeof(char*) * myArgvCount);    
+    char *toolName = NULL;
+    int i;
+    int newIndex = 0;
+
+    /* 
+     * if we can't figure out what tool we are, just bail
+     */    
+    toolName = cleanToolName(argv[0]);
+    
+    if (toolName == NULL) { 
+        fprintf(stderr, "Uknown tool name %s\n", argv[0]);
+        return 1;
+    }
+
+    /*
+     *  get the jdkroot and the construct invocation path for exe
+     *  and the full paths to jars.  This way, we can be called 
+     *  from anywhere
+     */    
+    char *jdkRoot = getJDKRoot();
+    printf("root = %s\n", jdkRoot);
+    
+    if (!jdkRoot) { 
+        fprintf(stderr, "Unable to find JDK Root");
+        return 2;
+    }
+       
+    char *fullExePath = (char *) malloc(strlen(jdkRoot) + strlen(EXE_POSTFIX) + 1);
+    
+    strcpy(fullExePath, jdkRoot);
+    strcat(fullExePath, EXE_POSTFIX);
+    
+    char *classpath = (char *) malloc(strlen(jdkRoot) * 2 + strlen(LIB_POSTFIX) * 2
+                    + strlen(TOOL_JAR) + strlen(ECJ_JAR) + strlen(CLASSPATH_SEP) + 1);
+         
+    strcpy(classpath, jdkRoot);
+    strcat(classpath, LIB_POSTFIX);
+    strcat(classpath, TOOL_JAR);
+    strcat(classpath, CLASSPATH_SEP);
+    strcat(classpath, jdkRoot);
+    strcat(classpath, LIB_POSTFIX);
+    strcat(classpath, ECJ_JAR);
+
+    /*
+     *  we're invoking java with the following 
+     *    -cp toolpath  clasname .......
+     */
+    myArgv[newIndex++] = fullExePath;
+    myArgv[newIndex++] = "-cp";
+    myArgv[newIndex++] = classpath;
+
+    char *buffer = (char *) malloc(strlen(CLASS_PREFIX) + strlen(toolName) + strlen(CLASS_POSTFIX)
+ 1);
+
+    strcpy(buffer, CLASS_PREFIX);
+    strcat(buffer, toolName);
+    strcat(buffer, CLASS_POSTFIX);
+    
+    myArgv[newIndex++] = buffer;
+    
+    for (i = 1; i < argc; i++) {
+        myArgv[newIndex++] = argv[i];
+    }
+    
+    myArgv[newIndex] = '\0';
+
+    for (i=0; i < myArgvCount; i++) { 
+        printf(" %d = %s\n", i, myArgv[i]);
+    }
+    
+    /*
+     * now simply execv() the java app w/ the new params
+     */     
+    execv(fullExePath, myArgv);    
+}
+
+/**
+ * cleanToolName
+ * 
+ * takes a executable name and finds the tool name
+ * in it
+ * 
+ * returns real tool name, or NULL if not found
+ */
+char *cleanToolName(const char *name) 
+{
+    int i;
+    char *toolNames[] = { "javac", "javap", "javah" };
+    
+    for (i=0; i < sizeof(toolNames)/sizeof(toolNames[0]); i++) { 
+        if (strstr(name, toolNames[i])) {
+            return toolNames[i];
+        }
+    }
+    
+    return NULL;    
+}
+
+
+char *getJDKRoot() { 
+    
+    char *exeDir = getExeDir();
+
+    char *last = strrchr(exeDir, '/');
+    
+    if (last != NULL) { 
+        *last = '\0';
+        return exeDir;
+    }
+    
+    return NULL;
+}
+/**
+ * getExeDir
+ * 
+ *  returns directory of running exe
+ */
+char *getExeDir() {
+    
+    char buffer[PATH_MAX + 1];
+    
+    int size = readlink ("/proc/self/exe", buffer, sizeof(buffer)-1);
+    
+    buffer[size+1] = '\0';
+   
+    char *last = strrchr(buffer, '/');
+   
+    if (last != NULL) { 
+        *last = '\0';
+        return strdup(buffer);
+    }
+    
+    return NULL;
+}

Propchange: harmony/enhanced/jdktools/trunk/modules/samsa/src/main/native/samsa/samsa.c
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message