Commit fc2bb03e authored by Lukáš Marek's avatar Lukáš Marek

build script complete - added packeging

parent 1b87bfbd
......@@ -9,7 +9,8 @@ src.test=src-test
bin=bin
build=build
build.thread=build-thread
build.afterbootstrap=build-abs
extendthread.path=${build}/extendedthread.jar
extendedthread.path=${build}/extendedthread.jar
instr.jar.name=dislinstr.jar
<project name="disl" default="package" basedir=".">
<property file="build.properties"/>
<property file="disl.version"/>
<property file="build.properties" />
<property file="disl.version" />
<path id="buildpath">
<pathelement location="${asm.path}"/>
<pathelement location="${bin}"/>
<pathelement location="${asm.path}" />
<pathelement location="${bin}" />
</path>
<!-- it automatically compiles all other necessary stuff :) -->
<target name="compile-tlvinserter">
<mkdir dir="${bin}"/>
<mkdir dir="${bin}" />
<javac srcdir="${src.disl}" includes="ch/usi/dag/disl/utilinstr/tlvinserter/" destdir="${bin}" debug="true" includeAntRuntime="false">
<classpath refid="buildpath"/>
<classpath refid="buildpath" />
</javac>
</target>
<target name="prepare-extendedthread" depends="compile-tlvinserter">
<mkdir dir="bin-thread/java/lang"/>
<mkdir dir="bin-thread/java/lang" />
<java fork="true" classname="ch.usi.dag.disl.utilinstr.tlvinserter.ExtendThread">
<classpath refid="buildpath"/>
<classpath refid="buildpath" />
</java>
<mkdir dir="${build}"/>
<jar basedir="bin-thread" destfile="${extendthread.path}" />
<delete dir="bin-thread"/>
<mkdir dir="${build}" />
<jar basedir="bin-thread" destfile="${extendedthread.path}" />
<delete dir="bin-thread" />
</target>
<target name="compile-dynamicbypass" depends="prepare-extendedthread">
<mkdir dir="${bin}"/>
<mkdir dir="${bin}" />
<javac srcdir="${src.dynbypass}" destdir="${bin}" debug="true" includeAntRuntime="false">
<classpath refid="buildpath"/>
<compilerarg value="-Xbootclasspath/p:${extendthread.path}"/>
<classpath refid="buildpath" />
<compilerarg value="-Xbootclasspath/p:${extendedthread.path}" />
</javac>
<delete file="${extendthread.path}"/>
<delete file="${extendedthread.path}" />
</target>
<target name="compile-disl" depends="compile-dynamicbypass">
<javac srcdir="${src.disl}" destdir="${bin}" debug="true" includeAntRuntime="false">
<classpath refid="buildpath"/>
<classpath refid="buildpath" />
</javac>
</target>
<target name="compile-agent-java" depends="compile-dynamicbypass">
<javac srcdir="${src.agent.java}" destdir="${bin}" debug="true" includeAntRuntime="false">
<classpath refid="buildpath"/>
<classpath refid="buildpath" />
</javac>
</target>
<target name="compile-test" depends="compile-disl">
<javac srcdir="${src.test}" destdir="bin" debug="true" includeAntRuntime="false">
<classpath refid="buildpath"/>
<classpath refid="buildpath" />
</javac>
</target>
<target name="compile" depends="compile-disl,compile-agent-java,compile-test"/>
<target name="compile" depends="compile-disl,compile-agent-java,compile-test" />
<target name="prepare-dynamicbypass-afterbootstrap"/>
<target name="package-dislserver" depends="compile-disl,prepare-dynamicbypass-afterbootstrap">
<jar basedir="${bin}" destfile="${build}/disl-${disl.version}.jar">
<target name="package-dislserver" depends="compile-disl">
<jar basedir="${bin}" destfile="${build}/dislserver-${disl.version}.jar"
includes="ch/usi/dag/disl/**,ch/usi/dag/dislserver/**"
excludes="ch/usi/dag/disl/test/**,ch/usi/dag/disl/testtools/**">
<manifest>
<attribute name="Class-Path" value="${instr.jar.name}"/>
<attribute name="Class-Path" value="${instr.jar.name}" />
<attribute name="Main-Class" value="ch.usi.dag.dislserver.DiSLServer" />
</manifest>
</jar>
</target>
<target name="package" depends="compile,prepare-dynamicbypass-afterbootstrap">
<jar basedir="${bin}" destfile="${build}/disl-${disl.version}.jar">
<target name="compile-dynamicbypass-afterbootstrap">
<mkdir dir="${build.afterbootstrap}" />
<javac srcdir="${src.dynbypass.act}" destdir="${build.afterbootstrap}" debug="true" includeAntRuntime="false">
<classpath refid="buildpath" />
</javac>
</target>
<target name="package-dislagent-java" depends="compile-agent-java,compile-dynamicbypass,compile-dynamicbypass-afterbootstrap">
<!-- rename after bootstrap class -->
<move file="${build.afterbootstrap}/ch/usi/dag/disl/dynamicbypass/DynamicBypassCheck.class"
tofile="${build.afterbootstrap}/DynamicBypassCheck-AfterBootstrap.class" />
<jar basedir="${bin}" destfile="${build}/dislagent-${disl.version}.jar"
includes="ch/usi/dag/dislagent/**,ch/usi/dag/disl/dynamicbypass/**">
<manifest>
<attribute name="Class-Path" value="${instr.jar.name}"/>
<attribute name="Class-Path" value="${instr.jar.name}" />
<attribute name="Premain-Class" value="ch.usi.dag.dislagent.DiSLAgent" />
</manifest>
<!-- include after bootstrap class -->
<fileset file="${build.afterbootstrap}/DynamicBypassCheck-AfterBootstrap.class" />
</jar>
<!-- delete dir with after bootstrap class -->
<delete dir="${build.afterbootstrap}" />
</target>
<target name="eclipse-agent" description="creates simple agent jar file for eclipse" >
<mkdir dir="build"/>
<target name="package" depends="package-dislserver,package-dislagent-java" />
<target name="eclipse-agent" description="creates simple agent jar file for eclipse">
<mkdir dir="build" />
<jar jarfile="build/eclipse-agent.jar">
<manifest>
<attribute name="Premain-Class" value="ch.usi.dag.disl.testtools.agent.Agent"/>
<attribute name="Premain-Class" value="ch.usi.dag.disl.testtools.agent.Agent" />
</manifest>
</jar>
</target>
<target name="eclipse-dynamicbypass" depends="compile-dynamicbypass" description="creates support library for DiSL development under eclipse">
<jar basedir="${bin}" destfile="${build}/eclipse-dynamicbypass.jar" includes="ch/usi/dag/disl/dynamicbypass/" />
<target name="eclipse-dynamicbypass" depends="compile-dynamicbypass"
description="creates support library for DiSL development under eclipse">
<jar basedir="${bin}" destfile="${build}/eclipse-dynamicbypass.jar"
includes="ch/usi/dag/disl/dynamicbypass/" />
</target>
<target name="eclipse" depends="eclipse-dynamicbypass,eclipse-agent"/>
<target name="eclipse" depends="eclipse-dynamicbypass,eclipse-agent" />
<target name="clean">
<delete dir="${bin}"/>
<delete dir="${build}"/>
<delete dir="${bin}" />
<delete dir="${build}" />
<delete dir="${build.thread}" />
<delete dir="${build.afterbootstrap}" />
</target>
</project>
......@@ -4,7 +4,7 @@ import java.lang.instrument.Instrumentation;
import ch.usi.dag.disl.dynamicbypass.Bootstrap;
public class JavaAgent {
public class DiSLAgent {
public static void premain(String agentArguments,
Instrumentation instrumentation) {
......
......@@ -15,11 +15,12 @@ public class Bootstrap {
ClassLoader cl = Bootstrap.class.getClassLoader();
// find our class in resources
InputStream dbcIS =
cl.getResourceAsStream("DynamicBypass-DynamicBypassCheck");
InputStream dbcIS = cl.getResourceAsStream(
"DynamicBypassCheck-AfterBootstrap.class");
byte[] newDBCCode = loadAsBytes(dbcIS);
instr.redefineClasses(new ClassDefinition(DynamicBypassCheck.class, newDBCCode));
instr.redefineClasses(new ClassDefinition(DynamicBypassCheck.class,
newDBCCode));
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -182,7 +182,7 @@ public class ScopeImpl implements Scope {
// replace delimiters for matching
className = className.replace(
Constants.PACKAGE_ASM_DELIM, Constants.PACKAGE_STD_DELIM);
Constants.PACKAGE_INTERN_DELIM, Constants.PACKAGE_STD_DELIM);
String packageName = new String();
// extract package name from class name if any
......
......@@ -4,9 +4,8 @@ public class Constants {
final public static String STATIC_CONTEXT_METHOD_DELIM = ".";
// TODO ! rename to PACKAGE_INTERN_DELIM
final public static char PACKAGE_ASM_DELIM = '/';
final public static char PACKAGE_STD_DELIM = '.';
final public static char PACKAGE_INTERN_DELIM = '/';
final public static String CONSTRUCTOR_NAME = "<init>";
final public static String STATIC_INIT_NAME = "<clinit>";
......
......@@ -46,7 +46,7 @@ public final class ExtendThread {
// prepare Thread file name
String threadFileName = tc.getName();
threadFileName = threadFileName.replace(
Constants.PACKAGE_STD_DELIM, Constants.PACKAGE_ASM_DELIM);
Constants.PACKAGE_STD_DELIM, Constants.PACKAGE_INTERN_DELIM);
threadFileName += Constants.CLASS_EXT;
// output Thread code into special thread bin directory
......
......@@ -6,7 +6,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import ch.usi.dag.disl.DiSL;
import ch.usi.dag.disl.exception.DiSLException;
public abstract class InstrumentationServer {
public abstract class DiSLServer {
public static final String PROP_DEBUG = "debug";
private static final boolean debug = Boolean.getBoolean(PROP_DEBUG);
......
......@@ -21,7 +21,7 @@ import ch.usi.dag.disl.util.Constants;
public class Worker extends Thread {
private static final boolean debug = Boolean
.getBoolean(InstrumentationServer.PROP_DEBUG);
.getBoolean(DiSLServer.PROP_DEBUG);
private static final String PROP_EXCLIST = "dislserver.exclusionList";
private static final String excListPath =
......@@ -54,10 +54,10 @@ public class Worker extends Thread {
sc.close();
}
catch (Throwable e) {
InstrumentationServer.reportError(e);
DiSLServer.reportError(e);
}
finally {
InstrumentationServer.workerDone();
DiSLServer.workerDone();
}
}
......@@ -122,7 +122,7 @@ public class Worker extends Thread {
private String internClassName(String normalClassName) {
return normalClassName.replace(
Constants.PACKAGE_STD_DELIM, Constants.PACKAGE_ASM_DELIM);
Constants.PACKAGE_STD_DELIM, Constants.PACKAGE_INTERN_DELIM);
}
private void instrumentationLoop() throws DiSLServerException, DiSLException {
......@@ -211,7 +211,7 @@ public class Worker extends Thread {
try {
// extract the class name and package name
int i = className.lastIndexOf(Constants.PACKAGE_ASM_DELIM);
int i = className.lastIndexOf(Constants.PACKAGE_INTERN_DELIM);
String onlyClassName = className.substring(i + 1);
String packageName = className.substring(0, i + 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment