Source code drop for the Actionscript virtual machine in the Adobe Flash Player for December 2013
47 lines
1.3 KiB
Python
Executable File
47 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# -*- Mode: Python; indent-tabs-mode: nil -*-
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
"""Reads stdin and extracts a list of all header dependencies to
|
|
a file. It requires exactly one argument.
|
|
|
|
The input is expected to take form of C preprocessor output, where
|
|
paths to originating input source files are indicated via the form
|
|
# LINENO "PATH"
|
|
|
|
The argument to the script is the target file to be overwritten.
|
|
It will contain the extracted dependencies (unquoted absolute paths).
|
|
|
|
Relative paths generated by the C preprocessor are resolved relative
|
|
to the current working directory (see Bug 652544)."""
|
|
|
|
import re
|
|
import sys
|
|
import os
|
|
|
|
if len(sys.argv) != 2:
|
|
raise Exception("Unexpected command line argument.")
|
|
|
|
outfile = sys.argv[1]
|
|
relative_to_dir = os.getcwd()
|
|
|
|
_lineExp = re.compile("#(?:line)? ?\d+ \"([^\"<>]+[^/])\"");
|
|
|
|
deps = set()
|
|
|
|
for line in sys.stdin:
|
|
m = _lineExp.match(line)
|
|
if m:
|
|
path = m.group(1)
|
|
if not os.path.isabs(path):
|
|
path = os.path.abspath(os.path.join(relative_to_dir, path))
|
|
deps.add(path)
|
|
|
|
|
|
ostream = open(outfile, "w")
|
|
ostream.write("\n".join(deps))
|
|
ostream.close()
|