Exemplo n.º 1
0
def make_build(cfgpath, tmp_dir, build_info):
    merge_path = os.path.join(BASE_DIR, 'merge.py')

    with open('build.ninja', 'w') as f:
        n = Writer(f)

        for ftname, ft_build_info in build_info.iteritems():
            tmp_dir = ft_build_info['tmp_dir']
            dest_dir = ft_build_info['dest_dir']
            options = ft_build_info['options']
            sep = ft_build_info['seperator']
            cfgsect = 'Type:{}'.format(ftname)

            # declare rule
            cmds = []
            first = True
            if 'merge' in options:
                cmds.append('/usr/bin/env python ' + merge_path +
                            ' {} {} $in'.format(cfgpath, cfgsect))
                first = False
            if 'sort' in options:
                sortcol = ft_build_info['sort_col']
                cmds.append("sort -t \"`printf '{}'`\" -T {} -k{}".
                            format(sep, tmp_dir, sortcol) + (' $in' if first
                                                             else ''))
                first = False
            if 'zip' in options:
                cmds.append("gzip -kc" + (' $in' if first else ''))

            rule_name = '{}_rule'.format(ftname)
            n.rule(rule_name, command=' | '.join(cmds) + ' > $out')
            n.newline()

            # declare build
            _make_bulid_declare_build(n, options, dest_dir, ft_build_info,
                                      rule_name)
            n.newline()
    "Nes_Apu.cpp", "Nes_Cpu.cpp", "Nes_Fme7_Apu.cpp", "Nes_Namco_Apu.cpp",
    "Nes_Oscs.cpp", "Nes_Vrc6_Apu.cpp", "Nsfe_Emu.cpp", "Nsf_Emu.cpp",
    "Sap_Apu.cpp", "Sap_Cpu.cpp", "Sap_Emu.cpp", "Sms_Apu.cpp", "Snes_Spc.cpp",
    "Spc_Cpu.cpp", "Spc_Dsp.cpp", "Spc_Emu.cpp", "Spc_Filter.cpp",
    "Vgm_Emu.cpp", "Vgm_Emu_Impl.cpp", "Ym2413_Emu.cpp", "Ym2612_Emu.cpp"
]

buildfile = open("build.ninja", "w")

n = Writer(buildfile)

# variable declarations
n.comment("variable declarations")
n.variable("CC", "emcc")
n.variable("CXX", "em++")
n.newline()
n.variable("ROOT", ".")
n.variable("XZ_ROOT", "$ROOT/xz-embedded")
n.variable("GME_ROOT", "$ROOT/gme-source-0.6.1")
n.variable("OBJECTS", "$ROOT/objects")
n.variable("FINAL_DIR", "$ROOT/final")
n.newline()
n.variable(
    "EXPORT_LIST",
    "\"['_crPlayerContextSize', '_crPlayerInitialize', '_crPlayerLoadFile', '_crPlayerSetTrack', '_crPlayerGenerateStereoFrames', '_crPlayerVoicesCanBeToggled', '_crPlayerGetVoiceCount', '_crPlayerGetVoiceName', '_crPlayerSetVoiceState', '_crPlayerCleanup', '_main']\""
)
n.newline()

# build rules
n.comment("build rules")
n.rule(
Exemplo n.º 3
0
# ninja/miscにパスを通す
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'ninja', 'misc'))
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',
Exemplo n.º 4
0
def ninjaCommonHeader(cursor: Writer, ag: Any) -> None:
    '''
    Writes a common header to the ninja file. ag is parsed arguments.
    '''
    cursor.comment('-- start common ninja header --')
    cursor.comment(f'Note, this ninja file was automatically generated by {__file__}')
    cursor.newline()
    cursor.comment('-- compiling tools --')
    cursor.newline()
    cursor.variable('CXX', 'g++')
    cursor.variable('PROTOC', '/usr/bin/protoc')
    cursor.variable('PROTO_TEXT', f'./proto_text')
    cursor.variable('SHOGUN_EXTRA', '') # used for adding specific flags for a specific target
    cursor.newline()
    cursor.comment('-- compiler flags --')
    cursor.newline()
    cursor.variable('CPPFLAGS', '-D_FORTIFY_SOURCE=2 ' + str(os.getenv('CPPFLAGS', '')))
    cursor.variable('CXXFLAGS', '-std=c++14 -O2 -pipe -fPIC -gsplit-dwarf -DNDEBUG'
        + ' -fstack-protector-strong -w ' + str(os.getenv('CXXFLAGS', '')))
    cursor.variable('LDFLAGS', '-Wl,-z,relro -Wl,-z,now ' + str(os.getenv('LDFLAGS', '')))
    cursor.variable('INCLUDES', '-I. -I./debian/embedded/eigen3 -I./third_party/eigen3/'
            + ' -I/usr/include/gemmlowp -I/usr/include/llvm-c-7'
            + ' -I/usr/include/llvm-7 -Ithird_party/toolchains/gpus/cuda/')
    cursor.variable('LIBS', '-lpthread -lprotobuf -lnsync -lnsync_cpp -ldouble-conversion'
	+ ' -ldl -lm -lz -lre2 -ljpeg -lpng -lsqlite3 -llmdb -lsnappy -lgif -lLLVM-7')
    cursor.newline()
    cursor.comment('-- compiling rules-- ')
    cursor.rule('rule_PROTOC', f'$PROTOC $in --cpp_out . $SHOGUN_EXTRA')
    cursor.rule('rule_PROTOC_GRPC', f'$PROTOC --grpc_out . --cpp_out . --plugin protoc-gen-grpc=/usr/bin/grpc_cpp_plugin $in')
    cursor.rule('rule_PROTO_TEXT', f'$PROTO_TEXT tensorflow/core tensorflow/core tensorflow/tools/proto_text/placeholder.txt $in')
    cursor.rule('rule_CXX_OBJ', f'$CXX $CPPFLAGS $CXXFLAGS $INCLUDES $SHOGUN_EXTRA -c $in -o $out')
    cursor.rule('rule_CXX_EXEC', f'$CXX $CPPFLAGS $CXXFLAGS $INCLUDES $LDFLAGS $LIBS $SHOGUN_EXTRA $in -o $out')
    cursor.rule('rule_CXX_SHLIB', f'$CXX -shared -fPIC $CPPFLAGS $CXXFLAGS $INCLUDES $LDFLAGS $LIBS $SHOGUN_EXTRA $in -o $out')
    cursor.rule('rule_CC_OP_GEN', f'LD_LIBRARY_PATH=. ./$in $out $cc_op_gen_internal tensorflow/core/api_def/base_api')
    cursor.rule('COPY', f'cp $in $out')
    cursor.newline()
    cursor.comment('-- end common ninja header --')
    cursor.newline()