From e85d70c8acae2c4ff939ebd5fd07a47914d451cb Mon Sep 17 00:00:00 2001 From: Andrew Datsenko Date: Wed, 19 Feb 2025 09:15:07 -0800 Subject: [PATCH] Create a CMake executable target (#49526) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/49526 Changelog: [Internal] Introduce a binary tester for Fantom that will be used in runner when ready so OSS can run integration tests. Here: - Add BUCK target - Add CMake target Reviewed By: cortinico Differential Revision: D69800975 fbshipit-source-id: 57e135e2a1cbfb88e0141ddc7859b9a29365ee1f --- .gitignore | 1 + .../react-native-fantom/tester/CMakeLists.txt | 37 +++++++++++++++++++ packages/react-native-fantom/tester/build.sh | 14 +++++++ .../react-native-fantom/tester/src/main.cpp | 19 ++++++++++ 4 files changed, 71 insertions(+) create mode 100644 packages/react-native-fantom/tester/CMakeLists.txt create mode 100755 packages/react-native-fantom/tester/build.sh create mode 100644 packages/react-native-fantom/tester/src/main.cpp diff --git a/.gitignore b/.gitignore index f67615b93e6..e0db44b0d94 100644 --- a/.gitignore +++ b/.gitignore @@ -163,6 +163,7 @@ fix_*.patch # Jest Integration /packages/react-native-fantom/build/ +/packages/react-native-fantom/tester/build/ # [Experimental] Generated TS type definitions /packages/**/types_generated/ diff --git a/packages/react-native-fantom/tester/CMakeLists.txt b/packages/react-native-fantom/tester/CMakeLists.txt new file mode 100644 index 00000000000..f64db755a41 --- /dev/null +++ b/packages/react-native-fantom/tester/CMakeLists.txt @@ -0,0 +1,37 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +project(fantom_tester) + +# Convert input paths to CMake format (with forward slashes) +file(TO_CMAKE_PATH "${REACT_COMMON_DIR}" REACT_COMMON_DIR) + +# Make sure every shared lib includes a .note.gnu.build-id header +add_link_options(-Wl,--build-id) + +function(add_react_common_subdir relative_path) + add_subdirectory(${REACT_COMMON_DIR}/${relative_path} src/${relative_path}) +endfunction() + +# Third-party downloaded targets + +# Common targets +add_react_common_subdir(yoga) + +file(GLOB SOURCES "src/*.cpp" "src/*.h") +add_executable(fantom_tester ${SOURCES}) + +target_link_libraries(fantom_tester PUBLIC yogacore) + +target_compile_options(fantom_tester + PRIVATE + -Wall + -Werror + -fexceptions + -frtti + -std=c++20) diff --git a/packages/react-native-fantom/tester/build.sh b/packages/react-native-fantom/tester/build.sh new file mode 100755 index 00000000000..5f3b1be771a --- /dev/null +++ b/packages/react-native-fantom/tester/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +set -e + +SCRIPT_DIR=$(dirname "$(readlink -f "$0")") +BUILD_DIR="$SCRIPT_DIR/build" +REACT_NATIVE_ROOT_DIR=$(readlink -f "$SCRIPT_DIR/../../react-native") + +cmake -S "$SCRIPT_DIR" -B "$BUILD_DIR" -DREACT_COMMON_DIR="${REACT_NATIVE_ROOT_DIR}/ReactCommon" +cmake --build "$BUILD_DIR" --target fantom_tester diff --git a/packages/react-native-fantom/tester/src/main.cpp b/packages/react-native-fantom/tester/src/main.cpp new file mode 100644 index 00000000000..043267c0a63 --- /dev/null +++ b/packages/react-native-fantom/tester/src/main.cpp @@ -0,0 +1,19 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#include +#include +#include + +int main() { + std::cout << "Hello, I am fantom_tester using Yoga!" << std::endl; + + std::cout << "[Yoga] undefined == zero: " << (YGValueZero == YGValueUndefined) + << std::endl; + + return 0; +}