Ejemplo n.º 1
0
            inputs=list(collect_files(srcdir)),
            variables=OrderedDict([
                ('name', prj),
                ('configure', configure),
                ('configure_flags', all_flags),
                ('srcdir', '$top_srcdir/%s' % srcdir),
                ('destdir', '$builddir/%s' % prj),
                ('workdir', '$intdir/%s' % prj),
            ]))
    return target


with open('build.ninja', 'w') as buildfile:
    n = Writer(buildfile)
    n.comment('generated by %s' % sys.argv[0])
    n.include('build.vars.ninja')

    targets = []

    targets.append(gen_configure(n, 'gettext',
                                 srcdir='gettext',
                                 configure='./configure',
                                 flags=[
                                     '--prefix=/',
                                     'CC=$cc',
                                     'CXX=$cxx',
                                     # When running configure under Xcode,
                                     # SIGALRM is ignored and this doesn't play
                                     # nice with some of the (useless - gnulib)
                                     # checks, resulting in hanging builds.
                                     # See http://comments.gmane.org/gmane.comp.lib.gnulib.bugs/13841
Ejemplo n.º 2
0
            inputs=list(collect_files(srcdir)),
            variables=OrderedDict([
                ('name', prj),
                ('configure', configure),
                ('configure_flags', all_flags),
                ('srcdir', '$top_srcdir/%s' % srcdir),
                ('destdir', '$builddir/%s' % prj),
                ('workdir', '$intdir/%s' % prj),
            ]))
    return target


with open('build.ninja', 'w') as buildfile:
    n = Writer(buildfile)
    n.comment('generated by %s' % sys.argv[0])
    n.include('build.vars.ninja')

    targets = []

    targets.append(gen_configure(n, 'gettext',
                                 srcdir='gettext',
                                 configure='./configure',
                                 flags=[
                                     '--prefix=/',
                                     'CC=$cc',
                                     'CXX=$cxx',
                                     # When running configure under Xcode,
                                     # SIGALRM is ignored and this doesn't play
                                     # nice with some of the (useless - gnulib)
                                     # checks, resulting in hanging builds.
                                     # See http://comments.gmane.org/gmane.comp.lib.gnulib.bugs/13841
Ejemplo n.º 3
0
from ninja_syntax import Writer

if __name__ == '__main__':
    # 引数処理
    parser = argparse.ArgumentParser()
    parser.add_argument('output')
    args = parser.parse_args()

    with codecs.open(args.output, 'w', 'utf-8') as f:
        writer = Writer(f)

        writer.comment('ninjaのルールを定義するファイル')
        writer.newline()

        # configファイルのインクルード
        writer.include('config.ninja')
        writer.newline()

        # ルール定義

        writer.rule(
            name='text_converter',
            command='python $text_converter $in $out --setting $setting_file',
            description='<キャラ名>を置換するコンバート')
        writer.newline()

        writer.rule(name='text_merger',
                    command='python $text_merger $in $out --depfile $out.d',
                    deps='gcc',
                    depfile='$out.d',
                    description='includeを展開するコンバート')
if __name__=='__main__':
    # 引数処理
    parser = argparse.ArgumentParser()
    parser.add_argument('output')
    parser.add_argument('--data_dir', required=True)
    args = parser.parse_args()

    with codecs.open(args.output, 'w', 'utf-8') as f:
        writer = Writer(f)

        data_dir = os.path.abspath(args.data_dir)

        writer.comment('ninjaでビルドするファイルを列挙するファイル')
        writer.newline()

        writer.include('rule.ninja')

        for root, directory, files in os.walk(data_dir):
            for infile in files:
                # 拡張子のチェック 
                ext = os.path.splitext(infile)[1]
                if ext != '.txt':
                    continue

                fullpath = os.path.join(root, infile)
                relpath = os.path.relpath(fullpath, data_dir)

                # キャラ名の置換の呼び出し
                text_converter(writer, 
                    infile=fullpath, 
                    outfile=os.path.join('$tmpdir', relpath) )