mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 20:25:33 +08:00
Format bzl files with new buildifier
Summary: Build file formatting Reviewed By: ttsugriy Differential Revision: D9778749 fbshipit-source-id: 4ee3743fabdbb9202b1fe1334fd255e9734352e2
This commit is contained in:
committed by
Facebook Github Bot
parent
2869117127
commit
7650a8913d
@@ -62,58 +62,57 @@ def rn_xplat_cxx_library(name, **kwargs):
|
||||
}
|
||||
|
||||
native.cxx_library(
|
||||
name=name,
|
||||
visibility=kwargs.get("visibility", []),
|
||||
name = name,
|
||||
visibility = kwargs.get("visibility", []),
|
||||
**new_kwargs
|
||||
)
|
||||
|
||||
# Example: react_native_target('java/com/facebook/react/common:common')
|
||||
def react_native_target(path):
|
||||
return '//ReactAndroid/src/main/' + path
|
||||
return "//ReactAndroid/src/main/" + path
|
||||
|
||||
# Example: react_native_xplat_target('bridge:bridge')
|
||||
def react_native_xplat_target(path):
|
||||
return '//ReactCommon/' + 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
|
||||
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
|
||||
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
|
||||
return "//ReactAndroid/src/main/" + path
|
||||
|
||||
# React property preprocessor
|
||||
def rn_android_library(name, deps=[], plugins=[], *args, **kwargs):
|
||||
|
||||
def rn_android_library(name, deps = [], plugins = [], *args, **kwargs):
|
||||
if react_native_target(
|
||||
'java/com/facebook/react/uimanager/annotations:annotations'
|
||||
) in deps and name != 'processing':
|
||||
"java/com/facebook/react/uimanager/annotations:annotations",
|
||||
) in deps and name != "processing":
|
||||
react_property_plugins = [
|
||||
react_native_target(
|
||||
'java/com/facebook/react/processing:processing'
|
||||
"java/com/facebook/react/processing:processing",
|
||||
),
|
||||
]
|
||||
|
||||
plugins = list(set(plugins + react_property_plugins))
|
||||
|
||||
if react_native_target(
|
||||
'java/com/facebook/react/module/annotations:annotations'
|
||||
) in deps and name != 'processing':
|
||||
"java/com/facebook/react/module/annotations:annotations",
|
||||
) in deps and name != "processing":
|
||||
react_module_plugins = [
|
||||
react_native_target(
|
||||
'java/com/facebook/react/module/processing:processing'
|
||||
"java/com/facebook/react/module/processing:processing",
|
||||
),
|
||||
]
|
||||
|
||||
plugins = list(set(plugins + react_module_plugins))
|
||||
|
||||
native.android_library(name=name, deps=deps, plugins=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)
|
||||
@@ -139,40 +138,40 @@ def rn_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):
|
||||
def rn_robolectric_test(name, srcs, vm_args = None, *args, **kwargs):
|
||||
vm_args = vm_args or []
|
||||
|
||||
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',
|
||||
"-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 native.read_config("user", "use_dev_shm"):
|
||||
extra_vm_args.append('-Djava.io.tmpdir=/dev/shm')
|
||||
extra_vm_args.append("-Djava.io.tmpdir=/dev/shm")
|
||||
|
||||
# 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
|
||||
# ClassLoader at a time, we need to run each in its own process, hence fork_mode = 'per_test'.
|
||||
native.robolectric_test(
|
||||
name=name,
|
||||
use_cxx_libraries=True,
|
||||
cxx_library_whitelist=[
|
||||
'//ReactCommon/yoga:yoga',
|
||||
'//ReactAndroid/src/main/jni/first-party/yogajni:jni',
|
||||
name = name,
|
||||
use_cxx_libraries = True,
|
||||
cxx_library_whitelist = [
|
||||
"//ReactCommon/yoga:yoga",
|
||||
"//ReactAndroid/src/main/jni/first-party/yogajni:jni",
|
||||
],
|
||||
fork_mode='per_test',
|
||||
srcs=srcs,
|
||||
vm_args=vm_args + extra_vm_args,
|
||||
fork_mode = "per_test",
|
||||
srcs = srcs,
|
||||
vm_args = vm_args + extra_vm_args,
|
||||
*args,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def cxx_library(allow_jni_merging=None, **kwargs):
|
||||
def cxx_library(allow_jni_merging = None, **kwargs):
|
||||
args = {
|
||||
k: v
|
||||
for k, v in kwargs.items()
|
||||
@@ -181,18 +180,18 @@ def cxx_library(allow_jni_merging=None, **kwargs):
|
||||
native.cxx_library(**args)
|
||||
|
||||
def _paths_join(path, *others):
|
||||
"""Joins one or more path components."""
|
||||
result = path
|
||||
"""Joins one or more path components."""
|
||||
result = path
|
||||
|
||||
for p in others:
|
||||
if p.startswith("/"): # absolute
|
||||
result = p
|
||||
elif not result or result.endswith("/"):
|
||||
result += p
|
||||
else:
|
||||
result += "/" + p
|
||||
for p in others:
|
||||
if p.startswith("/"): # absolute
|
||||
result = p
|
||||
elif not result or result.endswith("/"):
|
||||
result += p
|
||||
else:
|
||||
result += "/" + p
|
||||
|
||||
return result
|
||||
return result
|
||||
|
||||
def subdir_glob(glob_specs, exclude = None, prefix = ""):
|
||||
"""Returns a dict of sub-directory relative paths to full paths.
|
||||
|
||||
Reference in New Issue
Block a user