Move conditional logic into corresponding build defs.

Summary:
Conditional `load`s are not allowed in Skylark. The logic
that belongs to different environments has to be part of environment
specific build defs and include as part of cell resolution or CI
configuration.
More context: https://buckbuild.com/concept/skylark.html

Differential Revision: D8604673

fbshipit-source-id: 385f2e155c4d80219e6ed3a2e0a82c909ebabb13
This commit is contained in:
Taras Tsugrii 2018-06-24 14:34:00 -07:00 committed by Facebook Github Bot
parent 1dced3448a
commit 71cd2d79ec
3 changed files with 18 additions and 19 deletions

View File

@ -1,21 +1,11 @@
load("@xplat//tools/build_defs:glob_defs.bzl", "subdir_glob")
load("//ReactNative:DEFS.bzl", "ANDROID", "ANDROID_JSC_DEPS", "APPLE", "APPLE_JSC_DEPS", "IS_OSS_BUILD", "get_android_inspector_flags", "get_apple_inspector_flags", "react_native_xplat_target", "rn_xplat_cxx_library")
load("//ReactNative:DEFS.bzl", "ANDROID", "ANDROID_JSC_DEPS", "APPLE", "get_apple_compiler_flags", "APPLE_JSC_DEPS", "get_debug_preprocessor_flags", "IS_OSS_BUILD", "get_android_inspector_flags", "get_apple_inspector_flags", "react_native_xplat_target", "rn_xplat_cxx_library")
CXX_LIBRARY_COMPILER_FLAGS = [
"-std=c++14",
"-Wall",
]
APPLE_COMPILER_FLAGS = []
DEBUG_PREPROCESSOR_FLAGS = []
if not IS_OSS_BUILD:
load("@xplat//configurations/buck/apple:flag_defs.bzl", "flags", "get_debug_preprocessor_flags", "get_static_library_ios_flags")
APPLE_COMPILER_FLAGS = flags.get_flag_value(get_static_library_ios_flags(), "compiler_flags")
DEBUG_PREPROCESSOR_FLAGS = get_debug_preprocessor_flags()
rn_xplat_cxx_library(
name = "module",
header_namespace = "",
@ -28,7 +18,7 @@ rn_xplat_cxx_library(
prefix = "cxxreact",
),
compiler_flags = CXX_LIBRARY_COMPILER_FLAGS,
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
fbobjc_compiler_flags = get_apple_compiler_flags(),
force_static = True,
visibility = [
"PUBLIC",
@ -52,7 +42,7 @@ rn_xplat_cxx_library(
"-fexceptions",
"-frtti",
],
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
fbobjc_compiler_flags = get_apple_compiler_flags(),
force_static = True,
visibility = [
"PUBLIC",
@ -73,7 +63,7 @@ rn_xplat_cxx_library(
"-fno-omit-frame-pointer",
"-fexceptions",
],
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
fbobjc_compiler_flags = get_apple_compiler_flags(),
soname = "libxplat_react_module_samplemodule.$(ext)",
visibility = [
"PUBLIC",
@ -141,13 +131,13 @@ rn_xplat_cxx_library(
"-DWITH_JSC_MEMORY_PRESSURE=1",
"-DWITH_FB_MEMORY_PROFILING=1",
],
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
fbobjc_compiler_flags = get_apple_compiler_flags(),
fbobjc_deps = APPLE_JSC_DEPS,
fbobjc_force_static = True,
fbobjc_frameworks = [
"$SDKROOT/System/Library/Frameworks/JavaScriptCore.framework",
],
fbobjc_preprocessor_flags = DEBUG_PREPROCESSOR_FLAGS + get_apple_inspector_flags(),
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(),
force_static = True,
macosx_tests_override = [],
platforms = (ANDROID, APPLE),

View File

@ -13,11 +13,11 @@ rn_xplat_cxx_library(
name = "jscinternalhelpers",
srcs = glob(
["*.cpp"],
excludes = ["systemJSCWrapper.cpp"],
exclude = ["systemJSCWrapper.cpp"],
),
headers = glob(
["*.h"],
excludes = EXPORTED_HEADERS,
exclude = EXPORTED_HEADERS,
),
header_namespace = "",
exported_headers = dict([

View File

@ -6,12 +6,21 @@ This lets us build React Native:
"""
# @lint-ignore-every SKYLINT BUCKRESTRICTEDSYNTAX
_DEBUG_PREPROCESSOR_FLAGS = []
_APPLE_COMPILER_FLAGS = []
def get_debug_preprocessor_flags():
return _DEBUG_PREPROCESSOR_FLAGS
def get_apple_compiler_flags():
return _APPLE_COMPILER_FLAGS
IS_OSS_BUILD = True
GLOG_DEP = "//ReactAndroid/build/third-party-ndk/glog:glog"
INSPECTOR_FLAGS = []
DEBUG_PREPROCESSOR_FLAGS = []
APPLE_JSC_INTERNAL_DEPS = []
APPLE_JSC_DEPS = []