11import com .fizzed .blaze .Contexts ;
22import com .fizzed .blaze .Task ;
33import com .fizzed .blaze .TaskGroup ;
4+ import com .fizzed .blaze .incubating .VcVars ;
5+ import com .fizzed .blaze .maven .MavenClasspath ;
6+ import com .fizzed .blaze .maven .MavenProject ;
7+ import com .fizzed .blaze .maven .MavenProjects ;
48import com .fizzed .blaze .project .PublicBlaze ;
59import com .fizzed .buildx .Buildx ;
610import com .fizzed .buildx .Target ;
711import com .fizzed .jne .NativeTarget ;
812import com .fizzed .jne .OperatingSystem ;
913
1014import java .nio .file .Path ;
11- import java .util .List ;
15+ import java .util .* ;
1216
1317import static com .fizzed .blaze .Contexts .withBaseDir ;
1418import static com .fizzed .blaze .Systems .*;
19+ import static com .fizzed .blaze .Systems .exec ;
20+ import static com .fizzed .blaze .incubating .VisualStudios .vcVars ;
21+ import static com .fizzed .blaze .incubating .VisualStudios .vcVarsExec ;
22+ import static com .fizzed .blaze .maven .MavenProjects .mavenClasspath ;
1523import static com .fizzed .blaze .util .Globber .globber ;
1624import static java .util .Arrays .asList ;
1725
@@ -24,10 +32,14 @@ public class blaze extends PublicBlaze {
2432 private final Path targetDir = projectDir .resolve ("target" );
2533
2634 @ Task (group ="project" , order = 0 , value ="Runs a demo of detecting all JDKs on this host" )
27- public void demo_detect_javas () throws Exception {
28- // mvn process-test-classes exec:exec -Dexec.classpathScope=test -Dexec.executable=java -Dexec.args="-cp %classpath com.fizzed.jne.JavaHomesDemo"
29- exec ("mvn" , "process-test-classes" , "exec:exec" ,
30- "-Dexec.classpathScope=test" , "-Dexec.executable=java" , "-Dexec.args=-cp %classpath com.fizzed.jne.JavaHomesDemo" ).run ();
35+ public void demo_java_homes () throws Exception {
36+ final MavenProject maven = MavenProjects .mavenProject (withBaseDir ("../pom.xml" )).run ();
37+
38+ final MavenClasspath classpath = mavenClasspath (maven , "test" , "test-compile" )
39+ .run ();
40+
41+ exec ("java" , "-cp" , classpath , "com.fizzed.jne.JavaHomesDemo" )
42+ .run ();
3143 }
3244
3345 @ Task (group ="project" , order = 1 , value ="Builds native libraries and executables for the local os/arch" )
@@ -48,11 +60,18 @@ public void build_natives() throws Exception {
4860 final String libname = nativeTarget .resolveLibraryFileName ("helloj" );
4961
5062 if (nativeTarget .getOperatingSystem () == OperatingSystem .WINDOWS ) {
51- // unfortunately its easiest to delegate this to helper script
52- exec ("setup/build-native-lib-windows-action.bat" , nativeTarget .toJneOsAbi (), nativeTarget .toJneArch ())
53- .workingDir (this .projectDir )
54- .verbose ()
55- .run ();
63+ // we may be cross-compiling so we pass the arch we want
64+ try (VcVars vcVars = vcVars ().arch (nativeTarget .getHardwareArchitecture ().name ()).verbose ().run ()) {
65+ log .info ("Building jcat executable..." );
66+ vcVarsExec (vcVars , "nmake" , "-f" , "VCMakefile" )
67+ .workingDir (targetJcatDir )
68+ .run ();
69+
70+ log .info ("Building helloj library..." );
71+ vcVarsExec (vcVars , "nmake" , "-f" , "VCMakefile" )
72+ .workingDir (targetLibHelloJDir )
73+ .run ();
74+ }
5675 } else {
5776 String cmd = "make" ;
5877 // freebsd and openbsd, we need to use gmake
0 commit comments