Skip to content

Commit

Permalink
Merge branch 'master' into Hysteresis37
Browse files Browse the repository at this point in the history
  • Loading branch information
christiankral authored Sep 18, 2024
2 parents 01cebbc + 35ad28d commit 0c6b7f6
Show file tree
Hide file tree
Showing 273 changed files with 26,112 additions and 13,945 deletions.
26 changes: 23 additions & 3 deletions .CI/Test/Common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,37 @@
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

char* ModelicaAllocateString(size_t len) {
void *data = malloc(len + 1); /* Never free'd in the test programs */
assert(data);
if (NULL == data) {
ModelicaError("Failed to allocate string");
}
return data;
}

char* ModelicaAllocateStringWithErrorReturn(size_t len) {
return malloc(len + 1); /* Never free'd in the test programs */
}

char* ModelicaDuplicateString(const char* str) {
void *data = malloc(strlen(str) + 1); /* Never free'd in the test programs */
if (NULL == data) {
ModelicaError("Failed to duplicate string");
}
strcpy(data, str);
return data;
}

char* ModelicaDuplicateStringWithErrorReturn(const char* str) {
void *data = malloc(strlen(str) + 1); /* Never free'd in the test programs */
if (NULL != data) {
strcpy(data, str);
}
return data;
}

void ModelicaMessage(const char *string) {
printf("%s\n", string);
}
Expand All @@ -24,7 +44,7 @@ void ModelicaWarning(const char *string) {
void ModelicaError(const char *string) {
fputs(string, stderr);
fputc('\n', stderr);
assert(0);
abort();
}

void ModelicaFormatMessage(const char *string, ...) {
Expand Down Expand Up @@ -58,5 +78,5 @@ void ModelicaVFormatWarning(const char *string, va_list args) {

void ModelicaVFormatError(const char *string, va_list args) {
vfprintf(stderr, string, args);
assert(0);
abort();
}
50 changes: 32 additions & 18 deletions .CI/Test/ModelicaUtilities.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ModelicaUtilities.h - External utility functions header
Copyright (C) 2010-2020, Modelica Association and contributors
Copyright (C) 2010-2024, Modelica Association and contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -31,14 +31,11 @@

/* Utility functions which can be called by external Modelica functions.
These functions are defined in section 12.8.6 of the
Modelica Specification 3.0 and section 12.9.6 of the
Modelica Specification 3.1 and later.
These functions are defined in section 12.9.6 of the Modelica Specification 3.6.
A generic C-implementation of these functions cannot be given,
because it is tool dependent how strings are output in a
window of the respective simulation tool. Therefore, only
this header file is shipped with the Modelica Standard Library.
console or window of the respective simulation tool.
*/

#ifndef MODELICA_UTILITIES_H
Expand Down Expand Up @@ -131,19 +128,16 @@ void ModelicaMessage(const char *string);
Output the message string (no format control).
*/


void ModelicaFormatMessage(const char *string, ...) MODELICA_FORMATATTR_PRINTF;
void ModelicaFormatMessage(const char *format, ...) MODELICA_FORMATATTR_PRINTF;
/*
Output the message under the same format control as the C-function printf.
*/


void ModelicaVFormatMessage(const char *string, va_list args) MODELICA_FORMATATTR_VPRINTF;
void ModelicaVFormatMessage(const char *format, va_list args) MODELICA_FORMATATTR_VPRINTF;
/*
Output the message under the same format control as the C-function vprintf.
*/


MODELICA_NORETURN void ModelicaError(const char *string) MODELICA_NORETURNATTR;
/*
Output the error message string (no format control). This function
Expand All @@ -156,32 +150,30 @@ void ModelicaWarning(const char *string);
Output the warning message string (no format control).
*/

void ModelicaFormatWarning(const char *string, ...) MODELICA_FORMATATTR_PRINTF;
void ModelicaFormatWarning(const char *format, ...) MODELICA_FORMATATTR_PRINTF;
/*
Output the warning message under the same format control as the C-function printf.
*/

void ModelicaVFormatWarning(const char *string, va_list args) MODELICA_FORMATATTR_VPRINTF;
void ModelicaVFormatWarning(const char *format, va_list args) MODELICA_FORMATATTR_VPRINTF;
/*
Output the warning message under the same format control as the C-function vprintf.
*/

MODELICA_NORETURN void ModelicaFormatError(const char *string, ...) MODELICA_NORETURNATTR MODELICA_FORMATATTR_PRINTF;
MODELICA_NORETURN void ModelicaFormatError(const char *format, ...) MODELICA_NORETURNATTR MODELICA_FORMATATTR_PRINTF;
/*
Output the error message under the same format control as the C-function
printf. This function never returns to the calling function,
but handles the error similarly to an assert in the Modelica code.
*/


MODELICA_NORETURN void ModelicaVFormatError(const char *string, va_list args) MODELICA_NORETURNATTR MODELICA_FORMATATTR_VPRINTF;
MODELICA_NORETURN void ModelicaVFormatError(const char *format, va_list args) MODELICA_NORETURNATTR MODELICA_FORMATATTR_VPRINTF;
/*
Output the error message under the same format control as the C-function
vprintf. This function never returns to the calling function,
but handles the error similarly to an assert in the Modelica code.
*/


char* ModelicaAllocateString(size_t len);
/*
Allocate memory for a Modelica string which is used as return
Expand All @@ -191,7 +183,6 @@ calling program, as for any other array. If an error occurs, this
function does not return, but calls "ModelicaError".
*/


char* ModelicaAllocateStringWithErrorReturn(size_t len);
/*
Same as ModelicaAllocateString, except that in case of error, the
Expand All @@ -201,6 +192,29 @@ resources use ModelicaError or ModelicaFormatError to signal
the error.
*/

char* ModelicaDuplicateString(const char* str);
/*
Duplicate (= allocate memory and deep copy) a Modelica string which
is used as return argument of an external Modelica function. Note,
that the storage for string arrays (= pointer to string array) is still
provided by the calling program, as for any other array. If an error
occurs, this function does not return, but calls "ModelicaError".
*/

char* ModelicaDuplicateStringWithErrorReturn(const char* str);
/*
Same as ModelicaDuplicateString, except that in case of error, the
function returns 0. This allows the external function to close files
and free other open resources in case of error. After cleaning up
resources use, ModelicaError or ModelicaFormatError to signal
the error.
*/

#undef MODELICA_NORETURN
#undef MODELICA_NORETURNATTR
#undef MODELICA_FORMATATTR_PRINTF
#undef MODELICA_FORMATATTR_VPRINTF

#if defined(__cplusplus)
}
#endif
Expand Down
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Explicitly declare text files we want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.cmake text
*.csv text
*.h text
*.htm* text
Expand Down Expand Up @@ -46,3 +47,5 @@ Modelica/Resources/Images/Magnetic/FluxTubes/Shapes/HollowCylinder.vsdx export-i
Modelica/Resources/Images/Magnetic/FluxTubes/Shapes/Toroid.vsdx export-ignore
Modelica/Resources/Reference export-ignore
ModelicaTest/Resources/Reference export-ignore

*.mo linguist-language=Modelica
130 changes: 121 additions & 9 deletions .github/workflows/checkCI.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
name: CI

on: [pull_request]
on:
push:
pull_request:
workflow_dispatch:

defaults:
run:
shell: bash

jobs:
external_c_checks:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 5
- name: Build libraries
- name: Configure
run: |
rm -rf Modelica/Resources/Library/*
mkdir -p Modelica/Resources/Library/$LIBDIR
pushd Modelica/Resources/BuildProjects/autotools
git clean -fdx .
./autogen.sh
./configure --libdir="$PWD/../../Library/$LIBDIR" --enable-static --disable-shared --enable-static-zlib --disable-hdf5 CPPFLAGS="-I${GITHUB_WORKSPACE}/.CI/Test"
popd
env:
LIBDIR: linux64
- name: Build
run: |
pushd Modelica/Resources/BuildProjects/autotools
make --output-sync
sudo make install
popd
Expand All @@ -30,15 +44,109 @@ jobs:
env:
LIBDIR: linux64
CC: gcc

external_c_checks_cmake:
name: external_c_checks_cmake_${{ matrix.toolchain }}
runs-on: ${{ matrix.os }}
timeout-minutes: 5
strategy:
matrix:
toolchain:
- linux-gcc
- macos-clang
- windows-msvc
- windows-mingw
configuration:
- Debug
include:
- toolchain: linux-gcc
os: ubuntu-latest
compiler: gcc
- toolchain: macos-clang
os: macos-latest
compiler: clang
- toolchain: windows-msvc
os: windows-latest
compiler: msvc
- toolchain: windows-mingw
os: windows-latest
compiler: mingw
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 5
- name: Configure
run: |
if [ "${{ matrix.compiler }}" == "msvc" ]; then
cmake -S "$SRCDIR" -B build -DMODELICA_UTILITIES_INCLUDE_DIR="$TESTDIR" -DMODELICA_DEBUG_TIME_EVENTS=ON
elif [ "${{ matrix.compiler }}" == "mingw" ]; then
cmake -S "$SRCDIR" -B build -DMODELICA_UTILITIES_INCLUDE_DIR="$TESTDIR" -DMODELICA_DEBUG_TIME_EVENTS=ON -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -G "MinGW Makefiles"
else
cmake -S "$SRCDIR" -B build -DMODELICA_UTILITIES_INCLUDE_DIR="$TESTDIR" -DMODELICA_DEBUG_TIME_EVENTS=ON -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DCMAKE_C_FLAGS="-std=c89 -Wall -Wextra"
fi
env:
SRCDIR: ${{ github.workspace }}/Modelica/Resources
TESTDIR: ${{ github.workspace }}/.CI/Test
- name: Build with ${{ matrix.compiler }}
run: |
if [ "${{ matrix.compiler }}" == "msvc" ]; then
cmake --build build --config ${{ matrix.configuration }}
else
cmake --build build -- -j8
fi
- name: Run tests
run: ctest --test-dir build --build-config ${{ matrix.configuration }} --verbose

external_c_checks_cmake_cygwin:
name: external_c_checks_cmake_windows-cygwin
runs-on: windows-latest
timeout-minutes: 5
steps:
- name: Set git to use LF
run: git config --global core.autocrlf input
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 5
- name: Setup cygwin
uses: cygwin/cygwin-install-action@master
with:
packages: >-
cmake
gcc-core
make
ninja
- name: Configure
run: |
export PATH=/usr/bin:$PATH
cmake -S "$(cygpath ${SRCDIR})" -B build -DMODELICA_UTILITIES_INCLUDE_DIR="$(cygpath ${TESTDIR})" -DMODELICA_DEBUG_TIME_EVENTS=ON -DCMAKE_BUILD_TYPE=Debug -G Ninja
shell: C:\cygwin\bin\bash.exe -eo pipefail -o igncr '{0}'
env:
CYGWIN_NOWINPATH: 1
SRCDIR: ${{ github.workspace }}/Modelica/Resources
TESTDIR: ${{ github.workspace }}/.CI/Test
- name: Build with gcc
run: |
export PATH=/usr/bin:$PATH
cmake --build build -- -j8
shell: C:\cygwin\bin\bash.exe -eo pipefail -o igncr '{0}'
- name: Run tests
run: |
export PATH=/usr/bin:$PATH
ctest --test-dir build --build-config Debug --verbose
shell: C:\cygwin\bin\bash.exe -eo pipefail -o igncr '{0}'

html_documentation_checks:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 5
- name: Setup python environment
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install python packages
Expand All @@ -64,11 +172,13 @@ jobs:
echo "::add-matcher::./.github/checkTags.json"
python ./.CI/check_html.py checkTags ./
echo "::remove-matcher owner=checkTags::"
syntax_checks:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 5
- name: Get moparser
Expand All @@ -80,17 +190,19 @@ jobs:
- name: Check syntax
run: |
echo "::add-matcher::./.github/moparser.json"
ModelicaSyntaxChecker/Linux64/moparser -v 3.4 -r Complex.mo Modelica ModelicaReference ModelicaServices ModelicaTest ModelicaTestConversion4.mo ModelicaTestOverdetermined.mo ObsoleteModelica4.mo
ModelicaSyntaxChecker/Linux64/moparser -v 3.6 -r Complex.mo Modelica ModelicaReference ModelicaServices ModelicaTest ModelicaTestConversion4.mo ModelicaTestOverdetermined.mo ObsoleteModelica4.mo
echo "::remove-matcher owner=moparser::"
deprecation_checks:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 5
- name: Setup python environment
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Check deprecated Text.lineColor annotation
Expand Down
Loading

0 comments on commit 0c6b7f6

Please sign in to comment.