Skip to content

Commit 5ec358d

Browse files
Worked on building.
Tried the python method, with the Jar files. Abandoned that, and now just have Intellij setup to churn out runnable Jar files to pass on.
1 parent f6faf2d commit 5ec358d

File tree

9 files changed

+61
-17
lines changed

9 files changed

+61
-17
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ hs_err_pid*
2626
*.iml
2727
*.json
2828
SootOutput/*
29-
resources/out/*
29+
test_programs/out/*
3030
out/*

compile.py

+53-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
import os
22
import subprocess
3+
import shutil
4+
import platform
35

46
def execute_cmd(cmd):
7+
(outs, errs) = execute_cmd_helper(cmd)
8+
if errs:
9+
print('ERROR.')
10+
print(errs)
11+
else:
12+
print('Done.')
13+
14+
def execute_cmd_helper(cmd):
515
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
616
try:
717
outs, errs = proc.communicate()
@@ -11,16 +21,47 @@ def execute_cmd(cmd):
1121
outs, errs = proc.communicate()
1222
return (outs, errs)
1323

14-
cmd = 'javac ./resources/src/{} -d ./resources/out'
15-
16-
lst = os.listdir('./resources/src')
17-
for el in lst:
18-
if el.endswith('.java'):
19-
print('Compiling {}...'.format(el), end='')
20-
(outs, errs) = execute_cmd(cmd.format(el))
21-
if errs:
22-
print('ERROR.')
23-
print(errs)
24-
else:
25-
print('Done.')
24+
def cp_sep():
25+
if platform.system() == 'Windows':
26+
return ";"
27+
else:
28+
return ":"
29+
30+
def make_cp():
31+
jars = os.listdir('project_jars')
32+
cp = "\""
33+
for jar in jars:
34+
full_path = os.path.join('project_jars', jar)
35+
cp += "{}{}".format(full_path, cp_sep())
36+
cp += "\""
37+
return cp
38+
39+
def make_manifest():
40+
fh = open('manifest.txt', 'w+')
41+
fh.write('Main-Class: Main\n')
42+
tmp = make_cp()
43+
tmp = tmp.replace(cp_sep(), " ")
44+
tmp = tmp.replace("\"", '')
45+
fh.write("Class-Path: {}\n".format(tmp))
46+
fh.close()
47+
48+
# if os.path.exists('build'):
49+
# shutil.rmtree('build')
50+
# os.mkdir('build')
51+
52+
os.chdir('build')
53+
54+
make_manifest()
55+
56+
all_lib_jars = os.path.join('project_jars', '*.jar')
57+
all_class_files = os.path.join('*.class')
58+
all_src_files = os.path.join('..', 'src', '*.java')
59+
60+
cmd = 'javac -cp {} {} -d .'.format(make_cp(), all_src_files)
61+
execute_cmd(cmd)
62+
cmd = 'jar cvfm MPCLoopParallelization.jar manifest.txt *.class {}'.format(all_lib_jars)
63+
execute_cmd(cmd)
64+
65+
66+
2667

resources/META-INF/MANIFEST.MF

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
Main-Class: Main
3+

src/Constants.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class Constants {
1212
static final String JCE_PATH_UNIX = "/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jce.jar";
1313
static final String UTILS_JAVA_FILE = "src/Utils.java";
1414
static final String COMPILE_CMD = "javac %s -d %s -cp %s";
15-
static final String RESOURCE_SRC = "./resources/src/";
16-
static final String RESOURCE_OUT = "./resources/out/";
15+
static final String RESOURCE_SRC = "./test_programs/src/";
16+
static final String RESOURCE_OUT = "./test_programs/out/";
1717
static final String SSA_ARRAY_CPY = "arraycopy(%s, %s)";
1818
static final String SSA_ASSIGNMENT = "%s[%s] = %s";
1919
static final String SSA_PHI = "phi(%s, %s)";
@@ -26,8 +26,8 @@ class Constants {
2626
static final String ARR_VER_STR = "%s_%d";
2727
static final String ARR_PHI_STR = "phi(%s, %s)";
2828
static final Pattern BLOCK_RE = Pattern.compile("^(Block\\s\\d+)");
29-
static final String DEFAULT_CP = "resources/out";
30-
static final String DEFAULT_SD = "resources/src";
29+
static final String DEFAULT_CP = "test_programs/out";
30+
static final String DEFAULT_SD = "test_programs/src";
3131
static final String DEFAILT_RT_PATH = Utils.rt_path();
3232
static final String DEFAILT_JCE_PATH = Utils.jce_path();
3333
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)