Top | ![]() |
![]() |
![]() |
![]() |
IdeCompileCommands * | ide_compile_commands_new () |
gboolean | ide_compile_commands_load () |
void | ide_compile_commands_load_async () |
gboolean | ide_compile_commands_load_finish () |
gchar ** | ide_compile_commands_lookup () |
The IdeCompileCommands object provides a simplified interface to interact with compile_commands.json files which are generated by a number of build systems, including Clang tooling, Meson and CMake.
Create a new IdeCompileCommands instance, and then asynchronously
load the file using ide_compile_commands_load_async()
. After the
database has been loaded, you can access build commands using
ide_compile_commands_lookup()
.
Due to the rather unfortunate design of JSON, this file holds on to a number of strings during the lifetime of the object, for each of the compile commands. On larger projects, this can be the order of a couple of megabytes.
IdeCompileCommands *
ide_compile_commands_new (void
);
Creates a new IdeCompileCommands object which can be used to parse clang-style compile commands database files (compile_commands.json).
Since: 3.28
gboolean ide_compile_commands_load (IdeCompileCommands *self
,GFile *file
,GCancellable *cancellable
,GError **error
);
Synchronously loads the contents of the requested file
and parses
the JSON command database contained within.
You may only call this function once on an IdeCompileCommands object. If there is a failure, you must create a new IdeCompileCommands instance instead of calling this function again.
See also: ide_compile_commands_load_async()
self |
||
file |
a GFile |
|
cancellable |
a GCancellable, or |
[nullable] |
error |
A location for a GError, or |
Since: 3.28
void ide_compile_commands_load_async (IdeCompileCommands *self
,GFile *file
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Asynchronously loads the contents of the requested file
and parses
the JSON command database contained within.
You may only call this function once on an IdeCompileCommands object. If there is a failure, you must create a new IdeCompileCommands instance instead of calling this function again.
See also: ide_compile_commands_load_finish()
self |
||
file |
a GFile |
|
cancellable |
a GCancellable, or |
[nullable] |
callback |
the callback for the async operation |
|
user_data |
user data for |
Since: 3.28
gboolean ide_compile_commands_load_finish (IdeCompileCommands *self
,GAsyncResult *result
,GError **error
);
Completes an asynchronous request to ide_compile_commands_load_async()
.
See also: ide_compile_commands_load_async()
self |
||
result |
a GAsyncResult provided to the callback |
|
error |
A location for a GError, or |
Since: 3.28
gchar ** ide_compile_commands_lookup (IdeCompileCommands *self
,GFile *file
,const gchar * const *system_includes
,GFile **directory
,GError **error
);
Locates the commands to compile the file
requested.
If directory
is non-NULL, then the directory to run the command from
is placed in directory
.
self |
||
file |
a GFile representing the file to lookup |
|
system_includes |
system include dirs if any |
|
directory |
A location for a GFile, or |
[out][optional][transfer full] |
error |
A location for a GError, or |
A string array or NULL
if
there was a failure to locate or parse the command.
[nullable][transfer full]
Since: 3.28