@@ -30,11 +30,12 @@ We might even have `Bldr` create the maven artifacts....
30
30
To build HAT we need to ensure that ` JAVA_HOME ` is set
31
31
to point to our babylon jdk (the one we built [ here] ( hat-01-02-building-babylon.md ) )
32
32
33
- It will simplify our tasks going forward if we
33
+ It simplifes our tasks going forward if we
34
34
add ` ${JAVA_HOME}/bin ` to our PATH (before any other JAVA installs).
35
35
36
- The top level ` env.bash ` shell script can be sourced (dot included)
37
- into your shell to both set ` JAVA_HOME ` and update your ` PATH `
36
+ We also need to prebuild the ` bldr/bldr.jar `
37
+
38
+ Thankfully just sourcing the top level ` env.bash ` script will perform these tasks
38
39
39
40
It should detect the arch type (AARCH64 or X86_46) and
40
41
select the correct relative parent dir and inject that dir in your PATH.
@@ -46,12 +47,13 @@ echo ${JAVA_HOME}
46
47
/Users/ME/github/babylon/hat/../build/macosx-aarch64-server-release/jdk
47
48
echo ${PATH}
48
49
/Users/ME/github/babylon/hat/../build/macosx-aarch64-server-release/jdk/bin:/usr/local/bin:......
50
+ ls bldr/bldr.jar
51
+ bldr/bldr.jar
49
52
```
50
53
51
54
# Introducing Bldr
52
- ` Bldr ` is a minimal java build system which has all the capabilities needed so far
53
- to build existing HAT as well as it's examples and backends. It is just a set of
54
- static methods and helper classes wrapping javac/jar tooling.
55
+ ` Bldr ` is an evolving set of static methods and types needed (so far.. ;) )
56
+ to build HAT as well as the HAT examples and backends.
55
57
56
58
` Bldr ` itself is a java class in
57
59
```
63
65
└── Bldr.java
64
66
```
65
67
66
- We do need to compile this one class using javac one time, then we can use this in ` bld ` scripts to actually bld.
68
+ The first run of ` env.bash ` will compile and create build ` bldr/bldr.jar `
67
69
68
70
Assuming we have our babylon JDK build in our path (via ` . env.bash ` ) we should do this every time we 'pull' HAT.
69
71
70
72
``` shell
71
73
mkdir bldr/classes
72
74
javac --enable-preview -source 24 -d bldr/classes bldr/src/main/java/bldr/Bldr.java
75
+ jar -cf bldr/bldr.jar -C bldr/classes bldr
73
76
```
74
-
75
- Now the ` bldr/classes ` dir contains all we need to create build scripts
76
-
77
- In HAT's root dir is a ` #! ` (Hash Bang) java launcher style script called ` bld `
77
+ In HAT's root dir is a ` #! ` (Hash Bang) java launcher style script called ` bld ` (and one called ` sanity ` )
78
78
which uses tools exposed by the precompiled ` Bldr ` to compile, create jars, run jextract, download dependencies, tar/untar etc.
79
79
80
80
As git does not allow us to check in scripts with execute permission, we need to ` chmod +x ` this ` bld ` file.
81
81
82
82
``` bash
83
- chmod +x bld
83
+ chmod +x bld sanity
84
84
```
85
85
86
- A simple example of ` bld ` script which just compiles core HAT source to ` build/hat-1.0.jar ` is shown.
87
-
88
- ``` java
89
- #! / usr/ bin/ env java -- enable- preview -- source 24 -- class- path bldr/ classes
90
- import module java.compiler ;
91
- import static bldr.Bldr.* ;
92
- void main(String [] args) throws IOException , InterruptedException {
93
- var hatDir = Path . of(System . getProperty(" user.dir" ));
94
- var target = path(hatDir, " build" );// mkdir(rmdir(path(hatDir, "build")));
95
-
96
- var hatJarResult = javacjar($ - > $
97
- .opts( " --source" , " 24" ,
98
- " --enable-preview" ,
99
- " --add-exports=java.base/jdk.internal=ALL-UNNAMED" ,
100
- " --add-exports=java.base/jdk.internal.vm.annotation=ALL-UNNAMED" )
101
- .jar(path(target, " hat-1.0.jar" ))
102
- .source_path(path(hatDir, " hat/src/main/java" ))
103
- );
104
- }
105
- ```
106
86
Note that the first line has the ` #! ` magic to allow this java code to be executed as if it
107
87
were a script. Whilst ` bld ` is indeed real java code, we do not need to compile it. Instead we just execute using
108
88
109
89
``` bash
110
90
./bld
111
91
```
112
92
113
- The real ` bld ` is more complicated, but not much more. It will will build hat-1.0.jar, along with all the backend jars hat-backend-?-1.0.jar,
93
+ ` bld ` will build hat-1.0.jar, along with all the backend jars hat-backend-?-1.0.jar,
114
94
all the example jars hat-example-?-1.0.jar and will try to build all native artifacts (.so/.dylib) it can.
95
+
115
96
So if cmake finds OpenCL libs/headers, you will see libopencl_backend (.so or .dylib)
116
97
117
98
On a CUDA machine you will see libcuda_backend(.so or .dylib)
118
99
119
- ` bld ` will also sanity check .java/.cpp/.h files to make sure we don't have any tabs, lines that with whitespace
100
+ ` sanity ` will sanity check all .md/ .java/.cpp/.h files to make sure we don't have any tabs, lines that with whitespace
120
101
or files without appropriate licence headers
121
102
122
103
``` bash
@@ -152,4 +133,5 @@ name `opencl` and the package name `mandel`
152
133
153
134
``` bash
154
135
bash hatrun.bash opencl mandel
136
+ bash hatrun.bash opencl heal
155
137
```
0 commit comments