@@ -50,15 +50,10 @@ public void execute() throws Throwable {
50
50
51
51
Path tempSource = temp .resolve ("source" );
52
52
Path tempClasses = temp .resolve ("classes" );
53
- Path tempOutput = temp .resolve ("output" );
54
- Path tempCpp = tempOutput .resolve ("cpp" );
55
53
Files .createDirectories (tempSource );
56
54
Files .createDirectories (tempClasses );
57
- Files .createDirectories (tempOutput );
58
- Files .createDirectories (tempCpp );
59
55
60
56
Path idealJar = temp .resolve ("test.jar" );
61
- Path resultJar = tempOutput .resolve ("test.jar" );
62
57
63
58
List <Path > javaFiles = new ArrayList <>();
64
59
List <Path > resourceFiles = new ArrayList <>();
@@ -111,66 +106,74 @@ public void execute() throws Throwable {
111
106
System .out .println (String .format ("Took %dms" , idealRunResult .execTime ));
112
107
idealRunResult .check ("Ideal run" );
113
108
114
- System .out .println ("Processing..." );
109
+ for (Platform platform : Platform .values ()) {
110
+ System .out .println (String .format ("Processing platform %s..." , platform .toString ()));
115
111
116
- new NativeObfuscator ().process (idealJar , tempOutput , Collections .emptyList (), Collections .emptyList (),
117
- null , "native_library" , Platform .HOTSPOT , false );
112
+ Path tempOutput = temp .resolve (String .format ("output_%s" , platform ));
113
+ Path tempCpp = tempOutput .resolve ("cpp" );
114
+ Files .createDirectories (tempOutput );
115
+ Files .createDirectories (tempCpp );
116
+ Path resultJar = tempOutput .resolve ("test.jar" );
118
117
119
- System .out .println ("Compiling CPP code..." );
120
- if (System .getProperty ("os.name" ).toLowerCase ().contains ("windows" )) {
121
- String arch = "x64" ;
122
- if (System .getProperty ("sun.arch.data.model" ).equals ("32" )) {
123
- arch = "x86" ;
118
+ new NativeObfuscator ().process (idealJar , tempOutput , Collections .emptyList (), Collections .emptyList (),
119
+ null , "native_library" , platform , false );
120
+
121
+ System .out .println ("Compiling CPP code..." );
122
+ if (System .getProperty ("os.name" ).toLowerCase ().contains ("windows" )) {
123
+ String arch = "x64" ;
124
+ if (System .getProperty ("sun.arch.data.model" ).equals ("32" )) {
125
+ arch = "x86" ;
126
+ }
127
+ ProcessHelper .run (tempCpp , 60_000 ,
128
+ Arrays .asList ("cmake" , "-DCMAKE_GENERATOR_PLATFORM=" + arch , "." ))
129
+ .check ("CMake prepare" );
130
+ } else {
131
+ ProcessHelper .run (tempCpp , 60_000 ,
132
+ Arrays .asList ("cmake" , "." ))
133
+ .check ("CMake prepare" );
124
134
}
125
- ProcessHelper .run (tempCpp , 60_000 ,
126
- Arrays .asList ("cmake" , "-DCMAKE_GENERATOR_PLATFORM=" + arch , "." ))
127
- .check ("CMake prepare" );
128
- } else {
129
- ProcessHelper .run (tempCpp , 60_000 ,
130
- Arrays .asList ("cmake" , "." ))
131
- .check ("CMake prepare" );
132
- }
133
135
134
- ProcessResult compileRunresult = ProcessHelper .run (tempCpp , 160_000 ,
135
- Arrays .asList ("cmake" , "--build" , "." , "--config" , "Release" ));
136
- System .out .println (String .format ("Took %dms" , compileRunresult .execTime ));
137
- compileRunresult .check ("CMake build" );
138
-
139
-
140
- Files .find (tempCpp .resolve ("build" ).resolve ("lib" ), 1 , (path , args ) -> Files .isRegularFile (path ))
141
- .forEach (unchecked (p -> Files .copy (p , tempOutput .resolve (p .getFileName ()))));
142
-
143
- System .out .println ("Running test..." );
144
-
145
- long timeout = 200_000 ;
146
- ProcessResult testRunResult = ProcessHelper .run (tempOutput , timeout ,
147
- Arrays .asList ("java" ,
148
- "-Djava.library.path=." ,
149
- "-Dseed=1337" ,
150
- "-Dtest.src=" + temp .toString (),
151
- "-jar" , resultJar .toString ()));
152
- System .out .println (String .format ("Took %dms" , testRunResult .execTime ));
153
- testRunResult .check ("Test run" );
154
-
155
- if (!testRunResult .stdout .equals (idealRunResult .stdout )) {
156
- // Some tests are random based
157
- Pattern testResult = Pattern .compile ("^Passed = \\ d+,? failed = (\\ d+)$" , Pattern .MULTILINE );
158
- Matcher matcher = testResult .matcher (testRunResult .stdout );
159
- if (matcher .find ()) {
160
- if (!matcher .group (1 ).equals ("0" )) {
136
+ ProcessResult compileRunresult = ProcessHelper .run (tempCpp , 160_000 ,
137
+ Arrays .asList ("cmake" , "--build" , "." , "--config" , "Release" ));
138
+ System .out .println (String .format ("Took %dms" , compileRunresult .execTime ));
139
+ compileRunresult .check ("CMake build" );
140
+
141
+
142
+ Files .find (tempCpp .resolve ("build" ).resolve ("lib" ), 1 , (path , args ) -> Files .isRegularFile (path ))
143
+ .forEach (unchecked (p -> Files .copy (p , tempOutput .resolve (p .getFileName ()))));
144
+
145
+ System .out .println ("Running test..." );
146
+
147
+ long timeout = 200_000 ;
148
+ ProcessResult testRunResult = ProcessHelper .run (tempOutput , timeout ,
149
+ Arrays .asList ("java" ,
150
+ "-Djava.library.path=." ,
151
+ "-Dseed=1337" ,
152
+ "-Dtest.src=" + temp .toString (),
153
+ "-jar" , resultJar .toString ()));
154
+ System .out .println (String .format ("Took %dms" , testRunResult .execTime ));
155
+ testRunResult .check ("Test run" );
156
+
157
+ if (!testRunResult .stdout .equals (idealRunResult .stdout )) {
158
+ // Some tests are random based
159
+ Pattern testResult = Pattern .compile ("^Passed = \\ d+,? failed = (\\ d+)$" , Pattern .MULTILINE );
160
+ Matcher matcher = testResult .matcher (testRunResult .stdout );
161
+ if (matcher .find ()) {
162
+ if (!matcher .group (1 ).equals ("0" )) {
163
+ fail (testRunResult , idealRunResult );
164
+ }
165
+ } else {
161
166
fail (testRunResult , idealRunResult );
162
167
}
163
- } else {
164
- fail (testRunResult , idealRunResult );
165
168
}
166
- }
167
169
168
- System .out .println ("OK" );
170
+ System .out .println ("OK" );
171
+ }
169
172
} catch (IOException | RuntimeException e ) {
170
173
e .printStackTrace (System .err );
171
174
throw e ;
172
175
} finally {
173
- // clean();
176
+ clean ();
174
177
}
175
178
}
176
179
0 commit comments