soong delete the direct way to get compile_commands, which is suck to use, but instead ,provide a way to get clion project file, you can find it in soong document. but some generated CMakeList.txt is hard use like drm module, there are many CMakeList.txt generated in drm module, but I just want a compile_commands, not so many split .
so I write a script to solve it
cmake_minimum_required(VERSION 3.10)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(MY_CURRENT_DIR "./")
file(GLOB_RECURSE all ${MY_CURRENT_DIR}/CMakeLists.txt)
foreach(file ${all})
string(REPLACE "/CMakeLists.txt" "" direct ${file})
STRING(FIND ${direct} "arm64" result)
if (NOT -1 EQUAL ${result})
ADD_SUBDIRECTORY(${direct})
endif()
endforeach()
perfect version
current_absolute_workspace=$(pwd)
current_relative_workspace=${current_absolute_workspace#$ANDROID_BUILD_TOP}
export SOONG_GEN_CMAKEFILES=1
export SOONG_GEN_CMAKEFILES_DEBUG=1
mma
cd $ANDROID_BUILD_TOP/out/development/ide/clion/$current_relative_workspace
file=./CMakeLists.txt
if [ -e "$file" ]; then
echo "File exists"
else
cat > CMakeLists.txt << EOF
cmake_minimum_required(VERSION 3.10)
set(MY_CURRENT_DIR "./")
file(GLOB_RECURSE all ${MY_CURRENT_DIR}/CMakeLists.txt)
foreach(file ${all})
string(REPLACE "/CMakeLists.txt" "" direct ${file})
STRING(FIND ${direct} "arm64" result)
if (NOT -1 EQUAL ${result})
ADD_SUBDIRECTORY(${direct})
endif()
endforeach()
EOF
fi
mkdir build
cd build
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cp ./compile_commands.json $current_absolute_workspace
cd $current_absolute_workspace
将drm的android.mk修改为android.bp
由于android.mk无法生成对应的clion工程,所以需要将android.mk转化为android.bp,androidmk适应于简单情况,当android.mk复杂时需要手动转化。drm就是一个例子,他的mk文件使用了proto,参照其他bp文件处理proto的方法,做如下修正
aosp/frameworks/av/drm/mediacas/plugins/clearkey
//
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
cc_library_shared {
srcs: [
"ClearKeyCasPlugin.cpp",
"ClearKeyFetcher.cpp",
"ClearKeyLicenseFetcher.cpp",
"ClearKeySessionLibrary.cpp",
"ecm.cpp",
"ecm_generator.cpp",
"JsonAssetLoader.cpp",
"protos/license_protos.proto",
],
name: "libclearkeycasplugin",
proprietary: true,
relative_install_path: "mediacas",
shared_libs: [
"libutils",
"liblog",
"libcrypto",
"libstagefright_foundation",
"libprotobuf-cpp-lite",
"libRScpp",
],
header_libs: ["media_plugin_headers"],
static_libs: ["libjsmn"],
proto: {
export_proto_headers: true,
type: "full",
},
include_dirs: [
"external/jsmn",
"frameworks/av/include",
"frameworks/native/include/media",
"frameworks/av/drm/mediacas/plugins/clearkey/protos",
],
export_include_dirs: ["."],
}
//########################################################################
// Build unit tests
// ANDROIDMK TRANSLATION ERROR: unsupported include
// include $(LOCAL_PATH)/tests/Android.mk
网友评论