diff --git a/.gitignore b/.gitignore index 6e14c3fc7561c3..382e8aec6fa49f 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ project.xcworkspace /build/ /packages/react-native-codegen/android/build/ /packages/react-native-codegen/android/gradlePlugin-build/gradlePlugin/build +/packages/rn-tester/android/app/.cxx/ /packages/rn-tester/android/app/build/ /packages/rn-tester/android/app/gradle/ /packages/rn-tester/android/app/gradlew diff --git a/packages/react-native-codegen/android/generator/build.gradle b/packages/react-native-codegen/android/generator/build.gradle deleted file mode 100644 index 1ba58144a415db..00000000000000 --- a/packages/react-native-codegen/android/generator/build.gradle +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 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. - */ - -plugins { - id 'java' - id 'application' -} - -dependencies { - implementation 'com.squareup:javapoet:1.13.0' -} - -application { - mainClassName = 'com.facebook.react.codegen.JavaGeneratorMain' -} diff --git a/packages/rn-tester/android/app/build.gradle b/packages/rn-tester/android/app/build.gradle index 38b128c87a23ef..04d36897dc593b 100644 --- a/packages/rn-tester/android/app/build.gradle +++ b/packages/rn-tester/android/app/build.gradle @@ -85,6 +85,7 @@ project.ext.react = [ hermesCommand: "$rootDir/node_modules/hermes-engine/%OS-BIN%/hermesc", enableHermesForVariant: { def v -> v.name.contains("hermes") }, jsRootDir: "$rootDir/RNTester", + enableCodegen: (System.getenv('USE_CODEGEN') ?: '0').toBoolean(), enableFabric: (System.getenv('USE_FABRIC') ?: '0').toBoolean(), ] @@ -106,6 +107,11 @@ def enableSeparateBuildPerCPUArchitecture = true */ def enableProguardInReleaseBuilds = true +/** + * Build and enable codegen-related output in RN Tester app. + */ +def enableCodegen = project.ext.react.enableCodegen + /** * Build and enable Fabric in RN Tester app. */ @@ -179,6 +185,29 @@ android { } } +if (enableCodegen) { + android { + defaultConfig { + externalNativeBuild { + ndkBuild { + abiFilters "armeabi-v7a", "x86", "x86_64", "arm64-v8a" + arguments "APP_PLATFORM=android-16", + "APP_STL=c++_shared", + "NDK_TOOLCHAIN_VERSION=clang" + cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1" + cppFlags "-std=c++1y" + targets "rntester_appmodules" + } + } + } + externalNativeBuild { + ndkBuild { + path "$projectDir/src/main/jni/Android.mk" + } + } + } +} + configurations { hermesDebugImplementation {} hermesReleaseImplementation {} diff --git a/packages/rn-tester/android/app/src/main/jni/Android.mk b/packages/rn-tester/android/app/src/main/jni/Android.mk new file mode 100644 index 00000000000000..c5c26f6e1da7e9 --- /dev/null +++ b/packages/rn-tester/android/app/src/main/jni/Android.mk @@ -0,0 +1,29 @@ +# 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. + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := rntester_appmodules + +LOCAL_C_INCLUDES := $(LOCAL_PATH) + +LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) + +# TODO +# LOCAL_SHARED_LIBRARIES := libreact_nativemodule_core libreactnativejni + +# TODO +# LOCAL_STATIC_LIBRARIES := libjsi + +LOCAL_CFLAGS := \ + -DLOG_TAG=\"ReactNative\" + +LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall + +include $(BUILD_SHARED_LIBRARY) diff --git a/packages/rn-tester/android/app/src/main/jni/RNTesterAppModuleProvider.cpp b/packages/rn-tester/android/app/src/main/jni/RNTesterAppModuleProvider.cpp new file mode 100644 index 00000000000000..7a6e281f1020a2 --- /dev/null +++ b/packages/rn-tester/android/app/src/main/jni/RNTesterAppModuleProvider.cpp @@ -0,0 +1,18 @@ +/* + * 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 "RNTesterAppModuleProvider.h" + +namespace facebook { +namespace react { + +std::shared_ptr RNTesterAppModuleProvider(const std::string moduleName) { + return nullptr; +} + +} // namespace react +} // namespace facebook diff --git a/packages/rn-tester/android/app/src/main/jni/RNTesterAppModuleProvider.h b/packages/rn-tester/android/app/src/main/jni/RNTesterAppModuleProvider.h new file mode 100644 index 00000000000000..50a7e16fd96463 --- /dev/null +++ b/packages/rn-tester/android/app/src/main/jni/RNTesterAppModuleProvider.h @@ -0,0 +1,19 @@ +/* + * 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 +#include + +namespace facebook { +namespace react { + +std::shared_ptr RNTesterAppModuleProvider(const std::string moduleName); + +} // namespace react +} // namespace facebook