Skip to content

Commit b1dbe98

Browse files
committed
Update to support -c for build step. Create runone.sh to run all for one project, runall.sh to use runone.sh, and move main/test jar names from runall.sh to each projects yaml file.
1 parent 5d62b74 commit b1dbe98

File tree

11 files changed

+136
-56
lines changed

11 files changed

+136
-56
lines changed

artifacts/configs/convex-fixed/convex-fixed.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ URL: https://github.com/Convex-Dev/convex.git
33
checkoutID: e6db05a611cd4a1fb51f959e20d246637bb7744a
44
patchName: artifacts/configs/convex-fixed/convex-fixed.patch
55
subProject: convex-core
6+
mainJar: convex-core-0.7.1-jar-with-dependencies.jar
7+
testJar: convex-core-0.7.1-tests.jar
68
#mvnOptions: -DfailIfNoTests=false -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
79
mvnOptions: -DfailIfNoTests=false
810
properties:

artifacts/configs/convex/convex.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ URL: https://github.com/Convex-Dev/convex.git
33
checkoutID: e6db05a611cd4a1fb51f959e20d246637bb7744a
44
patchName: artifacts/configs/convex/convex.patch
55
subProject: convex-core
6+
mainJar: convex-core-0.7.1-jar-with-dependencies.jar
7+
testJar: convex-core-0.7.1-tests.jar
68
#mvnOptions: -DfailIfNoTests=false -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
79
mvnOptions: -DfailIfNoTests=false
810
properties:

artifacts/configs/jflex-fixed/jflex-fixed.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ URL: https://github.com/jflex-de/jflex.git
33
checkoutID: e6d1752bd48a7ccb2a2b78479dc5a73ac475bbb9
44
patchName: artifacts/configs/jflex-fixed/jflex-fixed.patch
55
subProject: jflex
6+
mainJar: jflex-1.8.2-jar-with-dependencies.jar
7+
testJar: jflex-1.8.2-tests.jar
68
#mvnOptions: -DfailIfNoTests=false -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
79
mvnOptions: -DfailIfNoTests=false
810
properties:

artifacts/configs/jflex/jflex.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ URL: https://github.com/jflex-de/jflex.git
33
checkoutID: e6d1752bd48a7ccb2a2b78479dc5a73ac475bbb9
44
patchName: artifacts/configs/jflex/jflex.patch
55
subProject: jflex
6+
mainJar: jflex-1.8.2-jar-with-dependencies.jar
7+
testJar: jflex-1.8.2-tests.jar
68
#mvnOptions: -DfailIfNoTests=false -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
79
mvnOptions: -DfailIfNoTests=false
810
properties:

artifacts/configs/mph-table-fixed/mph-table-fixed.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: mph-table-fixed
22
URL: https://github.com/indeedeng/mph-table.git
33
checkoutID: dbd5413df33bf8f0a995822eeefe94df50f3c5a7
44
patchName: artifacts/configs/mph-table-fixed/mph-table-fixed.patch
5+
mainJar: mph-table-1.0.6-SNAPSHOT-jar-with-dependencies.jar
6+
testJar: mph-table-1.0.6-SNAPSHOT-tests.jar
57
#mvnOptions: -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
68
properties:
79
- name: TestSmartListSerializer#canRoundTripSerializableLists

artifacts/configs/mph-table/mph-table.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: mph-table
22
URL: https://github.com/indeedeng/mph-table.git
33
checkoutID: dbd5413df33bf8f0a995822eeefe94df50f3c5a7
44
patchName: artifacts/configs/mph-table/mph-table.patch
5+
mainJar: mph-table-1.0.6-SNAPSHOT-jar-with-dependencies.jar
6+
testJar: mph-table-1.0.6-SNAPSHOT-tests.jar
57
#mvnOptions: -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
68
properties:
79
- name: TestSmartListSerializer#canRoundTripSerializableLists

runall.sh

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,6 @@
33
# SET JCG_HOME based on the directory where this script resides
44
JCG_HOME="$(pwd)/$( dirname -- "$0"; )";
55

6-
declare -A mainjar
7-
mainjar[convex]=convex-core-0.7.1-jar-with-dependencies.jar
8-
mainjar[jflex]=jflex-1.8.2-jar-with-dependencies.jar
9-
mainjar[mph-table]=mph-table-1.0.6-SNAPSHOT-jar-with-dependencies.jar
10-
mainjar[JQF]=jqf-fuzz-1.9-jar-with-dependencies.jar
11-
mainjar[rpki-commons]=rpki-commons-DEV.jar
12-
13-
14-
declare -A testjar
15-
testjar[convex]=convex-core-0.7.1-tests.jar
16-
testjar[jflex]=jflex-1.8.2-tests.jar
17-
testjar[mph-table]=mph-table-1.0.6-SNAPSHOT-tests.jar
18-
testjar[JQF]=jqf-fuzz-1.9-tests.jar
19-
testjar[rpki-commons]=rpki-commons-DEV-tests.jar
20-
21-
226
cd $JCG_HOME || exit
237

248
mkdir -p serializedGraphs
@@ -37,29 +21,7 @@ do
3721
projectName=$project-$type
3822
fi
3923

40-
# clean project
41-
rm -rf $projectName
42-
43-
# clean output
44-
rm -rf output
45-
mkdir output
46-
47-
# git project
48-
java -jar ./target/javacg-0.1-SNAPSHOT-jar-with-dependencies.jar git -c $projectName
49-
50-
# build project
51-
java -jar ./target/javacg-0.1-SNAPSHOT-jar-with-dependencies.jar build -j ./artifacts/output/${mainjar[$project]} -t ./artifacts/output/${testjar[$project]} -o serializedGraphs/$projectName
52-
53-
# test project
54-
java -jar ./target/javacg-0.1-SNAPSHOT-jar-with-dependencies.jar test -c $projectName -f serializedGraphs/$projectName
55-
56-
# copy output
57-
rm -rf output-$projectName
58-
mv output output-$projectName
59-
60-
cd output-$projectName || exit
61-
../buildsvg.sh
62-
cd ..
24+
./runone.sh $projectName
6325
done
6426
done
6527

runone.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
# exit if anything throws a bad exit code
4+
set -e
5+
6+
# SET JCG_HOME based on the directory where this script resides
7+
JCG_HOME="$(pwd)/$( dirname -- "$0"; )";
8+
9+
cd $JCG_HOME || exit
10+
11+
mkdir -p serializedGraphs
12+
13+
# check $1 to be sure it is at least 1 character and only contains alpha, number, _, and -.
14+
if [[ $# -ne 1 || ! $1 =~ ^[A-Za-z0-9_\-]+$ ]]; then
15+
echo "Provide a project name (alphanumeric with _ and - allowed).";
16+
else
17+
projectName=$1
18+
19+
# clean project
20+
rm -rf "$projectName"
21+
22+
# clean output
23+
rm -rf output
24+
mkdir output
25+
26+
# git project
27+
java -jar ./target/javacg-0.1-SNAPSHOT-jar-with-dependencies.jar git -c $projectName
28+
29+
# build project
30+
java -jar ./target/javacg-0.1-SNAPSHOT-jar-with-dependencies.jar build -c $projectName -o serializedGraphs/$projectName
31+
32+
# test project
33+
java -jar ./target/javacg-0.1-SNAPSHOT-jar-with-dependencies.jar test -c $projectName -f serializedGraphs/$projectName
34+
35+
# copy output
36+
rm -rf output-$projectName
37+
mv output output-$projectName
38+
39+
cd output-$projectName || exit
40+
../buildsvg.sh
41+
cd ..
42+
fi

src/main/java/gr/gousiosg/javacg/stat/JCallGraph.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import gr.gousiosg.javacg.stat.support.GitArguments;
3939
import gr.gousiosg.javacg.stat.support.RepoTool;
4040
import gr.gousiosg.javacg.stat.support.TestArguments;
41-
import org.apache.bcel.classfile.AnnotationEntry;
4241
import org.apache.bcel.classfile.ClassParser;
4342
import org.apache.bcel.classfile.JavaClass;
4443
import org.apache.bcel.classfile.Method;
@@ -60,7 +59,6 @@
6059
import java.util.jar.JarEntry;
6160
import java.util.jar.JarFile;
6261
import java.util.jar.JarInputStream;
63-
import java.util.stream.Collectors;
6462

6563
import static java.util.Map.entry;
6664

src/main/java/gr/gousiosg/javacg/stat/support/BuildArguments.java

Lines changed: 62 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.slf4j.LoggerFactory;
77

88
import java.io.File;
9+
import java.nio.file.Path;
910
import java.util.*;
1011

1112
public class BuildArguments {
@@ -19,11 +20,19 @@ public class BuildArguments {
1920
private static final String TEST_JAR_INPUT = "t";
2021
private static final String TEST_JAR_INPUT_LONG = "testJarPath";
2122

23+
private static final String CONFIG_NAME = "c";
24+
25+
private static final String CONFIG_NAME_LONG = "config";
26+
2227
private final List<Pair<String, File>> jars = new ArrayList<>();
2328
private Optional<String> maybeOutput = Optional.empty();
2429

2530
private Optional<Pair<String, File>> maybeTestJar = Optional.empty();
2631

32+
private Optional<String> maybeConfig = Optional.empty();
33+
34+
private final static String jarBasePath = "artifacts/output/";
35+
2736
/**
2837
* Parse command line args into variables
2938
*
@@ -38,17 +47,36 @@ public BuildArguments(String[] args) {
3847
CommandLine cmd;
3948
try {
4049
cmd = parser.parse(options, args);
41-
/* Parse JARs */
42-
if (cmd.hasOption(JAR_INPUT)) {
43-
jarPaths.addAll(Arrays.asList(cmd.getOptionValues(JAR_INPUT)));
44-
}
4550

46-
/* Parse test JAR */
47-
if (cmd.hasOption(TEST_JAR_INPUT)) {
48-
String testJarPath = cmd.getOptionValue(TEST_JAR_INPUT);
49-
Pair<String, File> testJarPair = pathAndJarFile(testJarPath);
50-
jars.add(testJarPair);
51-
maybeTestJar = Optional.of(testJarPair);
51+
/* Get from configuration */
52+
if (cmd.hasOption(CONFIG_NAME)) {
53+
Optional<RepoTool> rt = RepoTool.obtainTool(cmd.getOptionValue(CONFIG_NAME));
54+
55+
if (rt.isPresent()) {
56+
String mainJar = getJarRelativePath(rt.get().getMainJar());
57+
jarPaths.add(mainJar);
58+
59+
String testJar = getJarRelativePath(rt.get().getTestJar());
60+
Pair<String, File> testJarPair = pathAndJarFile(testJar);
61+
jars.add(testJarPair);
62+
maybeTestJar = Optional.of(testJarPair);
63+
} else {
64+
LOGGER.error("Unable to obtain RepoTool.");
65+
System.exit(1);
66+
}
67+
} else {
68+
/* Parse JARs */
69+
if (cmd.hasOption(JAR_INPUT)) {
70+
jarPaths.addAll(Arrays.asList(cmd.getOptionValues(JAR_INPUT)));
71+
}
72+
73+
/* Parse test JAR */
74+
if (cmd.hasOption(TEST_JAR_INPUT)) {
75+
String testJarPath = cmd.getOptionValue(TEST_JAR_INPUT);
76+
Pair<String, File> testJarPair = pathAndJarFile(testJarPath);
77+
jars.add(testJarPair);
78+
maybeTestJar = Optional.of(testJarPair);
79+
}
5280
}
5381

5482
/* Parse output name */
@@ -69,17 +97,34 @@ public BuildArguments(String[] args) {
6997
.forEach(this.jars::add);
7098
}
7199

100+
private static String getJarRelativePath(String jar) {
101+
return jar.charAt(0) == '/' ? jar : Path.of(jarBasePath, jar).toString();
102+
}
103+
72104
private static Options getOptions() {
73105
Options options = new Options();
106+
OptionGroup configOrMainJar = new OptionGroup();
74107

75-
options.addOption(
108+
configOrMainJar.isRequired();
109+
110+
configOrMainJar.addOption(
111+
Option.builder(CONFIG_NAME)
112+
.longOpt(CONFIG_NAME_LONG)
113+
.hasArg(true)
114+
.desc("[REQUIRED if -"+JAR_INPUT+" not specified] specify an output name for the bytecode")
115+
.required(false)
116+
.build());
117+
118+
configOrMainJar.addOption(
76119
Option.builder(JAR_INPUT)
77120
.longOpt(JAR_INPUT_LONG)
78121
.hasArg(true)
79-
.desc("[REQUIRED] specify one or more paths to JARs to analyze")
80-
.required(true)
122+
.desc("[REQUIRED if -"+CONFIG_NAME+"not specified] specify one or more paths to JARs to analyze")
123+
.required(false)
81124
.build());
82125

126+
options.addOptionGroup(configOrMainJar);
127+
83128
options.addOption(
84129
Option.builder(TEST_JAR_INPUT)
85130
.longOpt(TEST_JAR_INPUT_LONG)
@@ -110,6 +155,10 @@ public Optional<Pair<String, File>> getMaybeTestJar() {
110155
return maybeTestJar;
111156
}
112157

158+
public Optional<String> getMaybeConfig() {
159+
return maybeConfig;
160+
}
161+
113162
// Make sure the path is a path to a jar file
114163
private void validateJarSuffix(String jarPath) {
115164
if (!jarPath.endsWith(JAR_SUFFIX)) {

0 commit comments

Comments
 (0)