Skip to content

Commit

Permalink
Merge pull request #259 from lovyan03/develop
Browse files Browse the repository at this point in the history
0.4.18
  • Loading branch information
lovyan03 authored Jul 9, 2022
2 parents 6319a0b + 6a409f0 commit e8333de
Show file tree
Hide file tree
Showing 95 changed files with 2,571 additions and 895 deletions.
40 changes: 40 additions & 0 deletions .github/scripts/OpenCV.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
cmake_minimum_required (VERSION 3.8)
project(LGFXOpenCV)

# Use this if OpenCV_DIR was not added to the PATH
# set( OpenCV_DIR "C:/path/to/opencv/build" )

find_package(OpenCV REQUIRED )

# Uncomment this if LovyanGFX_DIR was not added to the PATH
set( LovyanGFX_DIR "../../../LovyanGFX/src" )

message(STATUS "LGFXOpenCV status:")
message(STATUS " LovyanGFX dir = ${LovyanGFX_DIR}")
message(STATUS " OpenCV config = ${OpenCV_DIR}")
message(STATUS " OpenCV version = ${OpenCV_VERSION}")
message(STATUS " OpenCV libraries = ${OpenCV_LIBS}")
message(STATUS " OpenCV include path = ${OpenCV_INCLUDE_DIRS}")

add_definitions(-DLGFX_OPENCV)

file(GLOB Target_Files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS
*.cpp
${LovyanGFX_DIR}/lgfx/Fonts/efont/*.c
${LovyanGFX_DIR}/lgfx/Fonts/IPA/*.c
${LovyanGFX_DIR}/lgfx/utility/*.c
${LovyanGFX_DIR}/lgfx/v1/*.cpp
${LovyanGFX_DIR}/lgfx/v1/misc/*.cpp
${LovyanGFX_DIR}/lgfx/v1/panel/Panel_Device.cpp
${LovyanGFX_DIR}/lgfx/v1/platforms/opencv/*.cpp
)
add_executable (LGFXOpenCV ${Target_Files})

if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")
endif()

target_include_directories(LGFXOpenCV PUBLIC ${LovyanGFX_DIR} ${OpenCV_INCLUDE_DIRS})
target_link_libraries(LGFXOpenCV PUBLIC ${OpenCV_LIBS})
target_compile_features(LGFXOpenCV PRIVATE cxx_std_17)

49 changes: 49 additions & 0 deletions .github/scripts/SDL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
cmake_minimum_required (VERSION 3.8)
project(LGFX_SDL)

set( LovyanGFX_DIR "../../../LovyanGFX/src" )
# set( SDL2_DIR "C:/path/to/SDL2" )

add_definitions(-DLGFX_SDL)

file(GLOB Target_Files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS
*.cpp
${LovyanGFX_DIR}/lgfx/Fonts/efont/*.c
${LovyanGFX_DIR}/lgfx/Fonts/IPA/*.c
${LovyanGFX_DIR}/lgfx/utility/*.c
${LovyanGFX_DIR}/lgfx/v1/*.cpp
${LovyanGFX_DIR}/lgfx/v1/misc/*.cpp
${LovyanGFX_DIR}/lgfx/v1/panel/Panel_Device.cpp
${LovyanGFX_DIR}/lgfx/v1/platforms/sdl/*.cpp
)
add_executable (${PROJECT_NAME} ${Target_Files})

find_package(SDL2 REQUIRED)

message(STATUS "LGFX_SDL status:")
message(STATUS " LovyanGFX dir = ${LovyanGFX_DIR}")
message(STATUS " SDL2 include path = ${SDL2_INCLUDE_DIRS}")
message(STATUS " SDL2 libraries = ${SDL2_LIBRARIES}")

target_include_directories(${PROJECT_NAME} PUBLIC ${LovyanGFX_DIR} ${SDL2_INCLUDE_DIRS})

if(UNIX)
target_link_libraries(${PROJECT_NAME} -lpthread ${SDL2_LIBRARIES})
endif()

if(WIN32)
set(CMAKE_CXX_COMPILER "clang++")
target_link_libraries(${PROJECT_NAME} PUBLIC ${SDL2_LIBRARIES})
# Copy the SDL .dll file into the application binary directory
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:SDL2::SDL2>
$<TARGET_FILE_DIR:${PROJECT_NAME}>
VERBATIM
)
endif()


target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)

44 changes: 44 additions & 0 deletions .github/scripts/installOpenCV.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
::@echo off
setlocal enabledelayedexpansion
::DO_NOT_CHANGE::
::============================================::
set cvVersion=4.5.5
echo Installing OpenCV-%cvVersion%
::============================================::
mkdir opencv-%cvVersion%
cd opencv-%cvVersion%
mkdir Installation
set count=1
set cwd=%cd%
::============================================::
echo Downloading opencv from github
::download opencv from git
git clone https:/opencv/opencv.git
cd opencv
::checkout appropriate cv version
git checkout %cvVersion%
cd ..
::============================================::
echo Compiling using cmake
cd opencv


set cwd=%cd%

echo ============================================
echo Building Debug version
echo ============================================

mkdir build
cd build
::xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx::
::Configure OpenCV
cmake -G "Visual Studio 17 2022" -T host=x64 -DCMAKE_INSTALL_PREFIX=%cwd%/Installation -D BUILD_opencv_java=OFF -D BUILD_opencv_python=OFF ..
::DO_NOT_CHANGE::
::============================================::
::Compile OpenCV in release mode
cmake.exe --build . --config Debug --target INSTALL
cd ..
cd ..
cd ..

60 changes: 60 additions & 0 deletions .github/scripts/installSDL2.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
::@echo off
setlocal enabledelayedexpansion
::============================================::
set sdlVersion=2.0.22
echo Installing SDL2-%sdlVersion%
::============================================::
::set count=1
::============================================::

mkdir contrib

rem echo ============================================
rem echo Downloading SDL2 for VisualC++
rem echo ============================================
rem
rem curl https://libsdl.org/release/SDL2-devel-%sdlVersion%-VC.zip -o contrib/SDL2-VC.zip
rem 7z x contrib/SDL2-VC.zip -ocontrib/MSVC/
rem cp ".github/scripts/sdl2-config-vc.cmake" contrib/MSVC/SDL2-%sdlVersion%/sdl2-config.cmake
rem
rem echo ============================================
rem echo Downloading SDL2 for mingw
rem echo ============================================
rem
rem curl https://libsdl.org/release/SDL2-devel-%sdlVersion%-mingw.tar.gz -o contrib/SDL2-mingw.tar.gz
rem 7z x contrib/SDL2-mingw.tar.gz -ocontrib/
rem 7z x contrib/SDL2-mingw.tar -ocontrib/mingw/
rem cp ".github/scripts/sdl2-config-mingw.cmake" contrib/mingw/SDL2-%sdlVersion%/sdl2-config.cmake
rem
rem ls contrib/src/
rem ls contrib/MSVC/
rem ls contrib/mingw/

echo ============================================
echo Downloading SDL2 Source
echo ============================================

curl https://www.libsdl.org/release/SDL2-%sdlVersion%.zip -o contrib/SDL2-SRC.zip
7z x contrib/SDL2-SRC.zip -ocontrib/src/


cd contrib/src/SDL2-%sdlVersion%

set cwd=%cd%

echo ============================================
echo Building Debug version
echo ============================================

:: build debug version
cmake -S . -B build/debug -G "Visual Studio 17 2022" -T host=x64 -DCMAKE_INSTALL_PREFIX=%cwd%/install -DCMAKE_BUILD_TYPE=Debug
cmake --build build/debug --target install

echo ============================================
echo Building Release version
echo ============================================

:: build release verion
cmake -S . -B build/release -G "Visual Studio 17 2022" -T host=x64 -DCMAKE_INSTALL_PREFIX=%cwd%/install -DCMAKE_BUILD_TYPE=Release
cmake --build build/release --target install

2 changes: 1 addition & 1 deletion .github/workflows/ArduinoBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- 2.0.0
- 2.0.1
- 2.0.2
- 2.0.3-RC1
- 2.0.3

include:
# 3D matrix doesn't apply to these:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/IDFBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- [email protected]
- [email protected]
- [email protected]
- [email protected]-rc1
- [email protected].1

include:
- esp-idf-fqbn: [email protected]
Expand All @@ -44,9 +44,9 @@ jobs:
- esp-idf-fqbn: [email protected]
idf-board: esp32s2
idf-version: v4.3.1
- esp-idf-fqbn: [email protected]-rc1
- esp-idf-fqbn: [email protected].1
idf-board: esp32s3
idf-version: v4.4-rc1
idf-version: v4.4.1

fail-fast: false

Expand Down
105 changes: 105 additions & 0 deletions .github/workflows/OpenCVBuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# OpenCVBuild.yml
name: OpenCVBuild

env:
PROJECT_DIR: examples_for_PC/CMake_OpenCV


on:
push:
paths:
- '**.ino'
- '**.cpp'
- '**.hpp'
- '**.h'
- '**.c'
- '**OpenCVBuild.yml'
- '**OpenCV.cmake'
- '**installOpenCV.bat'
pull_request:

workflow_dispatch:

jobs:

LGFXOpenCV:

name: LGFXOpenCV (${{ matrix.os }})

runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- { os: windows-latest, OpenCV_DIR: "D:/a/LovyanGFX/LovyanGFX/opencv-4.5.5/opencv/build/" }
- { os: macos-latest, OpenCV_DIR: "/usr/local/Cellar/opencv/4.5.5_2/" }
- { os: ubuntu-latest, OpenCV_DIR: "/home/runner/work/LovyanGFX/LovyanGFX/opencv-install/opencv/build" }

steps:
- name: Checkout
uses: actions/checkout@v2


- name: Cache OpenCV for Windows
if: ${{ matrix.os == 'windows-latest' }}
uses: actions/cache@v2
id: cache-opencv-windows
with:
path: opencv-4.5.5
key: ${{ runner.os }}-${{ hashFiles('.github/scripts/installOpenCV.bat') }}

- name: Build+Install OpenCV for Windows
if: matrix.os == 'windows-latest' && steps.cache-opencv-windows.outputs.cache-hit != 'true'
run: |
.github/scripts/installOpenCV.bat
- name: Build LGFXOpenCV for Windows
if: ${{ matrix.os == 'windows-latest' }}
env:
OpenCV_DIR: ${{ matrix.OpenCV_DIR }}
CC: clang
CXX: clang++
run: |
cp .github/scripts/OpenCV.cmake ${{ env.PROJECT_DIR }}/CMakeLists.txt
cd ${{ env.PROJECT_DIR }}
mkdir build
cd build
cmake -G "Visual Studio 17 2022" -A x64 -T ClangCL ..
cmake --build . --config Debug
- name: Cache OpenCV for linux
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/cache@v2
id: opencv-cache
with:
path: ./opencv-install
key: ${{ runner.os }}-opencv-cache

- name: Build+Install OpenCV for linux
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: rayandrews/with-opencv-action@v1
with:
dir: ./opencv-install
cached: ${{ steps.opencv-cache.outputs.cache-hit }}
opencv-version: '4.5.5'


- name: Install OpenCV for Mac
if: matrix.os == 'macos-latest'
env:
HOMEBREW_NO_AUTO_UPDATE: 1
run: brew install opencv cmake


- name: Build LGFXOpenCV for Mac/Linux
if: ${{ matrix.os != 'windows-latest' }}
env:
OpenCV_DIR: ${{ matrix.OpenCV_DIR }}
run: |
cp .github/scripts/OpenCV.cmake ${{ env.PROJECT_DIR }}/CMakeLists.txt
cd ${{ env.PROJECT_DIR }}
mkdir build
cd build
cmake ..
cmake --build .
4 changes: 2 additions & 2 deletions .github/workflows/PlatformioBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- 2.0.0
- 2.0.1
- 2.0.2
- 2.0.3-RC1
- 2.0.3

exclude:
- board: esp32-s3
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
pip install --upgrade platformio
- name: Run PlatformIO

run: |
cd ${{ env.PROJECT_DIR }}
pio lib -e ${{ matrix.board }}@${{ matrix.platform-version }} install --no-save file://$(realpath ../../../)
Expand Down
Loading

0 comments on commit e8333de

Please sign in to comment.