Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ is_gh_example_app = ENV["GH_EXAMPLE_APP_NAME"] != nil

compilation_metadata_dir = "CompilationDatabase"
compilation_metadata_generation_flag = is_gh_example_app ? '-gen-cdb-fragment-path ' + compilation_metadata_dir : ''
version_flag = "-DREACT_NATIVE_MINOR_VERSION=#{GestureHandlerUtils.get_react_native_minor_version()}"
use_worklets = GestureHandlerUtils.react_native_worklets_supports_stable_api()
worklets_flag = use_worklets ? '-DRNGH_USE_WORKLETS=1' : ''

Expand All @@ -24,7 +23,7 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.platforms = { ios: '15.1', tvos: '15.1', osx: '14.0', visionos: '1.0' }
s.xcconfig = {
"OTHER_CFLAGS" => "$(inherited) #{compilation_metadata_generation_flag} #{version_flag} #{worklets_flag}"
"OTHER_CFLAGS" => "$(inherited) #{compilation_metadata_generation_flag} #{worklets_flag}"
}

install_modules_dependencies(s);
Expand Down
8 changes: 0 additions & 8 deletions packages/react-native-gesture-handler/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,6 @@ def reactNativeArchitectures() {

def REACT_NATIVE_DIR = resolveReactNativeDirectory()

def reactProperties = new Properties()
file("$REACT_NATIVE_DIR/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }

def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.split("\\.")[1].toInteger()

repositories {
mavenCentral()
}
Expand All @@ -177,13 +171,11 @@ android {
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 24)
targetSdkVersion safeExtGet('targetSdkVersion', 33)
buildConfigField "int", "REACT_NATIVE_MINOR_VERSION", REACT_NATIVE_MINOR_VERSION.toString()

externalNativeBuild {
cmake {
cppFlags "-O2", "-frtti", "-fexceptions", "-Wall", "-Werror", "-std=c++20", "-DANDROID"
arguments "-DREACT_NATIVE_DIR=${REACT_NATIVE_DIR}",
"-DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}",
"-DRNGH_USE_WORKLETS=${shouldUseRuntimeFromWorklets()}",
"-DANDROID_STL=c++_shared",
"-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
project(GestureHandler)
cmake_minimum_required(VERSION 3.9.0)

string(
APPEND
CMAKE_CXX_FLAGS
" -DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}")

set(CMAKE_VERBOSE_MAKEFILE ON)
if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 73)
Comment thread
j-piasecki marked this conversation as resolved.
set(CMAKE_CXX_STANDARD 20)
else()
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD 20)

set(PACKAGE_NAME "gesturehandler")
set(RNGH_DIR "${CMAKE_SOURCE_DIR}/../../../../")
Expand All @@ -23,6 +14,8 @@ file(GLOB_RECURSE gesture_handler_shared_SRCS CONFIGURE_DEPENDS "${RNGH_DIR}/sha
include(${REACT_ANDROID_DIR}/cmake-utils/folly-flags.cmake)
add_compile_options(${folly_FLAGS})

include(${REACT_NATIVE_DIR}/ReactCommon/cmake-utils/react-native-flags.cmake)
Comment thread
j-piasecki marked this conversation as resolved.

add_library(${PACKAGE_NAME}
SHARED
${gesture_handler_SRCS}
Expand All @@ -38,13 +31,11 @@ target_include_directories(
"${REACT_NATIVE_DIR}/ReactCommon"
)

if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 80)
target_compile_reactnative_options(${LIB_TARGET_NAME} PRIVATE)
endif()

find_package(ReactAndroid REQUIRED CONFIG)
find_package(fbjni REQUIRED CONFIG)

target_compile_reactnative_options(${PACKAGE_NAME} PRIVATE)
Comment thread
j-piasecki marked this conversation as resolved.

target_link_libraries(
${PACKAGE_NAME}
ReactAndroid::reactnative
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,6 @@ module GestureHandlerUtils

MIN_REACT_NATIVE_WORKLETS_VERSION = Gem::Version.new('0.8.0')

def try_to_parse_react_native_package_json(react_native_dir)
react_native_package_json_path = File.join(react_native_dir, 'package.json')

if !File.exist?(react_native_package_json_path)
return nil
end

return JSON.parse(File.read(react_native_package_json_path))
end

def get_react_native_minor_version()
react_native_dir = File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native/package.json')"`)
react_native_json = try_to_parse_react_native_package_json(react_native_dir)

if react_native_json == nil
node_modules_dir = ENV["REACT_NATIVE_NODE_MODULES_DIR"]
if node_modules_dir != nil
react_native_json = try_to_parse_react_native_package_json(File.join(node_modules_dir, 'react-native'))
end
end

if react_native_json == nil
raise '[react-native-gesture-handler] Unable to recognize your `react-native` version. Please set environmental variable with `react-native` location: `export REACT_NATIVE_NODE_MODULES_DIR="<path to react-native>" && pod install`.'
end

return react_native_json['version'].split('.')[1].to_i
end

def node_package_dir(package_name)
package_json_path = `cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('#{package_name}/package.json')" 2>/dev/null`.strip

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@ void RNGHRuntimeDecorator::installRNRuntimeBindings(
return jsi::Value::null();
}

#if REACT_NATIVE_MINOR_VERSION >= 81
auto shadowNode = Bridging<std::shared_ptr<const ShadowNode>>::fromJs(
runtime, args[0]);
#else
auto shadowNode = shadowNodeFromValue(runtime, args[0]);
#endif

#ifndef ANDROID
if (dynamic_pointer_cast<const ParagraphShadowNode>(shadowNode)) {
Expand Down
Loading