|
| 1 | +# |
| 2 | +# Copyright (c) Software Mansion <swmansion.com>. |
| 3 | +# Copyright (c) Kudo Chien. |
| 4 | +# |
| 5 | +# This source code is licensed under the MIT license found in the |
| 6 | +# LICENSE file in the root directory of this source tree. |
| 7 | +# |
| 8 | + |
| 9 | +cmake_minimum_required(VERSION 3.5.1) |
| 10 | + |
| 11 | +set(CMAKE_VERBOSE_MAKEFILE ON) |
| 12 | +set(CMAKE_CXX_STANDARD 14) |
| 13 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 14 | +set(CMAKE_CXX_EXTENSIONS OFF) |
| 15 | +set(CMAKE_CXX_FLAGS "-DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -fexceptions -fno-omit-frame-pointer -frtti -Wno-sign-compare") |
| 16 | + |
| 17 | +# if(${NATIVE_DEBUG}) |
| 18 | +# set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g") |
| 19 | +# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g") |
| 20 | +# endif() |
| 21 | + |
| 22 | +if(${ANDROID_ABI} STREQUAL "arm64-v8a" OR ${ANDROID_ABI} STREQUAL "x86_64") |
| 23 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DV8_COMPRESS_POINTERS") |
| 24 | +endif() |
| 25 | + |
| 26 | +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| 27 | +set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") |
| 28 | + |
| 29 | +set(PACKAGE_NAME "v8executor") |
| 30 | +set(SRC_DIR "${CMAKE_SOURCE_DIR}/src/main/cpp") |
| 31 | + |
| 32 | +set(RN_SO_DIR "${RN_DIR}/ReactAndroid/src/main/jni/first-party/react/jni") |
| 33 | +set(FBJNI_HEADERS_DIR "${RN_SO_DIR}/../../fbjni/headers") |
| 34 | + |
| 35 | +set(V8RUNTIME_COMMON_DIR "${CMAKE_SOURCE_DIR}/../src/v8runtime") |
| 36 | +file(GLOB SOURCES_V8RUNTIME "${V8RUNTIME_COMMON_DIR}/*.cpp") |
| 37 | + |
| 38 | +add_library( |
| 39 | + ${PACKAGE_NAME} |
| 40 | + SHARED |
| 41 | + ${SOURCES_V8RUNTIME} |
| 42 | + "${SRC_DIR}/V8ExecutorFactory.cpp" |
| 43 | + "${SRC_DIR}/OnLoad.cpp" |
| 44 | +) |
| 45 | + |
| 46 | +# includes |
| 47 | + |
| 48 | +file(GLOB LIBFBJNI_INCLUDE_DIR ${FBJNI_HEADERS_DIR}) |
| 49 | + |
| 50 | +target_include_directories( |
| 51 | + ${PACKAGE_NAME} |
| 52 | + PRIVATE |
| 53 | + "${V8RUNTIME_COMMON_DIR}" |
| 54 | + "${LIBFBJNI_INCLUDE_DIR}" |
| 55 | + "${BUILD_DIR}/third-party-ndk/boost/boost_${BOOST_VERSION}" |
| 56 | + "${BUILD_DIR}/third-party-ndk/double-conversion" |
| 57 | + "${BUILD_DIR}/third-party-ndk/folly" |
| 58 | + "${BUILD_DIR}/third-party-ndk/glog/exported" |
| 59 | + "${RN_DIR}/ReactAndroid/src/main/jni" |
| 60 | + "${RN_DIR}/ReactCommon" |
| 61 | + "${RN_DIR}/ReactCommon/jsi" |
| 62 | + "${RN_DIR}/ReactCommon/jsiexecutor" |
| 63 | + "${V8_ANDROID_DIR}/dist/include" |
| 64 | +) |
| 65 | + |
| 66 | +# find libraries |
| 67 | + |
| 68 | +file(GLOB LIBRN_DIR "${RN_SO_DIR}/${ANDROID_ABI}") |
| 69 | +file(GLOB LIBV8_DIR "${RN_SO_DIR}/../../v8/jni/${ANDROID_ABI}") |
| 70 | + |
| 71 | +find_library( |
| 72 | + LOG_LIB |
| 73 | + log |
| 74 | +) |
| 75 | +find_library( |
| 76 | + FOLLY_JSON_LIB |
| 77 | + folly_json |
| 78 | + PATHS ${LIBRN_DIR} |
| 79 | + NO_CMAKE_FIND_ROOT_PATH |
| 80 | +) |
| 81 | +find_library( |
| 82 | + REACT_NATIVE_JNI_LIB |
| 83 | + reactnativejni |
| 84 | + PATHS ${LIBRN_DIR} |
| 85 | + NO_CMAKE_FIND_ROOT_PATH |
| 86 | +) |
| 87 | +find_library( |
| 88 | + GLOG_LIB |
| 89 | + glog |
| 90 | + PATHS ${LIBRN_DIR} |
| 91 | + NO_CMAKE_FIND_ROOT_PATH |
| 92 | +) |
| 93 | +find_library( |
| 94 | + FBJNI_LIB |
| 95 | + fbjni |
| 96 | + PATHS ${LIBRN_DIR} |
| 97 | + NO_CMAKE_FIND_ROOT_PATH |
| 98 | +) |
| 99 | +find_library( |
| 100 | + JSI_LIB |
| 101 | + jsi |
| 102 | + PATHS ${LIBRN_DIR} |
| 103 | + NO_CMAKE_FIND_ROOT_PATH |
| 104 | +) |
| 105 | +find_library( |
| 106 | + V8_ANDROID_LIB |
| 107 | + v8android |
| 108 | + PATHS ${LIBV8_DIR} |
| 109 | + NO_CMAKE_FIND_ROOT_PATH |
| 110 | +) |
| 111 | + |
| 112 | +# reactnative_internal_static |
| 113 | +file(GLOB INCLUDE_RN_JSIREACT_CPP "${RN_DIR}/ReactCommon/jsiexecutor/jsireact/*.cpp") |
| 114 | +file(GLOB INCLUDE_RN_JSINSPECTOR_CPP "${RN_DIR}/ReactCommon/jsinspector/*.cpp") |
| 115 | +file(GLOB INCLUDE_RN_REACTPERFLOGGER_CPP "${RN_DIR}/ReactCommon/reactperflogger/reactperflogger/*.cpp") |
| 116 | + |
| 117 | +add_library( |
| 118 | + reactnative_internal_static |
| 119 | + STATIC |
| 120 | + "${INCLUDE_RN_JSIREACT_CPP}" |
| 121 | + "${INCLUDE_RN_JSINSPECTOR_CPP}" |
| 122 | + "${INCLUDE_RN_REACTPERFLOGGER_CPP}" |
| 123 | + "${RN_DIR}/ReactCommon/cxxreact/JSExecutor.cpp" |
| 124 | +) |
| 125 | + |
| 126 | +target_include_directories( |
| 127 | + reactnative_internal_static |
| 128 | + PRIVATE |
| 129 | + "${BUILD_DIR}/third-party-ndk/boost/boost_${BOOST_VERSION}" |
| 130 | + "${BUILD_DIR}/third-party-ndk/double-conversion" |
| 131 | + "${BUILD_DIR}/third-party-ndk/folly" |
| 132 | + "${BUILD_DIR}/third-party-ndk/glog/exported" |
| 133 | + "${RN_DIR}/ReactCommon" |
| 134 | + "${RN_DIR}/ReactCommon/jsi" |
| 135 | + "${RN_DIR}/ReactCommon/jsiexecutor" |
| 136 | + "${RN_DIR}/ReactCommon/jsinspector" |
| 137 | + "${RN_DIR}/ReactCommon/reactperflogger" |
| 138 | +) |
| 139 | + |
| 140 | +target_link_libraries( |
| 141 | + reactnative_internal_static |
| 142 | + ${FOLLY_JSON_LIB} |
| 143 | +) |
| 144 | + |
| 145 | +# link to shared libraries |
| 146 | + |
| 147 | +set_target_properties(${PACKAGE_NAME} PROPERTIES LINKER_LANGUAGE CXX) |
| 148 | + |
| 149 | +target_link_libraries( |
| 150 | + ${PACKAGE_NAME} |
| 151 | + ${LOG_LIB} |
| 152 | + ${JSI_LIB} |
| 153 | + ${GLOG_LIB} |
| 154 | + ${FBJNI_LIB} |
| 155 | + ${FOLLY_JSON_LIB} |
| 156 | + ${REACT_NATIVE_JNI_LIB} |
| 157 | + ${V8_ANDROID_LIB} |
| 158 | + reactnative_internal_static |
| 159 | + android |
| 160 | +) |
0 commit comments