Skylarkify ReactNative OSS build defs.

Summary:
Skylark parser will not allow access to file system other
than through `glob` and environment variables. The logic was also
making assumption about `buck-out` layout structure which is not
specified and as such is subject to change at any time without any
announcement.

Differential Revision: D8604721

fbshipit-source-id: 90826b4d5709580aad3092d0331d0e84e493c3b8
This commit is contained in:
Taras Tsugrii 2018-06-25 09:29:27 -07:00 committed by Facebook Github Bot
parent 71cd2d79ec
commit fe3bd9a65c
1 changed files with 14 additions and 36 deletions

View File

@ -23,34 +23,36 @@ GLOG_DEP = "//ReactAndroid/build/third-party-ndk/glog:glog"
INSPECTOR_FLAGS = []
APPLE_JSC_INTERNAL_DEPS = []
APPLE_JSC_DEPS = []
ANDROID_JSC_INTERNAL_DEPS = [
'//native/third-party/jsc:jsc',
'//native/third-party/jsc:jsc_legacy_profiler',
"//native/third-party/jsc:jsc",
"//native/third-party/jsc:jsc_legacy_profiler",
]
ANDROID_JSC_DEPS = ANDROID_JSC_INTERNAL_DEPS
ANDROID = "Android"
APPLE = ""
YOGA_TARGET = '//ReactAndroid/src/main/java/com/facebook:yoga'
FBGLOGINIT_TARGET = '//ReactAndroid/src/main/jni/first-party/fbgloginit:fbgloginit'
FBJNI_TARGET = '//ReactAndroid/src/main/jni/first-party/fb:jni'
JNI_TARGET = '//ReactAndroid/src/main/jni/first-party/jni-hack:jni-hack'
KEYSTORE_TARGET = '//keystores:debug'
YOGA_TARGET = "//ReactAndroid/src/main/java/com/facebook:yoga"
with allow_unsafe_import():
import os
FBGLOGINIT_TARGET = "//ReactAndroid/src/main/jni/first-party/fbgloginit:fbgloginit"
FBJNI_TARGET = "//ReactAndroid/src/main/jni/first-party/fb:jni"
JNI_TARGET = "//ReactAndroid/src/main/jni/first-party/jni-hack:jni-hack"
KEYSTORE_TARGET = "//keystores:debug"
def get_apple_inspector_flags():
return []
def get_android_inspector_flags():
return []
# Building is not supported in OSS right now
def rn_xplat_cxx_library(name, **kwargs):
new_kwargs = {
@ -65,33 +67,27 @@ def rn_xplat_cxx_library(name, **kwargs):
**new_kwargs
)
# Example: react_native_target('java/com/facebook/react/common:common')
def react_native_target(path):
return '//ReactAndroid/src/main/' + path
# Example: react_native_xplat_target('bridge:bridge')
def react_native_xplat_target(path):
return '//ReactCommon/' + path
# 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
# React property preprocessor
def rn_android_library(name, deps=[], plugins=[], *args, **kwargs):
@ -119,45 +115,33 @@ def rn_android_library(name, deps=[], plugins=[], *args, **kwargs):
native.android_library(name=name, deps=deps, plugins=plugins, *args, **kwargs)
def rn_android_binary(*args, **kwargs):
native.android_binary(*args, **kwargs)
def rn_android_build_config(*args, **kwargs):
native.android_build_config(*args, **kwargs)
def rn_android_resource(*args, **kwargs):
native.android_resource(*args, **kwargs)
def rn_android_prebuilt_aar(*args, **kwargs):
native.android_prebuilt_aar(*args, **kwargs)
def rn_java_library(*args, **kwargs):
native.java_library(*args, **kwargs)
def rn_java_annotation_processor(*args, **kwargs):
native.java_annotation_processor(*args, **kwargs)
def rn_prebuilt_native_library(*args, **kwargs):
native.prebuilt_native_library(*args, **kwargs)
def rn_prebuilt_jar(*args, **kwargs):
native.prebuilt_jar(*args, **kwargs)
def rn_robolectric_test(name, srcs, vm_args=None, *args, **kwargs):
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',
@ -168,13 +152,8 @@ def rn_robolectric_test(name, srcs, vm_args=None, *args, **kwargs):
'-XX:MaxPermSize=620m',
'-Drobolectric.offline=true',
]
if os.path.isdir("/dev/shm") and 'CIRCLECI' not in os.environ:
if native.read_config("user", "use_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')
)
# RN tests use Powermock, which means they get their own ClassLoaders.
# Because the yoga native library (or any native library) can only be loaded into one
@ -193,7 +172,6 @@ def rn_robolectric_test(name, srcs, vm_args=None, *args, **kwargs):
**kwargs
)
def cxx_library(allow_jni_merging=None, **kwargs):
args = {
k: v