32 INCLUDE_RE = re.compile(
'^#include "([^"]*)"$')
35 match = INCLUDE_RE.match(line)
36 return match.groups()[0]
if match
else None
41 self.
included =
set([
"upb/port_def.inc",
"upb/port_undef.inc"])
48 self.
output_h.
write(
"// Ruby is still using proto3 enum semantics for proto2\n")
49 self.
output_h.
write(
"#define UPB_DISABLE_PROTO2_ENUM_CHECKING\n")
60 self.
add_src(
"upb/port_undef.inc")
66 full_path = os.path.join(path, infile_name)
67 file =
open(full_path)
72 raise RuntimeError(
"Couldn't open file " + infile_name)
74 lines = file.readlines()
76 has_copyright = lines[1].startswith(
" * Copyright")
78 while not lines[0].startswith(
" */"):
82 lines.insert(0,
"\n/** " + infile_name +
" " + (
"*" * 60) +
"/");
92 if not (include.startswith(
"upb")
or include.startswith(
"google")):
94 if include.endswith(
"hpp"):
112 output_path = sys.argv[1]
117 for arg
in sys.argv[3:]:
119 if arg.startswith(
"-I"):
120 amalgamator.add_include_path(arg[2:])
121 elif arg.endswith(
".h")
or arg.endswith(
".inc"):
126 for filename
in files:
127 amalgamator.add_src(filename)