Skip to content

Commit

Permalink
Major Rive refactor (#98)
Browse files Browse the repository at this point in the history
* Example crash setup.

* Stats and insights integration.

* add insights named events

* Refactor: RiveFile is data only, Simplified Rive actor component, widget actor, and userwidget types; Cleaned up editor ticking UR-148, Support reimporting rive files

* cleanup a few missing details

* cleanup thumbnail renderer

* remove unused

* rive build script,  build both release and debug libs (with debug libs having a _d suffix)

* add build comment

* missing quote

* exclude darwin from rive_ lib prefix

* expose riveblendmode to URiveWidget

* Don't expose riveblend mode

* refactor RiveCore out, remove namespaces, rename Rive facilities more consistently

* remove rivedescriptor.cpp

* change redirects

* fix errorneous macro

* removed now unused bp ready async; these will be localized

* remove now unused onartboardchanged

* bring back do_android in build-rive

* ensure import is wrapped with editor macro

* UR-148 - rivefile assetdataonly (#94)

* Refactor: RiveFile is data only, Simplified Rive actor component, widget actor, and userwidget types; Cleaned up editor ticking UR-148, Support reimporting rive files

* cleanup a few missing details

* cleanup thumbnail renderer

* remove unused

* expose riveblendmode to URiveWidget

* Don't expose riveblend mode

* change redirects

* fix errorneous macro

* bring back do_android in build-rive

* ensure import is wrapped with editor macro

* just ensure screenuserwidget is available

* cleanup thumbnail renderer when a rivefile asset is removed

* expose WidgetClass ref to editor interface

* cleanup initialization for riveactorcomponent, riveobject, rivewidget

* don't overwrite widget in widget factory unless it's invalid

* remove outdated redirects

* rename RenderObjects, add function to determine if custom rendering is used

* use riveobject's descriptor for alignment/fit

* resize RiveWidget's render texture to match size after a few frames

* perform riveobject setup in widget after a few frames in it's entirety

* check widget validity before continuing

* remove bManualSize from riveobject, implement defaultartboardtick for default rivedescriptor in actor component

* Update Rive to the latest libraries (#97)

* update to latest rive libs, cleaned up RiveLibrary.Build.cs; Win64 release and debug

* macOS updated rive libs

* make sure to build libjpeg with the build script

* update win libs

* update macos libs

* update rive libs

* add commented out rive_yoga line

* update rive libs

* update rive libs

* update rive libs apple

* don't compile in yoga until we need it

* provide a method in which we can dynamically patch for android as-needed

* remove wait

* fix build script output for android

* fix build script copy_files

* remove destpath print

* update winows and android

* update apple


* Nested Inputs

* RiveWidget improvements and guards

---------

Co-authored-by: Braedy Kuzma <[email protected]>
Co-authored-by: Batname <[email protected]>
  • Loading branch information
3 people authored Jun 24, 2024
1 parent de8a6a2 commit fa93416
Show file tree
Hide file tree
Showing 355 changed files with 8,459 additions and 3,253 deletions.
7 changes: 4 additions & 3 deletions Config/DefaultRive.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[CoreRedirects]
+FunctionRedirects=(OldName="/Script/RiveCore.RiveArtboard.MouseButtonDown",NewName="/Script/RiveCore.RiveArtboard.PointerDown")
+FunctionRedirects=(OldName="/Script/RiveCore.RiveArtboard.MouseButtonUp",NewName="/Script/RiveCore.RiveArtboard.PointerUp")
+FunctionRedirects=(OldName="/Script/RiveCore.RiveArtboard.MouseMove",NewName="/Script/RiveCore.RiveArtboard.PointerMove")
+PropertyRedirects=(OldName="/Script/Rive.RiveActorComponent.RenderTarget",NewName="/Script/Rive.RiveActorComponent.RiveTexture")
+ClassRedirects=(OldName="/Script/Rive.RiveActor",NewName="/Script/Rive.RiveWidgetActor")
+PropertyRedirects=(OldName="/Script/Rive.RiveFile.RiveFilePath",NewName="/Script/Rive.RiveFile.RiveFilePath_DEPRECATED")
+FunctionRedirects=(OldName="/Script/Rive.RiveActorComponent.InstantiateArtboard",NewName="/Script/Rive.RiveActorComponent.AddArtboard")
6 changes: 0 additions & 6 deletions Rive.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@
"Type": "Editor",
"LoadingPhase": "Default",
"WhitelistPlatforms": ["Win64", "Mac", "IOS", "Android"]
},
{
"Name": "RiveCore",
"Type": "Runtime",
"LoadingPhase": "None",
"WhitelistPlatforms": ["Win64", "Mac", "IOS", "Android"]
}
]
}
90 changes: 58 additions & 32 deletions Scripts/build-rive/build-rive.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys

# install requirements via pip install -r requirements.txt
# runnning: python3 build-rive.py <path-to-rive-renderer-root>
# running: python3 build-rive.py <path-to-rive-renderer-root>

script_directory = os.path.dirname(os.path.abspath(__file__))

Expand All @@ -16,20 +16,21 @@
'rive_pls_renderer',
'rive_pls_shaders',
'rive_sheenbidi',
# 'rive_yoga',
'libpng',
'libjpeg',
'zlib'
]

def get_base_command(rive_renderer_path, release):
return (
f"premake5 --scripts=\"{rive_renderer_path}/submodules/rive-cpp/build\" "
f"--with_rive_text --with_rive_audio=external {'--release' if release else ''}"
f"--with_rive_text --with_rive_audio=external {'--config=release' if release else '--config=debug'}"
)

@click.command()
@click.argument('rive_renderer_path')
@click.option('--release', is_flag=True, default=False)
def main(rive_renderer_path, release):
def main(rive_renderer_path):
if sys.platform.startswith('darwin'):
os.environ["MACOSX_DEPLOYMENT_TARGET"] = '11.0'
# determine a sane build environment
Expand All @@ -41,16 +42,29 @@ def main(rive_renderer_path, release):
else:
print_green(f"Using SDK at: {output}")

if not do_mac(rive_renderer_path, release):
if not do_mac(rive_renderer_path, True) or not do_mac(rive_renderer_path, False):
return

if not do_ios(rive_renderer_path, release):
if not do_ios(rive_renderer_path, True) or not do_ios(rive_renderer_path, False):
return
elif sys.platform.startswith('win32'):
if not do_windows(rive_renderer_path, release):
if not do_windows(rive_renderer_path, True) or not do_windows(rive_renderer_path, False):
return

if not do_android(rive_renderer_path, release):
# apply android patch before android
os.chdir(os.path.join(rive_renderer_path, 'submodules', 'rive-cpp'))
patch_output = subprocess.check_output(['git', 'apply', f'{os.path.join(script_directory, "patches", "android.patch")}'], universal_newlines=True)
print(patch_output)
android_succeeded = True
if not do_android(rive_renderer_path, True) or not do_android(rive_renderer_path, False):
android_succeeded = False

# unapply android patch after
os.chdir(os.path.join(rive_renderer_path, 'submodules', 'rive-cpp'))
patch_output = subprocess.check_output(['git', 'apply', '-R', f'{os.path.join(script_directory, "patches", "android.patch")}'], universal_newlines=True)
print(patch_output)

if not android_succeeded:
return
else:
print_red("Unsupported platform")
Expand All @@ -73,25 +87,27 @@ def get_msbuild():

def do_android(rive_renderer_path, release):
try:
out_dir = os.path.join('out', 'android', 'release' if release else 'debug')
os.chdir(rive_renderer_path)

if 'NDK_ROOT' in os.environ and 'NDK_PATH' not in os.environ:
os.environ['NDK_PATH'] = os.environ['NDK_ROOT']

command = f'{get_base_command(rive_renderer_path, release)} --os=android --arch=arm64 --out=out/android vs2022'
command = f'{get_base_command(rive_renderer_path, release)} --os=android --arch=arm64 --out="{out_dir}" vs2022'
execute_command(command)

msbuild_path = get_msbuild()

os.chdir(os.path.join(rive_renderer_path, 'out', 'android'))
os.chdir(out_dir)
execute_command(f'"{msbuild_path}" ./rive.sln /t:{";".join(targets)}')

print_green(f'Built in {os.getcwd()}')

os.chdir(os.path.join('ARM64', 'default'))
rive_libraries_path = os.path.join(script_directory, '..', '..', 'Source', 'ThirdParty', 'RiveLibrary', 'Libraries')

print_green('Copying Android libs')
copy_files(os.getcwd(), os.path.join(rive_libraries_path, 'Android'), ".a")
copy_files(os.getcwd(), os.path.join(rive_libraries_path, 'Android'), ".a", release)
except Exception as e:
print_red(f"Exiting due to errors... {e}")
return False
Expand All @@ -101,21 +117,22 @@ def do_android(rive_renderer_path, release):

def do_windows(rive_renderer_path, release):
try:
out_dir = os.path.join('out', 'windows', 'release' if release else 'debug')
os.chdir(rive_renderer_path)
command = f'{get_base_command(rive_renderer_path, release)} --windows_runtime=dynamic --os=windows --out=out/windows vs2022'
command = f'{get_base_command(rive_renderer_path, release)} --windows_runtime=dynamic --os=windows --out="{out_dir}" vs2022'
execute_command(command)

msbuild_path = get_msbuild()

os.chdir(os.path.join(rive_renderer_path, 'out', 'windows'))
os.chdir(out_dir)
execute_command(f'"{msbuild_path}" ./rive.sln /t:{";".join(targets)}')

print_green(f'Built in {os.getcwd()}')

rive_libraries_path = os.path.join(script_directory, '..', '..', 'Source', 'ThirdParty', 'RiveLibrary', 'Libraries')

print_green('Copying Windows')
copy_files(os.getcwd(), os.path.join(rive_libraries_path, 'Win64'), ".lib")
copy_files(os.getcwd(), os.path.join(rive_libraries_path, 'Win64'), ".lib", release)
except Exception as e:
print_red("Exiting due to errors...")
print_red(e)
Expand All @@ -131,16 +148,18 @@ def do_ios(rive_renderer_path, release):
build_dirs = {}

print_green('Building iOS')
execute_command(f'{command} --variant=system --out=out/ios')
os.chdir(os.path.join(rive_renderer_path, 'out', 'ios'))
out_dir = os.path.join('out', 'ios', 'release' if release else 'debug')
execute_command(f'{command} --variant=system --out="{out_dir}"')
os.chdir(out_dir)
build_dirs['ios'] = os.getcwd()
for target in targets:
execute_command(f'make {target}')

print_green('Building iOS Simulator')
out_dir = os.path.join('out', 'ios_sim', 'release' if release else 'debug')
os.chdir(rive_renderer_path)
execute_command(f'{command} --variant=emulator --out=out/ios_sim')
os.chdir(os.path.join(rive_renderer_path, 'out', 'ios_sim'))
execute_command(f'{command} --variant=emulator --out="{out_dir}"')
os.chdir(out_dir)
build_dirs['ios_sim'] = os.getcwd()
for target in targets:
execute_command(f'make {target}')
Expand Down Expand Up @@ -170,8 +189,8 @@ def do_ios(rive_renderer_path, release):
rive_libraries_path = os.path.join(script_directory, '..', '..', 'Source', 'ThirdParty', 'RiveLibrary', 'Libraries')

print_green('Copying iOS and iOS simulator')
copy_files(build_dirs['ios'], os.path.join(rive_libraries_path, 'IOS'), ".a")
copy_files(build_dirs['ios_sim'], os.path.join(rive_libraries_path, 'IOS'), ".a")
copy_files(build_dirs['ios'], os.path.join(rive_libraries_path, 'IOS'), ".a", release)
copy_files(build_dirs['ios_sim'], os.path.join(rive_libraries_path, 'IOS'), ".sim.a", release)
except Exception as e:
print_red("Exiting due to errors...")
print_red(e)
Expand All @@ -182,7 +201,6 @@ def do_ios(rive_renderer_path, release):

def do_mac(rive_renderer_path, release):
try:
os.chdir(rive_renderer_path)
command = f'{get_base_command(rive_renderer_path, release)} --os=macosx gmake2'
build_dirs = {}

Expand All @@ -197,16 +215,19 @@ def do_mac(rive_renderer_path, release):


print_green('Building macOS x64')
execute_command(f'{command} --arch=x64 --out=out/mac_x64')
os.chdir(os.path.join(rive_renderer_path, 'out', 'mac_x64'))
out_dir = os.path.join('out', 'mac', 'x64', 'release' if release else 'debug')
os.chdir(rive_renderer_path)
execute_command(f'{command} --arch=x64 --out="{out_dir}"')
os.chdir(out_dir)
build_dirs['mac_x64'] = os.getcwd()
for target in targets:
execute_command(f'make {target}')

print_green('Building macOS x64')
print_green('Building macOS arm64')
out_dir = os.path.join('out', 'mac', 'arm64', 'release' if release else 'debug')
os.chdir(rive_renderer_path)
execute_command(f'{command} --arch=arm64 --out=out/mac_arm64')
os.chdir(os.path.join(rive_renderer_path, 'out', 'mac_arm64'))
execute_command(f'{command} --arch=arm64 --out="{out_dir}"')
os.chdir(out_dir)
build_dirs['mac_arm64'] = os.getcwd()
for target in targets:
execute_command(f'make {target}')
Expand All @@ -217,8 +238,8 @@ def do_mac(rive_renderer_path, release):
rive_libraries_path = os.path.join(script_directory, '..', '..', 'Source', 'ThirdParty', 'RiveLibrary', 'Libraries')

print_green('Copying macOS x64')
copy_files(build_dirs['mac_x64'], os.path.join(rive_libraries_path, 'Mac', 'Intel'), ".a")
copy_files(build_dirs['mac_arm64'], os.path.join(rive_libraries_path, 'Mac', 'Mac'), ".a")
copy_files(build_dirs['mac_x64'], os.path.join(rive_libraries_path, 'Mac', 'Intel'), ".a", release)
copy_files(build_dirs['mac_arm64'], os.path.join(rive_libraries_path, 'Mac', 'Mac'), ".a", release)
except Exception as e:
print_red("Exiting due to errors...")
print_red(e)
Expand All @@ -227,7 +248,7 @@ def do_mac(rive_renderer_path, release):
return True


def copy_files(src, dst, extension):
def copy_files(src, dst, extension, is_release):
# Ensure the source directory exists
if not os.path.exists(src):
print_red(f"The source directory {src} does not exist.")
Expand All @@ -237,10 +258,15 @@ def copy_files(src, dst, extension):

for root, dirs, files in os.walk(src):
files_to_copy = [f for f in files if f.endswith(extension)]
for file in files_to_copy:
src_path = os.path.join(root, file)
for file_name in files_to_copy:
src_path = os.path.join(root, file_name)

# ensure all libs are prefixed with "rive_" on non-darwin / apple platforms
if not sys.platform.startswith("darwin") and not file_name.startswith("rive") and not 'Android' in dst:
file_name = f'rive_{file_name}'

relative_path = os.path.relpath(root, src)
dest_path = os.path.join(dst, relative_path, file)
dest_path = os.path.join(dst, file_name if is_release else file_name.replace(extension, f'_d{extension}'))
os.makedirs(os.path.dirname(dest_path), exist_ok=True)
shutil.copy2(src_path, dest_path)

Expand Down
116 changes: 116 additions & 0 deletions Scripts/build-rive/patches/android.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
diff --git a/build/rive_build_config.lua b/build/rive_build_config.lua
index f6ff5103..5b69a75d 100644
--- a/build/rive_build_config.lua
+++ b/build/rive_build_config.lua
@@ -325,26 +325,26 @@ if _OPTIONS['os'] == 'android' then
filter('options:arch=x86')
do
architecture('x86')
- buildoptions({ '--target=i686-none-linux-android21' })
- linkoptions({ '--target=i686-none-linux-android21' })
+ buildoptions({ '--target=i686-none-linux-android31' })
+ linkoptions({ '--target=i686-none-linux-android31' })
end
filter('options:arch=x64')
do
architecture('x64')
- buildoptions({ '--target=x86_64-none-linux-android21' })
- linkoptions({ '--target=x86_64-none-linux-android21' })
+ buildoptions({ '--target=x86_64-none-linux-android31' })
+ linkoptions({ '--target=x86_64-none-linux-android31' })
end
filter('options:arch=arm')
do
architecture('arm')
- buildoptions({ '--target=armv7a-none-linux-android21' })
- linkoptions({ '--target=armv7a-none-linux-android21' })
+ buildoptions({ '--target=armv7a-none-linux-android31' })
+ linkoptions({ '--target=armv7a-none-linux-android31' })
end
filter('options:arch=arm64')
do
architecture('arm64')
- buildoptions({ '--target=aarch64-none-linux-android21' })
- linkoptions({ '--target=aarch64-none-linux-android21' })
+ buildoptions({ '--target=aarch64-none-linux-android31' })
+ linkoptions({ '--target=aarch64-none-linux-android31' })
end

filter({})
diff --git a/build/setup_compiler.lua b/build/setup_compiler.lua
index 88f54630..5dec770a 100644
--- a/build/setup_compiler.lua
+++ b/build/setup_compiler.lua
@@ -212,26 +212,26 @@ if _OPTIONS['os'] == 'android' then
filter('options:arch=x86')
do
architecture('x86')
- buildoptions({ '--target=i686-none-linux-android21' })
- linkoptions({ '--target=i686-none-linux-android21' })
+ buildoptions({ '--target=i686-none-linux-android31' })
+ linkoptions({ '--target=i686-none-linux-android31' })
end
filter('options:arch=x64')
do
architecture('x64')
- buildoptions({ '--target=x86_64-none-linux-android21' })
- linkoptions({ '--target=x86_64-none-linux-android21' })
+ buildoptions({ '--target=x86_64-none-linux-android31' })
+ linkoptions({ '--target=x86_64-none-linux-android31' })
end
filter('options:arch=arm')
do
architecture('arm')
- buildoptions({ '--target=armv7a-none-linux-android21' })
- linkoptions({ '--target=armv7a-none-linux-android21' })
+ buildoptions({ '--target=armv7a-none-linux-android31' })
+ linkoptions({ '--target=armv7a-none-linux-android31' })
end
filter('options:arch=arm64')
do
architecture('arm64')
- buildoptions({ '--target=aarch64-none-linux-android21' })
- linkoptions({ '--target=aarch64-none-linux-android21' })
+ buildoptions({ '--target=aarch64-none-linux-android31' })
+ linkoptions({ '--target=aarch64-none-linux-android31' })
end
filter({})
end
diff --git a/dependencies/premake5_harfbuzz_v2.lua b/dependencies/premake5_harfbuzz_v2.lua
index 428aa156..27b12025 100644
--- a/dependencies/premake5_harfbuzz_v2.lua
+++ b/dependencies/premake5_harfbuzz_v2.lua
@@ -266,7 +266,7 @@ do

filter('options:config=release')
do
- optimize('Size')
+ -- optimize('Size')
end

filter({ 'options:not no-harfbuzz-renames' })
diff --git a/dependencies/premake5_sheenbidi_v2.lua b/dependencies/premake5_sheenbidi_v2.lua
index f7410050..d6cc1cc2 100644
--- a/dependencies/premake5_sheenbidi_v2.lua
+++ b/dependencies/premake5_sheenbidi_v2.lua
@@ -47,6 +47,6 @@ do
filter('options:config=release')
do
defines({ 'SB_CONFIG_UNITY' })
- optimize('Size')
+ -- optimize('Size')
end
end
diff --git a/premake5_v2.lua b/premake5_v2.lua
index 3d6c8aa5..d5078a55 100644
--- a/premake5_v2.lua
+++ b/premake5_v2.lua
@@ -50,7 +50,7 @@ do

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

- flags({ 'FatalCompileWarnings' })
+ -- flags({ 'FatalCompileWarnings' })

filter({ 'options:with_rive_text', 'options:not no-harfbuzz-renames' })
do
Loading

0 comments on commit fa93416

Please sign in to comment.