2016-01-22 16:03:51 +00:00
|
|
|
# Helpers for referring to React Native open source code.
|
2016-02-24 10:17:56 +00:00
|
|
|
#
|
2016-01-22 16:03:51 +00:00
|
|
|
# This lets us build React Native:
|
|
|
|
# - At Facebook by running buck from the root of the fb repo
|
|
|
|
# - Outside of Facebook by running buck in the root of the git repo
|
|
|
|
|
2016-11-21 14:16:27 +00:00
|
|
|
IS_OSS_BUILD = True
|
|
|
|
|
2016-08-19 12:22:52 +00:00
|
|
|
with allow_unsafe_import():
|
|
|
|
import os
|
2016-01-23 10:57:58 +00:00
|
|
|
|
2016-01-22 16:03:51 +00:00
|
|
|
# Example: react_native_target('java/com/facebook/react/common:common')
|
|
|
|
def react_native_target(path):
|
|
|
|
return '//ReactAndroid/src/main/' + path
|
|
|
|
|
2016-09-29 15:22:39 +00:00
|
|
|
# Example: react_native_xplat_target('bridge:bridge')
|
2016-05-25 02:24:57 +00:00
|
|
|
def react_native_xplat_target(path):
|
|
|
|
return '//ReactCommon/' + path
|
|
|
|
|
2016-01-22 16:03:51 +00:00
|
|
|
# Example: react_native_tests_target('java/com/facebook/react/modules:modules')
|
|
|
|
def react_native_tests_target(path):
|
|
|
|
return '//ReactAndroid/src/test/' + path
|
|
|
|
|
|
|
|
# Example: react_native_integration_tests_target('java/com/facebook/react/testing:testing')
|
|
|
|
def react_native_integration_tests_target(path):
|
|
|
|
return '//ReactAndroid/src/androidTest/' + path
|
|
|
|
|
|
|
|
# Helper for referring to non-RN code from RN OSS code.
|
|
|
|
# Example: react_native_dep('java/com/facebook/systrace:systrace')
|
|
|
|
def react_native_dep(path):
|
|
|
|
return '//ReactAndroid/src/main/' + path
|
|
|
|
|
2017-03-10 17:08:05 +00:00
|
|
|
JSC_INTERNAL_DEPS = [
|
2016-02-24 10:01:37 +00:00
|
|
|
'//native/third-party/jsc:jsc',
|
|
|
|
'//native/third-party/jsc:jsc_legacy_profiler',
|
|
|
|
]
|
2017-03-10 17:08:05 +00:00
|
|
|
JSC_DEPS = JSC_INTERNAL_DEPS
|
2016-02-24 10:01:37 +00:00
|
|
|
|
2016-12-07 13:12:11 +00:00
|
|
|
YOGA_TARGET = '//ReactAndroid/src/main/java/com/facebook:yoga'
|
2016-03-10 14:01:26 +00:00
|
|
|
FBGLOGINIT_TARGET = '//ReactAndroid/src/main/jni/first-party/fbgloginit:fbgloginit'
|
2016-11-21 14:16:27 +00:00
|
|
|
FBJNI_TARGET = '//ReactAndroid/src/main/jni/first-party/fb:jni'
|
|
|
|
JNI_TARGET = '//ReactAndroid/src/main/jni/first-party/jni-hack:jni-hack'
|
2016-03-10 14:01:26 +00:00
|
|
|
|
2016-01-22 16:03:51 +00:00
|
|
|
# React property preprocessor
|
|
|
|
original_android_library=android_library
|
|
|
|
def android_library(
|
|
|
|
name,
|
|
|
|
deps=[],
|
|
|
|
annotation_processors=[],
|
|
|
|
annotation_processor_deps=[],
|
|
|
|
*args,
|
|
|
|
**kwargs):
|
|
|
|
|
|
|
|
if react_native_target('java/com/facebook/react/uimanager/annotations:annotations') in deps and name != 'processing':
|
2016-09-02 02:23:52 +00:00
|
|
|
react_property_processors = [
|
|
|
|
'com.facebook.react.processing.ReactPropertyProcessor',
|
|
|
|
]
|
|
|
|
react_property_processor_deps = [
|
|
|
|
react_native_target('java/com/facebook/react/processing:processing'),
|
|
|
|
]
|
|
|
|
|
|
|
|
annotation_processors = list(set(annotation_processors + react_property_processors))
|
|
|
|
annotation_processor_deps = list(set(annotation_processor_deps + react_property_processor_deps))
|
|
|
|
|
|
|
|
if react_native_target('java/com/facebook/react/module/annotations:annotations') in deps and name != 'processing':
|
|
|
|
react_module_processors = [
|
|
|
|
'com.facebook.react.module.processing.ReactModuleSpecProcessor',
|
|
|
|
]
|
|
|
|
react_module_processor_deps = [
|
|
|
|
react_native_target('java/com/facebook/react/module/processing:processing'),
|
|
|
|
]
|
|
|
|
|
|
|
|
annotation_processors = list(set(annotation_processors + react_module_processors))
|
|
|
|
annotation_processor_deps = list(set(annotation_processor_deps + react_module_processor_deps))
|
2016-01-22 16:03:51 +00:00
|
|
|
|
|
|
|
original_android_library(
|
|
|
|
name=name,
|
|
|
|
deps=deps,
|
|
|
|
annotation_processors=annotation_processors,
|
|
|
|
annotation_processor_deps=annotation_processor_deps,
|
|
|
|
*args,
|
|
|
|
**kwargs)
|
2016-01-23 10:57:58 +00:00
|
|
|
|
2016-11-21 14:16:27 +00:00
|
|
|
def rn_robolectric_test(name, srcs, vm_args = None, *args, **kwargs):
|
2016-01-23 10:57:58 +00:00
|
|
|
vm_args = vm_args or []
|
|
|
|
|
|
|
|
# We may need to create buck-out/gen/ if we're running after buck clean.
|
|
|
|
tmp = 'buck-out/gen/' + get_base_path() + '/__java_test_' + name + '_output__'
|
|
|
|
extra_vm_args = [
|
|
|
|
'-XX:+UseConcMarkSweepGC', # required by -XX:+CMSClassUnloadingEnabled
|
|
|
|
'-XX:+CMSClassUnloadingEnabled',
|
|
|
|
'-XX:ReservedCodeCacheSize=150M',
|
|
|
|
'-Drobolectric.dependency.dir=buck-out/gen/ReactAndroid/src/main/third-party/java/robolectric3/robolectric',
|
|
|
|
'-Dlibraries=buck-out/gen/ReactAndroid/src/main/third-party/java/robolectric3/robolectric/*.jar',
|
|
|
|
'-Drobolectric.logging.enabled=true',
|
|
|
|
'-XX:MaxPermSize=620m',
|
|
|
|
'-Drobolectric.offline=true',
|
|
|
|
]
|
|
|
|
if os.path.isdir("/dev/shm"):
|
|
|
|
extra_vm_args.append('-Djava.io.tmpdir=/dev/shm')
|
|
|
|
else:
|
|
|
|
extra_vm_args.append(
|
|
|
|
'-Djava.io.tmpdir=%s' % os.path.join(os.path.abspath('.'),
|
|
|
|
'buck-out/bin'))
|
|
|
|
|
2016-11-21 14:16:27 +00:00
|
|
|
# RN tests use Powermock, which means they get their own ClassLoaders.
|
2016-12-07 13:12:11 +00:00
|
|
|
# Because the yoga native library (or any native library) can only be loaded into one
|
2016-11-21 14:16:27 +00:00
|
|
|
# ClassLoader at a time, we need to run each in its own process, hence fork_mode = 'per_test'.
|
2016-01-23 10:57:58 +00:00
|
|
|
robolectric_test(
|
2016-11-21 14:16:27 +00:00
|
|
|
name = name,
|
|
|
|
use_cxx_libraries = True,
|
|
|
|
cxx_library_whitelist = [
|
2016-12-07 13:12:11 +00:00
|
|
|
'//ReactCommon/yoga:yoga',
|
|
|
|
'//ReactAndroid/src/main/jni/first-party/yogajni:jni',
|
2016-11-21 14:16:27 +00:00
|
|
|
],
|
|
|
|
fork_mode = 'per_test',
|
|
|
|
srcs = srcs,
|
|
|
|
vm_args = vm_args + extra_vm_args,
|
|
|
|
*args, **kwargs)
|