Skip to content

Commit

Permalink
V1.0.2 (#117)
Browse files Browse the repository at this point in the history
* removed dependencies

* fixes dlysm_opt issue

* keep PacakgeExtension/Requires

* copy/paste bug

* rm Requires, PacakgeExtensionCompat (part of FMIBase now)

* typo

* added new dlsym_opt
  • Loading branch information
ThummeTo authored Aug 9, 2024
1 parent debe082 commit f9dba58
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 33 deletions.
8 changes: 2 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
name = "FMIImport"
uuid = "9fcbc62e-52a0-44e9-a616-1359a0008194"
authors = ["TT <[email protected]>", "LM <[email protected]>", "JK <[email protected]>"]
version = "1.0.1"
version = "1.0.2"

[deps]
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
FMIBase = "900ee838-d029-460e-b485-d98a826ceef2"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
PackageExtensionCompat = "65ce6f38-6b18-4e1d-a461-8949797d7930"
RelocatableFolders = "05181044-ff0b-4ac5-8273-598c1e38db00"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"

[weakdeps]
FMIZoo = "724179cf-c260-40a9-bd27-cccc6fe2f195"
Expand All @@ -21,7 +19,5 @@ FMIZooExt = ["FMIZoo"]
Downloads = "1"
FMIBase = "1.0.0"
Libdl = "1"
PackageExtensionCompat = "1.0.0"
RelocatableFolders = "1"
Requires = "1.3.0"
julia = "1.6"
julia = "1.6"
18 changes: 9 additions & 9 deletions src/FMI2/ext.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,23 +175,23 @@ function loadPointers(fmu::FMU2)
fmu.cSetInteger = dlsym(fmu.libHandle, :fmi2SetInteger)
fmu.cGetBoolean = dlsym(fmu.libHandle, :fmi2GetBoolean)
fmu.cSetBoolean = dlsym(fmu.libHandle, :fmi2SetBoolean)
fmu.cGetString = dlsym_opt(fmu.libHandle, :fmi2GetString)
fmu.cSetString = dlsym_opt(fmu.libHandle, :fmi2SetString)
fmu.cGetString = dlsym_opt(fmu, fmu.libHandle, :fmi2GetString)
fmu.cSetString = dlsym_opt(fmu, fmu.libHandle, :fmi2SetString)

if canGetSetFMUState(fmu.modelDescription)
fmu.cGetFMUstate = dlsym_opt(fmu.libHandle, :fmi2GetFMUstate)
fmu.cSetFMUstate = dlsym_opt(fmu.libHandle, :fmi2SetFMUstate)
fmu.cFreeFMUstate = dlsym_opt(fmu.libHandle, :fmi2FreeFMUstate)
fmu.cGetFMUstate = dlsym_opt(fmu, fmu.libHandle, :fmi2GetFMUstate)
fmu.cSetFMUstate = dlsym_opt(fmu, fmu.libHandle, :fmi2SetFMUstate)
fmu.cFreeFMUstate = dlsym_opt(fmu, fmu.libHandle, :fmi2FreeFMUstate)
end

if canSerializeFMUState(fmu.modelDescription)
fmu.cSerializedFMUstateSize = dlsym_opt(fmu.libHandle, :fmi2SerializedFMUstateSize)
fmu.cSerializeFMUstate = dlsym_opt(fmu.libHandle, :fmi2SerializeFMUstate)
fmu.cDeSerializeFMUstate = dlsym_opt(fmu.libHandle, :fmi2DeSerializeFMUstate)
fmu.cSerializedFMUstateSize = dlsym_opt(fmu, fmu.libHandle, :fmi2SerializedFMUstateSize)
fmu.cSerializeFMUstate = dlsym_opt(fmu, fmu.libHandle, :fmi2SerializeFMUstate)
fmu.cDeSerializeFMUstate = dlsym_opt(fmu, fmu.libHandle, :fmi2DeSerializeFMUstate)
end

if providesDirectionalDerivatives(fmu.modelDescription)
fmu.cGetDirectionalDerivative = dlsym_opt(fmu.libHandle, :fmi2GetDirectionalDerivative)
fmu.cGetDirectionalDerivative = dlsym_opt(fmu, fmu.libHandle, :fmi2GetDirectionalDerivative)
end

# CS specific function calls
Expand Down
24 changes: 12 additions & 12 deletions src/FMI3/ext.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,29 +187,29 @@ function loadPointers(fmu::FMU3)
fmu.cGetBoolean = dlsym(fmu.libHandle, :fmi3GetBoolean)
fmu.cSetBoolean = dlsym(fmu.libHandle, :fmi3SetBoolean)

fmu.cGetString = dlsym_opt(fmu.libHandle, :fmi3GetString)
fmu.cSetString = dlsym_opt(fmu.libHandle, :fmi3SetString)
fmu.cGetBinary = dlsym_opt(fmu.libHandle, :fmi3GetBinary)
fmu.cSetBinary = dlsym_opt(fmu.libHandle, :fmi3SetBinary)
fmu.cGetString = dlsym_opt(fmu, fmu.libHandle, :fmi3GetString)
fmu.cSetString = dlsym_opt(fmu, fmu.libHandle, :fmi3SetString)
fmu.cGetBinary = dlsym_opt(fmu, fmu.libHandle, :fmi3GetBinary)
fmu.cSetBinary = dlsym_opt(fmu, fmu.libHandle, :fmi3SetBinary)

if canGetSetFMUState(fmu)
fmu.cGetFMUState = dlsym_opt(fmu.libHandle, :fmi3GetFMUState)
fmu.cSetFMUState = dlsym_opt(fmu.libHandle, :fmi3SetFMUState)
fmu.cFreeFMUState = dlsym_opt(fmu.libHandle, :fmi3FreeFMUState)
fmu.cGetFMUState = dlsym_opt(fmu, fmu.libHandle, :fmi3GetFMUState)
fmu.cSetFMUState = dlsym_opt(fmu, fmu.libHandle, :fmi3SetFMUState)
fmu.cFreeFMUState = dlsym_opt(fmu, fmu.libHandle, :fmi3FreeFMUState)
end

if canSerializeFMUState(fmu)
fmu.cSerializedFMUStateSize = dlsym_opt(fmu.libHandle, :fmi3SerializedFMUStateSize)
fmu.cSerializeFMUState = dlsym_opt(fmu.libHandle, :fmi3SerializeFMUState)
fmu.cDeSerializeFMUState = dlsym_opt(fmu.libHandle, :fmi3DeserializeFMUState)
fmu.cSerializedFMUStateSize = dlsym_opt(fmu, fmu.libHandle, :fmi3SerializedFMUStateSize)
fmu.cSerializeFMUState = dlsym_opt(fmu, fmu.libHandle, :fmi3SerializeFMUState)
fmu.cDeSerializeFMUState = dlsym_opt(fmu, fmu.libHandle, :fmi3DeserializeFMUState)
end

if providesDirectionalDerivatives(fmu)
fmu.cGetDirectionalDerivative = dlsym_opt(fmu.libHandle, :fmi3GetDirectionalDerivative)
fmu.cGetDirectionalDerivative = dlsym_opt(fmu, fmu.libHandle, :fmi3GetDirectionalDerivative)
end

if providesAdjointDerivatives(fmu)
fmu.cGetAdjointDerivative = dlsym_opt(fmu.libHandle, :fmi3GetAdjointDerivative)
fmu.cGetAdjointDerivative = dlsym_opt(fmu, fmu.libHandle, :fmi3GetAdjointDerivative)
end

# CS specific function calls
Expand Down
4 changes: 2 additions & 2 deletions src/FMIImport.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ include("FMI3/ext.jl")
include("FMI3/md.jl")

# extensions
using Requires
using PackageExtensionCompat
using FMIBase.Requires
using FMIBase.PackageExtensionCompat
function __init__()
@require_extensions
end
Expand Down
21 changes: 17 additions & 4 deletions src/binary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,26 @@

using FMIBase.EzXML

function dlsym_opt(libHandle, symbol)
"""
dlsym_opt(fmu, libHandle, symbol)
The same as `dlsym(libHandle, symbol)`, but returns - `Ptr{Cvoid}(C_NULL)` if the symbol `symbol` is not available.
# Arguments
- `fmu`: The FMU to log a info message if not available.
- `libHandle`: The library handle, see `dlsym`.
- `symbol`: The library symbol, see `dlsym`.
# Returns
Library symbol if available, else `Ptr{Cvoid}(C_NULL)`.
"""
function dlsym_opt(fmu, libHandle, symbol)
addr = dlsym(libHandle, symbol; throw_error=false)
if addr == nothing
logWarning(fmu, "This FMU does not support function '$symbol'.")
if isnothing(addr)
logInfo(fmu, "This FMU does not support the optional function '$symbol'.")
addr = Ptr{Cvoid}(C_NULL)
end
addr
return addr
end

"""
Expand Down

2 comments on commit f9dba58

@ThummeTo
Copy link
Owner Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/112753

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.2 -m "<description of version>" f9dba583932ad9103723ac8a65b745e40ba42f36
git push origin v1.0.2

Please sign in to comment.