Fabric: Enable CXX (aka Default) platfrom fravour for all C++ Fabric targets

Summary:
First of all, seems it's the right thing to do. Fabric C++ code is cross-platfrom and should run on *all* platforms including Windows, Linux, and Mac.
While we don't have a real *production* use cases where we need compilation for desktops, having CXX target is really handy for two reasons:
* It simplifies local test running process. Instead of going to `/fbandroid/` and executing something like `buck test fbsource//xplat/js/react-native-github/ReactCommon/fabric/core:coreAndroid` (note the suffix). We can just do `buck test fbsource//xplat/js/react-native-github/ReactCommon/fabric/core:core` everywhere and it works now out of the box. Running tests with "Apple" flavor never worked for me.
* It allows creating synthetic benchmark tests (using Google Benchmark) that can be used as a rough approximation of code micro-optimizations.

Reviewed By: JoshuaGross

Differential Revision: D15608678

fbshipit-source-id: d2449035685dbca6ab983480f5334ec4ac11cd35
This commit is contained in:
Valentin Shergin 2019-06-04 15:28:24 -07:00 коммит произвёл Facebook Github Bot
Родитель 608b1b5ea2
Коммит 15302284cc
27 изменённых файлов: 216 добавлений и 64 удалений

Просмотреть файл

@ -3,6 +3,7 @@ load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"get_apple_compiler_flags",
"get_apple_inspector_flags",
"rn_xplat_cxx_library",
@ -38,7 +39,7 @@ rn_xplat_cxx_library(
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(),
force_static = True,
macosx_tests_override = [],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",

Просмотреть файл

@ -1,4 +1,4 @@
load("@fbsource//tools/build_defs:default_platform_defs.bzl", "ANDROID", "APPLE")
load("@fbsource//tools/build_defs:default_platform_defs.bzl", "ANDROID", "APPLE", "CXX")
load("@fbsource//tools/build_defs:glob_defs.bzl", "subdir_glob")
load("@fbsource//tools/build_defs/apple:flag_defs.bzl", "flags", "get_debug_preprocessor_flags", "get_static_library_ios_flags")
load("@fbsource//tools/build_defs/oss:rn_defs.bzl", "get_apple_inspector_flags", "rn_xplat_cxx_library")
@ -27,7 +27,7 @@ rn_xplat_cxx_library(
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(),
force_static = True,
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",

Просмотреть файл

@ -3,6 +3,7 @@ load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"fb_xplat_cxx_test",
"get_apple_compiler_flags",
"get_apple_inspector_flags",
@ -40,7 +41,7 @@ rn_xplat_cxx_library(
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(),
force_static = True,
macosx_tests_override = [],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
@ -72,7 +73,7 @@ fb_xplat_cxx_test(
"-Wall",
],
contacts = ["oncall+react_native@xmail.facebook.com"],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
deps = [
"fbsource//xplat/folly:molly",
"fbsource//xplat/third-party/gmock:gtest",

Просмотреть файл

@ -1,5 +1,16 @@
load("@fbsource//tools/build_defs/apple:flag_defs.bzl", "get_debug_preprocessor_flags")
load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "fb_xplat_cxx_test", "get_apple_compiler_flags", "get_apple_inspector_flags", "react_native_xplat_target", "rn_xplat_cxx_library", "subdir_glob")
load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"fb_xplat_cxx_test",
"get_apple_compiler_flags",
"get_apple_inspector_flags",
"react_native_xplat_target",
"rn_xplat_cxx_library",
"subdir_glob",
)
APPLE_COMPILER_FLAGS = get_apple_compiler_flags()
@ -26,7 +37,7 @@ rn_xplat_cxx_library(
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(),
macosx_tests_override = [],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
@ -57,7 +68,7 @@ fb_xplat_cxx_test(
"-std=c++14",
"-Wall",
],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
deps = [
"fbsource//xplat/folly:molly",
"fbsource//xplat/third-party/gmock:gtest",

Просмотреть файл

@ -3,6 +3,7 @@ load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"fb_xplat_cxx_test",
"get_apple_compiler_flags",
"get_apple_inspector_flags",
@ -36,7 +37,7 @@ rn_xplat_cxx_library(
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(),
macosx_tests_override = [],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
@ -69,7 +70,7 @@ fb_xplat_cxx_test(
"-Wall",
],
contacts = ["oncall+react_native@xmail.facebook.com"],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
deps = [
"fbsource//xplat/folly:molly",
"fbsource//xplat/third-party/gmock:gtest",

Просмотреть файл

@ -3,10 +3,10 @@ load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"fb_xplat_cxx_test",
"get_apple_compiler_flags",
"get_apple_inspector_flags",
"react_native_target",
"react_native_xplat_target",
"rn_xplat_cxx_library",
"subdir_glob",
@ -37,9 +37,6 @@ rn_xplat_cxx_library(
"-std=c++14",
"-Wall",
],
fbandroid_deps = [
react_native_target("jni/react/jni:jni"),
],
fbandroid_exported_headers = subdir_glob(
[
("", "*.h"),
@ -64,7 +61,7 @@ rn_xplat_cxx_library(
prefix = "react/components/modal",
),
macosx_tests_override = [],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
@ -100,7 +97,7 @@ fb_xplat_cxx_test(
"-Wall",
],
contacts = ["oncall+react_native@xmail.facebook.com"],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
deps = [
"fbsource//xplat/folly:molly",
"fbsource//xplat/third-party/gmock:gtest",

Просмотреть файл

@ -3,6 +3,7 @@ load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"fb_xplat_cxx_test",
"get_apple_compiler_flags",
"get_apple_inspector_flags",
@ -36,7 +37,7 @@ rn_xplat_cxx_library(
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(),
macosx_tests_override = [],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
# Systraces are temporary disabled.
@ -69,7 +70,7 @@ fb_xplat_cxx_test(
"-Wall",
],
contacts = ["oncall+react_native@xmail.facebook.com"],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
deps = [
"fbsource//xplat/folly:molly",
"fbsource//xplat/third-party/gmock:gtest",

Просмотреть файл

@ -3,6 +3,7 @@ load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"fb_xplat_cxx_test",
"get_apple_compiler_flags",
"get_apple_inspector_flags",
@ -40,7 +41,7 @@ rn_xplat_cxx_library(
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(),
force_static = True,
macosx_tests_override = [],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
@ -72,7 +73,7 @@ fb_xplat_cxx_test(
"-Wall",
],
contacts = ["oncall+react_native@xmail.facebook.com"],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
deps = [
"fbsource//xplat/folly:molly",
"fbsource//xplat/third-party/gmock:gtest",

Просмотреть файл

@ -3,6 +3,7 @@ load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"fb_xplat_cxx_test",
"get_apple_compiler_flags",
"get_apple_inspector_flags",
@ -37,6 +38,7 @@ rn_xplat_cxx_library(
"-std=c++14",
"-Wall",
],
cxx_tests = [":tests"],
fbandroid_deps = [
react_native_target("jni/react/jni:jni"),
],
@ -69,13 +71,11 @@ rn_xplat_cxx_library(
ios_srcs = glob(
["platform/ios/*.cpp"],
),
macosx_tests_override = [],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
],
tests = [":tests"],
visibility = ["PUBLIC"],
deps = [
"fbsource//xplat/fbsystrace:fbsystrace",
@ -106,7 +106,12 @@ fb_xplat_cxx_test(
"-Wall",
],
contacts = ["oncall+react_native@xmail.facebook.com"],
platforms = (ANDROID, APPLE),
platforms = (
# `Apple` and `Android` flavors are disabled because the module (built with those flavors) requires Emulator/Simulator (which is expensive and slow). At the same time, we don't really have tests here.
# ANDROID,
# APPLE,
CXX,
),
deps = [
"fbsource//xplat/folly:molly",
"fbsource//xplat/third-party/gmock:gtest",

Просмотреть файл

@ -3,6 +3,7 @@ load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"fb_xplat_cxx_test",
"get_apple_compiler_flags",
"get_apple_inspector_flags",
@ -40,16 +41,15 @@ rn_xplat_cxx_library(
"-std=c++14",
"-Wall",
],
cxx_tests = [":tests"],
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(),
force_static = True,
macosx_tests_override = [],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
],
tests = [":tests"],
visibility = ["PUBLIC"],
deps = [
"fbsource//xplat/fbsystrace:fbsystrace",
@ -81,7 +81,14 @@ fb_xplat_cxx_test(
"-Wall",
],
contacts = ["oncall+react_native@xmail.facebook.com"],
platforms = (ANDROID, APPLE),
platforms = (
# `Apple` and `Android` flavors are disabled because the module depends on `textlayoutmanager` which requires real an Emulator/Simulator to run.
# At the same time, the code of tests does not rely on the simulator capabilities and it would be wasteful to add `fbandroid_use_instrumentation_test = True`.
# (Beware of this option though.)
# ANDROID,
# APPLE,
CXX
),
deps = [
"fbsource//xplat/folly:molly",
"fbsource//xplat/third-party/gmock:gtest",

Просмотреть файл

@ -3,6 +3,7 @@ load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"fb_xplat_cxx_test",
"get_apple_compiler_flags",
"get_apple_inspector_flags",
@ -43,7 +44,7 @@ rn_xplat_cxx_library(
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(),
force_static = True,
macosx_tests_override = [],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
# Systraces are temporary disabled.
@ -75,7 +76,7 @@ fb_xplat_cxx_test(
"-Wall",
],
contacts = ["oncall+react_native@xmail.facebook.com"],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
deps = [
"fbsource//xplat/folly:molly",
"fbsource//xplat/third-party/gmock:gtest",

Просмотреть файл

@ -1,5 +1,16 @@
load("@fbsource//tools/build_defs/apple:flag_defs.bzl", "get_debug_preprocessor_flags")
load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "fb_xplat_cxx_test", "get_apple_compiler_flags", "get_apple_inspector_flags", "react_native_xplat_target", "rn_xplat_cxx_library", "subdir_glob")
load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"fb_xplat_cxx_test",
"get_apple_compiler_flags",
"get_apple_inspector_flags",
"react_native_xplat_target",
"rn_xplat_cxx_library",
"subdir_glob",
)
APPLE_COMPILER_FLAGS = get_apple_compiler_flags()
@ -36,7 +47,7 @@ rn_xplat_cxx_library(
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(),
force_static = True,
macosx_tests_override = [],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
@ -68,7 +79,7 @@ fb_xplat_cxx_test(
"-Wall",
],
contacts = ["oncall+react_native@xmail.facebook.com"],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
deps = [
"fbsource//xplat/folly:molly",
"fbsource//xplat/third-party/gmock:gtest",

Просмотреть файл

@ -1,3 +1,4 @@
load("@fbsource//tools/build_defs:default_platform_defs.bzl", "CXX")
load(
"@fbsource//tools/build_defs/apple:flag_defs.bzl",
"get_debug_preprocessor_flags",
@ -42,7 +43,7 @@ rn_xplat_cxx_library(
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(),
force_static = True,
macosx_tests_override = [],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
@ -68,7 +69,7 @@ fb_xplat_cxx_test(
"-Wall",
],
contacts = ["oncall+react_native@xmail.facebook.com"],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
deps = [
"fbsource//xplat/folly:molly",
"fbsource//xplat/third-party/gmock:gtest",

Просмотреть файл

@ -3,6 +3,7 @@ load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"fb_xplat_cxx_test",
"get_apple_compiler_flags",
"get_apple_inspector_flags",
@ -38,15 +39,26 @@ rn_xplat_cxx_library(
"-std=c++14",
"-Wall",
],
cxx_exported_headers = subdir_glob(
[
("platform/cxx", "**/*.h"),
],
prefix = "react/graphics",
),
cxx_srcs = glob(
[
"platform/cxx/**/*.cpp",
],
),
fbandroid_exported_headers = subdir_glob(
[
("platform/android", "**/*.h"),
("platform/cxx", "**/*.h"),
],
prefix = "react/graphics",
),
fbandroid_srcs = glob(
[
"platform/android/**/*.cpp",
"platform/cxx/**/*.cpp",
],
),
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
@ -74,7 +86,7 @@ rn_xplat_cxx_library(
],
),
macosx_tests_override = [],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
@ -101,7 +113,7 @@ fb_xplat_cxx_test(
"-Wall",
],
contacts = ["oncall+react_native@xmail.facebook.com"],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
deps = [
"fbsource//xplat/folly:molly",
"fbsource//xplat/third-party/gmock:gtest",

Просмотреть файл

@ -3,6 +3,7 @@ load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"fb_xplat_cxx_test",
"get_apple_compiler_flags",
"get_apple_inspector_flags",
@ -31,19 +32,20 @@ rn_xplat_cxx_library(
fbandroid_exported_headers = subdir_glob(
[
("", "*.h"),
("platform/cxx", "**/*.h"),
],
prefix = "react/imagemanager",
),
fbandroid_headers = subdir_glob(
[
("", "*.h"),
("platform/android", "**/*.h"),
("platform/cxx", "**/*.h"),
],
prefix = "",
),
fbandroid_srcs = glob(
[
"platform/android/**/*.cpp",
"platform/cxx/**/*.cpp",
],
),
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
@ -82,7 +84,7 @@ rn_xplat_cxx_library(
],
),
macosx_tests_override = [],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
@ -114,7 +116,7 @@ fb_xplat_cxx_test(
"-Wall",
],
contacts = ["oncall+react_native@xmail.facebook.com"],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
deps = [
"fbsource//xplat/folly:molly",
"fbsource//xplat/third-party/gmock:gtest",

Просмотреть файл

@ -3,6 +3,7 @@ load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"fb_xplat_cxx_test",
"get_apple_compiler_flags",
"get_apple_inspector_flags",
@ -41,7 +42,7 @@ rn_xplat_cxx_library(
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(),
force_static = True,
macosx_tests_override = [],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
# Systraces are temporary disabled.
@ -75,7 +76,7 @@ fb_xplat_cxx_test(
"-Wall",
],
contacts = ["oncall+react_native@xmail.facebook.com"],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
deps = [
"fbsource//xplat/folly:molly",
"fbsource//xplat/third-party/gmock:gtest",

Просмотреть файл

@ -3,6 +3,7 @@ load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"fb_xplat_cxx_test",
"get_apple_compiler_flags",
"get_apple_inspector_flags",
@ -17,21 +18,15 @@ APPLE_COMPILER_FLAGS = get_apple_compiler_flags()
rn_xplat_cxx_library(
name = "textlayoutmanager",
srcs = glob(
[
"*.cpp",
],
[],
),
headers = subdir_glob(
[
("", "*.h"),
],
[],
prefix = "",
),
header_namespace = "",
exported_headers = subdir_glob(
[
("", "*.h"),
],
[],
prefix = "react/textlayoutmanager",
),
compiler_flags = [
@ -40,12 +35,29 @@ rn_xplat_cxx_library(
"-std=c++14",
"-Wall",
],
cxx_exported_headers = subdir_glob(
[
("platform/cxx", "*.h"),
],
prefix = "react/textlayoutmanager",
),
cxx_headers = subdir_glob(
[
("platform/cxx", "**/*.h"),
],
prefix = "",
),
cxx_srcs = glob(
[
"platform/cxx/**/*.cpp",
],
),
cxx_tests = [":tests"],
fbandroid_deps = [
react_native_target("jni/react/jni:jni"),
],
fbandroid_exported_headers = subdir_glob(
[
("", "*.h"),
("platform/android", "*.h"),
],
prefix = "react/textlayoutmanager",
@ -90,12 +102,11 @@ rn_xplat_cxx_library(
],
),
macosx_tests_override = [],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
],
tests = [":tests"],
visibility = ["PUBLIC"],
deps = [
"fbsource//xplat/fbsystrace:fbsystrace",
@ -123,7 +134,12 @@ fb_xplat_cxx_test(
"-Wall",
],
contacts = ["oncall+react_native@xmail.facebook.com"],
platforms = (ANDROID, APPLE),
platforms = (
# `Apple` and `Android` flavors are disabled because the module (built with those flavors) requires Emulator/Simulator (which is expensive and slow). At the same time, we don't really have tests here.
# ANDROID,
# APPLE,
CXX,
),
deps = [
"fbsource//xplat/folly:molly",
"fbsource//xplat/third-party/gmock:gtest",

Просмотреть файл

@ -0,0 +1,27 @@
/**
* 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.
*/
#include "TextLayoutManager.h"
namespace facebook {
namespace react {
TextLayoutManager::~TextLayoutManager() {}
void *TextLayoutManager::getNativeTextLayoutManager() const {
return self_;
}
Size TextLayoutManager::measure(
AttributedString attributedString,
ParagraphAttributes paragraphAttributes,
LayoutConstraints layoutConstraints) const {
return Size{0, 0};
}
} // namespace react
} // namespace facebook

Просмотреть файл

@ -0,0 +1,54 @@
/**
* 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.
*/
#pragma once
#include <memory>
#include <react/attributedstring/AttributedString.h>
#include <react/attributedstring/ParagraphAttributes.h>
#include <react/core/LayoutConstraints.h>
#include <react/utils/ContextContainer.h>
namespace facebook {
namespace react {
class TextLayoutManager;
using SharedTextLayoutManager = std::shared_ptr<const TextLayoutManager>;
/*
* Cross platform facade for Android-specific TextLayoutManager.
*/
class TextLayoutManager {
public:
TextLayoutManager(const ContextContainer::Shared &contextContainer)
: contextContainer_(contextContainer){};
~TextLayoutManager();
/*
* Measures `attributedString` using native text rendering infrastructure.
*/
Size measure(
AttributedString attributedString,
ParagraphAttributes paragraphAttributes,
LayoutConstraints layoutConstraints) const;
/*
* Returns an opaque pointer to platform-specific TextLayoutManager.
* Is used on a native views layer to delegate text rendering to the manager.
*/
void *getNativeTextLayoutManager() const;
private:
void *self_;
ContextContainer::Shared contextContainer_;
};
} // namespace react
} // namespace facebook

Просмотреть файл

@ -3,6 +3,7 @@ load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"fb_xplat_cxx_test",
"get_apple_compiler_flags",
"get_apple_inspector_flags",
@ -40,7 +41,7 @@ rn_xplat_cxx_library(
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(),
force_static = True,
macosx_tests_override = [],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
# Systraces are temporary disabled.
@ -76,7 +77,7 @@ fb_xplat_cxx_test(
"-Wall",
],
contacts = ["oncall+react_native@xmail.facebook.com"],
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
deps = [
"fbsource//xplat/folly:molly",
"fbsource//xplat/third-party/gmock:gtest",

Просмотреть файл

@ -1,5 +1,5 @@
load("@fbsource//tools/build_defs:glob_defs.bzl", "subdir_glob")
load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "get_apple_compiler_flags", "react_native_xplat_target", "rn_xplat_cxx_library")
load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "CXX", "get_apple_compiler_flags", "react_native_xplat_target", "rn_xplat_cxx_library")
CXX_LIBRARY_COMPILER_FLAGS = [
"-std=c++14",
@ -21,7 +21,7 @@ rn_xplat_cxx_library(
],
fbobjc_compiler_flags = get_apple_compiler_flags(),
force_static = True,
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
visibility = [
"PUBLIC",
],

Просмотреть файл

@ -5,6 +5,7 @@ load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"fb_xplat_cxx_test",
"get_apple_compiler_flags",
"get_apple_inspector_flags",
@ -123,7 +124,7 @@ def rn_codegen(
],
fbobjc_compiler_flags = get_apple_compiler_flags(),
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(),
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
@ -159,7 +160,7 @@ def rn_codegen(
],
contacts = ["oncall+react_native@xmail.facebook.com"],
apple_sdks = (IOS, MACOSX),
platforms = (ANDROID, APPLE),
platforms = (ANDROID, APPLE, CXX),
deps = [
"fbsource//xplat/third-party/gmock:gtest",
":generated_components-{}".format(name),