cmake/Tests/RunCMake/cmake-E-bin2c/generate_binary.cpp
Kyle Edwards 851f3a9e44
cmake -E: Add bin2c mode
Run Tests/RunCMake/cmake-E-bin2c/generate_files.sh to regenerate the
following files:

- Tests/RunCMake/cmake-E-bin2c/long.c.txt
- Tests/RunCMake/cmake-E-bin2c/long_signed.c.txt
- Tests/RunCMake/cmake-E-bin2c/jack_count.cmake
- Tests/RunCMake/cmake-E-bin2c/hashes.cmake
2026-01-17 10:37:35 -05:00

36 lines
887 B
C++

#include <fstream>
#include <ios>
#include <string>
static unsigned char const long_contents[] = {
#include "long.c.txt"
};
int main(int argc, char** argv)
{
if (argc != 3) {
return 1;
}
std::string name = argv[1];
std::ofstream fout(argv[2], std::ios::out | std::ios::binary);
if (name == "basic") {
fout.write("\xFC\xFD\xFE\xFF\x00\x01\x02\x03", 8);
} else if (name == "empty") {
// Write nothing
} else if (name == "text_lf") {
fout << "All work and no play makes Jack a dull boy.\n";
} else if (name == "text_crlf") {
fout << "All work and no play makes Jack a dull boy.\r\n";
} else if (name == "text_align") {
fout << "This exactly 32 characters long!";
} else if (name == "long") {
fout.write(reinterpret_cast<char const*>(long_contents),
sizeof(long_contents));
}
fout.flush();
fout.close();
return 0;
}