|
1 |
| -'''Generate header files from Boost source distribution.''' |
| 1 | +"""Generate header files from Boost source distribution.""" |
2 | 2 |
|
3 | 3 | import argparse
|
4 | 4 | import gzip
|
@@ -78,24 +78,38 @@ def _generate_headers(ver: str, verbose: bool):
|
78 | 78 | logger.info('Updating header files')
|
79 | 79 | if (base / 'boost').exists():
|
80 | 80 | shutil.rmtree(base / 'boost')
|
| 81 | + for f in pathlib.Path(__file__).parent.glob("Boost_*_README.md"): |
| 82 | + f.unlink() |
81 | 83 | shutil.move(dst / 'boost_tmp_build/include/boost', base / 'boost')
|
82 | 84 | shutil.move(dst / archive_name / 'LICENSE_1_0.txt', base / 'LICENSE_1_0.txt')
|
83 | 85 | shutil.move(dst / archive_name / 'README.md', base / f'Boost_{BOOST_VER_UND}_README.md')
|
84 | 86 | finally:
|
85 |
| - # We want to save the tar file as a temporary file and simulataneously |
| 87 | + # We want to save the tar file as a temporary file and simultaneously |
86 | 88 | # extract it, meaning it will need to be opened in a context manager
|
87 | 89 | # multiple times. While Linux can handle nested context managers
|
88 | 90 | # using the same file handle, Windows cannot. So we have to mark the
|
89 | 91 | # temporary file "ntf" as delete=False, close its context manager, and
|
90 | 92 | # then ensure cleanup happens in this "finally" statement
|
91 | 93 | ntf.close()
|
92 | 94 |
|
93 |
| - logger.info('Done!') |
| 95 | + logger.info('Done creating base Boost headers!') |
| 96 | + |
| 97 | + logger.info("Applying patches...") |
| 98 | + patch_dir = pathlib.Path(__file__).parent / "patches" |
| 99 | + for f in patch_dir.glob("*.patch"): |
| 100 | + if subprocess.run(["git", "apply", str(f)], cwd=base).returncode != 0: |
| 101 | + logger.error(f"Failed to apply patch: {f}. Skipping.") |
| 102 | + logger.info(f"Applied {f}") |
| 103 | + else: |
| 104 | + logger.info("Found no patches to apply!") |
| 105 | + |
| 106 | + logger.info("Done!") |
94 | 107 |
|
95 | 108 |
|
96 | 109 | if __name__ == '__main__':
|
97 | 110 | parser = argparse.ArgumentParser(__doc__)
|
98 |
| - parser.add_argument('--boost-version', type=str, help='Boost version to download formatted as [major].[minor].[patch].', default='1.75.0') |
| 111 | + parser.add_argument('--boost-version', type=str, |
| 112 | + help='Boost version to download formatted as [major].[minor].[patch].', required=True) |
99 | 113 | parser.add_argument('-v', action='store_true', help='Enable verbose logging.', default=False)
|
100 | 114 | args = parser.parse_args()
|
101 | 115 | _generate_headers(ver=args.boost_version, verbose=args.v)
|
0 commit comments