From 71cd2d79ec3f4cd836b22a3cb8b363b8fd48855a Mon Sep 17 00:00:00 2001 From: Taras Tsugrii Date: Sun, 24 Jun 2018 14:34:00 -0700 Subject: [PATCH] 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 --- ReactCommon/cxxreact/BUCK | 22 ++++++---------------- ReactCommon/jschelpers/BUCK | 4 ++-- ReactNative/DEFS.bzl | 11 ++++++++++- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/ReactCommon/cxxreact/BUCK b/ReactCommon/cxxreact/BUCK index 06bf8adbd..b24c56a3c 100644 --- a/ReactCommon/cxxreact/BUCK +++ b/ReactCommon/cxxreact/BUCK @@ -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), diff --git a/ReactCommon/jschelpers/BUCK b/ReactCommon/jschelpers/BUCK index 9f3c82617..7739b8f7d 100644 --- a/ReactCommon/jschelpers/BUCK +++ b/ReactCommon/jschelpers/BUCK @@ -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([ diff --git a/ReactNative/DEFS.bzl b/ReactNative/DEFS.bzl index b0c85a1aa..0909ede22 100644 --- a/ReactNative/DEFS.bzl +++ b/ReactNative/DEFS.bzl @@ -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 = []