Skip to content

Commit

Permalink
Yoga layout runtimes
Browse files Browse the repository at this point in the history
Starting to implement layout component with Yoga in CPP. Layouts works on iOS, macOS, Android and web runtimes.

https://github.com/rive-app/rive/assets/186340/e09e639a-d38e-46b8-951d-a5ecc392b53a

Diffs=
6c76b425f Yoga layout runtimes (#6787)

Co-authored-by: Luigi Rosso <[email protected]>
Co-authored-by: Philip Chung <[email protected]>
  • Loading branch information
3 people committed Jun 11, 2024
1 parent 3bba1c9 commit c134293
Show file tree
Hide file tree
Showing 50 changed files with 2,906 additions and 138 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
097b68f5616951d83b0c5b28345e6bfc9f0b1a5b
6c76b425f887a8adb3beb8ba8263200b9cdbb2c9
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ if [ "$OPTION" = 'help' ]; then
else
build() {
echo "Building Rive for platform=$platform option=$OPTION"
echo premake5 gmake2 --with_rive_text --with_rive_audio=system "$1"
PREMAKE="premake5 gmake2 --with_rive_text --with_rive_audio=system $1"
echo premake5 gmake2 --with_rive_text --with_rive_audio=system --with_rive_layout "$1"
PREMAKE="premake5 gmake2 --with_rive_text --with_rive_audio=system --with_rive_layout $1"
eval "$PREMAKE"
if [ "$OPTION" = "clean" ]; then
make clean
Expand Down
13 changes: 13 additions & 0 deletions build/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ do
'MA_NO_RESOURCE_MANAGER',
})
end
filter({ 'options:with_rive_layout' })
do
defines({ 'WITH_RIVE_LAYOUT' })
end
filter({})

dofile(path.join(path.getabsolute('../dependencies/'), 'premake5_harfbuzz.lua'))
dofile(path.join(path.getabsolute('../dependencies/'), 'premake5_sheenbidi.lua'))
dofile(path.join(path.getabsolute('../dependencies/'), 'premake5_miniaudio.lua'))
dofile(path.join(path.getabsolute('../dependencies/'), 'premake5_yoga.lua'))

project('rive')
do
Expand All @@ -43,8 +48,11 @@ do
harfbuzz .. '/src',
sheenbidi .. '/Headers',
miniaudio,
yoga
})

defines({ 'YOGA_EXPORT=' })

files({ '../src/**.cpp' })

flags({ 'FatalCompileWarnings' })
Expand Down Expand Up @@ -205,3 +213,8 @@ newoption({
description = 'The audio mode to use.',
allowed = { { 'disabled' }, { 'system' }, { 'external' } },
})

newoption({
trigger = 'with_rive_layout',
description = 'Compiles in layout features.',
})
138 changes: 138 additions & 0 deletions dependencies/premake5_yoga.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
local dependency = require('dependency')
yoga = dependency.github('rive-app/yoga', 'rive_changes_v2_0_1')

workspace('rive')
configurations({ 'debug', 'release' })

project('rive_yoga')
do
kind('StaticLib')
language('C++')
cppdialect('C++11')
targetdir('%{cfg.system}/cache/bin/%{cfg.buildcfg}/')
objdir('%{cfg.system}/cache/obj/%{cfg.buildcfg}/')
warnings('Off')

defines({ 'YOGA_EXPORT=' })

includedirs({ yoga })

files({
yoga .. '/yoga/Utils.cpp',
yoga .. '/yoga/YGConfig.cpp',
yoga .. '/yoga/YGLayout.cpp',
yoga .. '/yoga/YGEnums.cpp',
yoga .. '/yoga/YGNodePrint.cpp',
yoga .. '/yoga/YGNode.cpp',
yoga .. '/yoga/YGValue.cpp',
yoga .. '/yoga/YGStyle.cpp',
yoga .. '/yoga/Yoga.cpp',
yoga .. '/yoga/event/event.cpp',
yoga .. '/yoga/log.cpp',
})

buildoptions({ '-Wall', '-pedantic' })

linkoptions({ '-r' })

filter('system:emscripten')
do
buildoptions({ '-pthread' })
end

filter('configurations:debug')
do
defines({ 'DEBUG' })
symbols('On')
end

filter('toolset:clang')
do
flags({ 'FatalWarnings' })
buildoptions({
'-Werror=format',
'-Wimplicit-int-conversion',
'-Werror=vla',
})
end

filter('configurations:release')
do
buildoptions({ '-Oz' })
defines({ 'RELEASE', 'NDEBUG' })
optimize('On')
end

filter({ 'system:macosx', 'options:variant=runtime' })
do
buildoptions({
'-Wimplicit-float-conversion -fembed-bitcode -arch arm64 -arch x86_64 -isysroot'
.. (os.getenv('MACOS_SYSROOT') or ''),
})
end

filter({ 'system:macosx', 'configurations:release' })
do
buildoptions({ '-flto=full' })
end

filter({ 'system:ios' })
do
buildoptions({ '-flto=full' })
end

filter('system:windows')
do
architecture('x64')
defines({ '_USE_MATH_DEFINES' })
end

filter({ 'system:ios', 'options:variant=system' })
do
buildoptions({
'-mios-version-min=13.0 -fembed-bitcode -arch arm64 -isysroot '
.. (os.getenv('IOS_SYSROOT') or ''),
})
end

filter({ 'system:ios', 'options:variant=emulator' })
do
buildoptions({
'--target=arm64-apple-ios13.0.0-simulator',
'-mios-version-min=13.0 -arch arm64 -arch x86_64 -isysroot '
.. (os.getenv('IOS_SYSROOT') or ''),
})
targetdir('%{cfg.system}_sim/cache/bin/%{cfg.buildcfg}')
objdir('%{cfg.system}_sim/cache/obj/%{cfg.buildcfg}')
end

filter({ 'system:android', 'configurations:release' })
do
buildoptions({ '-flto=full' })
end

-- Is there a way to pass 'arch' as a variable here?
filter({ 'system:android', 'options:arch=x86' })
do
targetdir('%{cfg.system}/cache/x86/bin/%{cfg.buildcfg}')
objdir('%{cfg.system}/cache/x86/obj/%{cfg.buildcfg}')
end

filter({ 'system:android', 'options:arch=x64' })
do
targetdir('%{cfg.system}/cache/x64/bin/%{cfg.buildcfg}')
objdir('%{cfg.system}/cache/x64/obj/%{cfg.buildcfg}')
end

filter({ 'system:android', 'options:arch=arm' })
do
targetdir('%{cfg.system}/cache/arm/bin/%{cfg.buildcfg}')
objdir('%{cfg.system}/cache/arm/obj/%{cfg.buildcfg}')
end

filter({ 'system:android', 'options:arch=arm64' })
do
targetdir('%{cfg.system}/cache/arm64/bin/%{cfg.buildcfg}')
objdir('%{cfg.system}/cache/arm64/obj/%{cfg.buildcfg}')
end
end
28 changes: 28 additions & 0 deletions dependencies/premake5_yoga_v2.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
dofile('rive_build_config.lua')

local dependency = require('dependency')
yoga = dependency.github('rive-app/yoga', 'rive_changes_v2_0_1')

project('rive_yoga')
do
kind('StaticLib')
warnings('Off')

defines({ 'YOGA_EXPORT=' })

includedirs({ yoga })

files({
yoga .. '/yoga/Utils.cpp',
yoga .. '/yoga/YGConfig.cpp',
yoga .. '/yoga/YGLayout.cpp',
yoga .. '/yoga/YGEnums.cpp',
yoga .. '/yoga/YGNodePrint.cpp',
yoga .. '/yoga/YGNode.cpp',
yoga .. '/yoga/YGValue.cpp',
yoga .. '/yoga/YGStyle.cpp',
yoga .. '/yoga/Yoga.cpp',
yoga .. '/yoga/event/event.cpp',
yoga .. '/yoga/log.cpp',
})
end
29 changes: 1 addition & 28 deletions dev/defs/artboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,8 @@
"int": 1,
"string": "artboard"
},
"extends": "world_transform_component.json",
"extends": "layout_component.json",
"properties": {
"clip": {
"type": "bool",
"initialValue": "true",
"key": {
"int": 196,
"string": "clip"
},
"description": "True when the artboard bounds clip its contents."
},
"width": {
"type": "double",
"initialValue": "0",
"key": {
"int": 7,
"string": "w"
},
"description": "Width of the artboard."
},
"height": {
"type": "double",
"initialValue": "0",
"key": {
"int": 8,
"string": "h"
},
"description": "Height of the artboard."
},
"x": {
"type": "double",
"initialValue": "0",
Expand Down
Loading

0 comments on commit c134293

Please sign in to comment.