Escape spaces in depfile with backslashes.

This matches how Linux escapes spaces in paths.
The same syntax is also used by other build tools that output depfiles,
e.g. edd36eba5e/src/cargo/core/compiler/output_depinfo.rs (L19)

Signed-off-by: Colin Finck <mail@colinfinck.de>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Colin Finck 2024-10-21 13:34:25 +02:00 committed by David Gibson
parent f9968fa069
commit 18aa49a9f6
4 changed files with 28 additions and 3 deletions

5
util.h
View file

@ -42,6 +42,11 @@ static inline void NORETURN PRINTF(1, 2) die(const char *str, ...)
exit(1);
}
/**
* Writes path to fp, escaping spaces with a backslash.
*/
void fprint_path_escaped(FILE *fp, const char *path);
static inline void *xmalloc(size_t len)
{
void *new = malloc(len);