Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Use Microsoft C++ (MSVC) compiler for building and add VS support #87

Merged
merged 9 commits into from
Nov 22, 2024

Conversation

infeo
Copy link
Member

@infeo infeo commented Nov 22, 2024

This PR changes the compiler from the GNU C++ (g++) to the Microsoft C++ compiler (cl.exe). Additionally, files for Visual Studio are added for IDE support.

Since we are on Windows anyway, we ca benefit from Windows specific optimizations/flags. Additionally, we don't have to address mingw specific quirks and can replace this dependency. The VS solution file gives proper c/c++ support to improve the developer experience.

@infeo infeo self-assigned this Nov 22, 2024
Copy link

coderabbitai bot commented Nov 22, 2024

Walkthrough

The pull request introduces several modifications across various files to transition the project to a Windows-centric build environment, primarily using Microsoft tools. The .github/workflows/build.yml file is updated to include a new parameter in the Maven build command, specifying a directory for development command files. The .gitignore file is expanded to exclude Visual Studio-specific files and directories. The Makefile is altered to replace the g++ compiler with the Microsoft C++ compiler cl, including updates to paths and linking settings. A new Visual Studio solution file (integrations-win.sln) and project file (integrations-win.vcxproj) are added to facilitate the project setup in Visual Studio, supporting both x64 and Win32 architectures. The pom.xml file is modified to reflect the new build process, including a new property for the development command file directory. Additionally, the WinAppearance_Native.cpp file is updated for Unicode support and safer string handling. Workflow files for CodeQL analysis, publishing to GitHub Packages, and deployment are also modified to incorporate the new parameter related to the development command file directory.

Possibly related PRs

Warning

Rate limit exceeded

@infeo has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 8 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 0e9f7d4 and e422d36.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 13

🧹 Outside diff range and nitpick comments (10)
README.md (2)

13-19: Consider enhancing the requirements section

The requirements are generally clear, but could benefit from some improvements:

  1. Specify the minimum MSVC version required
  2. Clarify why make is needed on Windows

Consider this enhancement:

 ### Requirements

 * JDK 22
 * Maven
-* MSVC 2022 toolset (e.g. by installing Visual Studio 2022, Workset "Desktop development with C++")
-* make
+* MSVC 2022 toolset (v143) or newer
+  * Install through Visual Studio 2022 with "Desktop development with C++" workload
+* GNU Make (required for build automation)
+  * Can be installed via chocolatey, scoop, or msys2

20-26: Enhance build instructions for Windows users

The build instructions could be more Windows-specific and clearer:

  1. Missing language specification in code block
  2. The Visual Studio path could vary based on edition

Consider these enhancements:

 ### Build
 Open a terminal and run
-```
+```bash
 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\".
+If building the DLLs fails with "cl.exe cannot be found", specify the Visual Studio developer command file directory:
+
+bash +# For VS2022 Enterprise edition +mvn clean verify -DdevCommandFileDir="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build" + +# For VS2022 Community edition +mvn clean verify -DdevCommandFileDir="C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build" +


<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 LanguageTool</summary>

[grammar] ~20-~20: Please check the verb form.
Context: ...evelopment with C++") * make  ### Build Open a terminal and run ``` mvn clean verify...

(SHE_LIVE)

</details>
<details>
<summary>🪛 Markdownlint (0.35.0)</summary>

22-22: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

</details>

</details>

</blockquote></details>
<details>
<summary>src/main/native/org_cryptomator_windows_uiappearnce_WinAppearance_Native.cpp (2)</summary><blockquote>

`23-23`: **Improve error message buffer handling**

While using `sprintf_s` is safer, the current implementation has room for improvement:
1. The buffer size is hardcoded
2. The size might be insufficient for complex error messages
3. The magic number "50" is repeated

Consider this improvement:

```diff
+ #define ERROR_MSG_BUFFER_SIZE 128
+ 
  // In each error handling block:
- char msg[50];
- sprintf_s(msg, 50, "Failed to read registry value (status %d)", (int) status);
+ char msg[ERROR_MSG_BUFFER_SIZE];
+ sprintf_s(msg, ERROR_MSG_BUFFER_SIZE, "Failed to read registry value (status %d)", (int) status);

Also applies to: 34-34, 40-40


Line range hint 1-44: Consider centralizing Windows registry paths

Since this codebase is becoming more Windows-centric, consider creating a central configuration file or constants for Windows-specific paths and settings. This would make maintenance easier and prevent issues like the registry path syntax errors.

Example approach:

// windows_config.h
#define THEME_REGISTRY_KEY L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"
#define THEME_REGISTRY_VALUE L"AppsUseLightTheme"
src/main/native/org_cryptomator_windows_keychain_WinDataProtection_Native.cpp (4)

4-4: Consider removing redundant header inclusion

The dpapi.h header is already included implicitly through wincrypt.h. While not harmful, removing redundant includes helps maintain cleaner code.

-#include <dpapi.h>

Line range hint 7-24: Add error handling and prevent memory leaks

Several critical issues need to be addressed:

  1. Memory leak: CryptProtectData allocates memory for ciphertextBlob that needs to be freed using LocalFree
  2. No error information is captured when encryption fails
  3. Missing input validation

Here's the suggested fix:

 JNIEXPORT jbyteArray JNICALL Java_org_cryptomator_windows_keychain_WinDataProtection_00024Native_protect(JNIEnv *env, jobject thisObj, jbyteArray cleartext, jbyteArray salt) {
+  if (!cleartext || !salt) {
+    return NULL;
+  }
+
   DATA_BLOB cleartextBlob;
   cleartextBlob.pbData = (BYTE *) env->GetByteArrayElements(cleartext, JNI_FALSE);
   cleartextBlob.cbData = (DWORD) env->GetArrayLength(cleartext);
   DATA_BLOB saltBlob;
   saltBlob.pbData = (BYTE *) env->GetByteArrayElements(salt, JNI_FALSE);
   saltBlob.cbData = (DWORD) env->GetArrayLength(salt);

   DATA_BLOB ciphertextBlob;
   BOOL success = CryptProtectData(&cleartextBlob, NULL, &saltBlob, NULL, NULL, 0, &ciphertextBlob);

   env->ReleaseByteArrayElements(cleartext, (jbyte*) cleartextBlob.pbData, JNI_ABORT);
   env->ReleaseByteArrayElements(salt, (jbyte*) saltBlob.pbData, JNI_ABORT);

+  jbyteArray result = NULL;
   if (success) {
-    jbyteArray ciphertext = env->NewByteArray(ciphertextBlob.cbData);
-    env->SetByteArrayRegion(ciphertext, 0, ciphertextBlob.cbData, (jbyte *) ciphertextBlob.pbData);
-    return ciphertext;
+    result = env->NewByteArray(ciphertextBlob.cbData);
+    if (result) {
+      env->SetByteArrayRegion(result, 0, ciphertextBlob.cbData, (jbyte *) ciphertextBlob.pbData);
+    }
+    LocalFree(ciphertextBlob.pbData);
   } else {
-    return NULL;
+    // Log error for debugging
+    DWORD error = GetLastError();
+    // Consider throwing a Java exception here with the error code
   }
+  return result;
 }

Line range hint 26-45: Add error handling and prevent memory leaks in unprotect function

The unprotect function has the same critical issues as the protect function:

  1. Memory leak: CryptUnprotectData allocates memory that needs to be freed
  2. No error information is captured
  3. Missing input validation

Apply similar fixes as protect function:

 JNIEXPORT jbyteArray JNICALL Java_org_cryptomator_windows_keychain_WinDataProtection_00024Native_unprotect(JNIEnv *env, jobject thisObj, jbyteArray ciphertext, jbyteArray salt) {
+  if (!ciphertext || !salt) {
+    return NULL;
+  }
+
   DATA_BLOB ciphertextBlob;
   ciphertextBlob.pbData = (BYTE *) env->GetByteArrayElements(ciphertext, JNI_FALSE);
   ciphertextBlob.cbData = (DWORD) env->GetArrayLength(ciphertext);
   DATA_BLOB saltBlob;
   saltBlob.pbData = (BYTE *) env->GetByteArrayElements(salt, JNI_FALSE);
   saltBlob.cbData = (DWORD) env->GetArrayLength(salt);

   DATA_BLOB cleartextBlob;
   BOOL success = CryptUnprotectData(&ciphertextBlob, NULL, &saltBlob, NULL, NULL, 0, &cleartextBlob);

   env->ReleaseByteArrayElements(ciphertext, (jbyte*) ciphertextBlob.pbData, JNI_ABORT);
   env->ReleaseByteArrayElements(salt, (jbyte*) saltBlob.pbData, JNI_ABORT);

+  jbyteArray result = NULL;
   if (success) {
-    jbyteArray cleartext = env->NewByteArray(cleartextBlob.cbData);
-    env->SetByteArrayRegion(cleartext, 0, cleartextBlob.cbData, (jbyte *) cleartextBlob.pbData);
-    return cleartext;
+    result = env->NewByteArray(cleartextBlob.cbData);
+    if (result) {
+      env->SetByteArrayRegion(result, 0, cleartextBlob.cbData, (jbyte *) cleartextBlob.pbData);
+    }
+    LocalFree(cleartextBlob.pbData);
   } else {
-    return NULL;
+    // Log error for debugging
+    DWORD error = GetLastError();
+    // Consider throwing a Java exception here with the error code
   }
+  return result;
 }

Line range hint 7-45: Improve error handling architecture

The current error handling approach of returning NULL doesn't provide enough information to the Java side about what went wrong. Consider implementing a more robust error handling strategy:

  1. Create specific Java exceptions for different error cases (e.g., InvalidInputException, EncryptionFailedException)
  2. Use JNI's exception throwing capabilities to provide detailed error information

Here's a suggested approach for implementing exception handling:

// Helper function to throw Java exceptions
void ThrowException(JNIEnv* env, const char* exceptionClass, DWORD errorCode) {
    char errorMsg[256];
    FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, errorCode,
                   0, errorMsg, sizeof(errorMsg), NULL);
    jclass cls = env->FindClass(exceptionClass);
    if (cls != NULL) {
        env->ThrowNew(cls, errorMsg);
    }
}

Usage in the protect/unprotect functions:

if (!success) {
    DWORD error = GetLastError();
    switch (error) {
        case ERROR_INVALID_PARAMETER:
            ThrowException(env, "java/lang/IllegalArgumentException", error);
            break;
        default:
            ThrowException(env, "org/cryptomator/windows/keychain/CryptoException", error);
    }
}
integrations-win.vcxproj (1)

26-26: Consider using a more flexible SDK version specification

The hard-coded Windows SDK version (10.0.22621.0) might cause build issues if developers have different SDK versions installed.

Consider using 10.0 instead to automatically use the latest installed SDK version:

-    <WindowsTargetPlatformVersion>10.0.22621.0</WindowsTargetPlatformVersion>
+    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
pom.xml (1)

Line range hint 1-577: Consider documenting Windows build requirements

Given the transition to MSVC, it's important to document the build requirements and setup process for developers. This should include:

  1. Required Visual Studio components (C++ build tools, Windows SDK)
  2. Environment setup instructions
  3. Common troubleshooting steps

Additionally, consider:

  1. Adding CI checks to verify MSVC toolchain availability
  2. Creating a build verification script
  3. Documenting any platform-specific optimizations enabled by MSVC

Would you like me to help create:

  1. A detailed README section about build requirements?
  2. CI checks for the MSVC toolchain?
  3. A build verification script?
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2d026d6 and 9ce8d07.

📒 Files selected for processing (9)
  • .github/workflows/build.yml (1 hunks)
  • .gitignore (1 hunks)
  • Makefile (1 hunks)
  • README.md (1 hunks)
  • integrations-win.sln (1 hunks)
  • integrations-win.vcxproj (1 hunks)
  • pom.xml (2 hunks)
  • src/main/native/org_cryptomator_windows_keychain_WinDataProtection_Native.cpp (1 hunks)
  • src/main/native/org_cryptomator_windows_uiappearnce_WinAppearance_Native.cpp (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • .gitignore
  • integrations-win.sln
🧰 Additional context used
🪛 LanguageTool
README.md

[grammar] ~20-~20: Please check the verb form.
Context: ...evelopment with C++") * make ### Build Open a terminal and run ``` mvn clean verify...

(SHE_LIVE)

🪛 Markdownlint (0.35.0)
README.md

22-22: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🔇 Additional comments (2)
README.md (1)

Line range hint 1-26: Verify references to build configurations

Let's ensure there are no outdated references to MinGW or g++ in other documentation files.

✅ Verification successful

Build configuration references are consistent with MSVC toolchain

The documentation is clean and properly aligned with the MSVC toolchain requirements. There are no outdated references to MinGW or g++, and the only build-related content is in README.md which correctly specifies MSVC 2022 as the required toolset. The build instructions are clear and up-to-date with the current toolchain choice.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any references to MinGW or g++ in documentation files
rg -i "mingw|g\+\+" -g "*.{md,txt,rst}"

Length of output: 41


Script:

#!/bin/bash
# Let's do a more comprehensive search for build-related configurations and documentation
# 1. Find all documentation files first
fd -e md -e txt -e rst

# 2. Look for any build-related content in these files
rg -i "build|compile|toolchain|gcc|visual studio|msvc" -g "*.{md,txt,rst}"

Length of output: 505

🧰 Tools
🪛 LanguageTool

[grammar] ~20-~20: Please check the verb form.
Context: ...evelopment with C++") * make ### Build Open a terminal and run ``` mvn clean verify...

(SHE_LIVE)

🪛 Markdownlint (0.35.0)

22-22: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

pom.xml (1)

314-321: 🛠️ Refactor suggestion

Verify the build command execution

The build configuration has been updated to use Windows command prompt and Visual Studio build tools. However, there are a few concerns:

  1. The command concatenation using && might fail in certain Windows environments
  2. The success/failure of vcvars64.bat might not be properly propagated

Let's verify the build tools setup:

Consider using a dedicated batch script for more robust execution:

-										<argument>"${devCommandFileDir}\vcvars64.bat" && make install</argument>
+										<argument>${project.basedir}/build.bat</argument>

Create build.bat:

@echo off
call "%1\vcvars64.bat"
if errorlevel 1 exit /b %errorlevel%
make install
✅ Verification successful

Let me gather more information about the build configuration and existing build scripts.


Let me check the contents of the Makefile and README for any build-related information.


Command concatenation with && is safe in this Windows build setup

The current build configuration is appropriate for the following reasons:

  • The README explicitly documents the requirement for Visual Studio 2022 and the vcvars64.bat path setup
  • The Makefile shows proper usage of MSVC compiler (cl.exe) with correct Windows-specific flags and paths
  • The command concatenation using && is a standard Windows command prompt operator that correctly propagates errors
  • The vcvars64.bat setup is required before running make install as the Makefile depends on MSVC environment variables

The build will fail appropriately if:

  • vcvars64.bat fails to execute (non-zero exit code prevents make install from running)
  • make install fails during DLL compilation
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the Visual Studio build tools path exists in common locations
fd -t d "VC" "C:/Program Files/Microsoft Visual Studio" "C:/Program Files (x86)/Microsoft Visual Studio"

# Check if make is available in the repository
fd -t f "^make(\.exe)?$"

# Look for any existing build or compile scripts
rg -g "!target/" -g "!*.class" -g "!*.jar" "vcvars|cl\.exe|compile|build" 

Length of output: 2451


Script:

#!/bin/bash
# Check for any existing batch files that might handle build setup
fd -e bat -e cmd

# Look for Makefile to understand the build requirements
fd Makefile

# Check for any error handling or build setup in pom.xml
rg -A 5 -B 5 "vcvars64\.bat" pom.xml

Length of output: 439


Script:

#!/bin/bash
# Check Makefile contents for build requirements and error handling
cat Makefile

# Check README for build instructions and requirements
rg -A 5 "build|compile|install" README.md

Length of output: 1291

.github/workflows/build.yml Outdated Show resolved Hide resolved
integrations-win.vcxproj Show resolved Hide resolved
integrations-win.vcxproj Outdated Show resolved Hide resolved
integrations-win.vcxproj Outdated Show resolved Hide resolved
pom.xml Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated
Comment on lines 4 to 8
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"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Replace hardcoded include paths with environment variables

Using hardcoded paths for the Windows SDK and MSVC include directories reduces portability and can cause build failures on systems where these tools are installed in different locations.

Modify the Makefile to use environment variables provided by Visual Studio's environment setup script (vcvarsall.bat). Here's how you might adjust the HEADERS variable:

-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"$(WindowsSdkDir)\Include\$(UCRTVersion)\um" \
+	-I"$(VCToolsInstallDir)\include"

This change leverages environment variables set by Visual Studio's build tools:

  • WindowsSdkDir and UCRTVersion point to the Windows SDK directories.
  • VCToolsInstallDir points to the MSVC installation directory.

Before running make, ensure that the environment is properly set up by executing the vcvarsall.bat script corresponding to your target architecture (e.g., vcvarsall.bat x64).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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"$(WindowsSdkDir)\Include\$(UCRTVersion)\um" \
-I"$(VCToolsInstallDir)\include"

Makefile Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
.github/workflows/codeql-analysis.yml (1)

35-35: Consider using environment variables for Visual Studio paths

The hardcoded Visual Studio path makes the workflow brittle to changes in VS installation paths or editions. Consider using environment variables or GitHub Actions environment files for better maintainability.

-      run: mvn -B compile -DdevCommandFileDir="C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\"
+      env:
+        VS2022_PATH: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise"
+      run: mvn -B compile -DdevCommandFileDir="${VS2022_PATH}\\VC\\Auxiliary\\Build\\"

This approach:

  • Makes it easier to update paths across all workflow files
  • Improves readability and maintenance
  • Allows for easier testing with different VS editions
.github/workflows/publish-github.yml (1)

24-24: Consider making the Visual Studio path configurable.

While the change correctly specifies the Visual Studio build tools directory, consider making this path configurable through GitHub Actions variables or environment variables. This would improve maintainability and flexibility when Visual Studio versions or editions change.

Example improvement:

-        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.VS_BUILD_TOOLS_PATH || 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\' }}"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9ce8d07 and c4705ce.

📒 Files selected for processing (4)
  • .github/workflows/codeql-analysis.yml (1 hunks)
  • .github/workflows/publish-central.yml (1 hunks)
  • .github/workflows/publish-github.yml (1 hunks)
  • integrations-win.vcxproj (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • integrations-win.vcxproj
🔇 Additional comments (1)
.github/workflows/publish-github.yml (1)

24-24: Verify Visual Studio build tools path in the GitHub-hosted runner.

Let's verify that the specified Visual Studio path exists in the GitHub-hosted Windows runner.

✅ Verification successful

Visual Studio path in workflow is correct and matches GitHub runner environment

The specified path C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\ is correct as it aligns with the Visual Studio Enterprise 2022 installation path (C:\Program Files\Microsoft Visual Studio\2022\Enterprise) documented in the GitHub-hosted Windows 2022 runner specifications. The VC\Auxiliary\Build subdirectory is a standard location for Visual Studio build tools.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the Visual Studio build tools directory exists in recent workflow runs

# Get recent workflow runs and check their logs for the directory
gh run list --workflow=publish-github.yml --json databaseId --jq '.[0].databaseId' | \
xargs -I {} gh run view {} --log | \
grep -A 5 "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\"

# Additionally, check recent runner images changelog for any Visual Studio path changes
curl -s https://raw.githubusercontent.com/actions/runner-images/main/images/win/Windows2022-Changelog.md | \
grep -A 5 "Visual Studio Enterprise 2022"

Length of output: 557


Script:

#!/bin/bash
# Let's try a different approach to check Visual Studio installation on Windows runners
# First, let's check the workflow runs without complex path patterns
gh run list --workflow=publish-github.yml --json databaseId --jq '.[0].databaseId' | \
xargs -I {} gh run view {} --log | \
grep -i "visual studio"

# Also check if there are any environment variables or alternative paths being used
rg -i "visual studio" .github/workflows/

Length of output: 1145


Script:

#!/bin/bash
# Let's check the GitHub Actions documentation for Windows runner specifications
curl -s https://raw.githubusercontent.com/actions/runner-images/main/images/windows/Windows2022-Readme.md | \
grep -A 10 "Visual Studio Enterprise 2022"

# Also check if there are any related issues or discussions about this path
gh issue list --repo actions/runner-images --search "visual studio 2022 enterprise path" --json title,body --jq '.[]'

Length of output: 1450

.github/workflows/codeql-analysis.yml Outdated Show resolved Hide resolved
.github/workflows/publish-central.yml Outdated Show resolved Hide resolved
@infeo infeo changed the title Feature: Use Microsoft C++ (MSVC) for building Feature: Use Microsoft C++ (MSVC) compiler for building and add VS support Nov 22, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
Makefile (2)

4-8: Ensure consistent path separator usage

The HEADERS variable mixes backslashes and forward slashes. While both work on Windows, it's better to stick to one style for consistency.

 HEADERS := -I"src\main\headers" \
-	-I"${JAVA_HOME}\include" \
-	-I"${JAVA_HOME}\include\win32" \
+	-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"

18-18: Ensure target directory exists

The -Fo"target/" flag specifies output directory but doesn't ensure it exists. Consider adding directory creation.

 install:
+	if not exist "target" mkdir "target"
 	cl -EHsc -std:c++17 -LD -W4 -guard:cf \
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c4705ce and b211ede.

📒 Files selected for processing (1)
  • Makefile (1 hunks)
🔇 Additional comments (1)
Makefile (1)

16-22: Verify Control Flow Guard (CFG) configuration

The -guard:cf flag enables Control Flow Guard, but it requires proper configuration in both compiler and linker flags to be fully effective.

Makefile Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (1)
README.md (1)

13-19: Requirements section needs version specifications

While the requirements are clearly listed, specific version information would be helpful for reproducible builds:

  • MSVC 2022 version number (e.g., 17.7.x)
  • Minimum Make version

Consider adding version information:

 ### Requirements

 * JDK 22
 * Maven
-* MSVC 2022 toolset (e.g. by installing Visual Studio 2022, Workset "Desktop development with C++")
-* Make (`choco install make`)
+* MSVC 2022 toolset v17.7 or later (Install via Visual Studio 2022, Workload "Desktop development with C++")
+* Make 4.0 or later (`choco install make`)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0e9f7d4 and e422d36.

📒 Files selected for processing (1)
  • README.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md

[grammar] ~20-~20: Please check the verb form.
Context: ... Make (choco install make) ### Build Open a terminal and run ``` mvn clean verify...

(SHE_LIVE)

🪛 Markdownlint (0.35.0)
README.md

22-22: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
@infeo infeo merged commit efdb137 into develop Nov 22, 2024
2 checks passed
@infeo infeo deleted the feature/use-msvc branch November 22, 2024 17:06
@coderabbitai coderabbitai bot mentioned this pull request Nov 25, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant