Small changes to make the codebase more Win friendly
Minor changes that came up while trying building with MSVC.
Bug: 174454879
Change-Id: Ie34f3f8bb0c8ed879672eaffba34c210809618b0
diff --git a/tools/gen_merged_sql_metrics.py b/tools/gen_merged_sql_metrics.py
index 065ff1b..eed5d8e 100755
--- a/tools/gen_merged_sql_metrics.py
+++ b/tools/gen_merged_sql_metrics.py
@@ -95,9 +95,19 @@
for path, sql in sql_outputs.items():
name = os.path.basename(path)
variable = filename_to_variable(os.path.splitext(name)[0])
- output.write(
- '\nconst char {}[] = R"gendelimiter(\n{})gendelimiter";\n'.format(
- variable, sql))
+ output.write('\nconst char {}[] = '.format(variable))
+ # MSVC doesn't like string literals that are individually longer than 16k.
+ # However it's still fine "if" "we" "concatenate" "many" "of" "them".
+ # This code splits the sql in string literals of ~1000 chars each.
+ line_groups = ['']
+ for line in sql.split('\n'):
+ line_groups[-1] += line + '\n'
+ if len(line_groups[-1]) > 1000:
+ line_groups.append('')
+
+ for line in line_groups:
+ output.write('R"_d3l1m1t3r_({})_d3l1m1t3r_"\n'.format(line))
+ output.write(';\n')
output.write(FILE_TO_SQL_STRUCT)