Skip to content

Commit

Permalink
also make building on CI possible
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed Nov 22, 2024
1 parent 365c5a5 commit 979c796
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: mvn -B versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/}
- name: Build and Test
id: buildAndTest
run: mvn -B clean test
run: mvn clean test "-DdevCommandFileDir=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\"
- name: Codesign DLL on release
if: startsWith(github.ref, 'refs/tags/')
uses: skymatic/code-sign-action@v3
Expand Down
22 changes: 12 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# Note: make apparently thinks, that options specified with "/" are absolute paths and resolves them. see also https://stackoverflow.com/questions/17012419/d9024-make-unrecognized-source-file-type
WIN_SDK_VERSION ?= 10.0.22621.0
MSVC_VERSION ?= 14.41.34120
HEADERS := /I"src/main/headers" \
/I"${JAVA_HOME}\include" \
/I"${JAVA_HOME}\include\win32" \
/I"C:\Program Files (x86)\Windows Kits\10\Include\$(WIN_SDK_VERSION)\cppwinrt" \
/I"C:\Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/$(MSVC_VERSION)/include"
HEADERS := -I"src\main\headers" \
-I"${JAVA_HOME}\include" \
-I"${JAVA_HOME}\include\win32" \
-I"C:\Program Files (x86)\Windows Kits\10\Include\$(WIN_SDK_VERSION)\cppwinrt" \
-I"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\$(MSVC_VERSION)\include"
SOURCES := $(wildcard src/main/native/*.cpp)

########

all: install

install:
cl /EHsc /std:c++17 /LD /W4 /guard:cf \
/Fe:src/main/resources/integrations.dll \
$(HEADERS) $(SOURCES) \
/link /NXCOMPAT /DYNAMICBASE \
crypt32.lib shell32.lib ole32.lib uuid.lib user32.lib windowsapp.lib
cl -EHsc /std:c++17 -LD -W4 -guard:cf \
-Fe"src/main/resources/integrations.dll" \
-Fo"target/" \
$(HEADERS) $(SOURCES) \
-link -NXCOMPAT -DYNAMICBASE \
crypt32.lib shell32.lib ole32.lib uuid.lib user32.lib windowsapp.lib
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ This project uses the following JVM properties:

* JDK 22
* Maven
* MSVC 2022 toolchain (Visual Studio 2022, Workset "Desktop development with C++")
* MSVC 2022 toolset (e.g. by installing Visual Studio 2022, Workset "Desktop development with C++")
* make

### Build
Start the _Developer PowerShell for Visual Studio 2022_ and run the following commands:
```pwsh
Open a terminal and run
```
mvn clean verify
```
```

If building the dlls fails with "`cl.exe` cannot be found", you have to specify the developer command file directory as a property `-DdevCommandFileDir=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\"`.
8 changes: 6 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@
<name>!skipNativeCompile</name>
</property>
</activation>
<properties>
<devCommandFileDir>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\</devCommandFileDir>
</properties>
<build>
<plugins>
<plugin>
Expand All @@ -308,13 +311,14 @@
</goals>
<phase>compile</phase>
<configuration>
<executable>make</executable>
<executable>cmd</executable>
<workingDirectory>${project.basedir}</workingDirectory>
<environmentVariables>
<JAVA_HOME>${java.home}</JAVA_HOME>
</environmentVariables>
<arguments>
<argument>install</argument>
<argument>/c</argument>
<argument>"${devCommandFileDir}\vcvars64.bat" &amp;&amp; make install</argument>
</arguments>
</configuration>
</execution>
Expand Down

0 comments on commit 979c796

Please sign in to comment.