Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: duplicate worklets code the smart way #6827

Merged
merged 42 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2f8b9c4
feat: stub of node module react-native-worklets
tjzel Dec 11, 2024
fcfda4f
feat: preliminary use of react-native-worklets in reanimated
tjzel Dec 11, 2024
a9b6af2
chore: fix CMakeLists
tjzel Dec 12, 2024
96b76d7
Merge branch 'main' into @tjzel/worklets/node-module-with-rea-support
tjzel Dec 12, 2024
3ee4d4f
chore: add explanatory comments
tjzel Dec 17, 2024
1f40ace
feat: add linting to react-native-worklets
tjzel Dec 17, 2024
7fccc99
chore: add missing dependency
tjzel Dec 17, 2024
661706a
chore: add external-worklets-example
tjzel Dec 12, 2024
b127bea
chore: fix FabricExample occurences
tjzel Dec 17, 2024
a507fdc
chore: update github actions
tjzel Dec 17, 2024
afd030d
chore: fix CI
tjzel Dec 17, 2024
2634199
chore: remove excessive changes
tjzel Dec 12, 2024
64aea46
chore: remove external worklets
tjzel Jan 20, 2025
3701183
chore: cleanup
tjzel Jan 20, 2025
ceee2f7
chore: draft duplication
tjzel Dec 17, 2024
62c9488
chore: cleanup
tjzel Jan 21, 2025
50d3f00
chore: improve react-native-worklets detection script
tjzel Jan 21, 2025
7e75fb3
refactor: move ReanimatedVersion to Reanimated
tjzel Jan 21, 2025
88e38c0
Merge branch 'main' into @tjzel/worklets/restructure-worklets-source-…
tjzel Jan 23, 2025
08ad6ab
chore: cleanup
tjzel Jan 23, 2025
6a35149
chore: cleanup
tjzel Jan 23, 2025
45a4c27
Merge branch 'main' into @tjzel/worklets/restructure-worklets-source-…
tjzel Jan 23, 2025
1bcb1a9
Merge remote-tracking branch 'origin/@tjzel/worklets/restructure-work…
tjzel Jan 24, 2025
077304b
chore: fix CI issues
tjzel Jan 24, 2025
2017a8e
refactor: actually copy from worklets
tjzel Jan 24, 2025
6a85786
chore: fix dir
tjzel Jan 24, 2025
48669d5
chore: remove worklets
tjzel Jan 24, 2025
cb09fa5
refactor: major
tjzel Jan 27, 2025
8604d29
chore: apple
tjzel Jan 27, 2025
627827d
refactor: adjust to downstream changes
tjzel Jan 27, 2025
8d30b32
Merge branch 'main' into @tjzel/worklets/restructure-worklets-source-…
tjzel Jan 27, 2025
5585839
chore: update CI
tjzel Jan 27, 2025
8b9319c
chore: dont fire CIs twice
tjzel Jan 27, 2025
55301e8
chore: fix java package
tjzel Jan 27, 2025
3b9eac8
Merge branch '@tjzel/worklets/restructure-worklets-source-sets' into …
tjzel Jan 27, 2025
2cd50bc
chore: update CI
tjzel Jan 27, 2025
15c4fba
Merge branch '@tjzel/worklets/restructure-worklets-source-sets' into …
tjzel Jan 28, 2025
70ededc
chore: cleanup
tjzel Jan 28, 2025
85b3e07
chore: apply formatting
tjzel Jan 28, 2025
daad12a
Merge branch 'main' into @tjzel/worklets/duplicate-reanimated-code
tjzel Jan 28, 2025
8aa02a7
chore: add targets to build gradle`
tjzel Jan 28, 2025
510cbff
chore: restore order
tjzel Jan 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: stub of node module react-native-worklets
  • Loading branch information
tjzel committed Dec 11, 2024
commit 2f8b9c4653657e9e2dccdfc59d87e801bcec0856
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"packages/react-native-reanimated",
"packages/eslint-plugin-reanimated",
"packages/react-native-reanimated/plugin",
"packages/react-native-worklets",
"apps/common-app",
"apps/paper-example",
"apps/fabric-example",
Expand Down
4 changes: 4 additions & 0 deletions packages/react-native-worklets/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('eslint').ESLint.ConfigData} */
module.exports = {
extends: ['../../.eslintrc.js'],
};
3 changes: 3 additions & 0 deletions packages/react-native-worklets/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.pbxproj -text
# specific for windows script files
*.bat text eol=crlf
62 changes: 62 additions & 0 deletions packages/react-native-worklets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# OSX
.DS_Store

# VSCode
.vscode/
jsconfig.json

# Xcode
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IJ
.classpath
.cxx
.gradle
.idea
.project
.settings
local.properties
android.iml

# node.js
node_modules/
npm-debug.log
yarn-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
android/app/libs
android/keystores/debug.keystore

# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# generated by bob
lib/

# React Native Codegen
apple/generated
android/generated
1 change: 1 addition & 0 deletions packages/react-native-worklets/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
20 changes: 20 additions & 0 deletions packages/react-native-worklets/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
MIT License

Copyright (c) 2024 nobody
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
64 changes: 64 additions & 0 deletions packages/react-native-worklets/RNWorklets.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
require "json"

package = JSON.parse(File.read(File.join(__dir__, "package.json")))
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'

Pod::Spec.new do |s|
s.name = "RNWorklets"
s.version = package["version"]
s.summary = package["description"]
s.homepage = "https://github.com/software-mansion/react-native-reanimated"
s.license = package["license"]
s.authors = { "author" => "[email protected]" }
s.platforms = { :ios => min_ios_version_supported }
s.source = { :git => "https://github.com/software-mansion/react-native-reanimated.git", :tag => "#{s.version}" }

s.source_files = "apple/*.{h,m,mm,cpp}"

s.subspec "worklets" do |ss|
ss.source_files = "Common/cpp/worklets/**/*.{cpp,h}"
ss.header_dir = "worklets"
ss.header_mappings_dir = "Common/cpp/worklets"

ss.subspec "apple" do |sss|
# Please be careful with the snakes.
# 🐍🐍🐍
# Thank you for your understanding.
sss.source_files = "apple/worklets/**/*.{mm,h,m}"
sss.header_dir = "worklets"
sss.header_mappings_dir = "apple/worklets"
end
end

# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
if respond_to?(:install_modules_dependencies, true)
install_modules_dependencies(s)
else
s.dependency "React-Core"

# Don't install the dependencies when we run `pod install` in the old architecture.
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
s.pod_target_xcconfig = {
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
}
s.dependency "React-Codegen"
s.dependency "RCT-Folly"
s.dependency "RCTRequired"
s.dependency "RCTTypeSafety"
s.dependency "ReactCommon/turbomodule/core"
end
end

s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
"DEFINES_MODULE" => "YES",
"HEADER_SEARCH_PATHS" => '"$(PODS_TARGET_SRCROOT)/ReactCommon" "$(PODS_TARGET_SRCROOT)" "$(PODS_ROOT)/RCT-Folly" "$(PODS_ROOT)/boost" "$(PODS_ROOT)/boost-for-react-native" "$(PODS_ROOT)/DoubleConversion" "$(PODS_ROOT)/Headers/Private/React-Core" "$(PODS_ROOT)/Headers/Private/Yoga"',
"FRAMEWORK_SEARCH_PATHS" => '"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes"',
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
}

end
60 changes: 60 additions & 0 deletions packages/react-native-worklets/android/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
project(Worklets)
cmake_minimum_required(VERSION 3.8)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS
ON
CACHE INTERNAL "")

set(CMAKE_CXX_STANDARD 20)

# default CMAKE_CXX_FLAGS: "-g -DANDROID -fdata-sections -ffunction-sections
# -funwind-tables -fstack-protector-strong -no-canonical-prefixes
# -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-protector-all"
include("${REACT_NATIVE_DIR}/ReactAndroid/cmake-utils/folly-flags.cmake")
add_compile_options(${folly_FLAGS})

string(
APPEND
CMAKE_CXX_FLAGS
" -DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION} -DREANIMATED_VERSION=${REANIMATED_VERSION} -DHERMES_ENABLE_DEBUGGER=${HERMES_ENABLE_DEBUGGER}"
)

string(
APPEND
CMAKE_CXX_FLAGS
" -fexceptions -fno-omit-frame-pointer -frtti -fstack-protector-all -std=c++${CMAKE_CXX_STANDARD} -Wall -Werror"
)

if(${IS_NEW_ARCHITECTURE_ENABLED})
string(APPEND CMAKE_CXX_FLAGS " -DRCT_NEW_ARCH_ENABLED")
endif()

if(${IS_REANIMATED_EXAMPLE_APP})
string(APPEND CMAKE_CXX_FLAGS " -DIS_REANIMATED_EXAMPLE_APP -Wpedantic")
endif()

if(NOT ${CMAKE_BUILD_TYPE} MATCHES "Debug")
string(APPEND CMAKE_CXX_FLAGS " -DNDEBUG")
endif()

if(${JS_RUNTIME} STREQUAL "hermes")
string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_HERMES=1")
elseif(${JS_RUNTIME} STREQUAL "jsc")
string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_JSC=1")
elseif(${JS_RUNTIME} STREQUAL "v8")
string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_V8=1")
else()
message(FATAL_ERROR "Unknown JS runtime ${JS_RUNTIME}.")
endif()

# Resolves "CMake Warning: Manually-specified variables were not used by the
# project" when any of the following variables is not used in some build
# configuration.
set(ignoreMe "${JS_RUNTIME_DIR}")

set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build")
set(ANDROID_CPP_DIR "${CMAKE_SOURCE_DIR}/src/main/cpp")
set(COMMON_CPP_DIR "${CMAKE_SOURCE_DIR}/../Common/cpp")

add_subdirectory("${ANDROID_CPP_DIR}/worklets")
Loading
Loading