1# Copyright (c) Meta Platforms, Inc. and affiliates.
2#
3# This source code is licensed under the MIT license found in the
4# LICENSE file in the root directory of this source tree.
5
6require "json"
7
8package = JSON.parse(File.read(File.join(__dir__, "..", "package.json")))
9version = package['version']
10
11
12
13folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -Wno-gnu-zero-variadic-macro-arguments'
14folly_version = '2021.07.22.00'
15boost_compiler_flags = '-Wno-documentation'
16using_hermes = ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == "1"
17Pod::Spec.new do |s|
18  s.name                   = "ABI48_0_0ReactCommon"
19  s.module_name            = "ABI48_0_0ReactCommon"
20  s.version                = version
21  s.summary                = "-"  # TODO
22  s.homepage               = "https://reactnative.dev/"
23  s.license                = package["license"]
24  s.author                 = "Facebook, Inc. and its affiliates"
25  s.platforms              = { :ios => "12.4" }
26  s.source                 = { :path => "." }
27  s.header_dir             = "ABI48_0_0ReactCommon" # Use global header_dir for all subspecs for use_frameworks! compatibility
28  s.compiler_flags         = folly_compiler_flags + ' ' + boost_compiler_flags
29  s.pod_target_xcconfig    = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/ABI48_0_0React-Core\"",
30                               "USE_HEADERMAP" => "YES", "DEFINES_MODULE" => "YES",
31                               "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
32                               "GCC_WARN_PEDANTIC" => "YES" }
33
34  # TODO (T48588859): Restructure this target to align with dir structure: "react/nativemodule/..."
35  # Note: Update this only when ready to minimize breaking changes.
36  s.subspec "turbomodule" do |ss|
37    ss.dependency "ABI48_0_0React-callinvoker", version
38    ss.dependency "ABI48_0_0React-perflogger", version
39    ss.dependency "ABI48_0_0React-Core", version
40    ss.dependency "ABI48_0_0React-cxxreact", version
41    ss.dependency "ABI48_0_0React-jsi", version
42    ss.dependency "RCT-Folly", folly_version
43    s.dependency "ABI48_0_0React-logger", version
44    ss.dependency "DoubleConversion"
45    ss.dependency "glog"
46    if using_hermes
47      ss.dependency "ABI48_0_0hermes-engine"
48    end
49
50    ss.subspec "bridging" do |sss|
51      sss.dependency           "ABI48_0_0React-jsi", version
52      sss.source_files         = "react/bridging/**/*.{cpp,h}"
53      sss.exclude_files        = "react/bridging/tests"
54      sss.header_dir           = "ABI48_0_0react/bridging"
55      sss.pod_target_xcconfig  = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" }
56      if using_hermes
57        sss.dependency "ABI48_0_0hermes-engine"
58      end
59    end
60
61    ss.subspec "core" do |sss|
62      sss.source_files = "react/nativemodule/core/ReactCommon/**/*.{cpp,h}",
63                         "react/nativemodule/core/platform/ios/**/*.{mm,cpp,h}"
64      excluded_files = ENV['USE_FRAMEWORKS'] == nil ?
65        "react/nativemodule/core/ReactCommon/LongLivedObject.h" :
66        "react/nativemodule/core/ReactCommon/{LongLivedObject,CallbackWrapper}.h"
67      sss.exclude_files = excluded_files
68    end
69
70    s.subspec "react_debug_core" do |sss|
71        sss.source_files = "react/debug/*.{cpp,h}"
72    end
73
74    ss.subspec "samples" do |sss|
75      sss.source_files = "react/nativemodule/samples/ReactCommon/**/*.{cpp,h}",
76                         "react/nativemodule/samples/platform/ios/**/*.{mm,cpp,h}"
77      sss.dependency "ABI48_0_0ReactCommon/turbomodule/core", version
78    end
79  end
80end
81