c85fd9f33c
Fixes #17. Stage 2 is fairly minimal, stage 3 builds/installs OpenCV and WPILib et al, and stage 4 builds/installs the FRCVision webdash and adds the vision examples. Other changes: - OpenCV compiled with ffmpeg, OpenBLAS, and libgtk (fixes #79, fixes #80) - OpenBLAS added to image (fixes #65) - C++ Makefile is more easily extensible (fixes #71) - Sources for everything are bundled into image into /usr/src - README updated (fixes #16) - pkg-config files for wpilibc et al are now installed and C++ Makefile uses them (if compiled local to Pi) - Both dynamic and static libs are included in image The only downside of all these changes (particularly the ffmpeg, OpenBLAS, and libgtk inclusion) is the image size is now over 3GB (800MB compressed). The previous image didn't quite fit on a 2GB card however.
34 lines
1.3 KiB
Python
Executable File
34 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
import os
|
|
import re
|
|
|
|
parser = argparse.ArgumentParser(description='Generate resource .cpp file.')
|
|
parser.add_argument('outputFile', help='output file')
|
|
parser.add_argument('inputFile', help='input file')
|
|
parser.add_argument('--prefix', dest='prefix', default='', help='C function prefix')
|
|
parser.add_argument('--namespace', dest='namespace', default='', help='C++ namespace')
|
|
|
|
args = parser.parse_args()
|
|
|
|
with open(args.inputFile, "rb") as f:
|
|
data = f.read()
|
|
|
|
fileSize = len(data)
|
|
|
|
inputBase = os.path.basename(args.inputFile)
|
|
funcName = "GetResource_" + re.sub(r"[^a-zA-Z0-9]", "_", inputBase)
|
|
|
|
with open(args.outputFile, "wt") as f:
|
|
print("#include <stddef.h>\n#include <wpi/StringRef.h>\nextern \"C\" {\nstatic const unsigned char contents[] = { ", file=f, end='')
|
|
print(", ".join("0x%02x" % x for x in data), file=f, end='')
|
|
print(" };", file=f)
|
|
print("const unsigned char* {}{}(size_t* len) {{\n *len = {};\n return contents;\n}}\n}}".format(args.prefix, funcName, fileSize), file=f)
|
|
|
|
if args.namespace:
|
|
print("namespace {} {{".format(namespace), file=f)
|
|
print("wpi::StringRef {}() {{\n return wpi::StringRef(reinterpret_cast<const char*>(contents), {});\n}}".format(funcName, fileSize), file=f)
|
|
if args.namespace:
|
|
print("}", file=f)
|