diff options
| author | Nicholas Rodrigues Lordello <[email protected]> | 2026-10-23 22:07:14 +0200 |
|---|---|---|
| committer | Nicholas Rodrigues Lordello <[email protected]> | 2026-10-23 23:03:39 +0200 |
| commit | 1c4eada99c6f98eae40c676d261c8d4fc1de6079 (patch) | |
| tree | 9eb46918b0252cddd5b3131aea0494eb4ed6d27c /tools | |
| parent | 7c789a974625bcee34a22757344cf4fbe268e0b5 (diff) | |
Various Small Bug Fixes
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/generate-sysroot.c | 35 |
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" |
