aboutsummaryrefslogtreecommitdiff
path: root/tools/generate-sysroot.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/generate-sysroot.c')
-rw-r--r--tools/generate-sysroot.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/tools/generate-sysroot.c b/tools/generate-sysroot.c
index 1acf35f..97d5bb5 100644
--- a/tools/generate-sysroot.c
+++ b/tools/generate-sysroot.c
@@ -68,24 +68,29 @@ static void write_sysroot_data(struct sysroot_output *out, char const *name,
size_t size = (size_t)pos;
fprintfx(out->h, "extern struct pw_sysroot_data %s;\n", name);
- fprintfx(out->c, "struct pw_sysroot_data %s = {\n", name);
- fprintfx(out->c, " .size = %zu,\n", size);
- fprintfx(out->c, " .data = {\n");
+ fprintfx(out->c, "static uint8_t const %s_data[] = {\n", name);
size_t total = 0;
- size_t n;
- uint8_t data[16];
- while ((n = fread(data, 1, sizeof(data), f))) {
- total += n;
-
- fprintfx(out->c, " ");
- for (size_t i = 0; i < n; i++) {
- fprintfx(out->c, " 0x%02x,", data[i]);
+ {
+ size_t n;
+ uint8_t data[16];
+ while ((n = fread(data, 1, sizeof(data), f))) {
+ total += n;
+
+ fprintfx(out->c, " ");
+ for (size_t i = 0; i < n; i++) {
+ fprintfx(out->c, " 0x%02x,", data[i]);
+ }
+ fprintfx(out->c, "\n");
}
- fprintfx(out->c, "\n");
}
-
- fprintfx(out->c, " },\n};\n");
+ fprintfx(out->c,
+ "};\n"
+ "struct pw_sysroot_data %s = {\n"
+ " .data = %s_data,\n"
+ " .size = %zu,\n"
+ "};\n",
+ name, name, size);
check(total == size, "fread(input)");
fclosex(f);
@@ -109,8 +114,8 @@ int main(int argc, char *argv[argc + 1]) {
"#include <stddef.h>\n"
"#include <stdint.h>\n\n"
"struct pw_sysroot_data {\n"
+ " uint8_t const *data;\n"
" size_t size;\n"
- " uint8_t data[];\n"
"};\n\n");
fprintfx(out.c,
"// This file is automatically generated, do not edit by hand.\n"