blob: f715b1d7e1b1de8a5b80b9a37cf2b264b49119e2 [file] [log] [blame]
Austin Schuh24adb6b2015-09-06 17:37:40 -07001#!/usr/bin/env python
2
3import os, os.path, sys
4
5print """
6#include "internal/Embedded.h"
7
8#include <string>
9#include <unordered_map>
10
11namespace {
12
13std::unordered_map<std::string, EmbeddedContent> embedded = {
14"""
15
16for f in sys.argv[1:]:
17 bytes = open(f, 'rb').read()
18 print '{"/%s", {' % os.path.basename(f)
19 print '"' + "".join(['\\x%02x' % ord(x) for x in bytes]) + '"'
20 print ',%d }},' % len(bytes)
21
22print """
23};
24
25} // namespace
26
27const EmbeddedContent* findEmbeddedContent(const std::string& name) {
28 auto found = embedded.find(name);
29 if (found == embedded.end()) {
30 return NULL;
31 }
32 return &found->second;
33}
34"""
35