[libcxx-commits] [libcxx] 647fb6b - [libc++] Update the <version> header in-place from generate_feature_test_macro_components

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Oct 13 06:18:52 PDT 2020


Author: Louis Dionne
Date: 2020-10-13T09:18:35-04:00
New Revision: 647fb6b37488080efd8dd5e5a40d21e926b6e726

URL: https://github.com/llvm/llvm-project/commit/647fb6b37488080efd8dd5e5a40d21e926b6e726
DIFF: https://github.com/llvm/llvm-project/commit/647fb6b37488080efd8dd5e5a40d21e926b6e726.diff

LOG: [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.

Added: 
    

Modified: 
    libcxx/docs/DesignDocs/FeatureTestMacros.rst
    libcxx/utils/generate_feature_test_macro_components.py

Removed: 
    


################################################################################
diff  --git a/libcxx/docs/DesignDocs/FeatureTestMacros.rst b/libcxx/docs/DesignDocs/FeatureTestMacros.rst
index 2fbba6547bb6..644eb4a6b411 100644
--- a/libcxx/docs/DesignDocs/FeatureTestMacros.rst
+++ b/libcxx/docs/DesignDocs/FeatureTestMacros.rst
@@ -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.

diff  --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py
index 889eabff8b6e..edf668921f9c 100755
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -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 @@ def produce_docs():
     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()
 


        


More information about the libcxx-commits mailing list