Skip to content

Commit a70d3e9

Browse files
author
Gary Frost
committedJun 15, 2024
Switching to maven build
1 parent f21fef0 commit a70d3e9

File tree

20 files changed

+216
-122
lines changed

20 files changed

+216
-122
lines changed
 

‎hat/CMakeLists.txt

+18
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@ cmake_minimum_required(VERSION 3.21) #limited by jetson project(HAT)
22

33
project(hat)
44

5+
message(WARNING "HAT builds with maven now !!")
6+
message("You should be able to build using")
7+
message("->8- ")
8+
message(" . ./env.bash")
9+
message(" mvn clean compile jar:jar install")
10+
message("-8<- ")
11+
message("All jars, libs and executables should end up in the maven-build dir")
12+
message(" ")
13+
message("If the build fails check the pom.xml properties are correct using ")
14+
message("->8- ")
15+
message(" grep \"<properties>\" -A 10 pom.xml")
16+
message("-8<- ")
17+
message(" ")
18+
message("See https://github.com/openjdk/babylon/tree/code-reflection/hat#readme ")
19+
message(" ")
20+
message(FATAL_ERROR " Crashing out for your own safety ;)")
21+
22+
523
set(BABYLON_JDK ${CMAKE_SOURCE_DIR}/..)
624
if (EXISTS ${BABYLON_JDK})
725
message("BABYLON_JDK ${BABYLON_JDK} OK")

‎hat/backends/cuda/CMakeLists.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ if(CUDAToolkit_FOUND)
4949
add_custom_target(cuda_natives DEPENDS cuda_info cuda_backend)
5050

5151
add_custom_target(copy_cuda_libs DEPENDS cuda_info cuda_backend
52-
COMMAND cp ${CMAKE_BINARY_DIR}/cuda/libcuda_backend.* ${CMAKE_SOURCE_DIR}/../maven-build
53-
COMMAND cp ${CMAKE_BINARY_DIR}/cuda/cuda_info ${CMAKE_SOURCE_DIR}/../maven-build
52+
COMMAND cp ${CMAKE_BINARY_DIR}/cuda/libcuda_backend.* ${HAT_TARGET}
53+
COMMAND cp ${CMAKE_BINARY_DIR}/cuda/cuda_info ${HAT_TARGET}
5454
)
55-
add_dependencies(copy_libs copy_cuda_libs)
56-
55+
add_dependencies(copy_libs copy_cuda_libs)
5756
endif()

‎hat/backends/cuda/pom.xml

+18-7
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ questions.
3131
<artifactId>hat-backend-cuda</artifactId>
3232
<version>1.0</version>
3333
<packaging>jar</packaging>
34+
<!-- this required to inherit parent properties -->
35+
<parent>
36+
<groupId>oracle.code</groupId>
37+
<version>1.0</version>
38+
<artifactId>hat.backends</artifactId>
39+
</parent>
3440

3541
<dependencies>
3642
<dependency>
@@ -40,14 +46,19 @@ questions.
4046
</dependency>
4147
</dependencies>
4248

43-
<properties>
44-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
45-
<maven.compiler.source>23</maven.compiler.source>
46-
<maven.compiler.target>23</maven.compiler.target>
47-
</properties>
48-
4949
<build>
5050
<plugins>
51+
<plugin>
52+
<groupId>org.codehaus.mojo</groupId>
53+
<artifactId>exec-maven-plugin</artifactId>
54+
<configuration>
55+
<skip>true</skip>
56+
<!-- we want to inherit properties from parent but not the
57+
plugin that calls cmake -->
58+
</configuration>
59+
</plugin>
60+
61+
5162
<plugin>
5263
<groupId>org.apache.maven.plugins</groupId>
5364
<artifactId>maven-antrun-plugin</artifactId>
@@ -57,7 +68,7 @@ questions.
5768
<phase>install</phase>
5869
<configuration>
5970
<target>
60-
<copy file="target/hat-backend-cuda-1.0.jar" todir="../../maven-build"/>
71+
<copy file="target/hat-backend-cuda-1.0.jar" todir="${hat.target}"/>
6172
</target>
6273
</configuration>
6374
<goals>

‎hat/backends/mock/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ target_link_libraries(mock_info
4040
)
4141
add_custom_target(mock_natives DEPENDS mock_info mock_backend)
4242
add_custom_target(copy_mock_libs DEPENDS mock_info mock_backend
43-
COMMAND cp ${CMAKE_BINARY_DIR}/mock/libmock_backend.* ${CMAKE_SOURCE_DIR}/../maven-build
44-
COMMAND cp ${CMAKE_BINARY_DIR}/mock/mock_info ${CMAKE_SOURCE_DIR}/../maven-build
43+
COMMAND cp ${CMAKE_BINARY_DIR}/mock/libmock_backend.* ${HAT_TARGET}
44+
COMMAND cp ${CMAKE_BINARY_DIR}/mock/mock_info ${HAT_TARGET}
4545
)
4646
add_dependencies(copy_libs copy_mock_libs)
4747

‎hat/backends/mock/pom.xml

+17-7
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ questions.
3131
<artifactId>hat-backend-mock</artifactId>
3232
<version>1.0</version>
3333
<packaging>jar</packaging>
34-
35-
<properties>
36-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
37-
<maven.compiler.source>23</maven.compiler.source>
38-
<maven.compiler.target>23</maven.compiler.target>
39-
</properties>
34+
<!-- this required to inherit parent properties -->
35+
<parent>
36+
<groupId>oracle.code</groupId>
37+
<version>1.0</version>
38+
<artifactId>hat.backends</artifactId>
39+
</parent>
4040

4141
<dependencies>
4242
<dependency>
@@ -48,6 +48,16 @@ questions.
4848

4949
<build>
5050
<plugins>
51+
<plugin>
52+
<groupId>org.codehaus.mojo</groupId>
53+
<artifactId>exec-maven-plugin</artifactId>
54+
<configuration>
55+
<skip>true</skip>
56+
<!-- we want to inherit properties from parent but not the
57+
plugin that calls cmake -->
58+
</configuration>
59+
</plugin>
60+
5161
<plugin>
5262
<groupId>org.apache.maven.plugins</groupId>
5363
<artifactId>maven-antrun-plugin</artifactId>
@@ -57,7 +67,7 @@ questions.
5767
<phase>install</phase>
5868
<configuration>
5969
<target>
60-
<copy file="target/hat-backend-mock-1.0.jar" todir="../../maven-build"/>
70+
<copy file="target/hat-backend-mock-1.0.jar" todir="${hat.target}"/>
6171
</target>
6272
</configuration>
6373
<goals>

‎hat/backends/opencl/CMakeLists.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ if(OPENCL_FOUND)
5050
)
5151
add_custom_target(opencl_natives DEPENDS opencl_info opencl_backend)
5252
add_custom_target(copy_opencl_libs DEPENDS opencl_info opencl_backend
53-
COMMAND cp ${CMAKE_BINARY_DIR}/opencl/libopencl_backend.* ${CMAKE_SOURCE_DIR}/../maven-build
54-
COMMAND cp ${CMAKE_BINARY_DIR}/opencl/opencl_info ${CMAKE_SOURCE_DIR}/../maven-build
53+
COMMAND cp ${CMAKE_BINARY_DIR}/opencl/libopencl_backend.* ${HAT_TARGET}
54+
COMMAND cp ${CMAKE_BINARY_DIR}/opencl/opencl_info ${HAT_TARGET}
5555
)
5656
add_dependencies(copy_libs copy_opencl_libs)
57+
5758
endif()

‎hat/backends/opencl/pom.xml

+16-8
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ questions.
3232
<version>1.0</version>
3333
<packaging>jar</packaging>
3434

35-
<properties>
36-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
37-
<maven.compiler.source>23</maven.compiler.source>
38-
<maven.compiler.target>23</maven.compiler.target>
39-
</properties>
35+
<!-- this required to inherit parent properties -->
36+
<parent>
37+
<groupId>oracle.code</groupId>
38+
<version>1.0</version>
39+
<artifactId>hat.backends</artifactId>
40+
</parent>
4041

4142
<dependencies>
4243
<dependency>
@@ -48,7 +49,15 @@ questions.
4849

4950
<build>
5051
<plugins>
51-
52+
<plugin>
53+
<groupId>org.codehaus.mojo</groupId>
54+
<artifactId>exec-maven-plugin</artifactId>
55+
<configuration>
56+
<skip>true</skip>
57+
<!-- we want to inherit properties from parent but not the
58+
plugin that calls cmake -->
59+
</configuration>
60+
</plugin>
5261

5362
<plugin>
5463
<groupId>org.apache.maven.plugins</groupId>
@@ -59,8 +68,7 @@ questions.
5968
<phase>install</phase>
6069
<configuration>
6170
<target>
62-
<copy file="target/hat-backend-opencl-1.0.jar" todir="../../maven-build"/>
63-
71+
<copy file="target/hat-backend-opencl-1.0.jar" todir="${hat.target}"/>
6472
</target>
6573
</configuration>
6674
<goals>

‎hat/backends/pom.xml

+10-2
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,21 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
3030
<modelVersion>4.0.0</modelVersion>
3131
<groupId>oracle.code</groupId>
3232
<version>1.0</version>
33-
<artifactId>backends</artifactId>
33+
<artifactId>hat.backends</artifactId>
3434
<packaging>pom</packaging>
35+
<!-- this required to inherit parent properties -->
36+
<parent>
37+
<groupId>oracle.code</groupId>
38+
<version>1.0</version>
39+
<artifactId>hat.root</artifactId>
40+
</parent>
41+
3542
<modules>
3643
<module>opencl</module>
3744
<module>cuda</module>
3845
<module>mock</module>
3946
<module>ptx</module>
40-
<!--<module>spirv</module>-->
47+
<module>spirv</module>
4148
</modules>
4249
<build>
4350
<plugins>
@@ -55,6 +62,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
5562
<configuration>
5663
<executable>cmake</executable>
5764
<arguments>
65+
<argument>-DHAT_TARGET=${hat.target}</argument>
5866
<argument>-B</argument>
5967
<argument>cmake-build-debug</argument>
6068
</arguments>

‎hat/backends/ptx/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ if(CUDAToolkit_FOUND)
4949
add_custom_target(ptx_natives DEPENDS ptx_info ptx_backend)
5050

5151
add_custom_target(copy_ptx_libs DEPENDS ptx_info ptx_backend
52-
COMMAND cp ${CMAKE_BINARY_DIR}/ptx/libptx_backend.* ${CMAKE_SOURCE_DIR}/../maven-build
53-
COMMAND cp ${CMAKE_BINARY_DIR}/ptx/ptx_info ${CMAKE_SOURCE_DIR}/../maven-build
52+
COMMAND cp ${CMAKE_BINARY_DIR}/ptx/libptx_backend.* ${HAT_TARGET}
53+
COMMAND cp ${CMAKE_BINARY_DIR}/ptx/ptx_info ${HAT_TARGET}
5454
)
5555
add_dependencies(copy_libs copy_ptx_libs)
5656
endif()

‎hat/backends/ptx/pom.xml

+17-6
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ questions.
3232
<version>1.0</version>
3333
<packaging>jar</packaging>
3434

35-
<properties>
36-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
37-
<maven.compiler.source>23</maven.compiler.source>
38-
<maven.compiler.target>23</maven.compiler.target>
39-
</properties>
35+
<!-- this required to inherit parent properties -->
36+
<parent>
37+
<groupId>oracle.code</groupId>
38+
<version>1.0</version>
39+
<artifactId>hat.backends</artifactId>
40+
</parent>
4041

4142
<dependencies>
4243
<dependency>
@@ -47,6 +48,16 @@ questions.
4748
</dependencies>
4849
<build>
4950
<plugins>
51+
<plugin>
52+
<groupId>org.codehaus.mojo</groupId>
53+
<artifactId>exec-maven-plugin</artifactId>
54+
<configuration>
55+
<skip>true</skip>
56+
<!-- we want to inherit properties from parent but not the
57+
plugin that calls cmake -->
58+
</configuration>
59+
</plugin>
60+
5061
<plugin>
5162
<groupId>org.apache.maven.plugins</groupId>
5263
<artifactId>maven-antrun-plugin</artifactId>
@@ -56,7 +67,7 @@ questions.
5667
<phase>install</phase>
5768
<configuration>
5869
<target>
59-
<copy file="target/hat-backend-ptx-1.0.jar" todir="../../maven-build"/>
70+
<copy file="target/hat-backend-ptx-1.0.jar" todir="${hat.target}"/>
6071
</target>
6172
</configuration>
6273
<goals>

‎hat/backends/spirv/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ target_link_libraries(spirv_info
4141
add_custom_target(spirv_natives DEPENDS spirv_info spirv_backend)
4242

4343
add_custom_target(copy_spirv_libs DEPENDS spirv_info spirv_backend
44-
COMMAND cp ${CMAKE_BINARY_DIR}/spirv/libspirv_backend.* ${CMAKE_SOURCE_DIR}/../maven-build
45-
COMMAND cp ${CMAKE_BINARY_DIR}/spirv/spirv_info ${CMAKE_SOURCE_DIR}/../maven-build
44+
COMMAND cp ${CMAKE_BINARY_DIR}/spirv/libspirv_backend.* ${HAT_TARGET}
45+
COMMAND cp ${CMAKE_BINARY_DIR}/spirv/spirv_info ${HAT_TARGET}
4646
)
4747
add_dependencies(copy_libs copy_spirv_libs)
4848

‎hat/backends/spirv/pom.xml

+19-8
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ questions.
3131
<artifactId>hat-backend-spirv</artifactId>
3232
<version>1.0</version>
3333
<packaging>jar</packaging>
34+
<!-- this required to inherit parent properties -->
35+
<parent>
36+
<groupId>oracle.code</groupId>
37+
<version>1.0</version>
38+
<artifactId>hat.backends</artifactId>
39+
</parent>
3440

35-
<properties>
36-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
37-
<maven.compiler.source>23</maven.compiler.source>
38-
<maven.compiler.target>23</maven.compiler.target>
39-
</properties>
4041

4142
<dependencies>
4243
<dependency>
@@ -47,6 +48,16 @@ questions.
4748
</dependencies>
4849
<build>
4950
<plugins>
51+
<plugin>
52+
<groupId>org.codehaus.mojo</groupId>
53+
<artifactId>exec-maven-plugin</artifactId>
54+
<configuration>
55+
<skip>true</skip>
56+
<!-- we want to inherit properties from parent but not the
57+
plugin that calls cmake -->
58+
</configuration>
59+
</plugin>
60+
5061
<plugin>
5162
<groupId>org.apache.maven.plugins</groupId>
5263
<artifactId>maven-antrun-plugin</artifactId>
@@ -56,7 +67,7 @@ questions.
5667
<phase>install</phase>
5768
<configuration>
5869
<target>
59-
<copy file="target/hat-backend-spirv-1.0.jar" todir="../../maven-build"/>
70+
<copy file="target/hat-backend-spirv-1.0.jar" todir="${hat.target}"/>
6071
</target>
6172
</configuration>
6273
<goals>
@@ -79,8 +90,8 @@ questions.
7990
</goals>
8091
<configuration>
8192
<sources>
82-
<source> ../../../cr-examples/spirv/src/main/java </source>
83-
<source>../../../../beehive-spirv-toolkit/lib/src/main/java</source>
93+
<source>${babylon.dir}/cr-examples/spirv/src/main/java </source>
94+
<source>${beehive.spirv.toolkit.dir}/lib/src/main/java</source>
8495
</sources>
8596
</configuration>
8697
</execution>

‎hat/build.bash

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
cmake -B build
2-
for backend in \
3-
opencl\
4-
mock\
5-
ptx\
6-
;do
7-
cmake --build build --target ${backend}_backend
8-
done
9-
10-
mvn clean compile jar:jar
1+
mvn clean compile jar:jar install

‎hat/examples/experiments/pom.xml

+7-7
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ questions.
3131
<artifactId>hat-example-experiments</artifactId>
3232
<version>1.0</version>
3333
<packaging>jar</packaging>
34-
35-
<properties>
36-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
37-
<maven.compiler.source>23</maven.compiler.source>
38-
<maven.compiler.target>23</maven.compiler.target>
39-
</properties>
34+
<!-- this required to inherit parent properties -->
35+
<parent>
36+
<groupId>oracle.code</groupId>
37+
<version>1.0</version>
38+
<artifactId>hat.examples</artifactId>
39+
</parent>
4040

4141
<dependencies>
4242
<dependency>
@@ -57,7 +57,7 @@ questions.
5757
<phase>install</phase>
5858
<configuration>
5959
<target>
60-
<copy file="target/hat-example-experiments-1.0.jar" todir="../../maven-build"/>
60+
<copy file="target/hat-example-experiments-1.0.jar" todir="${hat.target}"/>
6161
</target>
6262
</configuration>
6363
<goals>

0 commit comments

Comments
 (0)
Please sign in to comment.