[RDF] Print regmask index in more user-friendly way
[llvm-project.git] / clang / utils / bundle_resources.py
blob66871fbe99c1179ad286132c2c858b7a4f820ca0
1 #!/usr/bin/env python3
3 # ===- bundle_resources.py - Generate string constants with file contents. ===
5 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6 # See https://llvm.org/LICENSE.txt for license information.
7 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9 # ===----------------------------------------------------------------------===
11 # Usage: bundle-resources.py foo.inc a.js path/b.css ...
12 # Produces foo.inc containing:
13 # const char a_js[] = "...";
14 # const char b_css[] = "...";
15 import os
16 import sys
18 outfile = sys.argv[1]
19 infiles = sys.argv[2:]
21 with open(outfile, "w") as out:
22 for filename in infiles:
23 varname = os.path.basename(filename).replace(".", "_")
24 out.write("const char " + varname + "[] = \n")
25 # MSVC limits each chunk of string to 2k, so split by lines.
26 # The overall limit is 64k, which ought to be enough for anyone.
27 for line in open(filename).read().split("\n"):
28 out.write(' R"x(' + line + ')x" "\\n"\n')
29 out.write(" ;\n")