ryansuchocki / microscheme

A Scheme subset for Atmel microcontrollers.
http://ryansuchocki.github.io/microscheme/
MIT License
300 stars 20 forks source link

Dependency on xxd #29

Closed mazeto closed 1 year ago

mazeto commented 6 years ago

Hi,

It's a little weird to have a text editor as a dependency for a project. Could you please explain what xxd does exactly so I can implement it with hexdump or something else?

Thanks in advance.

Best, Mazeto.

ryansuchocki commented 6 years ago

xxd easily produces predictably named output formatted as a C array definition, followed by an unsigned int definition containing the length of the array.

For example, these two lines in the makefile:

echo "// Hexified internal microscheme files." > src/assembly_hex.c xxd -i src/preamble.s >> src/assembly_hex.c

produce a file containing:

// Hexified internal microscheme files. unsigned char src_preamble_s[] = { 0x2e, 0x74, 0x65, 0x78, 0x74, 0x0a, 0x2e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x0a, 0x6d, 0x61, 0x69, 0x6e, 0x3a, ... 0x0a, 0x0a, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x5f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x3a, 0x0a }; unsigned int src_preamble_s_len = 5799;

I'm sure it's possible to replicate this using hexdump and bash/makefile if you really want to.

mazeto commented 6 years ago

Hello,

I ended up writing a little hexer program in C yesterday.

The patch is at termbin.com/uclh.

I'll be glad if you merge (git am) that change to the project.

Thx.