Skip to content
Merged
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
21 changes: 3 additions & 18 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Read the Docs configuration file for IMAS-Matlab
# Read the Docs configuration file for IMAS-MATLAB
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
Expand All @@ -10,21 +10,6 @@ build:
tools:
python: "3.11"

jobs:
post_checkout:
# Clone IMAS-Core (only if not already present)
- |
if [ ! -d "IMAS-Core" ]; then
git clone --depth 1 --branch develop \
https://github.com/iterorganization/IMAS-Core.git \
IMAS-Core
fi
- ls -la
- ln -sfn $PWD/IMAS-Core/common/doc_common $PWD/doc/doc_common
- ls -la doc/
- ls -la doc/doc_common/
- echo "Created symlink doc/doc_common -> IMAS-Core/common/doc_common"

# Build documentation in the "doc" directory with Sphinx
sphinx:
configuration: doc/conf.py
Expand All @@ -35,11 +20,11 @@ formats:
- pdf
- epub

# Optional but recommended, declare the Python requirements required
# Optional but Python requirements required recommended, declare the
# to build your documentation
python:
install:
- requirements: IMAS-Core/common/doc_common/requirements.txt
- requirements: doc/doc_common/requirements.txt

# Submodules configuration (optional)
submodules:
Expand Down
119 changes: 54 additions & 65 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,76 +20,70 @@ if(WIN32)
endif()
endif()

# Configuration options for common assets
# Local paths for IMAS-MATLAB
################################################################################
# Include local paths to eliminate AL_COMMON_PATH dependency
# Use full path since CMAKE_MODULE_PATH hasn't been configured yet
include(${CMAKE_CURRENT_SOURCE_DIR}/common/cmake/ALLocalPaths.cmake)
option( AL_DOWNLOAD_DEPENDENCIES "Automatically download assets from the AL git repository" ON )
set( AL_CORE_GIT_REPOSITORY "https://github.com/iterorganization/IMAS-Core.git" CACHE STRING "Git repository of AL-core" )
set( AL_CORE_VERSION "main" CACHE STRING "Git commit/tag/branch of AL-core" )

include(FetchContent)
# Load common assets
# Load AL-core library (used for the shared library)
################################################################################
if( DEFINED ENV{AL_COMMON_PATH} )
# Take common assets from the path in this environment variable instead of al-core
set( AL_COMMON_PATH $ENV{AL_COMMON_PATH} )
else()
if(WIN32)
if( ${AL_DOWNLOAD_DEPENDENCIES} )
# FetchContent_Declare causing reursive call wrapped by vcpkg to _find_package
# So manually clone al-core here. Need fix in later release
set( al-core_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_deps/al-core-src" )
if( NOT EXISTS "${al-core_SOURCE_DIR}/.git" )
message( STATUS "Cloning al-core from ${AL_CORE_GIT_REPOSITORY}" )
execute_process(
COMMAND git clone "${AL_CORE_GIT_REPOSITORY}" "${al-core_SOURCE_DIR}"
RESULT_VARIABLE _GIT_CLONE_RESULT
ERROR_VARIABLE _GIT_CLONE_ERROR
)
if( _GIT_CLONE_RESULT )
message( FATAL_ERROR "Failed to clone al-core: ${_GIT_CLONE_ERROR}" )
endif()
endif()
# Checkout the specified version
execute_process(
COMMAND git fetch origin
WORKING_DIRECTORY "${al-core_SOURCE_DIR}"
RESULT_VARIABLE _GIT_FETCH_RESULT
)
if(WIN32)
if( ${AL_DOWNLOAD_DEPENDENCIES} )
# FetchContent_Declare causing reursive call wrapped by vcpkg to _find_package
# So manually clone al-core here. Need fix in later release
set( al-core_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_deps/al-core-src" )
if( NOT EXISTS "${al-core_SOURCE_DIR}/.git" )
message( STATUS "Cloning al-core from ${AL_CORE_GIT_REPOSITORY}" )
execute_process(
COMMAND git checkout "${AL_CORE_VERSION}"
WORKING_DIRECTORY "${al-core_SOURCE_DIR}"
RESULT_VARIABLE _GIT_CHECKOUT_RESULT
ERROR_VARIABLE _GIT_CHECKOUT_ERROR
COMMAND git clone "${AL_CORE_GIT_REPOSITORY}" "${al-core_SOURCE_DIR}"
RESULT_VARIABLE _GIT_CLONE_RESULT
ERROR_VARIABLE _GIT_CLONE_ERROR
)
if( _GIT_CHECKOUT_RESULT )
message( FATAL_ERROR "Failed to checkout ${AL_CORE_VERSION}: ${_GIT_CHECKOUT_ERROR}" )
endif()
else()
set( al-core_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../al-core" )
if( NOT IS_DIRECTORY "${al-core_SOURCE_DIR}" )
message( FATAL_ERROR "${al-core_SOURCE_DIR} does not exist. Set AL_DOWNLOAD_DEPENDENCIES=ON to download." )
if( _GIT_CLONE_RESULT )
message( FATAL_ERROR "Failed to clone al-core: ${_GIT_CLONE_ERROR}" )
endif()
endif()
set( AL_COMMON_PATH "${al-core_SOURCE_DIR}/common" )
else()
if( ${AL_DOWNLOAD_DEPENDENCIES} )
# Download common assets from the ITER git:
FetchContent_Declare(
al-core
GIT_REPOSITORY "${AL_CORE_GIT_REPOSITORY}"
GIT_TAG "${AL_CORE_VERSION}"
)
else()
FetchContent_Declare(
al-core
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../al-core"
)
# Checkout the specified version
execute_process(
COMMAND git fetch origin
WORKING_DIRECTORY "${al-core_SOURCE_DIR}"
RESULT_VARIABLE _GIT_FETCH_RESULT
)
execute_process(
COMMAND git checkout "${AL_CORE_VERSION}"
WORKING_DIRECTORY "${al-core_SOURCE_DIR}"
RESULT_VARIABLE _GIT_CHECKOUT_RESULT
ERROR_VARIABLE _GIT_CHECKOUT_ERROR
)
if( _GIT_CHECKOUT_RESULT )
message( FATAL_ERROR "Failed to checkout ${AL_CORE_VERSION}: ${_GIT_CHECKOUT_ERROR}" )
endif()
elseif ( ${AL_DEVELOPMENT_LAYOUT} )
set( al-core_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../al-core" )
endif()
else()
if( ${AL_DOWNLOAD_DEPENDENCIES} )
# Download common assets from the ITER git:
FetchContent_Declare(
al-core
GIT_REPOSITORY "${AL_CORE_GIT_REPOSITORY}"
GIT_TAG "${AL_CORE_VERSION}"
)
FetchContent_MakeAvailable( al-core )
elseif ( ${AL_DEVELOPMENT_LAYOUT} )
FetchContent_Declare(
al-core
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../al-core"
)
FetchContent_MakeAvailable( al-core )
set( AL_COMMON_PATH "${al-core_SOURCE_DIR}/common" )
endif()
endif()
endif()
add_subdirectory( ${AL_COMMON_PATH} _common )


# Define project
################################################################################
Expand Down Expand Up @@ -120,8 +114,6 @@ include( ALCore )
if( AL_DOCS_ONLY )
return()
endif()


# Dependencies
################################################################################
find_package( Python3 REQUIRED COMPONENTS Interpreter )
Expand All @@ -130,8 +122,6 @@ if(WIN32)
else()
find_package( Matlab REQUIRED )
endif()


# Utility sources and target
################################################################################

Expand All @@ -149,7 +139,6 @@ if(WIN32)
target_link_libraries( al-mex PUBLIC al Matlab::mex Matlab::mx )
target_include_directories( al-mex PRIVATE src )
target_include_directories( al-mex PUBLIC ${Matlab_INCLUDE_DIRS} )
target_include_directories( al-mex PUBLIC ${AL_COMMON_PATH}/../include )

# Use separate (non-interleaved) complex API for compatibility
target_compile_definitions( al-mex PUBLIC)
Expand Down Expand Up @@ -238,7 +227,7 @@ macro( GENERATE GENERATOR IS_C_GENERATOR OUTPUT_FILES )
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${GENERATOR}_dummy.txt
COMMAND
${_SAXONCHE_VENV_PYTHON} "${AL_COMMON_PATH}/xsltproc.py"
${_SAXONCHE_VENV_PYTHON} "${AL_LOCAL_XSLTPROC_SCRIPT}"
-xsl ${CMAKE_CURRENT_SOURCE_DIR}/${GENERATOR}.xsl
-s ${IDSDEF}
-o ${CMAKE_CURRENT_BINARY_DIR}/${GENERATOR}_output.xml
Expand Down Expand Up @@ -273,6 +262,8 @@ if(WIN32)
target_include_directories( "mex-${NAME}" PRIVATE src )
# Use separate (non-interleaved) complex API for compatibility
target_compile_definitions( "mex-${NAME}" PUBLIC)
# Add /bigobj flag for large generated code files
target_compile_options( "mex-${NAME}" PRIVATE /bigobj )
list( APPEND MEX_TARGETS "mex-${NAME}" )
endmacro()
else()
Expand All @@ -283,8 +274,6 @@ else()
list( APPEND MEX_TARGETS "mex-${NAME}" )
endmacro()
endif()


# These XSLs generate files in triplets, which are then compiled into one mex target
foreach( METHOD_NAME allocate delete gen get get_sample get_slice init put put_slice rand validate )
FILES_FROM_METHOD_NAME( OUTPUT_FILES ${METHOD_NAME} )
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Contributing guidelines

We welcome any kind of contribution to `IMAS-Matlab`,
We welcome any kind of contribution to `IMAS-MATLAB`,
from a simple comment, a question or even a full fledged pull
request.
Please first make sure you read and follow the
[Code of Conduct](CODE_OF_CONDUCT.md).

## You think you found a bug in the code, or have a question in its use
1. use the [issue search](https://github.com/iterorganization/IMAS-Matlab/issues)
1. use the [issue search](https://github.com/iterorganization/IMAS-MATLAB/issues)
to check if someone already created a similar issue;
2. if not, make a **new issue** to describe your problem or question.
In the case of a bug suspiscion, please try to give all the relevant
information to allow reproducing the error or identifying
its root cause (version of the IMAS-Matlab, OS and relevant
its root cause (version of the IMAS-MATLAB, OS and relevant
dependencies, snippet of code);
3. apply relevant labels to the issue.

## You want to make or ask some change to the code
1. use the [issue search](https://github.com/iterorganization/IMAS-Matlab/issues)
1. use the [issue search](https://github.com/iterorganization/IMAS-MATLAB/issues)
to check if someone already proposed a similar idea/change;
2. if not, create a **new issue** to describe what change you would like to see
implemented and specify it if you intend to work on it yourself or if some help
Expand Down
2 changes: 1 addition & 1 deletion ci/build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CMAKE_ARGS=(
-D AL_PLUGINS_VERSION=${AL_PLUGINS_VERSION:-main}
-D AL_CORE_VERSION=${AL_CORE_VERSION:-main}
-D DD_VERSION=${DD_VERSION:-main}
# Build only documentation
# Build only documentationv
-D AL_HLI_DOCS=${AL_HLI_DOCS:-ON}
-D AL_DOCS_ONLY=${AL_DOCS_ONLY:-ON}
)
Expand Down
27 changes: 27 additions & 0 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# CMake configuration for AL common assets
# Intended for inclusion (using FetchContent_MakeAvailable) in other AL components

# Add ./cmake to the module path in the parent scope:
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake PARENT_SCOPE )

if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} )
message( FATAL_ERROR "In-source builds not supported. Please use a separate build directory, for example `cmake -B build [...]`" )
endif()

if( AL_PYTHON_BINDINGS )
find_package( Python3 )
set( PYVER "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}" )
endif()
configure_file( al_env.sh.in ${CMAKE_CURRENT_BINARY_DIR}/al_env.sh )

# Don't generate the environment file when building modules:
if( AL_DOWNLOAD_DEPENDENCIES OR AL_DEVELOPMENT_LAYOUT )
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/al_env.sh
TYPE BIN
)
endif()

# al-common_SOURCE_DIR is used in some scripts in the cmake/ folder to refer to the
# current source directory:
set( al-common_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE )
7 changes: 7 additions & 0 deletions common/al_env.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export PATH="${CMAKE_INSTALL_PREFIX}/bin:$PATH"
export LD_LIBRARY_PATH="${CMAKE_INSTALL_PREFIX}/lib:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="${CMAKE_INSTALL_PREFIX}/lib/pkgconfig:$PKG_CONFIG_PATH"

if [ -d "${CMAKE_INSTALL_PREFIX}/mex" ]; then
export MATLABPATH="${CMAKE_INSTALL_PREFIX}/mex:$MATLABPATH"
fi
Loading
Loading