Ejemplo n.º 1
0
            # Only write out the dependencies if the script was successful
            if not ret:
                # Add dependencies on any python modules that were imported by
                # the script.
                deps |= set(
                    six.ensure_text(s) for s in iter_modules_in_path(
                        buildconfig.topsrcdir, buildconfig.topobjdir))
                # Add dependencies on any buildconfig items that were accessed
                # by the script.
                deps |= set(
                    six.ensure_text(s) for s in buildconfig.get_dependencies())

                mk = Makefile()
                mk.create_rule([args.dep_target]).add_dependencies(deps)
                with FileAvoidWrite(args.dep_file) as dep_file:
                    mk.dump(dep_file)
            else:
                # Ensure that we don't overwrite the file if the script failed.
                output.avoid_writing_to_file()

    except IOError as e:
        print('Error opening file "{0}"'.format(e.filename), file=sys.stderr)
        traceback.print_exc()
        return 1
    return ret


if __name__ == "__main__":
    sys.exit(log_build_task(main, sys.argv[1:]))
Ejemplo n.º 2
0
# 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/.

from __future__ import absolute_import, print_function

import sys

from mozbuild.preprocessor import Preprocessor
from mozbuild.action.util import log_build_task


def generate(output, *args):
    pp = Preprocessor()
    pp.out = output
    pp.handleCommandLine(list(args), True)
    return set(pp.includes)


def main(args):
    pp = Preprocessor()
    pp.handleCommandLine(args, True)


if __name__ == "__main__":
    log_build_task(main, sys.argv[1:])