1 2 # Intellij and Clion 3 ---- 4 5 * [Contents](hat-00.md) 6 * House Keeping 7 * [Project Layout](hat-01-01-project-layout.md) 8 * [Building Babylon](hat-01-02-building-babylon.md) 9 * [Maven and CMake](hat-01-03-maven-cmake.md) 10 * Programming Model 11 * [Programming Model](hat-03-programming-model.md) 12 * Interface Mapping 13 * [Interface Mapping Overview](hat-04-01-interface-mapping.md) 14 * [Cascade Interface Mapping](hat-04-02-cascade-interface-mapping.md) 15 * Implementation Detail 16 * [Walkthrough Of Accelerator.compute()](hat-accelerator-compute.md) 17 18 --- 19 20 ## Intellij and Clion 21 22 We can use JetBrains' `IntelliJ` and `Clion` for dev work and 23 decided to leave some project artifacts in the repo. 24 25 Care must be taken with Intellij and Clion 26 as these tools do not play well together, 27 specifically we cannot have `Clion` and `Intellij` 28 project artifacts rooted under each other or in the same dir. 29 30 ### Intellij 31 The `intellij` subdir under the root HAT directory 32 contains the `.idea` project dir and the various `*.iml` files 33 for each of the various `modules` 34 (note the use of `Intellji`'s meaning of the word of module here) 35 36 As you will note the `intellij` dir is somewhat self contained. the various `*.iml` 37 files refer to the source dirs using relative paths. 38 39 I tend to add `Intellij` modules by hand. There are gotchas ;) 40 41 As with every intellij project, `.idea/modules.xml` 'points' to the iml files for each module (intellij's notion of module ;) ) 42 ```xml 43 <!-- 44 └──hat 45 └── intellij 46 └── .idea 47 └── modules.xml 48 --> 49 <modules> 50 <module fileurl="file://$PROJECT_DIR$/hat.iml" /> 51 <module fileurl="file://$PROJECT_DIR$/backend_opencl.iml" /> 52 <!-- yada yada --> 53 </modules> 54 55 ``` 56 57 The various `.iml` files then have relative paths to their source/resource dirs roots. 58 59 ```xml 60 <module type="JAVA_MODULE" version="4"> 61 <component name="NewModuleRootManager" inherit-compiler-output="true"> 62 <exclude-output /> 63 <content url="file://$MODULE_DIR$/../../../hat/src/java"> 64 <sourceFolder url="file://$MODULE_DIR$/../../../hat/src/java" isTestSource="false" /> 65 </content> 66 <orderEntry type="inheritedJdk" /> 67 <orderEntry type="sourceFolder" forTests="false" /> 68 <orderEntry type="module" module-name="hat" /> 69 </component> 70 </module> 71 72 ``` 73 74 Making run configurations available to other developers is probably `a bridge too far` 75 76 But with some careful XML tooling we can make it easier to add 'run configurations'. 77 78 ### How intellij stores run configurations 79 80 I also tend to hand hack run configurations so will leave this here for reference 81 82 ```xml 83 <component name="RunManager" selected="Application.MandelTest"> 84 <configuration name="Mandel" type="Application" 85 factoryName="Application" temporary="true" 86 nameIsGenerated="true"> 87 <option name="MAIN_CLASS_NAME" value="mandel.Mandel" /> 88 <module name="mandel" /> 89 <option name="VM_PARAMETERS" value=" 90 --enable-preview 91 --add-exports=java.base/java.lang.reflect.code.descriptor.impl=ALL-UNNAMED 92 --add-exports=java.base/java.lang.foreign.mapper=ALL-UNNAMED 93 --patch-module=java.base=$PROJECT_DIR$/out/production/java_base_patch 94 -Djava.lang.foreign.mapper.debug=true" /> 95 <extension name="coverage"> 96 <pattern> 97 <option name="PATTERN" value="mandel.*" /> 98 <option name="ENABLED" value="true" /> 99 </pattern> 100 </extension> 101 <method v="2"> 102 <option name="Make" enabled="true" /> 103 </method> 104 </configuration> 105 <!-- more configs --> 106 </component> 107 ``` 108 109 ### Clion 110 111 Thankfully Clion uses cmake, so we get to re-use the CMakeLists.txt in the various backends to build. 112 113 The intent is that these cmake artifacts can be run standalone (using cmake in the appropriate dir), 114 from within Clion and can be used by maven. So the CMakeLists.txt files have some extra variables to 115 help us use them in these three modes. 116 117 118 119