mirror of
https://github.com/The-OpenROAD-Project/OpenROAD.git
synced 2026-06-02 01:08:34 +08:00
* For Tcl9, all relevant system tcl files, the tcl library and readline library, are packed in a zip file, compiled into the binary mounted on the virtual filesystem //zipfs:/ * On Tcl 8, which does not allow to do that quite yet, we take the same directory structure (unpacked), and use them via runfiles as before; however, since this is now a single directory the runfile symbolic links are reduced to one. Default for now is to use the runfile method, as we're still on Tcl8; The code is prepared for Tcl9, awaiting some changes in STA to be merged, then we can change the default. Fixes: #9962 #9980 Signed-off-by: Henner Zeller <h.zeller@acm.org>
55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
// SPDX-License-Identifier: BSD-3-Clause
|
|
// Copyright (c) 2026, The OpenROAD Authors
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
if (argc != 4) {
|
|
fprintf(stderr,
|
|
"Usage: %s <variable-name> <input-file> <output_file>\n",
|
|
argv[0]);
|
|
return 1;
|
|
}
|
|
|
|
const char* variable_name = argv[1];
|
|
const char* input_file = argv[2];
|
|
const char* output_file = argv[3];
|
|
|
|
FILE* in_file = fopen(input_file, "rb");
|
|
if (!in_file) {
|
|
perror("Could not open input.");
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
FILE* out_file = fopen(output_file, "wb");
|
|
if (!out_file) {
|
|
fclose(in_file);
|
|
perror("Could not open output.");
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
fprintf(out_file,
|
|
"static inline constexpr unsigned char %s[] = {\n ",
|
|
variable_name);
|
|
uint8_t buffer[100 * 12];
|
|
size_t nread;
|
|
while ((nread = fread(buffer, 1, sizeof(buffer), in_file)) > 0) {
|
|
for (int i = 0; i < nread; ++i) {
|
|
fprintf(out_file, "0x%02x,%s", buffer[i], i % 12 == 11 ? "\n " : " ");
|
|
}
|
|
}
|
|
const bool any_issue = ferror(in_file) || ferror(out_file);
|
|
if (any_issue) {
|
|
perror("trouble reading file.");
|
|
}
|
|
fprintf(out_file, "};\n");
|
|
fclose(in_file);
|
|
fclose(out_file);
|
|
|
|
return any_issue ? EXIT_FAILURE : EXIT_SUCCESS;
|
|
}
|