Skip to content

Commit e49e7df

Browse files
authored
Merge pull request #18 from fizzed/feature/new-win-native-compile
Feature/new win native compile
2 parents 27c6474 + 16bea00 commit e49e7df

File tree

10 files changed

+42
-65
lines changed

10 files changed

+42
-65
lines changed

.blaze/blaze.conf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
blaze.dependencies = [
2+
"com.fizzed:blaze-maven",
23
"com.fizzed:blaze-ssh",
3-
"com.fizzed:blaze-public-project:3.1.0",
4-
# force buildx version, can be removed once blaze-public-project is updated
5-
#"com.fizzed:buildx:2.0.3-SNAPSHOT"
4+
"com.fizzed:blaze-public-project:3.3.0"
65
]
76

87
java.source.version = 8

.blaze/blaze.java

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
import com.fizzed.blaze.Contexts;
22
import com.fizzed.blaze.Task;
33
import 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;
48
import com.fizzed.blaze.project.PublicBlaze;
59
import com.fizzed.buildx.Buildx;
610
import com.fizzed.buildx.Target;
711
import com.fizzed.jne.NativeTarget;
812
import com.fizzed.jne.OperatingSystem;
913

1014
import java.nio.file.Path;
11-
import java.util.List;
15+
import java.util.*;
1216

1317
import static com.fizzed.blaze.Contexts.withBaseDir;
1418
import 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;
1523
import static com.fizzed.blaze.util.Globber.globber;
1624
import 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

.blaze/pom.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<dependency>
2424
<groupId>com.fizzed</groupId>
2525
<artifactId>blaze-core</artifactId>
26-
<version>2.3.0</version>
26+
<version>2.4.0</version>
2727
</dependency>
2828
<dependency>
2929
<groupId>org.slf4j</groupId>
@@ -48,22 +48,27 @@
4848
<dependency>
4949
<groupId>com.fizzed</groupId>
5050
<artifactId>blaze-ivy</artifactId>
51-
<version>2.3.0</version>
51+
<version>2.4.0</version>
5252
</dependency>
5353
<dependency>
5454
<groupId>org.apache.ivy</groupId>
5555
<artifactId>ivy</artifactId>
5656
<version>2.5.3</version>
5757
</dependency>
58+
<dependency>
59+
<groupId>com.fizzed</groupId>
60+
<artifactId>blaze-maven</artifactId>
61+
<version>2.4.0</version>
62+
</dependency>
5863
<dependency>
5964
<groupId>com.fizzed</groupId>
6065
<artifactId>blaze-ssh</artifactId>
61-
<version>2.3.0</version>
66+
<version>2.4.0</version>
6267
</dependency>
6368
<dependency>
6469
<groupId>com.fizzed</groupId>
6570
<artifactId>blaze-public-project</artifactId>
66-
<version>3.1.0</version>
71+
<version>3.3.0</version>
6772
</dependency>
6873
</dependencies>
6974
</project>

blaze.jar

-3 Bytes
Binary file not shown.

buildx-results.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Buildx Results
33

44
Cross platform tests based on https://github.com/fizzed/buildx
55

6-
Commit: f34dc4cf6c3a93267a80093413e8ed37122219c5
7-
Date: 2025-11-05T15:07:54.827383687Z[UTC]
6+
Commit: 369328e98296758e707745d02238e6b500a5ddea
7+
Date: 2025-11-05T22:19:20.051604143Z[UTC]
88

99
jdk-25 (Zulu JDK 25.0.1 (Linux, x64, /usr/lib/jvm/zulu-jdk-25.0.1.8))...... success
1010
jdk-21 (Zulu JDK 21.0.8 (Linux, x64, /usr/lib/jvm/zulu-jdk-21.0.8.9))...... success

setup/build-native-lib-windows-action.bat

Lines changed: 0 additions & 46 deletions
This file was deleted.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)