Skip to content

Add License annotation to external functions #4513

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 1 commit into
base: master
Choose a base branch
from

Conversation

beutlich
Copy link
Member

@beutlich beutlich commented Dec 28, 2024

This PR comes along with #4411 (after merging Mo-2900) and makes the license texts of the external functions/objects explicit such that FMU exporting tools no longer need to distribute all files of modelica:/Modelica/Resources/Licenses/ along with the FMU, but only the actually used license texts.

Edit: Dependency on lapack (and the corresponding license texts) still is an exception since it is not seen as MSL dependency, but as tool requirement (see #2849).

Edit 2: Needs to be coordinated with #4240 and #4496.

Summary by CodeRabbit

  • Chores
    • Added explicit license information to external C function annotations across multiple packages, enhancing metadata about third-party and internal library usage.
    • No changes to function signatures, logic, or user-facing behavior; only license references were added for greater transparency regarding external dependencies.

@beutlich beutlich added the requires Modelica 3.7 Issue that requires Modelica Language Specification 3.7 label Dec 28, 2024
@beutlich beutlich changed the title Add license annotation to external functions Add License annotation to external functions Dec 28, 2024
Copy link
Contributor

@HansOlsson HansOlsson left a comment

Choose a reason for hiding this comment

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

LGTM

@beutlich beutlich force-pushed the add-license-information-to-external-functions branch from 75f68ed to 9c05651 Compare January 2, 2025 16:54
@beutlich beutlich force-pushed the add-license-information-to-external-functions branch 2 times, most recently from 25ae486 to 60bb551 Compare January 21, 2025 17:34
@beutlich beutlich force-pushed the add-license-information-to-external-functions branch from 60bb551 to 9b173ad Compare February 12, 2025 19:02
@beutlich beutlich force-pushed the add-license-information-to-external-functions branch from 9b173ad to bc31e7f Compare March 18, 2025 19:32
Make license texts explicit.
@beutlich beutlich force-pushed the add-license-information-to-external-functions branch from bc31e7f to 44ec97a Compare April 22, 2025 04:55
Copy link

coderabbitai bot commented Apr 22, 2025

Walkthrough

This update adds explicit license annotations to all external C function declarations across multiple Modelica packages. The modifications introduce License attributes referencing relevant license files for both internal Modelica code and third-party dependencies. These changes are limited to metadata within function annotations and do not alter function signatures, logic, control flow, or exported/public APIs. The affected areas include table handling, random number generation, file and string utilities, system operations, and obsolete table functions.

Changes

File(s) Change Summary
Modelica/Blocks/Tables.mo,
ObsoleteModelica4.mo
Added explicit License annotations to all external C function declarations for table reading and interpolation functions.
Modelica/Blocks/Types.mo Added License annotations to external function declarations for table object constructors/destructors.
Modelica/Math/FastFourierTransform.mo Added a License annotation to the external C function annotation for the FFT implementation.
Modelica/Math/Random.mo Added License annotations to all external C function declarations for random number generators and related utilities.
Modelica/Utilities/Files.mo Added License annotations to external C function declarations for file path and temporary file utilities.
Modelica/Utilities/Internal.mo Added License annotations to all external C function declarations in the internal file system utilities.
Modelica/Utilities/Streams.mo Added License annotations to all external C function declarations for file and matrix stream operations.
Modelica/Utilities/Strings.mo Added License annotations to all external C function declarations for string operations and advanced scanning functions.
Modelica/Utilities/System.mo Added License annotations to all external C function declarations for system-level operations.

Suggested labels

task

Poem

Oh, what a hop through Modelica's code,
Where licenses now lighten every load!
From tables and streams to strings and files,
Each annotation brings compliant smiles.
With every C call, a license in tow,
This rabbit ensures the right credits show.
🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2d5dea3 and 44ec97a.

📒 Files selected for processing (10)
  • Modelica/Blocks/Tables.mo (25 hunks)
  • Modelica/Blocks/Types.mo (3 hunks)
  • Modelica/Math/FastFourierTransform.mo (1 hunks)
  • Modelica/Math/Random.mo (6 hunks)
  • Modelica/Utilities/Files.mo (2 hunks)
  • Modelica/Utilities/Internal.mo (3 hunks)
  • Modelica/Utilities/Streams.mo (8 hunks)
  • Modelica/Utilities/Strings.mo (9 hunks)
  • Modelica/Utilities/System.mo (6 hunks)
  • ObsoleteModelica4.mo (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: external_c_checks_cmake_windows-msvc
  • GitHub Check: external_c_checks_cmake_windows-cygwin
🔇 Additional comments (40)
Modelica/Math/FastFourierTransform.mo (1)

645-645: Add License annotation for rawRealFFT external binding
The License attribute correctly references the KissFFT license file (LICENSE_ModelicaKissFFT.txt), fulfilling the PR objective to include explicit license metadata for external dependencies.

Modelica/Math/Random.mo (6)

225-225: Add License annotation for Xorshift64star random external binding
The License attribute lists both the KissFFT and stdint MSVC license files, ensuring proper attribution for the C dependencies.


398-398: Add License annotation for Xorshift128plus random external binding
The annotation now includes the correct license files for the external C implementation, matching the pattern used across the library.


575-575: Add License annotation for Xorshift1024star random external binding
The license metadata for KissFFT and stdint MSVC is consistently applied to this external function as well.


938-938: Add License annotation for automaticGlobalSeed external binding
The License entry accurately references the third‑party license files for the C implementation of the global seed generator.


1076-1076: Add License annotation for setInternalState external binding
The License attribute is properly set for the function that initializes the C static state, aligning with PR-wide metadata updates.


1156-1156: Add License annotation for impureRandom external binding
The external C call now includes explicit license references for both KissFFT and stdint MSVC, consistent with other RNG bindings.

Modelica/Blocks/Types.mo (6)

135-135: Add License annotation for ExternalCombiTimeTable constructor
The annotation lists all relevant license files for the ModelicaStandardTables C library and its third‑party dependencies.


142-142: Add License annotation for ExternalCombiTimeTable destructor
Consistent license metadata added to the destructor to mirror the constructor’s licensing.


175-175: Add License annotation for ExternalCombiTable1D constructor
The license list correctly covers the core tables library and its dependencies, matching the style of related packages.


182-182: Add License annotation for ExternalCombiTable1D destructor
The destructor now carries the same set of license references as the constructor.


212-212: Add License annotation for ExternalCombiTable2D constructor
All required license files are explicitly declared for the 2D table external binding.


219-219: Add License annotation for ExternalCombiTable2D destructor
The license metadata is appropriately extended to the 2D table destructor as well.

Modelica/Utilities/Internal.mo (8)

165-165: Add License annotation for mkdir external function
The License attribute now includes ModelicaInternal and its third‑party license files, in line with PR objectives.


171-171: Add License annotation for rmdir external function
Consistent license metadata has been added for the directory‑removal binding.


178-178: Add License annotation for stat external function
The license list covers the core ModelicaInternal license and third‑party components used by stat.


185-185: Add License annotation for rename external function
The annotation now explicitly declares all relevant license files for the rename binding.


191-191: Add License annotation for removeFile external function
License metadata correctly added to the file‑removal external call.


199-199: Add License annotation for copyFile external function
The license list for ModelicaInternal copy operation is now explicit.


211-211: Add License annotation for readDirectory external function
Proper license references are now included for directory‑reading functionality.


220-220: Add License annotation for getNumberOfFiles external function
The external binding for counting files now includes the required license metadata.

Modelica/Utilities/System.mo (6)

9-9: Add License annotation for getWorkDirectory external function
The binding to getcwd now carries explicit information on ModelicaInternal and related third‑party licenses.


19-19: Add License annotation for setWorkDirectory external function
Consistent license metadata has been applied to the chdir binding.


34-34: Add License annotation for getEnvironmentVariable external function
The getenv binding now includes all pertinent license files in its annotation.


46-46: Add License annotation for setEnvironmentVariable external function
License references have been correctly extended to the setenv binding.


62-62: Add License annotation for getTime external function
The annotation now declares ModelicaInternal and third‑party license files for the time‑retrieval binding.


134-134: Add License annotation for getPid external function
The getpid binding is now accompanied by explicit license metadata for all dependencies.

Modelica/Utilities/Files.mo (2)

572-572: License annotation addition looks correct.

The License annotation has been properly added to the fullPathName external C function declaration, referencing all the relevant license files. This change aligns with the PR objective to explicitly specify license texts for external functions and objects.


661-661: License annotation addition looks correct.

The License annotation has been properly added to the temporaryFileName external C function declaration, referencing all the relevant license files. This change aligns with the PR objective to explicitly specify license texts for external functions and objects.

Modelica/Blocks/Tables.mo (1)

1038-1329: All license annotations have been correctly added to external C functions.

The License annotations have been systematically added to all 25 external C function declarations in the Internal package. Each annotation consistently references the same set of relevant license files for the ModelicaStandardTables library and its dependencies. This implementation aligns perfectly with the PR objective to explicitly specify license texts for external functions and objects within the Modelica Standard Library.

ObsoleteModelica4.mo (1)

220-223: Add explicit license annotation for readTimeTableData.
The License attribute now lists all relevant licence files for ModelicaStandardTables, ModelicaIO, ModelicaMatIO, zlib, and the included third‑party snippets. This meets the objective of including only the licences actually used by external functions.

Modelica/Utilities/Strings.mo (1)

9-9: Add explicit license annotation to length.
The external binding now references LICENSE_ModelicaStrings.txt and the required third‑party licences (uthash, stdint_msvc, APHashFunction).

Modelica/Utilities/Streams.mo (8)

9-9: License annotation added for ModelicaInternal_print.
The License attribute now explicitly lists the internal (LICENSE_ModelicaInternal.txt) and third‑party dependencies (uthash, stdint_msvc, win32_dirent). This matches the PR objective to include only used license texts.


47-47: License annotation added for ModelicaInternal_readFile.
The License attribute correctly covers LICENSE_ModelicaInternal.txt and the relevant third‑party libraries. Good alignment with FMU export requirements.


69-69: License annotation added for ModelicaInternal_readLine.
Explicitly listing the internal and third‑party license files (uthash, stdint_msvc, win32_dirent) ensures only required texts are packaged.


94-94: License annotation added for ModelicaInternal_countLines.
The new License list matches the other Internal functions in this package and covers all dependencies.


143-143: License annotation added for ModelicaStreams_closeFile.
Consistent with the other Streams functions, the License attribute now details all relevant internal and third‑party licenses.


162-162: License annotation added for ModelicaIO_readMatrixSizes.
The annotation includes LICENSE_ModelicaIO.txt, LICENSE_ModelicaMatIO.txt, and third‑party licenses (zlib, stdint_msvc, portable-snippets, c99-snprintf), covering all code paths.


199-199: License annotation added for ModelicaIO_readRealMatrix.
The set of license files mirrors readMatrixSizes, ensuring the FMU export only bundles necessary license texts for ModelicaIO and its dependencies.


241-241: License annotation added for ModelicaIO_writeRealMatrix.
Consistent with other IO functions, the License attribute enumerates internal and third‑party license files. This completes the metadata enhancement for all external C interfaces.


🪧 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 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
requires Modelica 3.7 Issue that requires Modelica Language Specification 3.7
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants