-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add cmake formatting and linting (#6811)
## Summary 🚀 ## Test plan Android linting CI
- Loading branch information
Showing
6 changed files
with
120 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 22 additions & 41 deletions
63
packages/react-native-reanimated/android/src/main/cpp/reanimated/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,38 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
|
||
file(GLOB_RECURSE REANIMATED_COMMON_CPP_SOURCES CONFIGURE_DEPENDS "${COMMON_CPP_DIR}/reanimated/*.cpp") | ||
file(GLOB_RECURSE REANIMATED_ANDROID_CPP_SOURCES CONFIGURE_DEPENDS "${ANDROID_CPP_DIR}/reanimated/*.cpp") | ||
file(GLOB_RECURSE REANIMATED_COMMON_CPP_SOURCES CONFIGURE_DEPENDS | ||
"${COMMON_CPP_DIR}/reanimated/*.cpp") | ||
file(GLOB_RECURSE REANIMATED_ANDROID_CPP_SOURCES CONFIGURE_DEPENDS | ||
"${ANDROID_CPP_DIR}/reanimated/*.cpp") | ||
|
||
find_package(ReactAndroid REQUIRED CONFIG) | ||
|
||
add_library( | ||
reanimated | ||
SHARED | ||
${REANIMATED_COMMON_CPP_SOURCES} | ||
${REANIMATED_ANDROID_CPP_SOURCES} | ||
) | ||
add_library(reanimated SHARED ${REANIMATED_COMMON_CPP_SOURCES} | ||
${REANIMATED_ANDROID_CPP_SOURCES}) | ||
|
||
target_include_directories( | ||
reanimated | ||
PRIVATE | ||
"${COMMON_CPP_DIR}" | ||
"${ANDROID_CPP_DIR}" | ||
"${REACT_NATIVE_DIR}/ReactCommon" | ||
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/turbomodule" | ||
"${REACT_NATIVE_DIR}/ReactCommon/callinvoker" | ||
"${REACT_NATIVE_DIR}/ReactCommon/runtimeexecutor" | ||
) | ||
reanimated | ||
PRIVATE "${COMMON_CPP_DIR}" | ||
"${ANDROID_CPP_DIR}" | ||
"${REACT_NATIVE_DIR}/ReactCommon" | ||
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/turbomodule" | ||
"${REACT_NATIVE_DIR}/ReactCommon/callinvoker" | ||
"${REACT_NATIVE_DIR}/ReactCommon/runtimeexecutor") | ||
|
||
if(${IS_NEW_ARCHITECTURE_ENABLED}) | ||
target_include_directories( | ||
reanimated | ||
PRIVATE | ||
"${REACT_NATIVE_DIR}/ReactCommon/yoga" | ||
"${REACT_NATIVE_DIR}/ReactCommon/react/renderer/graphics/platform/cxx" | ||
) | ||
target_include_directories( | ||
reanimated | ||
PRIVATE | ||
"${REACT_NATIVE_DIR}/ReactCommon/yoga" | ||
"${REACT_NATIVE_DIR}/ReactCommon/react/renderer/graphics/platform/cxx") | ||
endif() | ||
|
||
set_target_properties( | ||
reanimated | ||
PROPERTIES | ||
LINKER_LANGUAGE | ||
CXX | ||
) | ||
set_target_properties(reanimated PROPERTIES LINKER_LANGUAGE CXX) | ||
|
||
target_link_libraries( | ||
reanimated | ||
worklets | ||
) | ||
target_link_libraries(reanimated worklets) | ||
|
||
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76) | ||
target_link_libraries( | ||
reanimated | ||
ReactAndroid::reactnative | ||
) | ||
target_link_libraries(reanimated ReactAndroid::reactnative) | ||
else() | ||
target_link_libraries( | ||
reanimated | ||
ReactAndroid::react_nativemodule_core | ||
) | ||
target_link_libraries(reanimated ReactAndroid::react_nativemodule_core) | ||
endif() |
161 changes: 55 additions & 106 deletions
161
packages/react-native-reanimated/android/src/main/cpp/worklets/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,139 +1,88 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
|
||
file(GLOB_RECURSE WORKLETS_COMMON_CPP_SOURCES CONFIGURE_DEPENDS "${COMMON_CPP_DIR}/worklets/*.cpp") | ||
file(GLOB_RECURSE WORKLETS_ANDROID_CPP_SOURCES CONFIGURE_DEPENDS "${ANDROID_CPP_DIR}/worklets/*.cpp") | ||
file(GLOB_RECURSE WORKLETS_COMMON_CPP_SOURCES CONFIGURE_DEPENDS | ||
"${COMMON_CPP_DIR}/worklets/*.cpp") | ||
file(GLOB_RECURSE WORKLETS_ANDROID_CPP_SOURCES CONFIGURE_DEPENDS | ||
"${ANDROID_CPP_DIR}/worklets/*.cpp") | ||
|
||
# Consume shared libraries and headers from prefabs | ||
find_package(fbjni REQUIRED CONFIG) | ||
find_package(ReactAndroid REQUIRED CONFIG) | ||
|
||
if(${JS_RUNTIME} STREQUAL "hermes") | ||
find_package(hermes-engine REQUIRED CONFIG) | ||
find_package(hermes-engine REQUIRED CONFIG) | ||
endif() | ||
|
||
add_library( | ||
worklets | ||
SHARED | ||
${WORKLETS_COMMON_CPP_SOURCES} | ||
${WORKLETS_ANDROID_CPP_SOURCES} | ||
) | ||
add_library(worklets SHARED ${WORKLETS_COMMON_CPP_SOURCES} | ||
${WORKLETS_ANDROID_CPP_SOURCES}) | ||
|
||
# includes | ||
target_include_directories( | ||
worklets | ||
PUBLIC | ||
"${COMMON_CPP_DIR}" | ||
"${ANDROID_CPP_DIR}" | ||
) | ||
target_include_directories(worklets PUBLIC "${COMMON_CPP_DIR}" | ||
"${ANDROID_CPP_DIR}") | ||
|
||
target_include_directories( | ||
worklets | ||
PRIVATE | ||
"${REACT_NATIVE_DIR}/ReactCommon" | ||
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/turbomodule" | ||
"${REACT_NATIVE_DIR}/ReactCommon/react/nativemodule/core/ReactCommon" | ||
"${REACT_NATIVE_DIR}/ReactCommon/callinvoker" | ||
"${REACT_NATIVE_DIR}/ReactCommon/runtimeexecutor" | ||
) | ||
worklets | ||
PRIVATE "${REACT_NATIVE_DIR}/ReactCommon" | ||
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/turbomodule" | ||
"${REACT_NATIVE_DIR}/ReactCommon/react/nativemodule/core/ReactCommon" | ||
"${REACT_NATIVE_DIR}/ReactCommon/callinvoker" | ||
"${REACT_NATIVE_DIR}/ReactCommon/runtimeexecutor") | ||
|
||
if(${IS_NEW_ARCHITECTURE_ENABLED}) | ||
target_include_directories( | ||
worklets | ||
PRIVATE | ||
"${REACT_NATIVE_DIR}/ReactCommon/yoga" | ||
"${REACT_NATIVE_DIR}/ReactCommon/react/renderer/graphics/platform/cxx" | ||
) | ||
target_include_directories( | ||
worklets | ||
PRIVATE | ||
"${REACT_NATIVE_DIR}/ReactCommon/yoga" | ||
"${REACT_NATIVE_DIR}/ReactCommon/react/renderer/graphics/platform/cxx") | ||
|
||
if(ReactAndroid_VERSION_MINOR LESS 76) | ||
target_link_libraries( | ||
worklets | ||
ReactAndroid::fabricjni | ||
ReactAndroid::react_debug | ||
ReactAndroid::react_render_core | ||
ReactAndroid::react_render_componentregistry | ||
ReactAndroid::rrc_view | ||
) | ||
endif() | ||
if(ReactAndroid_VERSION_MINOR LESS 76) | ||
target_link_libraries( | ||
worklets ReactAndroid::fabricjni ReactAndroid::react_debug | ||
ReactAndroid::react_render_core | ||
ReactAndroid::react_render_componentregistry ReactAndroid::rrc_view) | ||
endif() | ||
endif() | ||
|
||
# build shared lib | ||
set_target_properties( | ||
worklets | ||
PROPERTIES | ||
LINKER_LANGUAGE | ||
CXX | ||
) | ||
set_target_properties(worklets PROPERTIES LINKER_LANGUAGE CXX) | ||
|
||
target_link_libraries( | ||
worklets | ||
log | ||
ReactAndroid::jsi | ||
fbjni::fbjni | ||
) | ||
target_link_libraries(worklets log ReactAndroid::jsi fbjni::fbjni) | ||
|
||
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76) | ||
target_link_libraries( | ||
worklets | ||
ReactAndroid::reactnative | ||
) | ||
target_link_libraries(worklets ReactAndroid::reactnative) | ||
else() | ||
target_link_libraries( | ||
worklets | ||
ReactAndroid::react_nativemodule_core | ||
ReactAndroid::folly_runtime | ||
ReactAndroid::glog | ||
ReactAndroid::reactnativejni | ||
) | ||
target_link_libraries( | ||
worklets ReactAndroid::react_nativemodule_core ReactAndroid::folly_runtime | ||
ReactAndroid::glog ReactAndroid::reactnativejni) | ||
endif() | ||
|
||
if(${JS_RUNTIME} STREQUAL "hermes") | ||
target_link_libraries( | ||
worklets | ||
hermes-engine::libhermes | ||
) | ||
target_link_libraries(worklets hermes-engine::libhermes) | ||
|
||
if(${HERMES_ENABLE_DEBUGGER}) | ||
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76) | ||
target_link_libraries( | ||
worklets | ||
ReactAndroid::hermestooling | ||
) | ||
else() | ||
target_link_libraries( | ||
worklets | ||
ReactAndroid::hermes_executor | ||
) | ||
endif() | ||
endif() | ||
elseif(${JS_RUNTIME} STREQUAL "jsc") | ||
if(${HERMES_ENABLE_DEBUGGER}) | ||
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76) | ||
target_link_libraries( | ||
worklets | ||
ReactAndroid::jsctooling | ||
) | ||
target_link_libraries(worklets ReactAndroid::hermestooling) | ||
else() | ||
target_link_libraries( | ||
worklets | ||
ReactAndroid::jscexecutor | ||
) | ||
target_link_libraries(worklets ReactAndroid::hermes_executor) | ||
endif() | ||
endif() | ||
elseif(${JS_RUNTIME} STREQUAL "jsc") | ||
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76) | ||
target_link_libraries(worklets ReactAndroid::jsctooling) | ||
else() | ||
target_link_libraries(worklets ReactAndroid::jscexecutor) | ||
endif() | ||
elseif(${JS_RUNTIME} STREQUAL "v8") | ||
# TODO: Refactor this when adding support for newest V8 | ||
target_include_directories( | ||
worklets | ||
PRIVATE | ||
"${JS_RUNTIME_DIR}/src" | ||
) | ||
file(GLOB V8_SO_DIR "${JS_RUNTIME_DIR}/android/build/intermediates/library_jni/**/jni/${ANDROID_ABI}") | ||
find_library( | ||
V8EXECUTOR_LIB | ||
v8executor | ||
PATHS ${V8_SO_DIR} | ||
NO_DEFAULT_PATH | ||
NO_CMAKE_FIND_ROOT_PATH | ||
) | ||
target_link_libraries( | ||
worklets | ||
${V8EXECUTOR_LIB} | ||
) | ||
# TODO: Refactor this when adding support for newest V8 | ||
target_include_directories(worklets PRIVATE "${JS_RUNTIME_DIR}/src") | ||
file( | ||
GLOB | ||
V8_SO_DIR | ||
"${JS_RUNTIME_DIR}/android/build/intermediates/library_jni/**/jni/${ANDROID_ABI}" | ||
) | ||
find_library( | ||
V8EXECUTOR_LIB v8executor | ||
PATHS ${V8_SO_DIR} | ||
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) | ||
target_link_libraries(worklets ${V8EXECUTOR_LIB}) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
if ! which cmake-format >/dev/null; then | ||
echo "error: cmake-format is not installed" | ||
exit 1 | ||
fi | ||
|
||
cmake-format -i "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
if ! which cmake-lint >/dev/null; then | ||
echo "error: cmake-lint is not installed" | ||
exit 1 | ||
fi | ||
|
||
cmake-lint "$@" |