-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4f99757
Showing
22 changed files
with
4,520 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Заставляем IDE сохранять файлы в кодировке UTF-8 | ||
# https://editorconfig.org | ||
|
||
# В родительских папках .editorconfig искаться не будет | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# Не меняем формат разделителя строк. Может возникнуть конфликт с настройками git | ||
#end_of_line = lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
external/** linguist-vendored | ||
|
||
# Автоматически нормализуем концы строк, если у пользователя не настроен параметр autocrlf | ||
# https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings | ||
# https://www.aleksandrhovhannisyan.com/blog/crlf-vs-lf-normalizing-line-endings-in-git/ | ||
* text=auto | ||
|
||
# Батники с юниксовыми концами строк глючат | ||
*.bat text eol=crlf | ||
*.cmd text eol=crlf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
name: CI/CD | ||
|
||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
linux: | ||
runs-on: ubuntu-24.04 | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
compiler: | ||
- { | ||
id: gcc, | ||
c: gcc-13, | ||
cxx: g++-13, | ||
} | ||
- { | ||
id: clang, | ||
c: clang-16, | ||
cxx: clang++-16, | ||
} | ||
build_type: [debug, release] | ||
|
||
name: 🐧-${{ matrix.compiler.id }}-${{ matrix.build_type }} | ||
|
||
steps: | ||
- name: Устанавливаем зависимости | ||
run: | | ||
sudo apt update | ||
sudo apt install libgl1-mesa-dev libxrandr-dev | ||
- name: Скачиваем репозиторий | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
submodules: recursive | ||
path: repo | ||
|
||
- name: Генерируем проекты | ||
run: | | ||
cmake repo -B build -G "Unix Makefiles" \ | ||
-D CMAKE_C_COMPILER=${{ matrix.compiler.c }} -D CMAKE_CXX_COMPILER=${{ matrix.compiler.cxx }} \ | ||
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \ | ||
-D DV_ALL_WARNINGS=1 -D DV_CTEST=1 | ||
- name: Компилируем | ||
run: | | ||
cmake --build build | ||
- name: CTest | ||
run: | | ||
xvfb-run ctest --verbose --test-dir build --timeout 60 | ||
windows: | ||
runs-on: windows-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
compiler: [vs, mingw] | ||
build_type: [debug, release] | ||
|
||
name: 🔲-${{ matrix.compiler }}-${{ matrix.build_type }} | ||
|
||
steps: | ||
- name: Устанавливаем MinGW | ||
if: matrix.compiler == 'mingw' | ||
uses: msys2/setup-msys2@v2 | ||
with: | ||
update: true | ||
install: mingw-w64-x86_64-toolchain | ||
|
||
- name: Добавляем в PATH путь к MinGW | ||
if: matrix.compiler == 'mingw' | ||
shell: bash | ||
run: echo "${RUNNER_TEMP}/msys64/mingw64/bin" >> $GITHUB_PATH | ||
|
||
- name: Скачиваем репозиторий | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
submodules: recursive | ||
path: repo | ||
|
||
- name: Генерируем проекты | ||
shell: bash | ||
run: | | ||
args=(repo -B build) | ||
if [ "${{ matrix.compiler }}" == "vs" ] | ||
then | ||
args+=(-G "Visual Studio 17 2022") | ||
else | ||
args+=(-G "MinGW Makefiles") | ||
args+=(-D CMAKE_BUILD_TYPE=${{ matrix.build_type }}) | ||
fi | ||
args+=(-D DV_ALL_WARNINGS=1 -D DV_CTEST=1) | ||
cmake "${args[@]}" | ||
- name: Компилируем | ||
shell: bash | ||
run: | | ||
args=(--build build) | ||
if [ "${{ matrix.compiler }}" == "vs" ] | ||
then | ||
args+=(--config ${{ matrix.build_type }}) | ||
fi | ||
cmake "${args[@]}" | ||
- name: Качаем Mesa | ||
shell: bash | ||
run: | | ||
curl.exe --location --output mesa.7z --url https://github.com/pal1000/mesa-dist-win/releases/download/22.2.3/mesa3d-22.2.3-release-msvc.7z | ||
7z x mesa.7z -omesa | ||
rm mesa.7z | ||
mv mesa/x64/libgallium_wgl.dll build/result | ||
mv mesa/x64/libglapi.dll build/result | ||
mv mesa/x64/opengl32.dll build/result | ||
- name: CTest | ||
shell: bash | ||
run: | | ||
args=(--verbose --test-dir build --timeout 60) | ||
if [ "${{ matrix.compiler }}" == "vs" ] | ||
then | ||
args+=(-C ${{ matrix.build_type }}) | ||
fi | ||
export LIBGL_ALWAYS_SOFTWARE=true | ||
ctest "${args[@]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# https://git-scm.com/docs/gitignore | ||
# https://www.atlassian.com/ru/git/tutorials/saving-changes/gitignore | ||
|
||
# Игнорируем папки, которые создаёт VS Code | ||
/.vscode/ | ||
/build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "external/dviglo2d"] | ||
path = external/dviglo2d | ||
url = https://github.com/dviglo2d/dviglo2d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Путь к исходникам движка | ||
set(engine_dir "${CMAKE_SOURCE_DIR}/external/dviglo2d") | ||
|
||
# Указываем минимальную версию CMake | ||
include(${engine_dir}/cmake/cmake_min_version.cmake) | ||
cmake_minimum_required(VERSION ${dv_cmake_min_version}) | ||
|
||
# Название проекта | ||
project(app) | ||
|
||
include(${engine_dir}/cmake/common.cmake) | ||
|
||
# Подключаем библиотеки | ||
add_subdirectory(external) | ||
|
||
# Папка для экзешников | ||
set(result_dir "${CMAKE_BINARY_DIR}/result") | ||
|
||
# Указываем папку для следующих скомпилированных экзешников | ||
dv_set_bin_dir(${result_dir}) | ||
|
||
# Создаём папку result | ||
file(MAKE_DIRECTORY ${result_dir}) | ||
|
||
# Название таргета | ||
set(target_name app) | ||
|
||
# Создаём список файлов | ||
file(GLOB_RECURSE source_files src/*.cpp src/*.hpp) | ||
|
||
# Создаём приложение | ||
add_executable(${target_name} ${source_files}) | ||
|
||
if(NOT DV_WIN32_CONSOLE) | ||
# Используем точку входа WinMain() | ||
set_property(TARGET ${target_name} PROPERTY WIN32_EXECUTABLE TRUE) | ||
endif() | ||
|
||
# Подключаем библиотеку | ||
target_link_libraries(${target_name} dviglo) | ||
|
||
# Копируем динамические библиотеки в папку с приложением | ||
dv_copy_shared_libs_to_bin_dir(${target_name}) | ||
|
||
# Список папок с ресурсами движка для копирования в result | ||
set(dir_names engine_data samples_data) | ||
|
||
# Копируем папки с ресурсами движка в result, если нужно | ||
foreach(dir_name ${dir_names}) | ||
if(NOT EXISTS ${result_dir}/${dir_name}) | ||
dv_create_dir_link(${engine_dir}/result/${dir_name} ${result_dir}/${dir_name}) | ||
endif() | ||
endforeach() | ||
|
||
# Копируем папку app_data в result, если нужно | ||
if(NOT EXISTS ${result_dir}/app_data) | ||
dv_create_dir_link(${CMAKE_SOURCE_DIR}/result/app_data ${result_dir}/app_data) | ||
endif() | ||
|
||
# Добавляем приложение в список тестируемых | ||
add_test(NAME ${target_name} COMMAND ${target_name} -duration 5) | ||
|
||
# Заставляем Visual Studio отображать дерево каталогов | ||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/src FILES ${source_files}) | ||
|
||
# В Visual Studio таргет будет назначен стартовым вместо ALL_BUILD, | ||
# чтобы потом не делать это вручную при отладке приложения | ||
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${target_name}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
|
||
set -x # Включаем эхо | ||
|
||
repo_dir=$(dirname "$0") | ||
|
||
git -C "$repo_dir" submodule add https://github.com/dviglo2d/dviglo2d external/dviglo2d | ||
|
||
git -C "$repo_dir" submodule update --init --recursive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
|
||
build_type="-D CMAKE_BUILD_TYPE=Debug" | ||
#build_type="-D CMAKE_BUILD_TYPE=Release" | ||
#build_type="-D CMAKE_BUILD_TYPE=MinSizeRel" | ||
#build_type="-D CMAKE_BUILD_TYPE=RelWithDebInfo" | ||
|
||
compiler="-D CMAKE_C_COMPILER=gcc-13 -D CMAKE_CXX_COMPILER=g++-13" | ||
#compiler="-D CMAKE_C_COMPILER=clang-15 -D CMAKE_CXX_COMPILER=clang++-15" | ||
|
||
repo_dir=$(dirname "$0") | ||
|
||
# Генерируем проекты | ||
cmake "$repo_dir" -B "$repo_dir/../build" -G "Unix Makefiles" $build_type $compiler \ | ||
-D DV_ALL_WARNINGS=1 -D DV_WIN32_CONSOLE=1 | ||
|
||
# Компилируем проекты | ||
cmake --build "$repo_dir/../build" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
:: Меняем кодировку консоли на UTF-8 | ||
chcp 65001 | ||
|
||
:: Указываем путь к cmake.exe и MinGW. Без system32 в PATH ссылки на папки не создаются | ||
set "PATH=%SystemRoot%\system32;c:\programs\cmake\bin;c:\msys64\ucrt64\bin" | ||
|
||
set build_type=Debug | ||
::set build_type=Release | ||
::set build_type=MinSizeRel | ||
::set build_type=RelWithDebInfo | ||
|
||
set "repo_dir=%~dp0" | ||
:: Удаляем обратный слэш в конце | ||
set "repo_dir=%repo_dir:~0,-1%" | ||
|
||
:: Генерируем проекты | ||
cmake "%repo_dir%" -B "%repo_dir%/../build_mingw" -G "MinGW Makefiles" -D CMAKE_BUILD_TYPE=%build_type%^ | ||
-D DV_ALL_WARNINGS=1 -D DV_WIN32_CONSOLE=1 | ||
|
||
:: Компилируем проекты | ||
cmake --build "%repo_dir%/../build_mingw" | ||
|
||
:: Ждём нажатие Enter перед закрытием консоли | ||
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
:: Меняем кодировку консоли на UTF-8 | ||
chcp 65001 | ||
|
||
:: Указываем путь к cmake.exe. Без system32 в PATH ссылки на папки не создаются | ||
set "PATH=%SystemRoot%\system32;c:\programs\cmake\bin" | ||
|
||
set build_type=Debug | ||
::set build_type=Release | ||
::set build_type=MinSizeRel | ||
::set build_type=RelWithDebInfo | ||
|
||
set "generator=Visual Studio 17" | ||
|
||
set "repo_dir=%~dp0" | ||
:: Удаляем обратный слэш в конце | ||
set "repo_dir=%repo_dir:~0,-1%" | ||
|
||
:: Генерируем проекты | ||
cmake "%repo_dir%" -B "%repo_dir%/../build_vs" -G "%generator%" -A x64^ | ||
-D DV_ALL_WARNINGS=1 -D DV_WIN32_CONSOLE=1 | ||
|
||
:: Компилируем проекты | ||
cmake --build "%repo_dir%/../build_vs" --config %build_type% | ||
|
||
:: Ждём нажатие Enter перед закрытием консоли | ||
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# В IDE библиотеки будут отображаться в папке "библиотеки" | ||
set(CMAKE_FOLDER "библиотеки") | ||
|
||
add_subdirectory(dviglo2d EXCLUDE_FROM_ALL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[![](https://github.com/dviglo2d-learn/minimal_app/actions/workflows/main.yml/badge.svg)](https://github.com/dviglo2d-learn/minimal_app/actions) | ||
|
||
# Шаблон приложения / Минимальное приложение | ||
|
||
Единственным способом использования [движка Dviglo2D](https://github.com/dviglo2d/dviglo2d) является подключение его как поддиректории. | ||
|
||
Подробнее о процессе сборки: <https://github.com/dviglo2d/dviglo2d/blob/main/docs/building.md>. | ||
|
||
## Скачивание репозитория вместе с движком | ||
|
||
``` | ||
git clone --recurse-submodules https://github.com/dviglo2d-learn/minimal_app repo | ||
``` | ||
|
||
## Добавление новых исходных файлов в проект | ||
|
||
Создайте новые cpp- и hpp-файлы в папке `src` и повторно запустите `CMake`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Удаляет пробелы в конце строк | ||
|
||
import os | ||
|
||
|
||
def get_newline(file_path): | ||
with open(file_path, 'rb') as file: | ||
content = file.read() | ||
|
||
if b'\r\n' in content: | ||
return '\r\n' | ||
else: | ||
return '\n' | ||
|
||
|
||
def remove_trailing_spaces(file_path): | ||
with open(file_path, 'r', encoding='utf-8') as file: | ||
lines = file.readlines() | ||
|
||
# Сохраняем формат разделителя строк | ||
nel = get_newline(file_path) | ||
|
||
with open(file_path, 'w', encoding='utf-8', newline=nel) as file: | ||
for line in lines: | ||
file.write(line.rstrip() + '\n') | ||
|
||
|
||
if __name__ == '__main__': | ||
repo_dir = os.path.dirname(os.path.realpath(__file__)) | ||
exts = {'.bat', '.sh', '.md', '.hpp', '.cpp', '.txt', '.py', '.yml', '.editorconfig', '.gitattributes', '.gitignore'} | ||
|
||
for root, dirs, files in os.walk(repo_dir): | ||
# Игнорируемые папки | ||
if root == repo_dir: | ||
dirs.remove('.git') | ||
dirs.remove('external') | ||
|
||
for file in files: | ||
if any(file.endswith(ext) for ext in exts): | ||
file_path = os.path.join(root, file) | ||
remove_trailing_spaces(file_path) | ||
print('Обработан файл: ' + file_path) |
Oops, something went wrong.