UNPKG

5.81 kBPlain TextView Raw
1require "json"
2require_relative './scripts/reanimated_utils'
3
4reanimated_package_json = JSON.parse(File.read(File.join(__dir__, "package.json")))
5$config = find_config()
6assert_latest_react_native_with_new_architecture($config, reanimated_package_json)
7assert_minimal_react_native_version($config)
8
9$new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
10is_release = ENV['PRODUCTION'] == '1'
11
12folly_flags = "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -DREACT_NATIVE_MINOR_VERSION=#{$config[:react_native_minor_version]}"
13folly_compiler_flags = "#{folly_flags} -Wno-comma -Wno-shorten-64-to-32"
14boost_compiler_flags = '-Wno-documentation'
15fabric_flags = $new_arch_enabled ? '-DRCT_NEW_ARCH_ENABLED' : ''
16example_flag = $config[:is_reanimated_example_app] ? '-DIS_REANIMATED_EXAMPLE_APP' : ''
17version_flag = "-DREANIMATED_VERSION=#{reanimated_package_json['version']}"
18debug_flag = is_release ? '-DNDEBUG' : ''
19ios_min_version = $config[:react_native_minor_version] >= 73 ? '13.4' : '9.0'
20
21# Directory in which data for further processing for clangd will be stored.
22compilation_metadata_dir = "CompilationDatabase"
23# We want generate the metadata only within the monorepo of Reanimated.
24compilation_metadata_generation_flag = $config[:is_reanimated_example_app] ? "-gen-cdb-fragment-path #{compilation_metadata_dir}" : ''
25
26def self.install_modules_dependencies_legacy(s)
27 using_hermes = ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == '1'
28 s.dependency "React-Core"
29 if $new_arch_enabled
30 s.dependency "React-RCTFabric"
31 s.dependency "ReactCodegen"
32 end
33 s.dependency "RCT-Folly"
34 s.dependency "RCTRequired"
35 s.dependency "RCTTypeSafety"
36 s.dependency 'FBLazyVector'
37 if $config[:react_native_minor_version] <= 71
38 s.dependency 'FBReactNativeSpec'
39 end
40 s.dependency 'React-Core'
41 s.dependency 'React-CoreModules'
42 s.dependency 'React-Core/DevSupport'
43 if !$config[:is_tvos_target]
44 s.dependency 'React-RCTActionSheet'
45 end
46 s.dependency 'React-RCTNetwork'
47 s.dependency 'React-RCTAnimation'
48 s.dependency 'React-RCTLinking'
49 s.dependency 'React-RCTBlob'
50 s.dependency 'React-RCTSettings'
51 s.dependency 'React-RCTText'
52 s.dependency 'React-RCTImage'
53 s.dependency 'React-Core/RCTWebSocket'
54 s.dependency 'React-cxxreact'
55 s.dependency 'React-jsi'
56 s.dependency 'React-jsiexecutor'
57 s.dependency 'React-jsinspector'
58 s.dependency 'Yoga'
59 s.dependency 'DoubleConversion'
60 s.dependency 'glog'
61 if using_hermes && !$config[:is_tvos_target] && $config[:react_native_minor_version] >= 70
62 s.dependency 'React-hermes'
63 s.dependency 'hermes-engine'
64 end
65 s.dependency 'React-callinvoker'
66 if $config[:react_native_minor_version] >= 72 && !$new_arch_enabled
67 s.dependency 'React-RCTAppDelegate'
68 end
69end
70
71Pod::Spec.new do |s|
72
73 s.name = "RNReanimated"
74 s.version = reanimated_package_json["version"]
75 s.summary = reanimated_package_json["description"]
76 s.description = <<-DESC
77 RNReanimated
78 DESC
79 s.homepage = "https://github.com/software-mansion/react-native-reanimated"
80 s.license = "MIT"
81 s.author = { "author" => "author@domain.cn" }
82 s.platforms = { :ios => ios_min_version, :tvos => "9.0", :osx => "10.14", :visionos => "1.0" }
83 s.source = { :git => "https://github.com/software-mansion/react-native-reanimated.git", :tag => "#{s.version}" }
84
85 s.subspec "reanimated" do |ss|
86 ss.source_files = "Common/cpp/reanimated/**/*.{cpp,h}"
87 ss.header_dir = "reanimated"
88 ss.header_mappings_dir = "Common/cpp/reanimated"
89
90 ss.subspec "apple" do |sss|
91 sss.source_files = "apple/reanimated/**/*.{mm,h,m}"
92 sss.header_dir = "reanimated"
93 sss.header_mappings_dir = "apple/reanimated"
94 end
95 end
96
97 s.subspec "worklets" do |ss|
98 ss.source_files = "Common/cpp/worklets/**/*.{cpp,h}"
99 ss.header_dir = "worklets"
100 ss.header_mappings_dir = "Common/cpp/worklets"
101 end
102
103 gcc_debug_definitions = "$(inherited)"
104 if $config[:react_native_minor_version] >= 73 || !is_release
105 gcc_debug_definitions << " HERMES_ENABLE_DEBUGGER=1"
106 end
107
108 s.pod_target_xcconfig = {
109 "USE_HEADERMAP" => "YES",
110 "DEFINES_MODULE" => "YES",
111 "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"',
112 "FRAMEWORK_SEARCH_PATHS" => '"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes"',
113 "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
114 "GCC_PREPROCESSOR_DEFINITIONS[config=Debug]" => gcc_debug_definitions,
115 "GCC_PREPROCESSOR_DEFINITIONS[config=Release]" => '$(inherited) NDEBUG=1',
116 }
117 s.compiler_flags = "#{folly_compiler_flags} #{boost_compiler_flags}"
118 s.xcconfig = {
119 "HEADER_SEARCH_PATHS" => [
120 '"$(PODS_ROOT)/boost"',
121 '"$(PODS_ROOT)/boost-for-react-native"',
122 '"$(PODS_ROOT)/glog"',
123 '"$(PODS_ROOT)/RCT-Folly"',
124 '"$(PODS_ROOT)/Headers/Public/React-hermes"',
125 '"$(PODS_ROOT)/Headers/Public/hermes-engine"',
126 "\"$(PODS_ROOT)/#{$config[:react_native_common_dir]}\"",
127 "\"$(PODS_ROOT)/#{$config[:react_native_reanimated_dir_from_pods_root]}/apple\"",
128 "\"$(PODS_ROOT)/#{$config[:react_native_reanimated_dir_from_pods_root]}/Common/cpp\"",
129 ].join(' '),
130 "OTHER_CFLAGS" => "$(inherited) #{folly_flags} #{fabric_flags} #{example_flag} #{version_flag} #{debug_flag} #{compilation_metadata_generation_flag}"
131 }
132 s.requires_arc = true
133 s.dependency "ReactCommon/turbomodule/core"
134 if defined?(install_modules_dependencies()) != nil
135 install_modules_dependencies(s)
136 else
137 install_modules_dependencies_legacy(s)
138 end
139end