Codegen: Make BUCK & DEFS.bzl OSS friendly

Summary:
This makes the build configuration compatible with OSS Buck (but doesn't provide the complete capability).

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D24414408

fbshipit-source-id: 4632933b8659389543ed72ae7c11c63d86bb3dce
This commit is contained in:
Kevin Gozali
2020-10-20 14:11:46 -07:00
committed by Facebook GitHub Bot
parent 82c95fadc1
commit eca9d9772c
5 changed files with 64 additions and 32 deletions
+4 -27
View File
@@ -1,10 +1,7 @@
load("@fbsource//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load("@fbsource//tools/build_defs:fb_xplat_cxx_binary.bzl", "fb_xplat_cxx_binary")
load("@fbsource//tools/build_defs:platform_defs.bzl", "ANDROID", "APPLE", "IOS")
load("@fbsource//tools/build_defs/oss:rn_defs.bzl", "rn_android_library", "rn_xplat_cxx_library")
load("@fbsource//tools/build_defs/third_party:yarn_defs.bzl", "yarn_workspace")
load("@fbsource//xplat/js/react-native-github/packages/react-native-codegen:DEFS.bzl", "rn_codegen_components", "rn_codegen_modules")
load("//tools/build_defs/oss:rn_defs.bzl", "react_native_target")
load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "IOS", "react_native_target", "rn_android_library", "rn_xplat_cxx_library")
load("//tools/build_defs/third_party:yarn_defs.bzl", "yarn_workspace")
load(":DEFS.bzl", "rn_codegen_components", "rn_codegen_modules")
fb_native.sh_binary(
name = "codegen_rn_modules_tests",
@@ -74,26 +71,6 @@ rn_codegen_modules(
schema_target = ":codegen_tests_schema",
)
fb_xplat_cxx_binary(
name = "rn_codegen_binary",
srcs = ["buck_tests/emptyFile.cpp"],
compiler_flags = [
"-fexceptions",
"-frtti",
"-std=c++14",
"-Wall",
],
platforms = (ANDROID, APPLE),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
],
visibility = ["PUBLIC"],
deps = [
":generated_components-codegen_tests",
],
)
rn_android_library(
name = "rn_codegen_library_java",
srcs = glob(
+5 -4
View File
@@ -1,16 +1,17 @@
load("@fbsource//tools/build_defs:buckconfig.bzl", "read_bool")
load("@fbsource//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load("@fbsource//tools/build_defs:platform_defs.bzl", "IOS", "MACOSX")
load("@fbsource//tools/build_defs/apple:flag_defs.bzl", "get_preprocessor_flags_for_build_mode")
load("//tools/build_defs:buckconfig.bzl", "read_bool")
load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"IOS",
"MACOSX",
"YOGA_CXX_TARGET",
"fb_xplat_cxx_test",
"get_apple_compiler_flags",
"get_apple_inspector_flags",
"get_preprocessor_flags_for_build_mode",
"react_native_dep",
"react_native_target",
"react_native_xplat_target",
+38
View File
@@ -0,0 +1,38 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
def read(section, field, default = None):
"""Read a `string` from `.buckconfig`."""
return native.read_config(section, field, default)
def read_bool(section, field, default = None, required = True):
"""Read a `boolean` from `.buckconfig`."""
# Treat the empty string as "unset". This allows the user to "override" a
# previous setting by "clearing" it out.
val = read(section, field)
if val != None and val != "":
# Fast-path string check
if val == "True" or val == "true":
return True
elif val == "False" or val == "false":
return False
# Else fall back to lower casing
if val.lower() == "true":
return True
elif val.lower() == "false":
return False
else:
fail(
"`{}:{}`: cannot coerce {!r} to bool".format(section, field, val),
)
elif default != None:
return default
elif not required:
return None
else:
fail("`{}:{}`: no value set".format(section, field))
+9 -1
View File
@@ -27,9 +27,17 @@ GLOG_DEP = "//ReactAndroid/build/third-party-ndk/glog:glog"
INSPECTOR_FLAGS = []
# Platform Definitions
CXX = "Default"
ANDROID = "Android"
APPLE = ""
APPLE = "Apple"
# Apple SDK Definitions
IOS = "ios"
MACOSX = "macosx"
YOGA_TARGET = "//ReactAndroid/src/main/java/com/facebook:yoga"
+8
View File
@@ -0,0 +1,8 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
def yarn_workspace(name, srcs = [], transform_ignore = None, visibility = None):
# Noop for OSS vs FB build compatibility for now
unused = True