[libc++] Update the <version> header in-place from generate_feature_test_macro_components

This simplifies the workflow for adding new feature-test macros for
contributors. Previously, they would have to move the generated <version>
header from a temporary directory to libc++'s include directory by hand.
This makes the behavior for the <version> header consistent with what's
done for the tests and the documentation.
This commit is contained in:
Louis Dionne 2020-10-13 09:16:40 -04:00
parent c78da03778
commit 647fb6b374
2 changed files with 10 additions and 8 deletions

View File

@ -39,7 +39,5 @@ The `generate_feature_test_macro_components.py` script is used to track and
update feature test macros in libc++.
Whenever a feature test macro is added or changed, the table should be updated
and the script should be re-ran. The script will clobber the existing test files
and the documentation and it will generate a new `<version>` header as a
temporary file. The generated `<version>` header should be merged with the
existing one.
and the script should be re-ran. The script will clobber the existing test files,
the documentation and the `<version>` header.

View File

@ -639,12 +639,18 @@ def produce_version_header():
#endif // _LIBCPP_VERSIONH
"""
return template.format(
version_str = template.format(
synopsis=produce_version_synopsis().strip(),
cxx14_macros=produce_macros_definition_for_std('c++14').strip(),
cxx17_macros=produce_macros_definition_for_std('c++17').strip(),
cxx2a_macros=produce_macros_definition_for_std('c++2a').strip())
version_header_path = os.path.join(include_path, 'version')
with open(version_header_path, 'w') as f:
f.write(version_str)
"""
Functions to produce test files
"""
@ -884,9 +890,7 @@ Status
f.write(doc_str)
def main():
with tempfile.NamedTemporaryFile(mode='w', prefix='version.', delete=False) as tmp_file:
print("producing new <version> header as %s" % tmp_file.name)
tmp_file.write(produce_version_header())
produce_version_header()
produce_tests()
produce_docs()