I am trying to build a custom kernel with Renderscript in Android native development. But got stuck at the compilation step. I took reference with the https://github.com/rpattabi/renderscript-ndk-cmake. Below is my CMakeList.txt
cmake_minimum_required(VERSION 3.4.1)
if(${CMAKE_BUILD_TYPE} MATCHES Release)
set (SRC_RS_GENERATED_PATH
build/generated/source/rs/release)
else()
set (SRC_RS_GENERATED_PATH
build/generated/source/rs/debug)
endif()
set(RENDER_SCRIPT_HEADERS_PATH ${CMAKE_ANDROID_NDK}/toolchains/renderscript/prebuilt/${ANDROID_HOST_TAG}/platform/rs)
include_directories(
${RENDER_SCRIPT_HEADERS_PATH}/cpp
${RENDER_SCRIPT_HEADERS_PATH}/scriptc
${RENDER_SCRIPT_HEADERS_PATH}
${SRC_RS_GENERATED_PATH}
)
set(RENDER_SCRIPT_LIB_PATH ${CMAKE_ANDROID_NDK}/toolchains/renderscript/prebuilt/${ANDROID_HOST_TAG}/platform/${ANDROID_SYSROOT_ABI})
find_library(rscript
NAMES RScpp_static libRScpp_static.a
HINTS ${RENDER_SCRIPT_LIB_PATH}/
)
find_library(blasv8
NAMES blasV8 libblasV8.so
HINTS ${RENDER_SCRIPT_LIB_PATH}/)
find_library(rssupport
NAMES libRSSupport.so
HINTS ${RENDER_SCRIPT_LIB_PATH}/)
add_library(
renderscript
SHARED
RenderScript.cpp
threshold.rs
${SRC_RS_GENERATED_PATH}/ScriptC_threshold.cpp #This file is missing <<<<<<<<<<<<<<<
)
target_link_libraries(
renderscript
log
${rscript}
${rssupport}
${blasv8}
android
jnigraphics
)
The first few parts are just finding the headers for prebuilt library for renderscript in the Android NDK.
The error comes at building the renderscript
library part. It suppose to build the threshold.rs
file, and generate a header and cpp pair (ScriptC_threshold.h and ScriptC_threshold.cpp), which the source code for renderscript
will include.
However, the build script does not generate the ScriptC_threshold.h
headers. What is the procedure or CMakeList configuration that allows me to generate the header file from rs
files?
Update 1 As suggested by Dan, I change the build script from cmakeList to Android.mk. However, I got another error
[x86] Compile RS : renderscript <= threshold.rs
error: error opening 'E:/dev/android/RenderScriptMk/app/E:/dev/android/RenderScriptMk/app/build/intermediates/ndkBuild/debug/obj/local/x86/objs-debug/renderscript/\threshold.bc': Invalid argument
make: *** [E:/dev/android/RenderScriptMk/app/build/intermediates/ndkBuild/debug/obj/local/x86/objs-debug/renderscript/threshold.o] Error 1
It appears the build process failed to generate the .bc file from the .rs script. I am stuck again. I uploaded my code to Github, it should be able to reproduce.