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

Parser stub #12

Merged
merged 8 commits into from
Jan 10, 2024
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
8 changes: 4 additions & 4 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3

- name: Install dependencies
run: |
pip install -r docs/requirements.txt

- name: Debugging information
run: |
echo "github.ref:" ${{github.ref}}
Expand All @@ -42,10 +46,6 @@ jobs:
( git branch gh-pages remotes/origin/gh-pages && git clone . --branch=gh-pages _gh-pages/ ) || mkdir _gh-pages
rm -rf _gh-pages/.git/

- name: Install dependencies
run: |
pip install -r docs/requirements.txt

- name: Build documentation
run: |
cd docs
Expand Down
86 changes: 86 additions & 0 deletions .github/workflows/mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Mac

on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
xcode_macos_12:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: macos-12
strategy:
matrix:
# all available versions of xcode: https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md#xcode
xcode: ['13.1', '14.1']
build_type: [Debug, Release]
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer

steps:
- uses: actions/checkout@v3

- name: Run Cmake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.build_type }}

- name: Build
run: cmake --build build --parallel 10

- name: Run tests
run: |
cd build
ctest -C ${{ matrix.build_type }} --rerun-failed --output-on-failure . --verbose -j 10

xcode_macos_13:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: macos-13
strategy:
matrix:
# all available versions of xcode: https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode
xcode: ['14.1', '15.0']
build_type: [Debug, Release]
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer

steps:
- uses: actions/checkout@v3

- name: Run Cmake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.build_type }}

- name: Build
run: cmake --build build --parallel 10

- name: Run tests
run: |
cd build
ctest -C ${{ matrix.build_type }} --rerun-failed --output-on-failure . --verbose -j 10

macos_lateset:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: macos-latest
strategy:
matrix:
compiler:
- { cpp: g++-11, c: gcc-11}
- { cpp: g++-12, c: gcc-12}
- { cpp: clang++, c: clang}
build_type: [Debug, Release]
env:
CC: ${{ matrix.compiler.c }}
CXX: ${{ matrix.compiler.cpp }}

steps:
- uses: actions/checkout@v3

- name: Run Cmake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.build_type }}

- name: Build
run: cmake --build build --parallel 10

- name: Run tests
run: |
cd build
ctest -C ${{ matrix.build_type }} --rerun-failed --output-on-failure . --verbose -j 10
56 changes: 56 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Ubuntu

on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
gcc:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
strategy:
matrix:
build_type: [Debug, Release]
env:
CC: gcc
CXX: g++
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run Cmake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.build_type }}

- name: Build
run: cmake --build build --parallel 10

- name: Run tests
run: |
cd build
ctest -C ${{ matrix.build_type }} --rerun-failed --output-on-failure . --verbose -j 10

clang:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
strategy:
matrix:
build_type: [Debug, Release]
env:
CC: clang
CXX: clang++
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run Cmake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.build_type }}

- name: Build
run: cmake --build build --verbose

- name: Run tests
run: |
cd build
ctest -C ${{ matrix.build_type }} --rerun-failed --output-on-failure . --verbose -j 10
31 changes: 31 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Windows

on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
msvc2022:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: windows-latest
strategy:
matrix:
build_type: [Release]
architecture: [Win32, x64]

steps:
- uses: actions/checkout@v3
- name: Run CMake
run: cmake -S . -B build -A ${{ matrix.architecture }}
if: matrix.build_type == 'Release'
- name: Run CMake
run: cmake -S . -B build -A ${{ matrix.architecture }}
if: matrix.build_type == 'Debug'
- name: Build
run: cmake --build build --config ${{ matrix.build_type }} --parallel 10
- name: Run tests
run: |
cd build
ctest -C ${{ matrix.build_type }} --rerun-failed --output-on-failure . --verbose
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
docs/build
build
51 changes: 51 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
################################################################################
# Preamble
cmake_minimum_required(VERSION 3.21)

project(
mechanism_configuration
VERSION 1.0.0
LANGUAGES CXX
)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()

message(STATUS "CMake build configuration for ${PROJECT_NAME} (${CMAKE_BUILD_TYPE}) ${PROJECT_VERSION}")

################################################################################
# Projet wide setup options

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake")

option(ENABLE_TESTS "Build the tests" ON)

################################################################################
# Dependencies

include(cmake/dependencies.cmake)

################################################################################
# micm targets and documentation

add_subdirectory(src)

################################################################################
# Tests

if(PROJECT_IS_TOP_LEVEL AND ENABLE_TESTS)
enable_testing()
add_subdirectory(test)
endif()

################################################################################
# Packaging

# only include packaging if we are the top level project being built
if(PROJECT_IS_TOP_LEVEL)
add_subdirectory(packaging)
endif()
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ An attempt at defining a model-independent configuration schema for atmospheric

[![GitHub Releases](https://img.shields.io/github/release/open-atmos/MechanismConfiguration.svg)](https://github.com/open-atmos/MechanismConfiguration/releases)
[![License](https://img.shields.io/github/license/open-atmos/MechanismConfiguration.svg)](https://github.com/open-atmos/MechanismConfiguration/blob/master/LICENSE)
[![Builds](https://github.com/open-atmos/MechanismConfiguration/actions/workflows/gh-pages.yml/badge.svg)](https://github.com/open-atmos/MechanismConfiguration/actions/workflows/gh-pages.yml)
[![Docs build](https://github.com/open-atmos/MechanismConfiguration/actions/workflows/gh-pages.yml/badge.svg)](https://github.com/open-atmos/MechanismConfiguration/actions/workflows/gh-pages.yml)
[![Windows](https://github.com/open-atmos/MechanismConfiguration/actions/workflows/windows.yml/badge.svg)](https://github.com/open-atmos/MechanismConfiguration/actions/workflows/windows.yml)
[![Mac](https://github.com/open-atmos/MechanismConfiguration/actions/workflows/mac.yml/badge.svg)](https://github.com/open-atmos/MechanismConfiguration/actions/workflows/mac.yml)
[![Ubuntu](https://github.com/open-atmos/MechanismConfiguration/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/open-atmos/MechanismConfiguration/actions/workflows/ubuntu.yml)

Copyright (C) 2017–2023 Barcelona Supercomputing Center, University of Illinois at Urbana–Champaign, and National Center for Atmospheric Research
Copyright (C) 2017–2024 Barcelona Supercomputing Center, University of Illinois at Urbana–Champaign, and National Center for Atmospheric Research

The configuration documentation can be found [here](https://open-atmos.github.io/MechanismConfiguration/).

Expand Down
37 changes: 37 additions & 0 deletions cmake/cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake

if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
endif()

file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif()
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif()
endforeach()

set(uninstall_dirs "@INSTALL_PREFIX@;@cmake_config_install_location@")

foreach(dir IN LISTS uninstall_dirs)
message(STATUS "Uninstalling ${dir}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove_directory ${dir}"
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing ${dir}")
endif()
endforeach()
25 changes: 25 additions & 0 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
include(FetchContent)

################################################################################
# google test

if(PROJECT_IS_TOP_LEVEL AND ENABLE_TESTS)
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
)

set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
set(BUILD_GMOCK OFF CACHE BOOL "" FORCE)

FetchContent_MakeAvailable(googletest)
endif()

################################################################################
# nlohmann::json

FetchContent_Declare(json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.2
)
FetchContent_MakeAvailable(json)
5 changes: 5 additions & 0 deletions cmake/mechanism_configurationConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@_Exports.cmake")

check_required_components("@PROJECT_NAME@")
38 changes: 38 additions & 0 deletions cmake/test_util.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
################################################################################
# build and add a standard test

function(create_standard_test)
set(prefix TEST)
set(optionalValues SKIP_MEMCHECK)
set(singleValues NAME WORKING_DIRECTORY)
set(multiValues SOURCES LIBRARIES)

include(CMakeParseArguments)
cmake_parse_arguments(${prefix} "${optionalValues}" "${singleValues}" "${multiValues}" ${ARGN})

add_executable(test_${TEST_NAME} ${TEST_SOURCES})

target_link_libraries(test_${TEST_NAME} PUBLIC open_atmos::mechanism_configuration GTest::gtest_main)

# link additional libraries
foreach(library ${TEST_LIBRARIES})
target_link_libraries(test_${TEST_NAME} PUBLIC ${library})
endforeach()

if(NOT DEFINED TEST_WORKING_DIRECTORY)
set(TEST_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
endif()

add_open_atmos_test(${TEST_NAME} test_${TEST_NAME} "" ${TEST_WORKING_DIRECTORY})
endfunction(create_standard_test)

################################################################################
# Add a test

function(add_open_atmos_test test_name test_binary test_args working_dir)
add_test(NAME ${test_name}
COMMAND ${test_binary} ${test_args}
WORKING_DIRECTORY ${working_dir})
endfunction(add_open_atmos_test)

################################################################################
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pydata-sphinx-theme
setuptools
sphinx
sphinx-design
sphinx-tabs
Expand Down
Loading