예제 #1
0
                          patches if tarball else collect_files(srcdir)),
            variables=OrderedDict([
                ('name', prj),
                ('configure', configure),
                ('configure_flags', all_flags),
                ('srcdir', '$top_srcdir/%s' % (srcdir if srcdir else prj)),
                ('destdir', '$builddir/%s' % prj),
                ('workdir', '$intdir/%s' % prj),
            ]))
    n.build([prj], 'phony', target)
    return target


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

    n.rule(
        'download',
        description='Downloading $url...',
        pool='console',
        command=
        'curl -o $out $url && test "$sha256" = `shasum -a256 $out | cut -f1 -d" "`'
    )

    targets = []

    n.build(
        ['tarballs/%s' % GETTEXT_TARBALL],
        'download',
예제 #2
0
import codecs

# 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',
예제 #3
0
        if os.path.basename(path) == 'hlp.png':
            name = 'hlp.png'
        elif path.endswith('.out.js'):
            name = path[:-7] + '.js'

        stream.write('  <file alias="%s">%s</file>\n' % (name, os.path.abspath(path)))

    stream.write('</qresource>\n')
    stream.write('</RCC>')

info('Writing build.ninja...\n')

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

    n.comment('Transformers')
    n.rule('uic', py_script('tools/common/uic.py', ['$in', '$out'] + pyuic), 'UIC $out')
    n.rule('rcc', cmd2str([rcc, '-binary', '$in', '-o', '$out']), 'RCC $out')
    n.rule('js_lupdate', py_script('tools/common/js_lupdate.py', ['-o', '$out', '$in']), 'JS-LUPDATE $out')
    n.rule('pylupdate', cmd2str(pylupdate + ['$in', '-ts', '$out']), 'PY-LUPDATE $out')
    n.rule('lupdate', cmd2str([lupdate, '$in', '-ts', '$out']), 'LUPDATE $out')
    n.rule('webpack', cmdenv([node, 'node_modules/webpack/bin/webpack.js'], {'USE_WEBKIT': webkit}), 'WEBPACK $out')

    if sys.platform.startswith('linux'):
        n.rule('cat', 'cat $in > $out', 'CAT $out')

    n.comment('Files')
    ui_targets = build_targets(n, UI_FILES, 'uic', new_ext='py', new_path='knossos/ui')
    n.build('knossos/data/resources.rcc', 'rcc', 'knossos/data/resources.qrc', implicit=RCC_FILES)
    n.build('html/js/translations.js', 'js_lupdate', ['html/js/main.js'])
    n.build('locale/_py.ts', 'pylupdate', SRC_FILES)
예제 #4
0
파일: configure.py 프로젝트: ngld/knossos
        if os.path.basename(path) == 'hlp.png':
            name = 'hlp.png'
        elif path.endswith('.out.js'):
            name = path[:-7] + '.js'

        stream.write('  <file alias="%s">%s</file>\n' % (name, os.path.abspath(path)))

    stream.write('</qresource>\n')
    stream.write('</RCC>')

info('Writing build.ninja...\n')

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

    n.comment('Transformers')
    n.rule('uic', py_script('tools/common/uic.py', ['$in', '$out'] + pyuic), 'UIC $out')
    n.rule('rcc', cmd2str([rcc, '-binary', '$in', '-o', '$out']), 'RCC $out')
    n.rule('js_lupdate', py_script('tools/common/js_lupdate.py', ['-o', '$out', '$in']), 'JS-LUPDATE $out')
    n.rule('pylupdate', cmd2str(pylupdate + ['$in', '-ts', '$out']), 'PY-LUPDATE $out')
    n.rule('lupdate', cmd2str([lupdate, '$in', '-ts', '$out']), 'LUPDATE $out')
    n.rule('webpack', cmdenv([node, 'node_modules/webpack/bin/webpack.js'], {'USE_WEBKIT': webkit}), 'WEBPACK $out')

    if sys.platform.startswith('linux'):
        n.rule('cat', 'cat $in > $out', 'CAT $out')

    n.comment('Files')
    ui_targets = build_targets(n, UI_FILES, 'uic', new_ext='py', new_path='knossos/ui')
    n.build('knossos/data/resources.rcc', 'rcc', 'knossos/data/resources.qrc', implicit=RCC_FILES)
    n.build('html/js/translations.js', 'js_lupdate', ['html/js/main.js'])
    n.build('locale/_py.ts', 'pylupdate', SRC_FILES)
    "Gb_Oscs.cpp", "Gbs_Emu.cpp", "gme.cpp", "Gme_File.cpp", "Gym_Emu.cpp",
    "Hes_Apu.cpp", "Hes_Cpu.cpp", "Hes_Emu.cpp", "Kss_Cpu.cpp", "Kss_Emu.cpp",
    "Kss_Scc_Apu.cpp", "M3u_Playlist.cpp", "Multi_Buffer.cpp", "Music_Emu.cpp",
    "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()
import codecs

# 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()

        # このリポジトリのルートディレクトリ
        root_dir = os.path.abspath(
            os.path.join(os.path.dirname(__file__), '..'))

        writer.comment('テキストコンバーター')
        writer.variable(key='text_converter',
                        value=os.path.join(root_dir, 'scripts',
                                           'text_converter.py'))

        writer.comment('テキストマージャー')
        writer.variable(key='text_merger',
                        value=os.path.join(root_dir, 'scripts',
                                           'text_merger.py'))
예제 #7
0
CC = 'g++' if sys.platform != 'win32' else 'cl'
CFLAGS = []
if sys.platform == 'win32':
    CFLAGS = ['-O2', '-EHsc', '-Zo', '/fp:fast', '-Iinclude']
else:
    CFLAGS = ['-std=c++11', '-O3', '-pthread', '-march=native', '-Iinclude']

SRC_DIR = 'src'
BUILD_DIR = 'build'
BIN_DIR = 'bin'

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

    n.comment('THIS FILE IS GENERATED BY configure.py')
    n.comment('EDITS WILL BE OVERWRITTEN')
    n.newline()

    ############################################################################
    # VARIABLES
    ############################################################################

    n.variable(key='ninja_required_version', value='1.9')

    if sys.platform == 'win32':
        n.variable(key='msvc_deps_prefix', value='Note: including file:')

    n.variable(key='cc', value=CC)
    n.variable(key='cflags', value=' '.join(CFLAGS))
    n.variable(key='project_name', value=PROJECT_NAME)
예제 #8
0
            '%s_build' % prj,
            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.
예제 #9
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()
    )
    writer.newline()

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)

                # キャラ名の置換の呼び出し