Skip to content

Commit 5033e60

Browse files
author
Gary Frost
committedJun 7, 2024
Mavenize the repo. Mostly file moves to maven layout form
1 parent b32d718 commit 5033e60

File tree

181 files changed

+749
-45
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+749
-45
lines changed
 

‎hat/CMakeLists.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ add_custom_target(info_executables)
103103
###
104104
### (!hat!)) -> tools
105105

106-
set(HAT_SOURCE_ROOT ${CMAKE_SOURCE_DIR}/hat/src/java)
106+
set(HAT_SOURCE_ROOT ${CMAKE_SOURCE_DIR}/hat/src/main/java)
107107
set(HAT_CLASS_DIR ${CMAKE_BINARY_DIR}/hat/classes)
108108
set(HAT_JAR ${CMAKE_BINARY_DIR}/hat/hat.jar)
109109
file(GLOB_RECURSE HAT_JAVA_SOURCE_FILES ${HAT_SOURCE_ROOT}/*.java)
@@ -138,7 +138,7 @@ add_custom_target(hat.jar DEPENDS hat.javac
138138

139139
set(SQUARES_CLASS_DIR ${CMAKE_BINARY_DIR}/squares/classes)
140140
set(SQUARES_JAR ${CMAKE_BINARY_DIR}/squares/squares.jar)
141-
set(SQUARES_SOURCE_ROOT ${CMAKE_SOURCE_DIR}/examples/squares/src/java)
141+
set(SQUARES_SOURCE_ROOT ${CMAKE_SOURCE_DIR}/examples/squares/src/main/java)
142142
file(GLOB_RECURSE SQUARES_JAVA_SOURCE_FILES ${SQUARES_SOURCE_ROOT}/*.java)
143143

144144
add_custom_target(squares.javac DEPENDS hat.jar
@@ -222,7 +222,7 @@ add_dependencies(example_jars view.jar)
222222

223223
set(MANDEL_CLASS_DIR ${CMAKE_BINARY_DIR}/mandel/classes)
224224
set(MANDEL_JAR ${CMAKE_BINARY_DIR}/mandel/mandel.jar)
225-
set(MANDEL_SOURCE_ROOT ${CMAKE_SOURCE_DIR}/examples/mandel/src/java)
225+
set(MANDEL_SOURCE_ROOT ${CMAKE_SOURCE_DIR}/examples/mandel/src/main/java)
226226
file(GLOB_RECURSE MANDEL_JAVA_SOURCE_FILES ${MANDEL_SOURCE_ROOT}/*.java)
227227

228228
add_custom_target(mandel.javac DEPENDS hat.jar
@@ -249,7 +249,7 @@ add_dependencies(example_jars mandel.jar)
249249

250250
set(VIOLAJONES_CLASS_DIR ${CMAKE_BINARY_DIR}/violajones/classes)
251251
set(VIOLAJONES_JAR ${CMAKE_BINARY_DIR}/violajones/violajones.jar)
252-
set(VIOLAJONES_SOURCE_ROOT ${CMAKE_SOURCE_DIR}/examples/violajones/src/java)
252+
set(VIOLAJONES_SOURCE_ROOT ${CMAKE_SOURCE_DIR}/examples/violajones/src/main/java)
253253
file(GLOB_RECURSE VIOLAJONES_JAVA_SOURCE_FILES ${VIOLAJONES_SOURCE_ROOT}/*.java)
254254

255255
add_custom_target(violajones.javac DEPENDS hat.jar
@@ -268,7 +268,7 @@ add_custom_target(violajones.jar DEPENDS violajones.javac
268268
${JAVA_HOME}/bin/jar --create --no-manifest
269269
--file ${VIOLAJONES_JAR}
270270
-C ${VIOLAJONES_CLASS_DIR} .
271-
-C ${CMAKE_SOURCE_DIR}/examples/violajones/src/resources .
271+
-C ${CMAKE_SOURCE_DIR}/examples/violajones/src/main/resources .
272272
)
273273
add_dependencies(example_jars violajones.jar)
274274

‎hat/docs/maven.md

+155
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# HAT Project Primer
2+
3+
This is a fairly large project with Java and Native artifacts.
4+
5+
We also rely on the `babylon` (JDK23+Babylon) project, and the project will initially be made available as a subproject
6+
called `hat` under [github.com/openjdk/babylon](https://github.com/openjdk/babylon)
7+
8+
## Intellij and Clion
9+
10+
Whilst I do use JetBrains' `IntelliJ` and `Clion` for dev work and plan to leave project artifacts in the tree.
11+
Care must be taken as these tools do not play well together, specifically we cannot have `Clion` and `Intellij`
12+
project artifacts rooted under each other or in the same dir.
13+
14+
I have `intellij` and `clion` siblings which will act as roots
15+
for various tools and then use relative paths (or even symbolic links) in the various `.iml` files to locate the various source roots
16+
17+
So far this has worked ok.
18+
19+
### cmake and maven
20+
21+
We use maven for java artifacts and cmake for native libs (backends) although the root level CMakeLists.txt can also create java artifacts.
22+
23+
Generally to run any cmake target.
24+
```bash
25+
cd hat
26+
mkdir build
27+
cd build
28+
cmake ..
29+
cd ..
30+
cmake --build build --target <yourtarget>
31+
```
32+
33+
The maven build will build hat and will then delegate to cmake to build the backends.
34+
35+
To build with maven
36+
37+
```bash
38+
mvn clean compile assembly:single test
39+
```
40+
41+
### Initial Project Layout
42+
43+
44+
```
45+
${BABYLON_JDK}
46+
└── hat
47+
48+
├── CMakeFile
49+
├── build
50+
51+
├── intellij
52+
│ ├── .idea
53+
│ │ ├── compiler.xml
54+
│ │ ├── misc.xml
55+
│ │ ├── modules.xml
56+
│ │ ├── uiDesigner.xml
57+
│ │ ├── vcs.xml
58+
│ │ └── workspace.xml
59+
│ │
60+
│ ├── hat.iml
61+
│ ├── backend_(spirv|mock|cuda|ptx|opencl).iml
62+
│ └── (mandel|violajones|experiments).iml
63+
64+
├── hat
65+
│ └── src
66+
│ └── java
67+
68+
├── backends
69+
│ └── (opencl|cuda|ptx|mock|shared)
70+
│ └── src
71+
│ ├── cpp
72+
│ ├── include
73+
│ ├── java
74+
│ └── services
75+
└── examples
76+
├── mandel
77+
│ └── src
78+
│ └── java
79+
└── violajones
80+
└── src
81+
├── java
82+
└── resources
83+
```
84+
As you will note the `intellij` dir is somewhat self contained. the various `*.iml`
85+
files refer to the source dirs using relative paths.
86+
87+
I tend to add `Intelli` modules by hand. There are gotchas ;)
88+
89+
As with every intellij project, `.idea/modules.xml` 'points' to the iml files for each module (intellij's notion of module ;) )
90+
```xml
91+
<!--
92+
└──hat
93+
└── intellij
94+
└── .idea
95+
└── modules.xml
96+
-->
97+
<modules>
98+
<module fileurl="file://$PROJECT_DIR$/hat.iml" />
99+
<module fileurl="file://$PROJECT_DIR$/backend_opencl.iml" />
100+
<!-- yada yada -->
101+
</modules>
102+
103+
```
104+
105+
The various `.iml` files then have relative paths to their source/resource dirs roots.
106+
107+
```xml
108+
<module type="JAVA_MODULE" version="4">
109+
<component name="NewModuleRootManager" inherit-compiler-output="true">
110+
<exclude-output />
111+
<content url="file://$MODULE_DIR$/../../../hat/src/java">
112+
<sourceFolder url="file://$MODULE_DIR$/../../../hat/src/java" isTestSource="false" />
113+
</content>
114+
<orderEntry type="inheritedJdk" />
115+
<orderEntry type="sourceFolder" forTests="false" />
116+
<orderEntry type="module" module-name="hat" />
117+
</component>
118+
</module>
119+
120+
```
121+
### How intellij stores run configurations
122+
123+
I also tend to hand hack run configurations so will leave this here for reference
124+
125+
```xml
126+
<component name="RunManager" selected="Application.MandelTest">
127+
<configuration name="Mandel" type="Application"
128+
factoryName="Application" temporary="true"
129+
nameIsGenerated="true">
130+
<option name="MAIN_CLASS_NAME" value="mandel.Mandel" />
131+
<module name="mandel" />
132+
<option name="VM_PARAMETERS" value="
133+
--enable-preview
134+
--add-exports=java.base/java.lang.reflect.code.descriptor.impl=ALL-UNNAMED
135+
--add-exports=java.base/java.lang.foreign.mapper=ALL-UNNAMED
136+
--patch-module=java.base=$PROJECT_DIR$/out/production/java_base_patch
137+
-Djava.lang.foreign.mapper.debug=true" />
138+
<extension name="coverage">
139+
<pattern>
140+
<option name="PATTERN" value="mandel.*" />
141+
<option name="ENABLED" value="true" />
142+
</pattern>
143+
</extension>
144+
<method v="2">
145+
<option name="Make" enabled="true" />
146+
</method>
147+
</configuration>
148+
<!-- more configs -->
149+
</component>
150+
```
151+
152+
153+
154+
155+

0 commit comments

Comments
 (0)
Please sign in to comment.