Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
markaren committed Jun 28, 2023
1 parent f93f0c5 commit 5486f11
Show file tree
Hide file tree
Showing 24 changed files with 95 additions and 171 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ IncludeCategories:
Priority: 10
- Regex: '^[<"]ecos[/.]'
Priority: 20
- Regex: '^[<"](CLI|ssp|spdlog|fmilibcpp|proxyfmu|)[/.]'
- Regex: '^[<"](CLI|thrift|ssp|spdlog|fmilibcpp|proxyfmu|)[/.]'
Priority: 30
- Regex: '^"'
Priority: 10
Expand Down
42 changes: 25 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
name: Build

env:
CONAN_REVISIONS_ENABLED: 1
CONAN_NON_INTERACTIVE: True

on: [ push, workflow_dispatch ]

jobs:
cmake-on-linux:
name: cmake

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -17,31 +13,38 @@ jobs:
build_type: [ Debug, Release ]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install prerequisites
run: |
sudo apt install libtbb-dev
sudo pip3 install --upgrade setuptools pip
sudo pip3 install conan
- name: Restore artifacts, or run vcpkg, build (and cache artifacts as post step)
uses: lukka/run-vcpkg@v10
id: runvcpkg
with:
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
vcpkgGitCommitId: '12c2a93b4007612b5ffa980c9d2235eb0bcac10f'
vcpkgJsonGlob: 'vcpkg.json'
appendedCacheKey: vcpkginstall

- name: Configure and build
run: |
cmake . -B build -DECOS_BUILD_EXAMPLES=ON -DECOS_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
cmake . -B build -DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DECOS_BUILD_EXAMPLES=ON -DECOS_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
cmake --build build
- name: Test
run: |
cd build/tests
ctest --output-on-failure
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
if: matrix.build_type == 'Release'
with:
name: ecos
path: build/bin/ecos*

cmake-on-windows:
name: cmake

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -50,15 +53,20 @@ jobs:
build_type: [ Debug, Release ]

steps:
- uses: actions/checkout@v2
- name: Install prerequisites
run: |
pip3 install --upgrade setuptools pip
pip3 install conan
- uses: actions/checkout@v3

- name: Restore artifacts, or run vcpkg, build (and cache artifacts as post step)
uses: lukka/run-vcpkg@v10
id: runvcpkg
with:
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
vcpkgGitCommitId: '12c2a93b4007612b5ffa980c9d2235eb0bcac10f'
vcpkgJsonGlob: 'vcpkg.json'
appendedCacheKey: vcpkginstall

- name: Configure and build
run: |
cmake . -A x64 -B build -DECOS_BUILD_EXAMPLES=ON -DECOS_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
cmake . -A x64 -B build -DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DECOS_BUILD_EXAMPLES=ON -DECOS_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
cmake --build build --config ${{ matrix.build_type }}
- name: Test
Expand Down
81 changes: 0 additions & 81 deletions .github/workflows/upload.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ cmake-build-*
/**/gunnerus/**/*.ssp

/**/results/**/*.csv

LicenseError.txt
20 changes: 4 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ option(ECOS_BUILD_CLIB "Build C library" ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)


include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
set(generatedSourcesDir "${CMAKE_BINARY_DIR}/generated")

if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
Expand All @@ -50,30 +52,15 @@ find_package(libzip CONFIG REQUIRED)
find_package(pugixml CONFIG REQUIRED)
find_package(Thrift CONFIG REQUIRED)
find_package(CLI11 CONFIG REQUIRED)
find_package(unofficial-fmilib CONFIG REQUIRED)

# ==============================================================================
# Targets
# ==============================================================================

if (ECOS_BUILD_CLI OR ECOS_BUILD_TESTS)
include(FetchContent)
endif()

add_subdirectory(src)
add_subdirectory(tool)

if (ECOS_BUILD_CLI)

FetchContent_Declare(
cli11
GIT_REPOSITORY https://github.com/CLIUtils/CLI11
GIT_TAG v2.2.0
)
FetchContent_MakeAvailable(cli11)

add_subdirectory(cli)
endif ()

if (ECOS_BUILD_EXAMPLES OR ECOS_BUILD_TESTS)

if (ECOS_BUILD_EXAMPLES)
Expand All @@ -82,6 +69,7 @@ if (ECOS_BUILD_EXAMPLES OR ECOS_BUILD_TESTS)

if (ECOS_BUILD_TESTS)

include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
Expand Down
8 changes: 0 additions & 8 deletions cli/CMakeLists.txt

This file was deleted.

3 changes: 2 additions & 1 deletion ecospy/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def build_extension(self, ext):
'..',
'-B',
buildFolder,
'-DCMAKE_TOOLCHAIN_FILE=C:/Users/Lars Ivar Hatledal/AppData/Local/vcpkg/scripts/buildsystems/vcpkg.cmake',
'-DCMAKE_BUILD_TYPE={}'.format(build_type)
]
if WINDOWS:
Expand Down Expand Up @@ -64,7 +65,7 @@ def binary_suffix():
packages=['ecospy'],
package_dir={'ecospy': '.'},
package_data={'ecospy': [f"{buildFolder}/bin/*.dll"]},
data_files=[("Scripts", [f"{buildFolder}/bin/proxyfmu{binary_suffix()}", f"{buildFolder}/bin/ecos{binary_suffix()}"])],
data_files=[("Scripts", [f"{buildFolder}/bin/Release/proxyfmu{binary_suffix()}", f"{buildFolder}/bin/Release/ecos{binary_suffix()}"])],
ext_modules=[CMakeExtension('ecospy')],
cmdclass=dict(build_ext=CMakeBuild),
)
2 changes: 1 addition & 1 deletion examples/quarter_truck/quarter_truck.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def pre(self, info: SimulationInfo):


def main():
print(EcosLib().version())
print(f"Ecoslib version: {EcosLib().version()}")

EcosLib().set_log_level("debug")

Expand Down
7 changes: 5 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ target_link_libraries(libecos
thrift::thrift
pugixml::pugixml
libzip::zip
spdlog::spdlog)
spdlog::spdlog
unofficial::fmilib::fmilib
$<TARGET_OBJECTS:proxyfmu-service>
)
if (UNIX)
target_link_libraries(libecos INTERFACE stdc++fs tbb)
endif ()
Expand All @@ -138,7 +141,7 @@ if (ECOS_BUILD_CLIB)
target_link_libraries(libecosc
PUBLIC
libecos)
endif()
endif ()


# ==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion src/ecos/fmi/fmi1/fmi1_model_description.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace ecos::fmi
{

inline model_description create_model_description(fmi1_import_t* handle);
model_description create_model_description(fmi1_import_t* handle);

} // namespace ecos::fmi

Expand Down
2 changes: 1 addition & 1 deletion src/ecos/fmi/fmi2/fmi2_model_description.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace ecos::fmi
{

inline model_description create_model_description(fmi2_import_t* handle);
model_description create_model_description(fmi2_import_t* handle);

} // namespace fmi

Expand Down
2 changes: 1 addition & 1 deletion src/ecos/fmi/fmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

using namespace ecos;

std::unique_ptr<fmi::fmu> loadFmu(const std::filesystem::path& fmuPath, bool fmiLogging)
std::unique_ptr<fmi::fmu> fmi::loadFmu(const std::filesystem::path& fmuPath, bool fmiLogging)
{
auto ctx = std::make_unique<fmi::fmicontext>(fmiLogging);

Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include_directories("${CMAKE_SOURCE_DIR}/src")
link_libraries(libecos Catch2::Catch2)
link_libraries(libecos $<TARGET_OBJECTS:proxyfmu-service> Catch2::Catch2)
add_compile_definitions(DATA_FOLDER="${CMAKE_SOURCE_DIR}/data")

add_executable(test_identity test_identity.cpp)
Expand Down
35 changes: 2 additions & 33 deletions tool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,3 @@

add_executable(proxyfmu
proxyfmu.cpp
"handlers/fmu_service_handler.cpp"
"handlers/boot_service_handler.cpp"
"$<TARGET_OBJECTS:proxyfmu-service>"
"${generatedSourcesDir}/ecos/lib_info.cpp")
target_include_directories(proxyfmu
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_SOURCE_DIR}/src"
"${SUBPROCESS_INCLUDE_DIR}"
"${generatedSourcesDir}")
target_link_libraries(proxyfmu
PRIVATE
libecos
CLI11::CLI11
thrift::thrift
)
if (UNIX)
target_link_libraries(proxyfmu PRIVATE pthread)
endif ()

if (PROXYFMU_BUILD_TESTS)
# Copy executable to test directory in order for CTest to function
add_custom_command(TARGET proxyfmu POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:proxyfmu> ${CMAKE_BINARY_DIR}/tests/$<TARGET_FILE_NAME:proxyfmu>
)
add_custom_command(TARGET proxyfmu POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo
Copying $<TARGET_FILE:proxyfmu> into ${CMAKE_BINARY_DIR}/tests/$<TARGET_FILE_NAME:proxyfmu>
)
endif()
add_subdirectory(proxyfmu)
add_subdirectory(cli)
12 changes: 12 additions & 0 deletions tool/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

add_executable(ecos main.cpp)
target_link_libraries(ecos
PRIVATE
libecos
CLI11::CLI11
)

install(
TARGETS ecos
DESTINATION ecos-targets}
)
File renamed without changes.
Loading

0 comments on commit 5486f11

Please sign in to comment.