summaryrefslogtreecommitdiff
path: root/Meta/generate-embedded-resource-assembly.sh
blob: 05aa4431176c42c5863acc25246213ecca2a430f (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
26
27
#!/bin/bash

set -e

if [ -z "$1" ]; then
    echo "ERROR: No output file specified"
    exit 1
fi

OUTPUT_FILE="$1"
shift

rm -f "${OUTPUT_FILE}"

while (( "$#" >= 2)); do
    SECTION_NAME="$1"
    INPUT_FILE="$2"

    {
        printf '    .section %s\n' "${SECTION_NAME}"
        printf '    .type %s, @object\n' "${SECTION_NAME}"
        printf '    .align 4\n'
        printf '    .incbin "%s"\n' "${INPUT_FILE}"
        printf '\n'
    } >> "${OUTPUT_FILE}"
    shift 2
done