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

UGRID-43: Handle SWIGTYPE_P_<T> #33

Open
wants to merge 87 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
ad797a4
Move unordered maps to API src
ahmad-el-sayed Nov 5, 2024
a2f7a70
Remove UGridAPI/UGridState.hpp from SWIG config
ahmad-el-sayed Nov 5, 2024
3043930
Apply type maps to signature of API funcs having SWIGTYPE_p_<TYPE>
ahmad-el-sayed Nov 5, 2024
11f0df3
Keep unsafe compilation option commented for now (needed if pinning i…
ahmad-el-sayed Nov 5, 2024
b88f2ff
Remove TopologyType enum getters from API
ahmad-el-sayed Nov 6, 2024
24f6f5f
Remove MeshLocations enum getters from API
ahmad-el-sayed Nov 6, 2024
9ef7927
Provide extensions and helpers for SWIGTYPR_p_T (part of unit tests f…
ahmad-el-sayed Nov 6, 2024
95fa911
Use System.IntPtr instead of SWIGTYPE_p_T
ahmad-el-sayed Nov 7, 2024
2749f02
Start working on abstraction
ahmad-el-sayed Nov 7, 2024
b5d09e9
cont impl
ahmad-el-sayed Nov 13, 2024
a190791
Handle char*
ahmad-el-sayed Nov 21, 2024
ca55acd
Move initial impl to lib
ahmad-el-sayed Nov 21, 2024
6a884d6
Dispose properly and refactor exit code processing
ahmad-el-sayed Nov 21, 2024
9a88215
Have a wrapper base class and derive for extension
ahmad-el-sayed Nov 25, 2024
cc3b760
Clean uo
ahmad-el-sayed Nov 25, 2024
c1bd70b
Split base and derived classes to different src files
ahmad-el-sayed Nov 25, 2024
b26172a
Byte alloc/free in entity extensions
ahmad-el-sayed Nov 25, 2024
d1c7f32
Refactor entity extensions: safety + maintenance
ahmad-el-sayed Nov 25, 2024
566db54
Termpalte IntPtrHelpers.Allocate to improve usability
ahmad-el-sayed Nov 26, 2024
ad9a060
Add doc for IntPtrHelpers
ahmad-el-sayed Nov 26, 2024
92a989b
Add doc for entity extensions
ahmad-el-sayed Nov 26, 2024
cb44edb
Change order of params: topology type then id
ahmad-el-sayed Nov 26, 2024
4f377d0
Support getting double attributes
ahmad-el-sayed Nov 28, 2024
adf5fa9
Provide useful string and byte array extensions
ahmad-el-sayed Nov 28, 2024
073a919
Add ug_attribute_global_char_get API function
ahmad-el-sayed Nov 28, 2024
e4b4312
More string and byte[] extensions
ahmad-el-sayed Nov 28, 2024
a27808b
Get attributes of variable and file attributes
ahmad-el-sayed Nov 28, 2024
ca7b77b
clean up
ahmad-el-sayed Nov 30, 2024
7a85675
Added doc and tetsts for IntPtrExtensions
ahmad-el-sayed Dec 12, 2024
1ad8c3b
Added custom exception with doc and unit tests
ahmad-el-sayed Dec 12, 2024
7264feb
Improve some err msgs, improvements to getting attr values as strings
ahmad-el-sayed Dec 12, 2024
98d94ec
Get IntPtrHelpers.Free to handle dangling pointers accessed by proper…
ahmad-el-sayed Dec 13, 2024
e3c9bb4
Remove commented code
ahmad-el-sayed Dec 13, 2024
8cb8a5d
Add StringExtensions unit tests
ahmad-el-sayed Dec 15, 2024
f504407
Remove unused StringExtensions methods and add doc
ahmad-el-sayed Dec 16, 2024
fcf2b5e
minor formatting
ahmad-el-sayed Dec 16, 2024
a814441
Add doc and tests for ByteArrayExtensions
ahmad-el-sayed Dec 16, 2024
8ea4f44
Added tests for topology extensions
ahmad-el-sayed Dec 16, 2024
d688ebd
Refactor the reader
ahmad-el-sayed Dec 16, 2024
440f516
Split the tests by context
ahmad-el-sayed Dec 16, 2024
62dd4be
Correct alloc size in Mesh1D ext
ahmad-el-sayed Dec 17, 2024
78b77cb
Make PACK_NUPKG_LOCALLY OFF by default
ahmad-el-sayed Dec 17, 2024
52744ec
Remove hardcoded path
ahmad-el-sayed Dec 19, 2024
6467d3c
Force MD compile opt in both release and debug MSVC builds to enable …
ahmad-el-sayed Dec 19, 2024
69b28ca
Suport netcdf-cxx installation under windows and fix various exisitin…
ahmad-el-sayed Dec 19, 2024
267f749
use for instead of while loop
ahmad-el-sayed Dec 19, 2024
a5f268b
fix size of contacts.contact_name_id
ahmad-el-sayed Dec 19, 2024
6103fa0
remove unneccesary code from swig tests
ahmad-el-sayed Dec 19, 2024
544c699
remove unnecessary declarations in ug_fil_<mode>_mode
ahmad-el-sayed Dec 19, 2024
ded5bbd
Rework disposal of manage and unmanaged resources
ahmad-el-sayed Dec 19, 2024
cda5c3d
Fix dstination dir of the deps of the dll of the nupkg
ahmad-el-sayed Dec 21, 2024
d3fe57d
Try to fix code smell due to strncpy usage
ahmad-el-sayed Jan 7, 2025
356e0cc
use memcpy
ahmad-el-sayed Jan 7, 2025
f6eb9f5
fix clang formatting issues
ahmad-el-sayed Jan 7, 2025
9753e27
Set InternalsVisibleToAttributes in AssemblyInfio.cs
ahmad-el-sayed Jan 7, 2025
1a6dd7c
only target netstandard2.0
ahmad-el-sayed Jan 8, 2025
95cf7d9
Change copy target dir in nupk targets
ahmad-el-sayed Jan 8, 2025
9932d5d
Update unit test consumers
ahmad-el-sayed Jan 8, 2025
254c8f0
clang formatting
ahmad-el-sayed Jan 8, 2025
45bae55
make class UGridNETException public
ahmad-el-sayed Jan 9, 2025
9e5b0b2
Propagate deps and let VS target the correct platform
ahmad-el-sayed Jan 13, 2025
ff6db0f
Set global prop PlatformTarget = AnyCPU and make str of platform comp…
ahmad-el-sayed Jan 14, 2025
0c85f6b
possibly unhandled exception in Close
ahmad-el-sayed Jan 16, 2025
055cb71
Add unit test for reading empty file
ahmad-el-sayed Jan 16, 2025
388d9c3
Add empty file to test data
ahmad-el-sayed Feb 3, 2025
fb9b30d
Bump GTest version
ahmad-el-sayed Feb 3, 2025
e42a991
Export ZLIB_ROOT in docker img
ahmad-el-sayed Feb 3, 2025
c53e188
Try to copy run time deps to build dir
ahmad-el-sayed Feb 3, 2025
112b723
Fix deps scripts
ahmad-el-sayed Feb 6, 2025
351afb9
Pack runtime deps in nupkg
ahmad-el-sayed Feb 12, 2025
3f3536d
Add namespaced alias for hdf5 shared libs
ahmad-el-sayed Feb 12, 2025
6d56840
comment aliases but keep namespace
ahmad-el-sayed Feb 12, 2025
f838651
specify hdf5 shared
ahmad-el-sayed Feb 12, 2025
e357215
remove -shared suffix from hdf5 imported target names
ahmad-el-sayed Feb 12, 2025
144a9dc
remove namespace but retain explicit shared import
ahmad-el-sayed Feb 12, 2025
3e290b6
get ZLIB_ROOT either from env or config command line
ahmad-el-sayed Feb 12, 2025
85fd0db
try to renormalize netcdf-cxx install script for line endings
ahmad-el-sayed Feb 12, 2025
e512806
Disable curl installtion under Linux and Darwin
ahmad-el-sayed Feb 15, 2025
0c77207
Revert "Disable curl installtion under Linux and Darwin"
ahmad-el-sayed Feb 15, 2025
3d2f5a8
Try to resolve openssl dep
ahmad-el-sayed Feb 16, 2025
4abf89e
Explictly set the xcode version of macos-13
ahmad-el-sayed Feb 16, 2025
2eb8896
Correct condition
ahmad-el-sayed Feb 16, 2025
e7ca411
treat condition as an expression
ahmad-el-sayed Feb 16, 2025
3357c35
try again
ahmad-el-sayed Feb 16, 2025
7a6d368
Make curl part of cmake prefix path
ahmad-el-sayed Feb 16, 2025
63ced35
Prevent throwing KeyNotFoundException if epsg attribute in var projec…
ahmad-el-sayed Feb 18, 2025
113336a
use strcpy instead of memcpy to handle the copying of error messages
ahmad-el-sayed Feb 18, 2025
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
12 changes: 11 additions & 1 deletion .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

# Explicitly set the Xcode version for macos-13. With the default (newer), GCC
# fails to find some components of the standard library which causes build failure.
# This should not happen if clang is used instead (clang has better support under macOS).
# Setting a newer GCC version in the env section might also resolve the issue.
# The Linux Docker build must use the same version for consistency.
- name: Set Xcode version
if: startsWith(matrix.platform, 'macos-13')
run: sudo xcode-select -s /Applications/Xcode_14.1.app/Contents/Developer

# Step: Set paths
- name: Set paths
id: paths
Expand Down Expand Up @@ -111,7 +120,8 @@ jobs:
# Step: Configure
- name: Configure
run: |
export netCDFCxx_DIR=${{ steps.paths.outputs.ext_deps_dir }}/install/netcdf_cxx4/lib/cmake/netCDF/
export netCDFCxx_DIR=${{ steps.paths.outputs.ext_deps_dir }}/install/netcdf_cxx4/lib/cmake/netCDF
export OPENSSL_ROOT_DIR=$(brew --prefix openssl)
cmake \
-S ${{ github.workspace }} \
-B ${{ steps.paths.outputs.build_dir }} \
Expand Down
90 changes: 45 additions & 45 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
cmake_minimum_required(VERSION 3.23)
# cached globals
include(cmake/cached_globals.cmake)
project(
UGrid
VERSION ${GLOB_UGRID_PROJECT_VERSION}
DESCRIPTION "Library for reading and writing UGrid files."
LANGUAGES CXX C
)
# configuration options
if (NOT WIN32)
message(NOTICE "Build type: ${CMAKE_BUILD_TYPE}")
endif()
# configuration options
include(cmake/user_config_options.cmake)
# configure the compiler
include(cmake/compiler_config.cmake)
# fetch dependencies, must appear after options.cmake
include(cmake/fetch_contents.cmake)
# find required packages
include(cmake/find_packages.cmake)
# organize targets into folders, can be remove in version > 3.26 (ON by default)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Docs only available if this is the main app
add_subdirectory(docs)
# Run packaging scripts: requires semantic version
add_subdirectory(package)
# Libraries
add_subdirectory(libs)
# Add unit tests
if(ENABLE_UNIT_TESTING)
add_subdirectory(tests)
endif()
cmake_minimum_required(VERSION 3.23)

# cached globals
include(cmake/cached_globals.cmake)

project(
UGrid
VERSION ${GLOB_UGRID_PROJECT_VERSION}
DESCRIPTION "Library for reading and writing UGrid files."
LANGUAGES CXX C
)

# configuration options
if (NOT WIN32)
message(NOTICE "Build type: ${CMAKE_BUILD_TYPE}")
endif()

# configuration options
include(cmake/user_config_options.cmake)

# configure the compiler
include(cmake/compiler_config.cmake)

# fetch dependencies, must appear after options.cmake
include(cmake/fetch_contents.cmake)

# find required packages
include(cmake/find_packages.cmake)

# organize targets into folders, can be remove in version > 3.26 (ON by default)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Docs only available if this is the main app
add_subdirectory(docs)

# Run packaging scripts: requires semantic version
add_subdirectory(package)

# Libraries
add_subdirectory(libs)

# Add unit tests
if(ENABLE_UNIT_TESTING)
add_subdirectory(tests)
endif()
6 changes: 3 additions & 3 deletions cmake/cached_globals.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ string(TIMESTAMP GLOB_CURRENT_YEAR "%Y")
set(GLOB_CURRENT_YEAR ${GLOB_CURRENT_YEAR} CACHE STRING "Current year")

# .NET config
if(WIN32 AND BUILD_DOTNET_WRAPPER)
if(BUILD_DOTNET_WRAPPER)
# .NET SDK
set(GLOB_DOTNET_SDK "Microsoft.NET.Sdk" CACHE STRING ".NET SDK")
# .NET target frameworks
# List of .NET target frameworks (semicolon-delimited)
# Note: Even if the list consists of a single element, make sure to terminate with a semicolon
# For ex: set(LIST_OF_DOTNET_TARGET_FRAMEWORKS "net481;" CACHE STRING "Supported .NET target framework")
# Otherwise, Visual Studio will not create subdir net481 under Release (of whichever build config is used) in the CMake binary dir
# <TargetFramework>net481</TargetFramework> works (notice the singular form in xml element "TargetFramework")
# <TargetFrameworks>net481</TargetFrameworks> does not work (notice the plural form in xml element "TargetFrameworks")
# <TargetFrameworks>net481;</TargetFrameworks> works (notice the plural form in xml element "TargetFrameworks" and the semicolon after "net481")
set(GLOB_LIB_DOTNET_TARGET_FRAMEWORKS "netstandard2.0;net481" CACHE STRING "Library .NET target framework")
set(GLOB_LIB_DOTNET_TARGET_FRAMEWORKS "netstandard2.0;" CACHE STRING "Library .NET target framework")
set(GLOB_TEST_DOTNET_TARGET_FRAMEWORKS "net481;" CACHE STRING "Test .NET target framework")
# .NET language version
set(GLOB_CSHARP_LANGUAGE_VERSION "7.3" CACHE STRING "C# Compiler Options for language feature rules")
Expand Down
64 changes: 32 additions & 32 deletions cmake/compiler_config.cmake
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
# Set the C++ standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Disable compiler-specific extensions
set(CMAKE_CXX_EXTENSIONS OFF)
# Create position-independent executables and shared libraries
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Add compiler-specific options and definitions per supported platform
if (UNIX)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-fvisibility=hidden;-Werror;-Wall;-Wextra;-pedantic;-Wno-unused-function>")
add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>:-O2>")
add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>:-g>")
else()
message(FATAL_ERROR "Unsupported compiler. Only GNU is supported under Linux. Found ${CMAKE_CXX_COMPILER_ID}.")
endif()
elseif(WIN32)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/EHsc;/MP;/W3;/WX>")
add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>:/O2>")
add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>:/Od;/DEBUG>")
add_compile_definitions("$<$<COMPILE_LANGUAGE:CXX>:_USE_MATH_DEFINES>")
add_compile_definitions("$<$<COMPILE_LANGUAGE:CXX>:_CRT_SECURE_NO_WARNINGS>")
else()
message(FATAL_ERROR "Unsupported compiler. Only MSVC is supported under Windows. Found ${CMAKE_CXX_COMPILER_ID}.")
endif()
else()
message(FATAL_ERROR "Unsupported platform. Only Linux and Windows are supported.")
endif()
# Set the C++ standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Disable compiler-specific extensions
set(CMAKE_CXX_EXTENSIONS OFF)

# Create position-independent executables and shared libraries
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Add compiler-specific options and definitions per supported platform
if (UNIX)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-fvisibility=hidden;-Werror;-Wall;-Wextra;-pedantic;-Wno-unused-function>")
add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>:-O2>")
add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>:-g>")
else()
message(FATAL_ERROR "Unsupported compiler. Only GNU is supported under Linux. Found ${CMAKE_CXX_COMPILER_ID}.")
endif()
elseif(WIN32)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/EHsc;/MP;/MD;/W3;/WX>")
add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>:/O2>")
add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>:/Od;/DEBUG>")
add_compile_definitions("$<$<COMPILE_LANGUAGE:CXX>:_USE_MATH_DEFINES>")
add_compile_definitions("$<$<COMPILE_LANGUAGE:CXX>:_CRT_SECURE_NO_WARNINGS>")
else()
message(FATAL_ERROR "Unsupported compiler. Only MSVC is supported under Windows. Found ${CMAKE_CXX_COMPILER_ID}.")
endif()
else()
message(FATAL_ERROR "Unsupported platform. Only Linux and Windows are supported.")
endif()
82 changes: 41 additions & 41 deletions cmake/fetch_contents.cmake
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
include(FetchContent)
if(ENABLE_UNIT_TESTING)
# Fetch googletest
set(googletest_url "https://github.com/google/googletest.git")
set(googletest_tag "v1.13.0")
set(cmake_FetchContent_Populate_deprecation_version "3.30.0")
if(CMAKE_VERSION VERSION_GREATER_EQUAL "${cmake_FetchContent_Populate_deprecation_version}")
FetchContent_Declare(
googletest
GIT_REPOSITORY ${googletest_url}
GIT_TAG ${googletest_tag}
EXCLUDE_FROM_ALL # available from v3.28.0+
)
else()
FetchContent_Declare(
googletest
GIT_REPOSITORY ${googletest_url}
GIT_TAG ${googletest_tag}
)
endif()
if(WIN32)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
endif()
if(CMAKE_VERSION VERSION_GREATER_EQUAL "${cmake_FetchContent_Populate_deprecation_version}")
FetchContent_MakeAvailable(googletest)
else()
# deprecated
FetchContent_GetProperties(googletest)
if(NOT googletest_POPULATED)
FetchContent_Populate(googletest)
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
endif()
enable_testing()
endif()
include(FetchContent)

if(ENABLE_UNIT_TESTING)

# Fetch googletest
set(googletest_url "https://github.com/google/googletest.git")
set(googletest_tag "v1.15.1")
set(cmake_FetchContent_Populate_deprecation_version "3.30.0")

if(CMAKE_VERSION VERSION_GREATER_EQUAL "${cmake_FetchContent_Populate_deprecation_version}")
FetchContent_Declare(
googletest
GIT_REPOSITORY ${googletest_url}
GIT_TAG ${googletest_tag}
EXCLUDE_FROM_ALL # available from v3.28.0+
)
else()
FetchContent_Declare(
googletest
GIT_REPOSITORY ${googletest_url}
GIT_TAG ${googletest_tag}
)
endif()

if(WIN32)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
endif()

if(CMAKE_VERSION VERSION_GREATER_EQUAL "${cmake_FetchContent_Populate_deprecation_version}")
FetchContent_MakeAvailable(googletest)
else()
# deprecated
FetchContent_GetProperties(googletest)
if(NOT googletest_POPULATED)
FetchContent_Populate(googletest)
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
endif()

enable_testing()
endif()
Loading
Loading