Browse Source

added template folder

master
Martin Vladic 2 years ago
parent
commit
f09d416aa2
  1. 61
      CMakeLists.txt
  2. 29
      README.md
  3. 6
      cmake.bat
  4. 0
      images/icon.ico
  5. 0
      images/icon.png
  6. 2
      src/conf/eez/conf.h
  7. 2
      src/platform/simulator/emscripten/index.html
  8. BIN
      src/platform/simulator/win32/icon.rc
  9. 0
      template/image.png
  10. 3
      template/manifest.json
  11. 50
      template/post.js

61
CMakeLists.txt

@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.10)
project(eez-flow-template-sdl)
set (PROJECT_NAME eez-flow-template-sdl)
project(${PROJECT_NAME})
set (CMAKE_CXX_STANDARD 17)
@ -138,62 +140,63 @@ if(WIN32)
set(SOURCES src/platform/simulator/win32/icon.rc ${src_files})
endif()
add_executable(eez-flow-template-sdl ${src_files} ${header_files})
add_executable(${PROJECT_NAME} ${src_files} ${header_files})
if(MSVC)
target_compile_options(eez-flow-template-sdl PRIVATE "/MP")
target_compile_options(${PROJECT_NAME} PRIVATE "/MP")
endif()
if (UNIX AND NOT(${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten"))
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(eez-flow-template-sdl Threads::Threads bsd)
target_link_libraries(${PROJECT_NAME} Threads::Threads bsd)
endif ()
target_link_libraries(eez-flow-template-sdl ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES})
if(WIN32)
target_link_libraries(eez-flow-template-sdl wsock32 ws2_32)
target_link_libraries(${PROJECT_NAME} wsock32 ws2_32)
add_custom_command(TARGET eez-flow-template-sdl POST_BUILD
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_SOURCE_DIR}/../../SDL2-2.0.14/lib/x86/SDL2.dll"
$<TARGET_FILE_DIR:eez-flow-template-sdl>)
"${PROJECT_SOURCE_DIR}/$ENV{SDL2DIR}/lib/x86/SDL2.dll"
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
add_custom_command(TARGET eez-flow-template-sdl POST_BUILD
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_SOURCE_DIR}/../../SDL2_image-2.0.4/lib/x86/libjpeg-9.dll"
$<TARGET_FILE_DIR:eez-flow-template-sdl>)
"${PROJECT_SOURCE_DIR}/$ENV{SDL2IMAGEDIR}/lib/x86/libjpeg-9.dll"
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
add_custom_command(TARGET eez-flow-template-sdl POST_BUILD
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_SOURCE_DIR}/../../SDL2_image-2.0.4/lib/x86/libpng16-16.dll"
$<TARGET_FILE_DIR:eez-flow-template-sdl>)
"${PROJECT_SOURCE_DIR}/$ENV{SDL2IMAGEDIR}/lib/x86/libpng16-16.dll"
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
add_custom_command(TARGET eez-flow-template-sdl POST_BUILD
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_SOURCE_DIR}/../../SDL2_image-2.0.4/lib/x86/libtiff-5.dll"
$<TARGET_FILE_DIR:eez-flow-template-sdl>)
"${PROJECT_SOURCE_DIR}/$ENV{SDL2IMAGEDIR}/lib/x86/libtiff-5.dll"
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
add_custom_command(TARGET eez-flow-template-sdl POST_BUILD
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_SOURCE_DIR}/../../SDL2_image-2.0.4/lib/x86/libwebp-7.dll"
$<TARGET_FILE_DIR:eez-flow-template-sdl>)
"${PROJECT_SOURCE_DIR}/$ENV{SDL2IMAGEDIR}/lib/x86/libwebp-7.dll"
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
add_custom_command(TARGET eez-flow-template-sdl POST_BUILD
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_SOURCE_DIR}/../../SDL2_image-2.0.4/lib/x86/SDL2_image.dll"
$<TARGET_FILE_DIR:eez-flow-template-sdl>)
"${PROJECT_SOURCE_DIR}/$ENV{SDL2IMAGEDIR}/lib/x86/SDL2_image.dll"
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
add_custom_command(TARGET eez-flow-template-sdl POST_BUILD
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_SOURCE_DIR}/../../SDL2_image-2.0.4/lib/x86/zlib1.dll"
$<TARGET_FILE_DIR:eez-flow-template-sdl>)
"${PROJECT_SOURCE_DIR}/$ENV{SDL2IMAGEDIR}/lib/x86/zlib1.dll"
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
add_custom_command(TARGET eez-flow-template-sdl POST_BUILD
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_SOURCE_DIR}/src/platform/simulator/emscripten"
$<TARGET_FILE_DIR:eez-flow-template-sdl>)
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
endif()

29
README.md

@ -2,7 +2,6 @@
The contributors are listed in CONTRIB.TXT. This project uses the GPL v3 license, see LICENSE.TXT.
This project uses the [C4.1 (Collective Code Construction Contract)](http://rfc.zeromq.org/spec:22) process for contributions.
To report an issue, use the [issues page](https://github.com/eez-open/eez-flow-template-sdl/issues) tracker.
## Build
@ -11,9 +10,7 @@ To report an issue, use the [issues page](https://github.com/eez-open/eez-flow-t
```
sudo apt-get update
sudo apt-get install -y git libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev cmake build-essential libbsd-dev
git clone https://github.com/eez-open/eez-flow-template-sdl
cd eez-flow-template-sdl
git submodule update --init --recursive
cd {{projectDirPath}}
mkdir -p build/linux
cd build/linux
cmake ../..
@ -23,17 +20,31 @@ make
Start simulator with:
```
./eez-flow-template-sdl
./{{projectName}}
```
#### Windows
Install [Visual Studio Community 2017](https://visualstudio.microsoft.com/downloads/) and [CMake](https://cmake.org/install/).
Use git to clone https://github.com/eez-open/eez-flow-template-sdl.
Download and install SDL2 development libraries for Windows from https://www.libsdl.org/download-2.0.php.
Also, execute: `git submodule update --init --recursive` inside `eez-flow-template-sdl`.
Download and install SDL2_Image development libraries for Windows from https://github.com/libsdl-org/SDL_image/releases.
Execute `cmake.bat`.
Update these environment variables in `cmake.bat` according to the location (and version) where SDL2 and SDL2_Image has been installed:
Visual Studio solution is created in `\path\to\eez-flow-template-sdl\build\win32`.
```
set SDL2DIR=..\SDL2-2.0.14
set SDL2IMAGEDIR=..\SDL2_image-2.0.4
```
Execute `cmake.bat`:
```
cd {{projectDirPath}}
.\cmake.bat
```
Visual Studio solution is created in `{{projectDirPath}}\build\win32`.
Use Visual Studio to build the solution.

6
cmake.bat

@ -1,11 +1,11 @@
set SDL2DIR=..\..\SDL2-2.0.14
set SDL2IMAGEDIR=..\..\SDL2_image-2.0.4
set SDL2DIR=..\SDL2-2.0.14
set SDL2IMAGEDIR=..\SDL2_image-2.0.4
if not exist "build" mkdir "build"
if not exist "build\win32" mkdir "build\win32"
cd build\win32
cmake ..\..
cmake -G "Visual Studio 15 2017" ..\..
cd ..\..

0
images/eez-flow-template-sdl.ico → images/icon.ico

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

0
images/eez-flow-template-sdl.png → images/icon.png

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

2
src/conf/eez/conf.h

@ -7,7 +7,7 @@ extern uint32_t DISPLAY_HEIGHT;
static const uint32_t DISPLAY_BPP = 32; // RGBA8888
static const char *TITLE = "EEZ Flow App";
static const char *ICON = "eez-flow-template-sdl.png";
static const char *ICON = "icon.png";
#define MAX_NUM_OF_Y_AXES 18
#define MAX_NUM_OF_Y_VALUES MAX_NUM_OF_Y_AXES

2
src/platform/simulator/emscripten/index.html

@ -16,7 +16,7 @@
</div>
<script>
var worker = new Worker("eez-flow-template-sdl.js");
var worker = new Worker("{{projectName}}.js");
const WIDTH = 480;
const HEIGHT = 272;

BIN
src/platform/simulator/win32/icon.rc

Binary file not shown.

0
image.png → template/image.png

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

3
template/manifest.json

@ -0,0 +1,3 @@
{
"eez-project-path": "{{projectName}}.eez-project"
}

50
template/post.js

@ -0,0 +1,50 @@
/**
* @callback RenameFile
* @param {string} fileSrcRelativePath
* @param {string} fileDstRelativePath
* @returns {Promise<void>}
*/
/**
* @callback ReplaceInFile
* @param {string} fileRelativePath
* @param {string} searchValue
* @param {string} newValue
* @returns {Promise<void>}
*/
/**
* @typedef {Object} WizardContext
* @property {string} projectDirPath
* @property {string} projectName
* @property {RenameFile} renameFile
* @property {ReplaceInFile} replaceInFile
*/
/**
* @param {WizardContext} context
*/
async function postProcessing(context) {
await context.replaceInFile("CMakeLists.txt", "eez-flow-template-sdl", context.projectName);
await context.replaceInFile("README.md", "{{projectDirPath}}", context.projectDirPath);
await context.replaceInFile("README.md", "{{projectName}}", context.projectName);
await context.replaceInFile("src/platform/simulator/win32/icon.rc", "{{projectName}}", context.projectName);
await context.replaceInFile("src/platform/simulator/emscripten/index.html", "{{projectName}}", context.projectName);
await context.replaceInFile("src/main.cpp", "eez-flow-template-sdl", context.projectName);
await context.replaceInFile("src/gui/app_context.cpp", "eez-flow-template-sdl", context.projectName);
await context.renameFile("app.eez-project", context.projectName + ".eez-project");
await context.renameFile("gui.eez-project", context.projectName + "-gui.eez-project");
await context.replaceInFile(context.projectName + ".eez-project", "gui.eez-project", context.projectName + "-gui.eez-project");
await context.replaceInFile(context.projectName + "-gui.eez-project", "app.eez-project", context.projectName + ".eez-project");
await context.replaceInFile("template/manifest.json", "{{projectName}}", context.projectName);
}
module.exports = postProcessing;
Loading…
Cancel
Save