how to get compile_commands.json by mma or mm from android.mk in aosp project of android 9

1,733 views
Skip to first unread message

ggl...@gmail.com

unread,
Mar 18, 2019, 12:54:54 PM3/18/19
to Android Building
I can get CMakeLists.txt from Android.bp by soong, then get compile_commands, but cann't get CMakeLists.json from android.mk. I've tried pass ' -t compdb cxx' but just get empty "[ \n ]" , any one can help me?


Dan Willemsen

unread,
Mar 18, 2019, 1:18:35 PM3/18/19
to Android Building
The ninja compilation database support doesn't work very well for our ninja files due to kati using a rule per command. This upstream ninja feature request may help, but that's assuming that whatever is parsing the compdb files can understand the raw rules (which is usually a bash script, not just a call to the compiler): https://github.com/ninja-build/ninja/issues/1377

I'd recommend converting to Android.bp so that you can use SOONG_GEN_COMPDB.

- Dan

On Mon, Mar 18, 2019 at 9:54 AM <ggl...@gmail.com> wrote:
I can get CMakeLists.txt from Android.bp by soong, then get compile_commands, but cann't get CMakeLists.json from android.mk. I've tried pass ' -t compdb cxx' but just get empty "[ \n ]" , any one can help me?


--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nick Diego Yamane

unread,
Mar 18, 2019, 4:34:13 PM3/18/19
to android-...@googlegroups.com
An alternative option would be compiledb tool (https://github.com/nickdiego/compiledb), which is able to parse compile commands from a build log. Some years ago I've been able to parse compilation database from some AOSP modules using a similar approach.

刘昊

unread,
Mar 18, 2019, 10:00:52 PM3/18/19
to android-...@googlegroups.com
some module like frameworks/av is really hard to convert to Android.bp.  In android-9.0.0_r34 , SOONG_GEN_COMPDB can't use directly, I need add related file to aosp soong module, then recompile soong, then I can SOONG_GEN_COMPDB, but the generated compile_commands is really big, like 83M. generated by CMakeLists.txt is much smaller. :)

'Dan Willemsen' via Android Building <android-...@googlegroups.com> 于2019年3月19日周二 上午1:18写道:

刘昊

unread,
Mar 18, 2019, 10:00:52 PM3/18/19
to android-...@googlegroups.com
thanks, I've tried compiledb-aosp.sh in android-9.0.0_r34, but failed. here is the out put

alex@alex-pc:~/code-reviww/aosp$ ./aosp-compdb.sh
# Loading build env
# Configuring x86_64 build
# Chosen module: bionic/libc
# Generating compilation database file /home/alex/code-reviww/aosp/bionic/libc/compile_commands.json
alex@alex-pc:~/code-reviww/aosp$ ls /home/alex/code-reviww/aosp/bionic/libc/compile_commands.json
ls: cannot access '/home/alex/code-reviww/aosp/bionic/libc/compile_commands.json': No such file or directory


Nick Diego Yamane <nick....@gmail.com> 于2019年3月19日周二 上午4:34写道:

Rounak Agarwal

unread,
Aug 25, 2019, 8:43:30 PM8/25/19
to Android Building
Hi Dan. It looks like the option SOONG_GEN_COMPDB is not available in Pie branches. Perhaps it was added later. I wish to make use of this option. Will it be safe to use soong from master branch with Pie source code ? Were any breaking changes made in soong since Pie was branched out ?


On Monday, 18 March 2019 22:48:35 UTC+5:30, Dan Willemsen wrote:
The ninja compilation database support doesn't work very well for our ninja files due to kati using a rule per command. This upstream ninja feature request may help, but that's assuming that whatever is parsing the compdb files can understand the raw rules (which is usually a bash script, not just a call to the compiler): https://github.com/ninja-build/ninja/issues/1377

I'd recommend converting to Android.bp so that you can use SOONG_GEN_COMPDB.

- Dan

On Mon, Mar 18, 2019 at 9:54 AM <ggl...@gmail.com> wrote:
I can get CMakeLists.txt from Android.bp by soong, then get compile_commands, but cann't get CMakeLists.json from android.mk. I've tried pass ' -t compdb cxx' but just get empty "[ \n ]" , any one can help me?


--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-...@googlegroups.com.

Paschalis Mpeis

unread,
May 26, 2020, 10:57:14 AM5/26/20
to Android Building
In my case SOONG_GEN_COMPDB exists (android 10), but following the instructions here did not generate the json file,
unless you actually proceed with a full build (i.e., make nothing didn't produce the file, and `m <multiple targets>` also didn't work.

But the suggested approach of building the json file using the output build log did work.
So you do the compilation as you would normally do (either full, or a subset), and then use the log file to generate the compdb like:

`compiledb --parse out/verbose.log`
Reply all
Reply to author
Forward
0 new messages