Skip to content

[Draft] Updating Coinor.cmake to update deprecated method exec_program #148

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Avni2000
Copy link

@Avni2000 Avni2000 commented Apr 11, 2025

Much of the reason this is a draft and not a full PR is because a) I haven't tested it on mac os yet, and b) There are quite a few 'register' warnings when building this way (on Fedora 41), but they seem harmless and the program compiles. Intends to close #145

Summary by CodeRabbit

  • Chores
    • Improved the build configuration process to enhance robustness, ensuring installation commands run in the proper context with better error detection.

Copy link

coderabbitai bot commented Apr 11, 2025

Walkthrough

The pull request updates the CMake configuration in the Coin-OR module by replacing the deprecated exec_program command with execute_process. The changes capture output and error details using OUTPUT_VARIABLE, RESULT_VARIABLE, and ERROR_VARIABLE. In addition, an explicit WORKING_DIRECTORY is set for both configuration and installation commands, and the installation job parameter is modified to -j1 to ensure it is treated as a single argument.

Changes

File(s) Change Summary
libraries.cmake/coinor.cmake Replaced exec_program with execute_process for configuration and installation commands; added explicit WORKING_DIRECTORY and updated parameter usage to capture output, result, and error; changed job specifier from -j 1 to -j1.

Sequence Diagram(s)

sequenceDiagram
    participant Script as coinor.cmake
    participant Exec as execute_process
    participant Shell as Shell/Command

    Script->>Exec: Invoke configuration command with WORKING_DIRECTORY, OUTPUT_VARIABLE, RESULT_VARIABLE, and ERROR_VARIABLE
    Exec->>Shell: Execute configuration command
    Shell-->>Exec: Return output, result, and error
    Exec-->>Script: Deliver configuration result

    Script->>Exec: Invoke installation command with WORKING_DIRECTORY and "-j1" argument
    Exec->>Shell: Execute installation command
    Shell-->>Exec: Return installation status
    Exec-->>Script: Deliver installation status
Loading

Assessment against linked issues

Objective Addressed Explanation
Replace deprecated exec_program usage with execute_process to remove warnings [#145]

Poem

In a garden of scripts under moonlit sky,
I’ve hopped to a new beat—no more exec_program sigh.
With execute_process shining like a guiding star,
My code now dances, near and far.
A hop, a jump, a cheer so grand—
This rabbit rejoices in a robust command!
🐇✨

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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: 1

🧹 Nitpick comments (2)
libraries.cmake/coinor.cmake (2)

182-191: Improved make install command implementation

Good job updating the make install command to use execute_process and specifying the job parameter as "-j1" to ensure it's treated as a single argument.

For consistency with the configure command, consider adding an ERROR_VARIABLE parameter to capture any potential error output from the make process. This would make error handling more robust.

  execute_process(
    COMMAND 
    ${CMAKE_MAKE_PROGRAM}
    install 
    "-j1"
    WORKING_DIRECTORY ${COINOR_DIR} 
      # Explicitly pass as one argument      
    OUTPUT_VARIABLE COINOR_MAKE_OUT
+   ERROR_VARIABLE COINOR_MAKE_ERR
    RESULT_VARIABLE COINOR_MAKE_SUCCESS
    )

If you add this parameter, consider also updating line 198 to include the error output:

- message( FATAL_ERROR ${COINOR_MAKE_OUT})
+ message( FATAL_ERROR ${COINOR_MAKE_OUT} ${COINOR_MAKE_ERR})

175-176: Include error output in configure failure message

For better debugging, consider including the error output in the error message when configuration fails.

- message( FATAL_ERROR ${COINOR_CONFIGURE_OUT})
+ message( FATAL_ERROR ${COINOR_CONFIGURE_OUT} ${COINOR_CONFIGURE_ERR})
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e6fde7c and f71a58f.

📒 Files selected for processing (1)
  • libraries.cmake/coinor.cmake (2 hunks)

Comment on lines +149 to +167
#exec_program -> execute_process
execute_process(
COMMAND
./configure
-C
--prefix=${PROJECT_BINARY_DIR}
${STATIC_BUILD}
${SHARED_BUILD}
--with-lapack=no
--with-blas=no
${COINOR_EXTRA_FLAGS_LIST}
CXX=${CMAKE_CXX_COMPILER}
CC=${CMAKE_C_COMPILER}
WORKING_DIRECTORY ${COINOR_DIR}
OUTPUT_VARIABLE COINOR_CONFIGURE_OUT
RETURN_VALUE COINOR_CONFIGURE_SUCCESS
)
ERROR_VARIABLE COINOR_CONFIGURE_ERR
RESULT_VARIABLE COINOR_CONFIGURE_SUCCESS
)

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Good transition from exec_program to execute_process

The replacement of the deprecated exec_program with execute_process is a positive improvement. You've correctly structured the command with appropriate parameters including WORKING_DIRECTORY, OUTPUT_VARIABLE, ERROR_VARIABLE, and RESULT_VARIABLE.

However, I noticed a potential issue: on line 159, you're using ${COINOR_EXTRA_FLAGS_LIST}, but this variable is defined as COINOR_EXTRA_FLAGS on lines 134/136. This mismatch could prevent the extra flags from being applied correctly.

- ${COINOR_EXTRA_FLAGS_LIST}
+ ${COINOR_EXTRA_FLAGS}
📝 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
#exec_program -> execute_process
execute_process(
COMMAND
./configure
-C
--prefix=${PROJECT_BINARY_DIR}
${STATIC_BUILD}
${SHARED_BUILD}
--with-lapack=no
--with-blas=no
${COINOR_EXTRA_FLAGS_LIST}
CXX=${CMAKE_CXX_COMPILER}
CC=${CMAKE_C_COMPILER}
WORKING_DIRECTORY ${COINOR_DIR}
OUTPUT_VARIABLE COINOR_CONFIGURE_OUT
RETURN_VALUE COINOR_CONFIGURE_SUCCESS
)
ERROR_VARIABLE COINOR_CONFIGURE_ERR
RESULT_VARIABLE COINOR_CONFIGURE_SUCCESS
)
#exec_program -> execute_process
execute_process(
COMMAND
./configure
-C
--prefix=${PROJECT_BINARY_DIR}
${STATIC_BUILD}
${SHARED_BUILD}
--with-lapack=no
--with-blas=no
${COINOR_EXTRA_FLAGS}
CXX=${CMAKE_CXX_COMPILER}
CC=${CMAKE_C_COMPILER}
WORKING_DIRECTORY ${COINOR_DIR}
OUTPUT_VARIABLE COINOR_CONFIGURE_OUT
ERROR_VARIABLE COINOR_CONFIGURE_ERR
RESULT_VARIABLE COINOR_CONFIGURE_SUCCESS
)

@Avni2000 Avni2000 marked this pull request as draft April 11, 2025 20:31
@Avni2000
Copy link
Author

Avni2000 commented Apr 12, 2025

Compiles on MacOS. Unsure why extra flags list is highlighted by code rabbit, doesn't make much of a difference in this scenario as it's just passing a list of arguments it seems like

@Avni2000 Avni2000 marked this pull request as ready for review April 15, 2025 16:43
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.

Brush up CMake script
1 participant