blob: b419879181fe71fa496c0760200de2e5b4ef1c60 [file] [log] [blame]
Elly Fong-Jones0873b2b2022-11-02 19:49:51 +00001#!/usr/bin/env python3
2#
Avi Drissmanea62cfa2023-01-24 14:57:29 -05003# Copyright 2022 The Chromium Authors
Elly Fong-Jones0873b2b2022-11-02 19:49:51 +00004# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6"""A script to update and tweak nasm's generated configs post-autoconf."""
7
8import re
9import os
10
11
12def RewriteFile(path, search_replace):
13 with open(path) as f:
14 contents = f.read()
15 with open(path, 'w') as f:
16 for search, replace in search_replace:
17 contents = re.sub(search, replace, contents)
18
19 # Cleanup trailing newlines.
20 f.write(contents.strip() + '\n')
21
22
23def UpdateLinuxConfig(path):
24 RewriteFile(
25 path,
26 [
27 # While glibc has canonicalize_file_name(3), other libcs do not,
28 # and we want the source tree not to depend on glibc if we can avoid it,
29 # especially for linux distribution tarballs. Since nasm has fallback
30 # code for not having canonicalize_file_name(3) anyway, just pretend it
31 # doesn't exist.
32 (r'#define HAVE_CANONICALIZE_FILE_NAME 1',
33 r'/* #undef HAVE_CANONICALIZE_FILE_NAME */ // Controlled by the Chromium build process - see generate_nasm_configs.py'
34 )
35 ])
36
37
38def UpdateMacConfig(path):
39 pass
40
41
42def main():
43 UpdateLinuxConfig('config/config-linux.h')
44 UpdateMacConfig('config/config-mac.h')
45
46
47if __name__ == "__main__":
48 main()