react-native/ReactCommon/cxxreact/BUCK

178 lines
4.1 KiB
Python
Raw Normal View History

CXX_LIBRARY_COMPILER_FLAGS = []
REACT_LIBRARY_EXTRA_COMPILER_FLAGS = []
if THIS_IS_FBOBJC:
inherited_buck_flags = STATIC_LIBRARY_IOS_FLAGS
CXX_LIBRARY_COMPILER_FLAGS = inherited_buck_flags.get_flag_value('compiler_flags')
REACT_LIBRARY_EXTRA_COMPILER_FLAGS = ['-Wno-shadow', '-Wno-missing-prototypes', '-Wno-global-constructors']
def kwargs_add(base_kwargs, **new_kwargs):
ret_kwargs = dict(base_kwargs)
for name, add_value in new_kwargs.iteritems():
if name in ret_kwargs:
# Don't use +=, it will modify base_kwargs
ret_kwargs[name] = ret_kwargs[name] + add_value
else:
ret_kwargs[name] = add_value
return ret_kwargs
if THIS_IS_FBANDROID:
include_defs('//ReactAndroid/DEFS')
def react_library(**kwargs):
kwargs = kwargs_add(
kwargs,
# We depend on JSC, support the same platforms
supported_platforms_regex = '^android-(armv7|x86)$',
compiler_flags = [
'-Wno-pessimizing-move',
],
deps = [
'//xplat/folly:molly',
])
cxx_library(
name = 'bridge',
**kwargs_add(
kwargs,
preprocessor_flags = [
'-DWITH_JSC_EXTRA_TRACING=1',
'-DWITH_JSC_MEMORY_PRESSURE=1',
'-DWITH_REACT_INTERNAL_SETTINGS=1',
'-DWITH_FB_MEMORY_PROFILING=1',
],
deps = JSC_DEPS
)
)
elif THIS_IS_FBOBJC:
def react_library(**kwargs):
ios_library(
name = 'bridge',
header_path_prefix = "cxxreact",
inherited_buck_flags = STATIC_LIBRARY_IOS_FLAGS,
frameworks = [
'$SDKROOT/System/Library/Frameworks/JavaScriptCore.framework',
],
**kwargs_add(
kwargs,
preprocessor_flags = DEBUG_PREPROCESSOR_FLAGS,
deps = [
'//xplat/folly:molly',
]
)
)
cxx_library(
name = 'module',
force_static = True,
compiler_flags = CXX_LIBRARY_COMPILER_FLAGS,
exported_headers = [
'CxxModule.h',
'FollySupport.h',
'JsArgumentHelpers.h',
'JsArgumentHelpers-inl.h',
],
header_namespace = 'cxxreact',
deps = [
'//xplat/folly:molly',
],
visibility = [
'PUBLIC',
],
)
cxx_library(
name = 'samplemodule',
soname = 'libxplat_react_module_samplemodule.so',
srcs = ['SampleCxxModule.cpp'],
exported_headers = ['SampleCxxModule.h'],
header_namespace = '',
compiler_flags = CXX_LIBRARY_COMPILER_FLAGS + [
'-fno-omit-frame-pointer',
'-Wall',
'-Werror',
'-std=c++11',
'-fexceptions',
],
deps = [
':module',
'//xplat/folly:molly',
],
visibility = [
'PUBLIC',
],
)
react_library(
soname = 'libreactnativefb.so',
header_namespace = 'cxxreact',
force_static = True,
srcs = [
'CxxMessageQueue.cpp',
'CxxNativeModule.cpp',
'Executor.cpp',
'Instance.cpp',
'JSCExecutor.cpp',
'JSCHelpers.cpp',
'JSCLegacyProfiler.cpp',
'JSCLegacyTracing.cpp',
'JSCMemory.cpp',
'JSCPerfStats.cpp',
'JSCSamplingProfiler.cpp',
'JSCTracing.cpp',
'JSCWebWorker.cpp',
'MethodCall.cpp',
'ModuleRegistry.cpp',
'NativeToJsBridge.cpp',
'Platform.cpp',
'Value.cpp',
'Unicode.cpp',
],
headers = [
'JSCLegacyProfiler.h',
'JSCLegacyTracing.h',
'JSCMemory.h',
'JSCPerfStats.h',
'JSCSamplingProfiler.h',
'JSCTracing.h',
],
exported_headers = [
'CxxMessageQueue.h',
'CxxNativeModule.h',
'Executor.h',
'ExecutorToken.h',
'ExecutorTokenFactory.h',
'Instance.h',
'JSCExecutor.h',
'JSCHelpers.h',
'JSCWebWorker.h',
'JSModulesUnbundle.h',
'MessageQueueThread.h',
'MethodCall.h',
'ModuleRegistry.h',
'NativeModule.h',
'NativeToJsBridge.h',
'noncopyable.h',
'Platform.h',
'SystraceSection.h',
'Value.h',
'Unicode.h',
],
preprocessor_flags = [
'-DLOG_TAG="ReactNative"',
'-DWITH_FBSYSTRACE=1',
],
compiler_flags = [
'-Wall',
'-fexceptions',
'-fvisibility=hidden',
'-frtti',
] + REACT_LIBRARY_EXTRA_COMPILER_FLAGS,
deps = [
':module',
'//xplat/fbsystrace:fbsystrace',
Add MicroProfiler for low-overhead profiling of JSC/bridge performance Summary: We have a lot of small-ish calls to JSC and within the bridge that add up during TTI. This gives us a way to measure them in aggregate in a reasonable way. From the comments: MicroProfiler is a performance profiler for measuring the cumulative impact of a large number of small-ish calls. This is normally a problem for standard profilers like Systrace because the overhead of the profiler itself skews the timings you are able to collect. This is especially a problem when doing nested calls to profiled functions, as the parent calls will contain the overhead of their profiling plus the overhead of all their childrens' profiling. MicroProfiler attempts to be low overhead by 1) aggregating timings in memory and 2) trying to remove estimated profiling overhead from the returned timings. To remove estimated overhead, at the beginning of each trace we calculate the average cost of profiling a no-op code section, as well as invoking the average cost of invoking the system clock. The former is subtracted out for each child profiler section that is invoked within a parent profiler section. The latter is subtracted from each section, child or not. The usage is similar to Systrace: you put a MICRO_PROFILER_BLOCK in the block you want to profile and C++ RAII will handle timing it. After MicroProfiler::stopProfiling() is called, a table of tracing data is emitted to glog (which shows up in logcat on Android). Differential Revision: D3635319 fbshipit-source-id: 01390b8ac76a68dd425cba2adfdde6e4957440cc
2016-08-02 14:32:59 +00:00
react_native_xplat_target('microprofiler:microprofiler'),
],
visibility = [ 'PUBLIC' ],
)