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

Restore ModelicaUtilities.h #4487

Draft
wants to merge 1 commit into
base: maint/4.1.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .CI/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ def allAutotools() {
def autotools(CC, CPPFLAGS, config, nostatic, dotest) {
sh label: "Build $CC $CPPFLAGS", script: """
export CC=$CC
export CPPFLAGS="$CPPFLAGS -I${WORKSPACE}/.CI/Test"
export CPPFLAGS=$CPPFLAGS
export CFLAGS="-Os -fPIC"
rm -rf Modelica/Resources/Library/*
mkdir -p Modelica/Resources/Library/\$LIBDIR
cd Modelica/Resources/BuildProjects/autotools
git clean -fdx .
./autogen.sh
./configure --libdir="${WORKSPACE}/Modelica/Resources/Library/\$LIBDIR" $config
./configure --libdir="\$PWD/../../Library/\$LIBDIR" $config
make --output-sync -j${numPhysicalCPU()}
make install
"""
Expand All @@ -223,7 +223,7 @@ def makefile(CC, dotest) {
rm -rf Modelica/Resources/Library/*
mkdir -p "Modelica/Resources/Library/$LIBDIR"
cd Modelica/Resources/BuildProjects/gcc
make --output-sync -j${numPhysicalCPU()} TARGETDIR="$LIBDIR" CPPFLAGS="-I${WORKSPACE}/.CI/Test"
make --output-sync -j${numPhysicalCPU()} TARGETDIR="$LIBDIR"
"""
sh label: "Test $CC", script: """
export CC=$CC
Expand Down
2 changes: 1 addition & 1 deletion .CI/Test/Common.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "ModelicaUtilities.h"
#include "../../Modelica/Resources/C-Sources/ModelicaUtilities.h"
#include <assert.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

(Attaching comment to one of several possible places.)

Considering that ModelicaUtilities.h has prototypes for functions that should be provided by the tool, and not for functions provided by the MSL, wouldn't a mode natural location be inside ModelicaServices?

Suggested change
#include "../../Modelica/Resources/C-Sources/ModelicaUtilities.h"
#include "../../ModelicaServices/Resources/Include/ModelicaUtilities.h"

(Also note the use of the default include directory for the library.)

#include <stdlib.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/checkCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
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"
./configure --libdir="$PWD/../../Library/$LIBDIR" --enable-static --disable-shared --enable-static-zlib --disable-hdf5
make --output-sync
sudo make install
popd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(MODELICA_UTILITIES_INCLUDE)&quot;"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;MODELICAIO_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
Expand Down Expand Up @@ -106,7 +106,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(MODELICA_UTILITIES_INCLUDE)&quot;"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;MODELICAIO_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
Expand Down Expand Up @@ -168,7 +168,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;$(MODELICA_UTILITIES_INCLUDE)&quot;"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;MODELICAIO_EXPORTS;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="0"
ProgramDataBaseFileName="$(IntDir)\$(ProjectName).pdb"
Expand Down Expand Up @@ -228,7 +228,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;$(MODELICA_UTILITIES_INCLUDE)&quot;"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;MODELICAIO_EXPORTS;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="0"
ProgramDataBaseFileName="$(IntDir)\$(ProjectName).pdb"
Expand Down Expand Up @@ -281,12 +281,16 @@
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\C-Sources\ModelicaMatIO.h"
>
</File>
<File
RelativePath="..\..\C-Sources\ModelicaIO.h"
>
</File>
<File
RelativePath="..\..\C-Sources\ModelicaMatIO.h"
RelativePath="..\..\C-Sources\ModelicaUtilities.h"
>
</File>
</Filter>
Expand All @@ -297,6 +301,4 @@
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(MODELICA_UTILITIES_INCLUDE)&quot;;&quot;..\..\C-Sources\zlib\&quot;"
AdditionalIncludeDirectories="..\..\C-Sources\zlib\"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;MODELICAMATIO_EXPORTS;PSNIP_SAFE_FORCE_PORTABLE;HAVE_ZLIB=1"
MinimalRebuild="true"
BasicRuntimeChecks="3"
Expand Down Expand Up @@ -106,7 +106,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(MODELICA_UTILITIES_INCLUDE)&quot;;&quot;..\..\C-Sources\zlib\&quot;"
AdditionalIncludeDirectories="..\..\C-Sources\zlib\"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;MODELICAMATIO_EXPORTS;PSNIP_SAFE_FORCE_PORTABLE;HAVE_ZLIB=1"
MinimalRebuild="true"
BasicRuntimeChecks="3"
Expand Down Expand Up @@ -168,7 +168,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;$(MODELICA_UTILITIES_INCLUDE)&quot;;&quot;..\..\C-Sources\zlib\&quot;"
AdditionalIncludeDirectories="..\..\C-Sources\zlib\"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;MODELICAMATIO_EXPORTS;PSNIP_SAFE_FORCE_PORTABLE;_CRT_SECURE_NO_WARNINGS;HAVE_ZLIB=1"
RuntimeLibrary="0"
ProgramDataBaseFileName="$(IntDir)\$(ProjectName).pdb"
Expand Down Expand Up @@ -228,7 +228,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;$(MODELICA_UTILITIES_INCLUDE)&quot;;&quot;..\..\C-Sources\zlib\&quot;"
AdditionalIncludeDirectories="..\..\C-Sources\zlib\"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;MODELICAMATIO_EXPORTS;PSNIP_SAFE_FORCE_PORTABLE;_CRT_SECURE_NO_WARNINGS;HAVE_ZLIB=1"
RuntimeLibrary="0"
ProgramDataBaseFileName="$(IntDir)\$(ProjectName).pdb"
Expand Down Expand Up @@ -289,6 +289,10 @@
RelativePath="..\..\C-Sources\ModelicaMatIO.h"
>
</File>
<File
RelativePath="..\..\C-Sources\ModelicaUtilities.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(MODELICA_UTILITIES_INCLUDE)&quot;"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;MODELICASTANDARDTABLES_EXPORTS;DEBUG_TIME_EVENTS;TABLE_SHARE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
Expand Down Expand Up @@ -106,7 +106,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(MODELICA_UTILITIES_INCLUDE)&quot;"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;MODELICASTANDARDTABLES_EXPORTS;DEBUG_TIME_EVENTS;TABLE_SHARE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
Expand Down Expand Up @@ -168,7 +168,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;$(MODELICA_UTILITIES_INCLUDE)&quot;"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;MODELICASTANDARDTABLES_EXPORTS;_CRT_SECURE_NO_WARNINGS;TABLE_SHARE"
RuntimeLibrary="0"
ProgramDataBaseFileName="$(IntDir)\$(ProjectName).pdb"
Expand Down Expand Up @@ -228,7 +228,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;$(MODELICA_UTILITIES_INCLUDE)&quot;"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;MODELICASTANDARDTABLES_EXPORTS;_CRT_SECURE_NO_WARNINGS;TABLE_SHARE"
RuntimeLibrary="0"
ProgramDataBaseFileName="$(IntDir)\$(ProjectName).pdb"
Expand Down Expand Up @@ -293,6 +293,10 @@
RelativePath="..\..\C-Sources\ModelicaStandardTables.h"
>
</File>
<File
RelativePath="..\..\C-Sources\ModelicaUtilities.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Expand Down
8 changes: 2 additions & 6 deletions Modelica/Resources/BuildProjects/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ from the C-code under ../C-Sources
The intention is that interested tool vendors can build these libraries
by using the provided build projects as a start.

The tool vendors are responsible for building the binary libraries
Note, the tool vendors are responsible for building the binary libraries
and including them in their tools.

When building the binary libraries by VisualStudio2005 the environment
variable MODELICA_UTILITIES_INCLUDE needs to be set to the path of the
(tool-vendor-specific) ModelicaUtilities.h header file.

September 24, 2021
May 17, 2018
27 changes: 27 additions & 0 deletions Modelica/Resources/Licenses/LICENSE_ModelicaUtilities.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (C) 2010-2024, Modelica Association and contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion Modelica/Utilities/Streams.mo
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ separated by LF or CR-LF.
pure function error "Print error message and cancel all actions - in case of an unrecoverable error"
extends Modelica.Icons.Function;
input String string "String to be printed to error message window";
external "C" ModelicaError(string) annotation(Include="#include \"ModelicaUtilities.h\"", Library="ModelicaExternalC");
Copy link
Contributor

@henrikt-ma henrikt-ma Oct 24, 2024

Choose a reason for hiding this comment

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

At the moment, it is a tool de-facto responsibility to ensure #include "ModelicaUtilities.h" will find the file, so doesn't this change belong in a separate discussion about how Modelica external functions should point to ModelicaUtilities.h?

external "C" ModelicaError(string) annotation(IncludeDirectory="modelica://Modelica/Resources/C-Sources", Include="#include \"ModelicaUtilities.h\"", Library="ModelicaExternalC");
annotation (Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
Expand Down
Loading