aboutsummaryrefslogtreecommitdiff
path: root/blob
blob: e0f4b4cb601d2cec8d6a0086d73976eec3207204 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh
input="$1"
base="$2"
symbol_base="$(echo "$base" | tr '[:punct:]' '_')"

# assembly (used to compile data with custom symbol name)
cat << EOF > "$base.s"
.section .rodata
.global ${symbol_base}_head
${symbol_base}_head:
.incbin "$input"
EOF

# C header
cat << EOF > "$base.h"
#pragma once
// NOTE: THIS FILE IS GENERATED, DO NOT EDIT
#include <stddef.h>

extern const char ${symbol_base}_head;
static const char* ${symbol_base} = &${symbol_base}_head;
static const size_t ${symbol_base}_size = $(wc -c < "$input");

EOF