From 365c5a502a91c7656e6d8b2e1b5e8615f478e261 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Fri, 15 Nov 2024 15:50:39 +0100 Subject: [PATCH 1/9] add config for local Microsoft cl compiling --- .gitignore | 70 ++++++++ Makefile | 14 +- README.md | 11 +- integrations-win.sln | 31 ++++ integrations-win.vcxproj | 165 ++++++++++++++++++ ...dows_keychain_WinDataProtection_Native.cpp | 1 + ...ndows_uiappearnce_WinAppearance_Native.cpp | 10 +- 7 files changed, 292 insertions(+), 10 deletions(-) create mode 100644 integrations-win.sln create mode 100644 integrations-win.vcxproj diff --git a/.gitignore b/.gitignore index f74150f..359ee37 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,73 @@ pom.xml.versionsBackup .idea/compiler.xml .idea/jarRepositories.xml *.iml + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +# but not Directory.Build.rsp, as it configures directory-level build defaults +!Directory.Build.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# exclude compile outputs not used by projects +*.exp +*.lib \ No newline at end of file diff --git a/Makefile b/Makefile index 09525fb..e94d9fe 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,10 @@ -HEADERS := -I"src/main/headers" -I"${JAVA_HOME}\include" -I"${JAVA_HOME}\include\win32" +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" SOURCES := $(wildcard src/main/native/*.cpp) ######## @@ -6,4 +12,8 @@ SOURCES := $(wildcard src/main/native/*.cpp) all: install install: - g++ -Wall -D_JNI_IMPLEMENTATION_ -Wl,--kill-at $(HEADERS) -shared -osrc/main/resources/integrations.dll $(SOURCES) -lcrypt32 -lshell32 -lole32 -luuid \ No newline at end of file + 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 \ No newline at end of file diff --git a/README.md b/README.md index 5bd462d..f7eed0e 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,14 @@ This project uses the following JVM properties: ## Building -This project uses JNI, hence you'll nedd Java as well as GCC build tools: +### Requirements * JDK 22 * Maven -* MinGW GCC compiler (`choco install mingw --version=10.2.0`) -* Make (`choco install make`) \ No newline at end of file +* MSVC 2022 toolchain (Visual Studio 2022, Workset "Desktop development with C++") + +### Build +Start the _Developer PowerShell for Visual Studio 2022_ and run the following commands: +```pwsh +mvn clean verify +``` \ No newline at end of file diff --git a/integrations-win.sln b/integrations-win.sln new file mode 100644 index 0000000..2e4e468 --- /dev/null +++ b/integrations-win.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35327.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "integrations-win", "integrations-win.vcxproj", "{CF96ACE0-9471-4BD6-AD0E-BE32AF14C358}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CF96ACE0-9471-4BD6-AD0E-BE32AF14C358}.Debug|x64.ActiveCfg = Debug|x64 + {CF96ACE0-9471-4BD6-AD0E-BE32AF14C358}.Debug|x64.Build.0 = Debug|x64 + {CF96ACE0-9471-4BD6-AD0E-BE32AF14C358}.Debug|x86.ActiveCfg = Debug|Win32 + {CF96ACE0-9471-4BD6-AD0E-BE32AF14C358}.Debug|x86.Build.0 = Debug|Win32 + {CF96ACE0-9471-4BD6-AD0E-BE32AF14C358}.Release|x64.ActiveCfg = Release|x64 + {CF96ACE0-9471-4BD6-AD0E-BE32AF14C358}.Release|x64.Build.0 = Release|x64 + {CF96ACE0-9471-4BD6-AD0E-BE32AF14C358}.Release|x86.ActiveCfg = Release|Win32 + {CF96ACE0-9471-4BD6-AD0E-BE32AF14C358}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DCEB853F-9857-4F7D-A508-A7390F37BC50} + EndGlobalSection +EndGlobal diff --git a/integrations-win.vcxproj b/integrations-win.vcxproj new file mode 100644 index 0000000..6314732 --- /dev/null +++ b/integrations-win.vcxproj @@ -0,0 +1,165 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {cf96ace0-9471-4bd6-ad0e-be32af14c358} + integrationswin + 10.0.22621.0 + + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + $(ProjectDir)src\main\headers;$(JAVA_HOME)include;$(JAVA_HOME)include\win32;$(IncludePath) + $(SolutionDir)target\native\$(Platform)\$(Configuration)\ + integrations + + + + Level3 + true + WIN32;_DEBUG;INTEGRATIONSWIN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + false + + + + + Level3 + true + true + true + WIN32;NDEBUG;INTEGRATIONSWIN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + true + true + false + + + + + Level3 + true + _DEBUG;INTEGRATIONSWIN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + NotUsing + + + stdcpp17 + + + Windows + true + false + %(ForceSymbolReferences) + crypt32.lib;shell32.lib;ole32.lib;uuid.lib;user32.lib;windowsapp.lib + + + + + Level3 + true + true + true + NDEBUG;INTEGRATIONSWIN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + true + true + false + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/native/org_cryptomator_windows_keychain_WinDataProtection_Native.cpp b/src/main/native/org_cryptomator_windows_keychain_WinDataProtection_Native.cpp index 51d4966..2f5256b 100644 --- a/src/main/native/org_cryptomator_windows_keychain_WinDataProtection_Native.cpp +++ b/src/main/native/org_cryptomator_windows_keychain_WinDataProtection_Native.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "org_cryptomator_windows_keychain_WinDataProtection_Native.h" JNIEXPORT jbyteArray JNICALL Java_org_cryptomator_windows_keychain_WinDataProtection_00024Native_protect(JNIEnv *env, jobject thisObj, jbyteArray cleartext, jbyteArray salt) { diff --git a/src/main/native/org_cryptomator_windows_uiappearnce_WinAppearance_Native.cpp b/src/main/native/org_cryptomator_windows_uiappearnce_WinAppearance_Native.cpp index 9ae99ba..ae7d9b5 100644 --- a/src/main/native/org_cryptomator_windows_uiappearnce_WinAppearance_Native.cpp +++ b/src/main/native/org_cryptomator_windows_uiappearnce_WinAppearance_Native.cpp @@ -17,10 +17,10 @@ void throwIllegalStateException(JNIEnv *env, const char* message) { JNIEXPORT jint JNICALL Java_org_cryptomator_windows_uiappearance_WinAppearance_00024Native_getCurrentTheme (JNIEnv *env, jobject thisObject){ DWORD data{}; DWORD dataSize = sizeof(data); - LSTATUS status = RegGetValue(HKEY_CURRENT_USER, R"(Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)", "AppsUseLightTheme", RRF_RT_DWORD, NULL, &data, &dataSize); + LSTATUS status = RegGetValueW(HKEY_CURRENT_USER, L"(Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize)", L"AppsUseLightTheme", RRF_RT_DWORD, NULL, &data, &dataSize); if(status != ERROR_SUCCESS){ char msg[50]; - sprintf(msg, "Failed to read registry value (status %d)", (int) status); + sprintf_s(msg, 50, "Failed to read registry value (status %d)", (int) status); throwIllegalStateException(env, msg); } return data ? 1 : 0; @@ -28,16 +28,16 @@ JNIEXPORT jint JNICALL Java_org_cryptomator_windows_uiappearance_WinAppearance_0 JNIEXPORT void JNICALL Java_org_cryptomator_windows_uiappearance_WinAppearance_00024Native_waitForNextThemeChange(JNIEnv *env, jobject thisObj){ HKEY key; - LSTATUS status = RegOpenKeyEx(HKEY_CURRENT_USER, R"(Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)", 0, KEY_READ, &key); + LSTATUS status = RegOpenKeyExW(HKEY_CURRENT_USER, L"(Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize)", 0, KEY_READ, &key); if (status != ERROR_SUCCESS) { char msg[50]; - sprintf(msg, "Failed to open registry key (status %d)", (int) status); + sprintf_s(msg, 50,"Failed to open registry key (status %d)", (int) status); throwIllegalStateException(env, msg); } status = RegNotifyChangeKeyValue(key, TRUE, REG_NOTIFY_CHANGE_LAST_SET, NULL, FALSE); if (status != ERROR_SUCCESS) { char msg[50]; - sprintf(msg, "Failed to observe registry key (status %d)", (int) status); + sprintf_s(msg, 50, "Failed to observe registry key (status %d)", (int) status); throwIllegalStateException(env, msg); } RegCloseKey(key); From 9ce8d07cabc144c7e5baca599215e2335dcc12bf Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Fri, 22 Nov 2024 15:58:55 +0100 Subject: [PATCH 2/9] also make building on CI possible --- .github/workflows/build.yml | 2 +- Makefile | 22 ++++++++++++---------- README.md | 11 +++++++---- pom.xml | 8 ++++++-- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9cc3824..9df3de3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/Makefile b/Makefile index e94d9fe..4734a63 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,11 @@ +# 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) ######## @@ -12,8 +13,9 @@ 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 \ No newline at end of file + 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 \ No newline at end of file diff --git a/README.md b/README.md index f7eed0e..5bb547b 100644 --- a/README.md +++ b/README.md @@ -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 -``` \ No newline at end of file +``` + +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\"`. \ No newline at end of file diff --git a/pom.xml b/pom.xml index e6a216d..e522bba 100644 --- a/pom.xml +++ b/pom.xml @@ -295,6 +295,9 @@ !skipNativeCompile + + C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\ + @@ -308,13 +311,14 @@ compile - make + cmd ${project.basedir} ${java.home} - install + /c + "${devCommandFileDir}\vcvars64.bat" && make install From c4705ceaf14aa26797df439abce1a4d21079ecd7 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Fri, 22 Nov 2024 16:40:58 +0100 Subject: [PATCH 3/9] apply suggestions --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/publish-central.yml | 2 +- .github/workflows/publish-github.yml | 2 +- integrations-win.vcxproj | 37 +-------------------------- 4 files changed, 4 insertions(+), 39 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index e786bc1..c256219 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -32,6 +32,6 @@ jobs: with: languages: java - name: Build - run: mvn -B compile + run: mvn -B compile -DdevCommandFileDir="C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\" - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 \ No newline at end of file diff --git a/.github/workflows/publish-central.yml b/.github/workflows/publish-central.yml index f445539..c5c5b85 100644 --- a/.github/workflows/publish-central.yml +++ b/.github/workflows/publish-central.yml @@ -29,7 +29,7 @@ jobs: - name: Enforce project version ${{ github.event.inputs.tag }} run: mvn versions:set -B -DnewVersion="${{ github.event.inputs.tag }}" - name: Deploy - run: mvn deploy -B -DskipTests -Psign,deploy-central --no-transfer-progress + run: mvn deploy -B -DskipTests -Psign,deploy-central --no-transfer-progress -DdevCommandFileDir="C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\" env: MAVEN_OPTS: > --add-opens=java.base/java.util=ALL-UNNAMED diff --git a/.github/workflows/publish-github.yml b/.github/workflows/publish-github.yml index 95fe4b8..b71883d 100644 --- a/.github/workflows/publish-github.yml +++ b/.github/workflows/publish-github.yml @@ -21,7 +21,7 @@ jobs: - name: Enforce project version ${{ github.event.release.tag_name }} run: mvn versions:set -B -DnewVersion="${{ github.event.release.tag_name }}" - name: Deploy - run: mvn deploy -B -DskipTests -Psign,deploy-github --no-transfer-progress + run: mvn deploy -B -DskipTests -Psign,deploy-github --no-transfer-progress -DdevCommandFileDir="C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }} diff --git a/integrations-win.vcxproj b/integrations-win.vcxproj index 6314732..053bbe7 100644 --- a/integrations-win.vcxproj +++ b/integrations-win.vcxproj @@ -75,40 +75,6 @@ $(SolutionDir)target\native\$(Platform)\$(Configuration)\ integrations - - - Level3 - true - WIN32;_DEBUG;INTEGRATIONSWIN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - Use - pch.h - - - Windows - true - false - - - - - Level3 - true - true - true - WIN32;NDEBUG;INTEGRATIONSWIN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - Use - pch.h - - - Windows - true - true - true - false - - Level3 @@ -152,12 +118,11 @@ - - + From b211ede40b6ae2b36c5e1909a2242a5f3ad1af16 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Fri, 22 Nov 2024 17:23:00 +0100 Subject: [PATCH 4/9] use always dash for commands and place lib & exp file in target --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4734a63..b1a84d0 100644 --- a/Makefile +++ b/Makefile @@ -13,9 +13,10 @@ SOURCES := $(wildcard src/main/native/*.cpp) all: install install: - cl -EHsc /std:c++17 -LD -W4 -guard:cf \ + cl -EHsc -std:c++17 -LD -W4 -guard:cf \ -Fe"src/main/resources/integrations.dll" \ -Fo"target/" \ $(HEADERS) $(SOURCES) \ -link -NXCOMPAT -DYNAMICBASE \ + -implib:target/integrations.lib \ crypt32.lib shell32.lib ole32.lib uuid.lib user32.lib windowsapp.lib \ No newline at end of file From cc516dc42e6e6292d30077cda5474657af188761 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Fri, 22 Nov 2024 17:37:40 +0100 Subject: [PATCH 5/9] use correct lib --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b1a84d0..3c3fe5a 100644 --- a/Makefile +++ b/Makefile @@ -19,4 +19,4 @@ install: $(HEADERS) $(SOURCES) \ -link -NXCOMPAT -DYNAMICBASE \ -implib:target/integrations.lib \ - crypt32.lib shell32.lib ole32.lib uuid.lib user32.lib windowsapp.lib \ No newline at end of file + crypt32.lib shell32.lib ole32.lib uuid.lib user32.lib Advapi32.lib \ No newline at end of file From b000879973c4b40911c941f8ccd149bfd8cff06c Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Fri, 22 Nov 2024 17:39:31 +0100 Subject: [PATCH 6/9] adjust native code --- ..._cryptomator_windows_keychain_WinDataProtection_Native.cpp | 1 - ...g_cryptomator_windows_uiappearnce_WinAppearance_Native.cpp | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/native/org_cryptomator_windows_keychain_WinDataProtection_Native.cpp b/src/main/native/org_cryptomator_windows_keychain_WinDataProtection_Native.cpp index 2f5256b..51d4966 100644 --- a/src/main/native/org_cryptomator_windows_keychain_WinDataProtection_Native.cpp +++ b/src/main/native/org_cryptomator_windows_keychain_WinDataProtection_Native.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include "org_cryptomator_windows_keychain_WinDataProtection_Native.h" JNIEXPORT jbyteArray JNICALL Java_org_cryptomator_windows_keychain_WinDataProtection_00024Native_protect(JNIEnv *env, jobject thisObj, jbyteArray cleartext, jbyteArray salt) { diff --git a/src/main/native/org_cryptomator_windows_uiappearnce_WinAppearance_Native.cpp b/src/main/native/org_cryptomator_windows_uiappearnce_WinAppearance_Native.cpp index ae7d9b5..ffaf353 100644 --- a/src/main/native/org_cryptomator_windows_uiappearnce_WinAppearance_Native.cpp +++ b/src/main/native/org_cryptomator_windows_uiappearnce_WinAppearance_Native.cpp @@ -17,7 +17,7 @@ void throwIllegalStateException(JNIEnv *env, const char* message) { JNIEXPORT jint JNICALL Java_org_cryptomator_windows_uiappearance_WinAppearance_00024Native_getCurrentTheme (JNIEnv *env, jobject thisObject){ DWORD data{}; DWORD dataSize = sizeof(data); - LSTATUS status = RegGetValueW(HKEY_CURRENT_USER, L"(Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize)", L"AppsUseLightTheme", RRF_RT_DWORD, NULL, &data, &dataSize); + LSTATUS status = RegGetValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", L"AppsUseLightTheme", RRF_RT_DWORD, NULL, &data, &dataSize); if(status != ERROR_SUCCESS){ char msg[50]; sprintf_s(msg, 50, "Failed to read registry value (status %d)", (int) status); @@ -28,7 +28,7 @@ JNIEXPORT jint JNICALL Java_org_cryptomator_windows_uiappearance_WinAppearance_0 JNIEXPORT void JNICALL Java_org_cryptomator_windows_uiappearance_WinAppearance_00024Native_waitForNextThemeChange(JNIEnv *env, jobject thisObj){ HKEY key; - LSTATUS status = RegOpenKeyExW(HKEY_CURRENT_USER, L"(Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize)", 0, KEY_READ, &key); + LSTATUS status = RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", 0, KEY_READ, &key); if (status != ERROR_SUCCESS) { char msg[50]; sprintf_s(msg, 50,"Failed to open registry key (status %d)", (int) status); From a95b4238865cc0a43cf6f1b3091c118694dcdd93 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Fri, 22 Nov 2024 17:46:07 +0100 Subject: [PATCH 7/9] remove unnecessary include path --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3c3fe5a..7048ed3 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,7 @@ 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" + -I"C:\Program Files (x86)\Windows Kits\10\Include\$(WIN_SDK_VERSION)\cppwinrt" SOURCES := $(wildcard src/main/native/*.cpp) ######## From 0e9f7d428b04b911fec60cae91b9c359dfcb4311 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Fri, 22 Nov 2024 17:59:07 +0100 Subject: [PATCH 8/9] use github action variable --- .github/workflows/build.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/publish-central.yml | 2 +- .github/workflows/publish-github.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9df3de3..de2ef05 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,7 @@ jobs: run: mvn -B versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/} - name: Build and Test id: buildAndTest - run: mvn clean test -DdevCommandFileDir="C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\" + run: mvn -B clean test -DdevCommandFileDir="${{ vars.MSVC_DEV_FILES_DIR }}" - name: Codesign DLL on release if: startsWith(github.ref, 'refs/tags/') uses: skymatic/code-sign-action@v3 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index c256219..39525fc 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -32,6 +32,6 @@ jobs: with: languages: java - name: Build - run: mvn -B compile -DdevCommandFileDir="C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\" + run: mvn -B compile -DdevCommandFileDir="${{ vars.MSVC_DEV_FILES_DIR }}" - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 \ No newline at end of file diff --git a/.github/workflows/publish-central.yml b/.github/workflows/publish-central.yml index c5c5b85..c8026ed 100644 --- a/.github/workflows/publish-central.yml +++ b/.github/workflows/publish-central.yml @@ -29,7 +29,7 @@ jobs: - name: Enforce project version ${{ github.event.inputs.tag }} run: mvn versions:set -B -DnewVersion="${{ github.event.inputs.tag }}" - name: Deploy - run: mvn deploy -B -DskipTests -Psign,deploy-central --no-transfer-progress -DdevCommandFileDir="C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\" + run: mvn deploy -B -DskipTests -Psign,deploy-central --no-transfer-progress -DdevCommandFileDir="${{ vars.MSVC_DEV_FILES_DIR }}" env: MAVEN_OPTS: > --add-opens=java.base/java.util=ALL-UNNAMED diff --git a/.github/workflows/publish-github.yml b/.github/workflows/publish-github.yml index b71883d..9b46bd6 100644 --- a/.github/workflows/publish-github.yml +++ b/.github/workflows/publish-github.yml @@ -21,7 +21,7 @@ jobs: - name: Enforce project version ${{ github.event.release.tag_name }} run: mvn versions:set -B -DnewVersion="${{ github.event.release.tag_name }}" - name: Deploy - run: mvn deploy -B -DskipTests -Psign,deploy-github --no-transfer-progress -DdevCommandFileDir="C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\" + run: mvn deploy -B -DskipTests -Psign,deploy-github --no-transfer-progress -DdevCommandFileDir="${{ vars.MSVC_DEV_FILES_DIR }}" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }} From e422d36ceaf331651be5d584b8ce474c5f517513 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Fri, 22 Nov 2024 18:01:39 +0100 Subject: [PATCH 9/9] update README [ci skip] --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5bb547b..42ce72b 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ This project uses the following JVM properties: * JDK 22 * Maven * MSVC 2022 toolset (e.g. by installing Visual Studio 2022, Workset "Desktop development with C++") -* make +* Make (`choco install make`) ### Build Open a terminal and run @@ -23,4 +23,4 @@ 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\"`. \ No newline at end of file +If building the dll fails with "cl.exe cannot be found", you have to specify the developer command file directory as a property, e.g. `-DdevCommandFileDir=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\"`. \ No newline at end of file