Ejemplo n.º 1
0
def build(ctx):
    if not ctx.env.GIT:
        return

    # Hub's alias command `hub alias -s' produces really simple output:
    #
    #     alias git=hub
    #
    # Just use hub's path instead of git if we have it.
    if ctx.env.HUB:
        git = ctx.env.HUB
        ctx.env.SHELL_ALIASES['git'] = ctx.shquote_cmd(git)
    else:
        git = ctx.env.GIT

    ctx.env.SHELL_ALIASES['g'] = ctx.shquote_cmd(git)
    ctx.env.SHELL_ALIASES['gt'] = ctx.shquote_cmd(git + ['status'])
    ctx.env.SHELL_ALIASES['gobuddygo'] = ctx.shquote_cmd(git + ['push'])
    ctx.env.SHELL_ALIASES['cometome'] = ctx.shquote_cmd(git + ['pull'])
    ctx.env.SHELL_ALIASES['gcm'] = ctx.shquote_cmd(
        git + ['checkout', 'master'])
    # Update dotfiles alias
    ctx.env.SHELL_ALIASES['ud'] = ' && '.join([
        ctx.shquote_cmd(['cd', ctx.srcnode.abspath()]),
        ctx.shquote_cmd(git + ['pull']),
        # Distclean to avoid possible errors. A full rebuild does not take
        # long.
        ctx.shquote_cmd([
            './waf', 'distclean', 'configure', 'build', 'install']),
    ])

    for name in ['gitconfig', 'gitignore-global']:
        ctx.install_dotfile(ctx.path.find_resource(['dotfiles', name]))

    ctx.install_subst_script('find-file-exts', PYTHON=ctx.env.DEFAULT_PYTHON)

    if ctx.env.WC and ctx.env.NUMFMT:
        # Find size of the working tree in a git repo.
        # See here for sources of approaches:
        # http://serverfault.com/questions/351598/get-total-files-size-from-a-file-containing-a-file-list
        ctx.env.SHELL_ALIASES['git-working-tree-size'] = (
            '{git} ls-files -z | {wc} --bytes --files0-from=- | '
            '{numfmt} --to=iec-i --suffix=B').format(
                git=ctx.shquote_cmd(git),
                wc=ctx.shquote_cmd(ctx.env.WC),
                numfmt=ctx.shquote_cmd(ctx.env.NUMFMT))
        # Another approach, using GNU stat and awk:
        #
        # git ls-files -z | while read -d $'\0' filename;
        # do $STAT -c '%s' "$filename"; done |
        # awk '{total+=$1} END {print total}

    if ctx.env.OHCOUNT:
        ctx.install_subst_script(
            'git-count-lines', GIT=shquote(ctx.env.GIT[0]))
Ejemplo n.º 2
0
    def do_main(self, argv):
        """
    This function contains the main code to run. Not intended to be called
    directly. Call main instead, which returns exit status for failing
    subprocesses.
    """
        args = parse_args(argv)
        args.output = self.output_path(argv[1:])
        if args.output is None:
            return self._no_codegen(args)
        if args.gomacc:
            self.gomacc = args.gomacc
        if args.no_gomacc:
            self.gomacc = None
        if args.jobs:
            self.jobs = int(args.jobs)

        basename = os.path.basename(args.output)
        # Only generate tailored native object files for targets on the allow list.
        # TODO: Find a better way to structure this. There are three different
        # ways we can perform linking: Local ThinLTO, distributed ThinLTO,
        # and distributed ThinLTO with common object files.
        # We expect the distributed ThinLTO variants to be faster, but
        # common object files cannot be used when -fsplit-lto-unit is in effect.
        # Currently, we don't detect this situation. We could, but it might
        # be better to instead move this logic out of this script and into
        # the build system.
        use_common_objects = not (args.allowlist or basename in self.ALLOWLIST)
        common_dir = 'common_objs'
        gen_dir = 'lto.' + basename
        params = self.analyze_args(args, gen_dir, common_dir,
                                   use_common_objects)
        # If we determined that no distributed code generation need be done, just
        # invoke the original command.
        if params is None:
            return self._no_codegen(args)
        if use_common_objects:
            objs = [x[0] for x in params.codegen]
            ensure_file(common_dir + '/empty.thinlto.bc')
        ninjaname = gen_dir + '/build.ninja'
        self.gen_ninja(ninjaname, params, gen_dir)
        if args.generate:
            sys.stderr.write('Generated ninja file %s\n' %
                             (shquote(ninjaname), ))
        else:
            cmd = [autoninja(), '-f', ninjaname]
            if self.jobs:
                cmd.extend(['-j', str(self.jobs)])
            report_run(cmd)
        return 0
Ejemplo n.º 3
0
def build(ctx):
    if not ctx.env.QPDF:
        return
    ctx.install_subst_script('pdf-merge', QPDF=shquote(ctx.env.QPDF[0]))
    ctx.env.SHELL_ALIASES['pdf-join'] = 'pdf-merge'
Ejemplo n.º 4
0
def build(ctx):
    if not ctx.env.GS:
        return
    ctx.install_subst_script('pdf-compress', GS=shquote(ctx.env.GS[0]))