Skip to content

Commit

Permalink
Added engine (wip)
Browse files Browse the repository at this point in the history
Only tested on Linux, will probably need fixes on Windows.
  • Loading branch information
rodlie committed Jan 1, 2024
1 parent 958347f commit 3401267
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 9 deletions.
9 changes: 3 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if(UNIX AND NOT APPLE)
set(CPACK_RPM_PACKAGE_URL ${PROJECT_HOMEPAGE_URL})
set(CPACK_RPM_FILE_NAME "${FRICTION_NAME}.rpm")

set(CPACK_DEBIAN_PACKAGE_DEPENDS "qt5-image-formats-plugins, libqt5multimedia5-plugins")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5multimedia5-plugins")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${PROJECT_COPYRIGHT})
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${PROJECT_HOMEPAGE_URL})
Expand All @@ -51,14 +51,11 @@ if(UNIX AND NOT APPLE)
include(CPack)
endif()

add_subdirectory(src/engine)
if(UNIX)
add_subdirectory(src/gperftools)
endif()
add_subdirectory(src/core)
add_subdirectory(src/app)

# Bundle experimental shaders
option(BUNDLE_SHADERS "Include shader effects with the application" OFF)
if(${BUNDLE_SHADERS})
add_subdirectory(src/plugins/shaders)
endif()
add_dependencies(frictioncore Engine)
2 changes: 1 addition & 1 deletion src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if(${USE_ROBOTO})
add_definitions(-DFRICTION_BUNDLE_ROBOTO)
endif()

option(USE_SKIA_SYSTEM_LIBS "Use skia (third-party) system libraries on Linux" OFF)
option(USE_SKIA_SYSTEM_LIBS "Use skia (third-party) system libraries on Linux" ON)
if(${USE_SKIA_SYSTEM_LIBS} AND UNIX)
pkg_check_modules(EXPAT REQUIRED expat)
pkg_check_modules(FREETYPE REQUIRED freetype2)
Expand Down
84 changes: 84 additions & 0 deletions src/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#
# Friction - https://friction.graphics
#
# Copyright (c) Friction contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

cmake_minimum_required(VERSION 3.9)

include(ExternalProject)
include(ProcessorCount)

ProcessorCount(N)

option(USE_SKIA_SYSTEM_LIBS "Use skia (third-party) system libraries on Linux" ON)

set(SKIA_SRC "${CMAKE_CURRENT_SOURCE_DIR}/skia")
set(SKIA_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/skia")

if(${USE_SKIA_SYSTEM_LIBS} AND UNIX)
set(SKIA_ENABLE_EXTERNAL "true")
else()
set(SKIA_ENABLE_EXTERNAL "false")
endif()

# skia_use_egl=
# skia_use_gl=
# skia_use_x11=

if(WIN32)
set(GN_PATH ${SKIA_SRC}/bin/gn.exe)
set(SKIA_ARGS_EXTRA --ide=vs)
set(SKIA_BUILD_CMD msbuild all.sln)
set(SKIA_UPDATE_CMD python.exe tools\git-sync-deps)
set(SKIA_ARGS "target_os=\"windows\" host_os=\"win\" current_os=\"win\" target_cpu=\"x64\"")
set(SKIA_ARGS "${SKIA_ARGS} clang_win=\"C:\Program Files\LLVM\" cc=\"clang-cl\" cxx=\"clang-cl\"")
set(SKIA_ARGS "${SKIA_ARGS} extra_cflags=[\"-Wno-error\",\"/MD\",\"/O2\"]")
else()
set(GN_PATH ${SKIA_SRC}/bin/gn)
set(SKIA_BUILD_CMD ninja -j${N})
set(SKIA_UPDATE_CMD true)
set(SKIA_ARGS "ar=\"${CMAKE_AR}\" cc=\"${CMAKE_C_COMPILER}\" cxx=\"${CMAKE_CXX_COMPILER}\"")
set(SKIA_ARGS "${SKIA_ARGS} extra_cflags=[\"-Wno-error\"]")
endif()

set(SKIA_ARGS "${SKIA_ARGS} is_official_build=true is_debug=false")
set(SKIA_ARGS "${SKIA_ARGS} skia_enable_pdf=false skia_enable_skottie=false skia_enable_tools=false skia_use_dng_sdk=false")
set(SKIA_ARGS "${SKIA_ARGS} skia_use_system_expat=${SKIA_ENABLE_EXTERNAL}")
set(SKIA_ARGS "${SKIA_ARGS} skia_use_system_freetype2=${SKIA_ENABLE_EXTERNAL}")
set(SKIA_ARGS "${SKIA_ARGS} skia_use_system_libjpeg_turbo=${SKIA_ENABLE_EXTERNAL}")
set(SKIA_ARGS "${SKIA_ARGS} skia_use_system_libpng=${SKIA_ENABLE_EXTERNAL}")
set(SKIA_ARGS "${SKIA_ARGS} skia_use_system_libwebp=${SKIA_ENABLE_EXTERNAL}")
set(SKIA_ARGS "${SKIA_ARGS} skia_use_system_icu=${SKIA_ENABLE_EXTERNAL}")
set(SKIA_ARGS "${SKIA_ARGS} skia_use_system_harfbuzz=${SKIA_ENABLE_EXTERNAL}")
#set(SKIA_ARGS "${SKIA_ARGS} skia_use_system_zlib=${SKIA_ENABLE_EXTERNAL}")

message("-- skia args: ${SKIA_ARGS}")

ExternalProject_Add(
Engine
LIST_SEPARATOR ","
SOURCE_DIR ${SKIA_SRC}
BINARY_DIR ${SKIA_BUILD_DIR}
DOWNLOAD_COMMAND true
UPDATE_COMMAND ${SKIA_UPDATE_CMD}
PATCH_COMMAND true
CONFIGURE_COMMAND ${GN_PATH} gen --root=${SKIA_SRC} ${SKIA_BUILD_DIR} "--args=${SKIA_ARGS}" ${SKIA_ARGS_EXTRA}
BUILD_COMMAND ${SKIA_BUILD_CMD}
INSTALL_COMMAND true
USES_TERMINAL_CONFIGURE true
USES_TERMINAL_BUILD true
)
2 changes: 1 addition & 1 deletion src/engine/skia
Submodule skia updated 2 files
+ bin/gn
+ bin/gn.exe
1 change: 0 additions & 1 deletion src/scripts/build_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ mkdir build-ci
cd build-ci

cmake -G Ninja \
-DUSE_SKIA_SYSTEM_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_CXX_COMPILER=clang++ \
Expand Down

0 comments on commit 3401267

Please sign in to comment.