Skip to content

Commit

Permalink
add vclib
Browse files Browse the repository at this point in the history
  • Loading branch information
yuichiis committed May 12, 2024
1 parent a340693 commit f032639
Show file tree
Hide file tree
Showing 132 changed files with 5,119 additions and 45 deletions.
82 changes: 75 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,92 @@
name: tests

permissions:
contents: write

on:
push:
branches:
- main
push:
branches:
- main
release:
types:
- published

jobs:
build_and_tests:
runs-on: ubuntu-22.04
build_tests:
name: build
runs-on: ${{ matrix.os }}

strategy:
fail-fast: true
matrix:
include:
- name: Windows
os: windows-latest
artifact_name: win64
- name: Linux
os: ubuntu-latest
artifact_name: linux
- name: macOS-x86_64
os: macos-13
artifact_name: macos-x86_64
- name: macOS-arm64
os: macos-latest
artifact_name: macos-arm64

steps:
- name: Checkout codes
uses: "actions/checkout@v4"

- name: Install dependencies (macOS)
if: ${{ startsWith(matrix.os, 'macos-') }}
run: |
brew install libomp
- name: Build
run: cmake -S . -B build && cmake --build build --config Release
if: ${{ startsWith(matrix.os, 'ubuntu-') || startsWith(matrix.os, 'windows-') }}
run: |
cmake -S . -B build && cmake --build build --config Release
- name: Build (macOS)
if: ${{ startsWith(matrix.os, 'macos-') }}
run: |
export OpenMP_ROOT=$(brew --prefix)/opt/libomp
cmake -S . -B build && cmake --build build --config Release
- name: GoogleTest Tests
run: cd build && ctest
run: |
cd build
ctest -C Release
- name: Packaging
run: |
cd build
cpack -C Release
- name: Archive production artifacts
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: package-${{ matrix.artifact_name }}
path: packages/*

release:
needs: [ build_tests ]
name: release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: packages
pattern: package-*
merge-multiple: true

- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
packages/*
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
cmake_minimum_required(VERSION 3.14)
#include (CMakePrintSystemInformation)
#set(CMAKE_CONFIGURATION_TYPES Debug Release)
#if(APPLE)
# set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Build architectures for macOS" FORCE)
#endif()
enable_testing()

project(rindow-matlib VERSION 1.0.0 LANGUAGES CXX C)
project(rindow-matlib VERSION 1.0.1 LANGUAGES CXX C)
#set(PROJECT_VERSION_MAJOR 1)
#set(PROJECT_VERSION_MINOR 0)
#set(PROJECT_VERSION_PATCH 0)
#set(PROJECT_VERSION_PATCH 1)

# GoogleTest requires at least C++14
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(APPLE)
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
endif()
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(Packing)

Expand All @@ -22,6 +27,9 @@ add_subdirectory(./tests)
if(UNIX AND NOT APPLE)
add_subdirectory(./debian)
endif()
if(MSVC)
add_subdirectory(./vclib)
endif()

message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "CPACK_PACKAGING_INSTALL_PREFIX: ${CPACK_PACKAGING_INSTALL_PREFIX}")
Expand Down
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,7 @@ Next, copy the include and lib directories to /usr/local.
```shell
$ sudo cp -r usr/include /usr/local/
$ sudo cp -r usr/lib /usr/local/
```

Depending on whether you are using OpenMP or not, you need to set the symbolic link.

```shell
$ sudo ln -s /usr/local/lib/rindowmatlib-openmp/librindowmatlib.dylib /usr/local/lib/librindowmatlib.dylib
$ brew install libomp
```

How to build from source code on Windows
Expand Down Expand Up @@ -184,6 +179,7 @@ Download source code from release and extract
Install openmp library with brew before build with cmake.

```shell
$ brew install libomp
$ cd \path\to\here
$ cmake -S . -B build
$ cmake --build build --config Release
Expand Down Expand Up @@ -277,6 +273,6 @@ $ g++ sample.cpp -lrindowmatlib -lm
### Build the sample program on MacOS.

```shell
$ g++ sample.cpp -lrindowmatlib -lm
$ c++ sample.cpp -lrindowmatlib -lm
```

3 changes: 2 additions & 1 deletion cmake/Packing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ if(MSVC)
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_PACKAGING_INSTALL_PREFIX ".")
elseif(APPLE)
set(CPACK_GENERATOR "TGZ")
set(CPACK_GENERATOR "TGZ")
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
elseif(UNIX)
set(CPACK_GENERATOR "DEB")
endif()
Expand Down
6 changes: 4 additions & 2 deletions include/rindow/matlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ enum rindow_matlib_dtype {
#if defined(RINDOW_COMPILING_DLL)
#define RINDOW_FUNC
#define RINDOW_FUNC_DECL extern __declspec(dllexport)
#elif defined(RINDOW_MATLIB_IMPORT)
#define RINDOW_FUNC
#define RINDOW_FUNC_DECL extern __declspec(dllimport)
#elif defined(RINDOW_MATLIB_INCLUDING_SOURCE)
#define RINDOW_FUNC
#define RINDOW_FUNC_DECL
#else
#define RINDOW_FUNC
#define RINDOW_FUNC_DECL extern __declspec(dllimport)
#define RINDOW_FUNC_DECL extern
#endif
#endif
#else // _MSC_VER
Expand Down Expand Up @@ -146,7 +149,6 @@ static inline int32_t rindow_matlib_common_dtype_is_bool(int32_t dtype)
return 0;
}


#ifdef __cplusplus
extern "C" {
#endif
Expand Down
Loading

0 comments on commit f032639

Please sign in to comment.