mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-26 00:20:37 +02:00
mesa_clc: add depfile support
This allows the tool to tell ninja what headers it read, so ninja can correctly rebuild when necessary. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Dylan Baker <dylan.c.baker@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32505>
This commit is contained in:
parent
33a1acb0da
commit
3d35ea6a6b
1 changed files with 23 additions and 3 deletions
|
|
@ -5,6 +5,8 @@
|
|||
*/
|
||||
|
||||
#include "compiler/clc/clc.h"
|
||||
#include "util/hash_table.h"
|
||||
#include "util/set.h"
|
||||
#include "util/u_dynarray.h"
|
||||
|
||||
#include <getopt.h>
|
||||
|
|
@ -58,11 +60,12 @@ main(int argc, char **argv)
|
|||
{"help", no_argument, 0, 'h'},
|
||||
{"in", required_argument, 0, 'i'},
|
||||
{"out", required_argument, 0, 'o'},
|
||||
{"depfile", required_argument, 0, 'd'},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
|
||||
char *outfile = NULL;
|
||||
char *outfile = NULL, *depfile = NULL;
|
||||
struct util_dynarray clang_args;
|
||||
struct util_dynarray input_files;
|
||||
struct util_dynarray spirv_objs;
|
||||
|
|
@ -75,8 +78,11 @@ main(int argc, char **argv)
|
|||
util_dynarray_init(&spirv_objs, mem_ctx);
|
||||
util_dynarray_init(&spirv_ptr_objs, mem_ctx);
|
||||
|
||||
struct set *deps =
|
||||
_mesa_set_create(mem_ctx, _mesa_hash_string, _mesa_key_string_equal);
|
||||
|
||||
int ch;
|
||||
while ((ch = getopt_long(argc, argv, "he:i:o:v", long_options, NULL)) !=
|
||||
while ((ch = getopt_long(argc, argv, "he:i:o:d:v", long_options, NULL)) !=
|
||||
-1) {
|
||||
switch (ch) {
|
||||
case 'h':
|
||||
|
|
@ -85,6 +91,9 @@ main(int argc, char **argv)
|
|||
case 'o':
|
||||
outfile = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
depfile = optarg;
|
||||
break;
|
||||
case 'i':
|
||||
util_dynarray_append(&input_files, char *, optarg);
|
||||
break;
|
||||
|
|
@ -155,12 +164,13 @@ main(int argc, char **argv)
|
|||
struct clc_binary *spirv_out =
|
||||
util_dynarray_grow(&spirv_objs, struct clc_binary, 1);
|
||||
|
||||
if (!clc_compile_c_to_spirv(&clc_args, &logger, spirv_out, NULL)) {
|
||||
if (!clc_compile_c_to_spirv(&clc_args, &logger, spirv_out, deps)) {
|
||||
ralloc_free(mem_ctx);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
util_dynarray_foreach(&spirv_objs, struct clc_binary, p) {
|
||||
util_dynarray_append(&spirv_ptr_objs, struct clc_binary *, p);
|
||||
}
|
||||
|
|
@ -205,6 +215,16 @@ main(int argc, char **argv)
|
|||
fwrite(final_spirv.data, final_spirv.size, 1, fp);
|
||||
fclose(fp);
|
||||
|
||||
if (depfile) {
|
||||
FILE *fp = fopen(depfile, "w");
|
||||
fprintf(fp, "%s:", outfile);
|
||||
set_foreach(deps, ent) {
|
||||
fprintf(fp, " %s", (const char *)ent->key);
|
||||
}
|
||||
fprintf(fp, "\n");
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
util_dynarray_foreach(&spirv_objs, struct clc_binary, p) {
|
||||
clc_free_spirv(p);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue