示例#1
0
def rules(i):
    return template('''
        rule js_compile_modules
            command = $
                %if not i.debug
                $closure_compiler $
                    $$($python3 $root/mk/misc/collect_js_deps.py $in $out $depfile) $
                    --js_output_file=$out $
                    --language_in=ECMASCRIPT5_STRICT $
                    --compilation_level=ADVANCED_OPTIMIZATIONS $
                    --output_wrapper='(function(){%{}output%{}})();' $
                    --jscomp_error=undefinedNames $
                    --jscomp_error=undefinedVars $
                    --create_name_map_files $
                    --process_common_js_modules $
                    --common_js_entry_module=$entry_module $
                    --common_js_module_path_prefix=$module_dir $
                    --externs=$root/mk/misc/closure_externs.js
                %else
                $python3 $root/mk/misc/gen_js_loader.py $
                    $$($python3 $root/mk/misc/collect_js_deps.py $in $out $depfile) $
                    >$out
                %end
            description = MIN $out
            depfile = $out.d

        rule js_minify_file
            command = $
                %if not i.debug
                $python3 $root/mk/misc/minify.py <$in >$out
                %else
                cp $in $out
                %end
            description = MIN $out
    ''', **locals())
示例#2
0
def rules(i):
    return template('''
        rule scripts_stamp
            command = touch $out
            description = STAMP $out

        rule copy_mod_scripts
            command = $python3 $root/mk/misc/copy_mod_scripts.py $
                --mod-name $mod_name $
                --input-dir $input_dir $
                --output-dir $output_dir $
                --stamp $out
            description = COPY $output_dir/$mod_name ($out)
            depfile = $out.d

        rule copy_script
            command = cp -f $in $out
            description = COPY $out

        rule gen_script_loader
            command = $python3 $root/mk/misc/gen_script_loader.py $
                --script-dir $script_dir $
                --mods $mods $
                --output $out
            description = GEN $out
    ''', **locals())
示例#3
0
def rules(i):
    return template('''
        rule process_font
            command = $python3 $root/src/gen/process_font.py $
                --font-image-in=$in $
                $extra_args $
                --font-image-out=$out_img $
                --font-metrics-out=$out_metrics
            description = GEN $out_img

        rule stack_fonts
            command = $python3 $root/src/gen/stack_fonts.py $
                $out_img $out_metrics $out_rust $in
            description = GEN $out_img

        rule process_day_night
            command = $python3 $root/src/gen/gen_day_night.py $in >$out
            description = GEN $out

        rule gen_ui_atlas
            command = $python3 $root/src/gen/gen_ui_atlas.py $in_dir $out_dir
            description = GEN $out_dir/ui_atlas.png
            depfile = $out_dir/ui_atlas.d

        rule gen_server_json
            command = $python3 $root/src/gen/gen_server_json.py >$out
            description = GEN $out

        rule gen_credits
            command = $python3 $root/src/gen/gen_credits.py $root $out $dep_files
            description = GEN $out
    ''', **locals())
示例#4
0
def credits(out_path):
    return template('''
        build %out_path: gen_credits $
            | $b_data/stamp $b_data/outpost.pack $
              $root/src/gen/gen_credits.py
            dep_files = $b_data/data.d $b_data/outpost.pack.d
    ''', **locals())
示例#5
0
def rules(i):
    rustc_base = join(
        '$rustc $in',
        '--out-dir $b_native',
        '--emit link,dep-info',
        '-L $b_native',
        maybe('-L %s', i.rust_extra_libdir),
        i.rust_lib_externs,
    )

    common_cflags = join(
        '-MMD -MF $out.d',
        '$picflag',
        cond(i.debug, '-ggdb', '-O3'),
    )

    return template(
        '''
        rustflags_debug = -g
        rustflags_release = -g -C opt-level=3
        rustflags_default = %if i.debug% $rustflags_debug %else% $rustflags_release %end%
        # LTO temporarily disabled because it causes LLVM to crash
        # TODO: fix this after upgrading beyond rustc 1.3.0-dev (dc6e3bbb7 2015-07-27)
        #rustflags_lto = %if not i.debug%  -C lto  %end%
        rustflags_lto =

        rule rustc_native_bin
            command = %rustc_base --crate-type=bin $rustflags_lto $rustflags
            depfile = $b_native/$crate_name.d
            description = RUSTC $out

        rule rustc_native_lib
            command = %rustc_base --crate-type=lib $rustflags
            depfile = $b_native/$crate_name.d
            description = RUSTC $out

        rule rustc_native_staticlib
            command = %rustc_base --crate-type=staticlib $rustflags_lto $rustflags
            depfile = $b_native/$crate_name.d
            description = RUSTC $out

        rule c_obj
            command = $cc -c $in -o $out -std=c99 %common_cflags $cflags $user_cflags
            depfile = $out.d
            description = CC $out

        rule cxx_obj
            command = $cxx -c $in -o $out -std=c++14 %common_cflags $cxxflags $user_cxxflags
            depfile = $out.d
            description = CXX $out

        rule link_bin
            command = $cxx $in -o $out $ldflags $user_ldflags $libs
            description = LD $out

        rule link_shlib
            command = $cxx -shared $in -o $out $ldflags $user_ldflags $libs
            description = LD $out
    ''', **locals())
示例#6
0
def rlib(crate_name, deps, src_file=None):
    src_file = src_file or '$root/src/lib%s/lib.rs' % crate_name

    return template('''
        build $b_asmjs/lib%{crate_name}.rlib: asm_compile_rlib %src_file $
            | %for d in deps% $b_asmjs/lib%{d}.rlib %end%
            crate_name = %crate_name
    ''', **locals())
示例#7
0
def minify(out_file, js_src):
    if out_file is None:
        out_file = '$b_js/%s' % os.path.basename(js_src)

    return template('''
        build %out_file: js_minify_file %js_src
            filter = | sed -e '1s/{/{"use asm";/'
    ''', **locals())
示例#8
0
def credits(out_path):
    return template(
        '''
        build %out_path: gen_credits $
            | $b_data/stamp $b_data/outpost.pack $
              $root/src/gen/gen_credits.py
            dep_files = $b_data/data.d $b_data/outpost.pack.d
    ''', **locals())
示例#9
0
def minify(i, out_file, js_src):
    if out_file is None:
        out_file = '$b_js/%s' % os.path.basename(js_src)

    return template('''
        build %out_file: js_minify_file %js_src $
            | %if i.debug% $root/mk/misc/minify.py %end%
            filter = | sed -e '1s/{/{"use asm";/'
    ''', **locals())
示例#10
0
def rlib(crate_name, deps, src_file=None):
    src_file = src_file or '$root/src/lib%s/lib.rs' % crate_name

    return template(
        '''
        build $b_asmjs/lib%{crate_name}.rlib: asm_compile_rlib %src_file $
            | %for d in deps% $b_asmjs/lib%{d}.rlib %end%
            crate_name = %crate_name
    ''', **locals())
示例#11
0
def ui_atlas(out_dir, src_dir):
    return template('''
        build %out_dir/ui_atlas.png $
            %out_dir/ui_atlas.json $
            %out_dir/ui_atlas.rs: gen_ui_atlas $
            | $root/src/gen/gen_ui_atlas.py %src_dir
            in_dir = %src_dir
            out_dir = %out_dir
    ''', **locals())
示例#12
0
def fix_bitflags(src_out, src_in):
    return template('''
        rule fix_bitflags_src
            command = $
                echo '#![feature(no_std)]' >$out && $
                echo '#![no_std]' >>$out && $
                cat $in >> $out
            description = PATCH bitflags.rs

        build %src_out: fix_bitflags_src %src_in
    ''', **locals())
示例#13
0
def pack():
    return template('''
        rule build_pack
            command = $python3 $root/mk/misc/make_pack.py $root $b_data $b_data/outpost.pack
            description = PACK
            depfile = $b_data/outpost.pack.d

        build $b_data/outpost.pack: build_pack $
            | $root/mk/misc/make_pack.py $
            || $b_data/stamp $b_data/font.png $b_data/day_night.json
    ''', **locals())
示例#14
0
def compile(i, out_file, main_src):
    main_dir, basename_ext = os.path.split(main_src)
    module_name, _ = os.path.splitext(basename_ext)

    return template('''
        build %out_file: js_compile_modules %main_src $
            | $root/mk/misc/collect_js_deps.py $
              %if i.debug% $root/mk/misc/gen_js_loader.py %end%
            entry_module = %module_name
            module_dir = %main_dir
    ''', **locals())
示例#15
0
def font(basename, src_img, charset_args='--first-char=0x21', extra_args=''):
    out_img = '$b_data/fonts/' + basename + '.png'
    out_metrics = '$b_data/fonts/' + basename + '_metrics.json'

    return template('''
        build %out_img %out_metrics: process_font %src_img $
            | $root/src/gen/process_font.py
            extra_args = %charset_args %extra_args
            out_img = %out_img
            out_metrics = %out_metrics
    ''', **locals())
示例#16
0
def font(out_base, src_img):
    out_img = out_base + '.png'
    out_metrics = out_base + '_metrics.json'

    return template('''
        build %out_img %out_metrics: process_font %src_img $
            | $root/src/gen/process_font.py
            first_char = 0x21
            out_img = %out_img
            out_metrics = %out_metrics
    ''', **locals())
示例#17
0
def pack():
    return template(
        '''
        rule build_pack
            command = $python3 $root/mk/misc/make_pack.py $root $b_data $b_data/outpost.pack
            description = PACK
            depfile = $b_data/outpost.pack.d

        build $b_data/outpost.pack: build_pack $
            | $root/mk/misc/make_pack.py $
            || $b_data/stamp $b_data/font.png $b_data/day_night.json
    ''', **locals())
示例#18
0
def font(out_base, src_img):
    out_img = out_base + '.png'
    out_metrics = out_base + '_metrics.json'

    return template(
        '''
        build %out_img %out_metrics: process_font %src_img $
            | $root/src/gen/process_font.py
            first_char = 0x21
            out_img = %out_img
            out_metrics = %out_metrics
    ''', **locals())
示例#19
0
def fix_bitflags(src_out, src_in):
    return template(
        '''
        rule fix_bitflags_src
            command = $
                echo '#![feature(no_std)]' >$out && $
                echo '#![no_std]' >>$out && $
                cat $in >> $out
            description = PATCH bitflags.rs

        build %src_out: fix_bitflags_src %src_in
    ''', **locals())
示例#20
0
def asmlibs(name, rust_src, rust_deps, exports_file, template_file):
    return template('''
        build %base.ll: asm_compile_ir %rust_src $
            | %for d in rust_deps% $b_asmjs/lib%d.rlib %end%
            crate_name = %name
        build %base.clean.ll: asm_clean_ir %base.ll
        build %base.bc: asm_assemble_bc %base.clean.ll
        build %base.exports.txt: asm_convert_exports %exports_file
        build %base.opt.bc: asm_optimize_bc %base.bc | %base.exports.txt
            exports_file = %base.exports.txt
        build %base.0.js: asm_generate_js %base.opt.bc
        build %base.js: asm_fill_template %template_file %base.0.js %exports_file $
            | $root/mk/misc/asmjs_fill_template.py
    ''', base = '$b_asmjs/%s' % name, **locals())
示例#21
0
def font_stack(out_base, in_basenames):
    out_img = out_base + '.png'
    out_metrics = out_base + '_metrics.json'
    out_rust = out_base + '_metrics.rs'

    return template('''
        build %out_img %out_metrics %out_rust: stack_fonts $
            %for name in in_basenames
                $b_data/fonts/%name.png $
                $b_data/fonts/%{name}_metrics.json $
            %end
            | $root/src/gen/stack_fonts.py
            out_img = %out_img
            out_metrics = %out_metrics
            out_rust = %out_rust
    ''', **locals())
示例#22
0
def rules(i):
    return template('''
        rule dist_stamp
            command = touch $out
            description = STAMP $out

        rule copy_file
            # Use -f to avoid "text file busy" when copying binaries
            command = cp -f $in $out
            description = COPY $out

        rule copy_dir_stamp
            command = $python3 $root/mk/misc/clone_dir.py $copy_src $copy_dest $stamp
            description = COPY $copy_dest ($stamp)
            depfile = $stamp.d
    ''', **locals())
示例#23
0
def rules(i):
    return template(
        '''
        rule dist_stamp
            command = touch $out
            description = STAMP $out

        rule copy_file
            # Use -f to avoid "text file busy" when copying binaries
            command = cp -f $in $out
            description = COPY $out

        rule copy_dir_stamp
            command = $python3 $root/mk/misc/clone_dir.py $copy_src $copy_dest $stamp
            description = COPY $copy_dest ($stamp)
            depfile = $stamp.d
    ''', **locals())
示例#24
0
def binary_defs(out_file):
    out_file = out_file or os.path.splitext(src_file)[0] + '.bin'

    deps = (
            '$b_data/stamp',
            '$b_data/day_night.json',
            )

    return template('''
        rule gen_binary_defs
            command = $python3 $root/src/gen/gen_binary_defs.py $b_data $out
            description = GEN $out
            depfile = $out.d

        build %out_file: gen_binary_defs $
            | $root/src/gen/gen_binary_defs.py $
              %{' '.join(deps)}
    ''', **locals())
示例#25
0
def rust(crate_name, crate_type, deps, src_file=None, build_type='default'):
    src_template, output_template, can_lto = {
        'bin': ('$root/src/%s/main.rs', '%s$_exe', True),
        'lib': ('$root/src/lib%s/lib.rs', 'lib%s.rlib', False),
        'staticlib': ('$root/src/lib%s/lib.rs', 'lib%s$_a', True),
    }[crate_type]

    output_name = output_template % crate_name
    src_file = src_file or src_template % crate_name

    return template(
        '''
        build $b_native/%output_name: rustc_native_%crate_type %src_file $
            | %for d in deps% $b_native/lib%{d}.rlib %end%
            crate_name = %crate_name
            crate_type = %crate_type
            rustflags = $rustflags_%build_type
    ''', **locals())
示例#26
0
def asmlibs(name, rust_src, rust_deps, exports_file, template_file):
    return template('''
        build %base.ll: asm_compile_ir %rust_src $
            | %for d in rust_deps% $b_asmjs/lib%d.rlib %end%
            crate_name = %name
        build %base.clean.ll: asm_clean_ir %base.ll
        build %base.bc: asm_assemble_bc %base.clean.ll
        build %base.exports.txt: asm_convert_exports %exports_file
        build %base.opt.bc: asm_optimize_bc %base.bc | %base.exports.txt
            exports_file = %base.exports.txt
        build %base.0.js: asm_generate_js %base.opt.bc
        build %base.1.js: asm_add_function_tables %base.0.js $
            | $root/mk/misc/asmjs_function_tables.py
        build %base.js: asm_insert_functions %template_file %base.1.js $
            | $root/mk/misc/asmjs_insert_functions.py
    ''',
                    base='$b_asmjs/%s' % name,
                    **locals())
示例#27
0
def header(i):
    def b(*args):
        return os.path.normpath(os.path.join(i.build_dir, *args))

    return template('''
        # Root of the source tree.  This used to be called $src, but that would
        # be confusing now that $root/src is an actual directory.
        root = %{os.path.normpath(i.root_dir)}
        # Note: (1) `build` is a ninja keyword; (2) `builddir` is a special
        # variable that determines where `.ninja_log` is stored.
        builddir = %{os.path.normpath(i.build_dir)}
        dist = %{os.path.normpath(i.dist_dir)}
        prebuilt = %{os.path.normpath(i.prebuilt_dir or '')}

        _exe = %{'' if not i.win32 else '.exe'}
        _so = %{'.so' if not i.win32 else '.dll'}
        _a = .a

        b_native = %{b('native')}
        b_asmjs = %{b('asmjs')}
        b_data = %{b('data')}
        b_js = %{b('js')}
        b_scripts = %{b('scripts')}

        mods = %{','.join(i.mod_list)}

        rust_home = %{i.rust_home}
        bitflags_home = %{i.bitflags_home}

        rustc = %{i.rustc}
        cc = %{i.cc}
        cxx = %{i.cxx}
        python3 = %{i.python3}
        closure_compiler = closure-compiler
        yui_compressor = yui-compressor

        user_cflags = %{i.cflags or ''}
        user_cxxflags = %{i.cxxflags or ''}
        user_ldflags = %{i.ldflags or ''}
    ''',
                    os=os,
                    **locals())
示例#28
0
def process():
    data_files = ['%s_%s.json' % (f,s)
            for s in ('server', 'client')
            for f in ('structures', 'blocks', 'items', 'recipes', 'animations', 'attach_slots')]
    data_files.append('loot_tables_server.json')
    data_files.append('extras_client.json')
    return template('''
        rule process_data
            command = $python3 $root/src/gen/data_main.py --mods=$mods $
                    --src-dir=$root --output-dir=$b_data
            description = DATA
            depfile = $b_data/data.d

        build $b_data/stamp $
            %for name in data_files
                $b_data/%{name} $
            %end
            $b_data/tiles.png $b_data/items.png: $
            process_data | $root/src/gen/data_main.py
    ''', **locals())
示例#29
0
def rust(crate_name, crate_type, deps, dyn_deps=(),
        src_file=None, build_type='default', extra_flags=''):
    src_template, output_template, can_lto = {
            'bin': ('$root/src/%s/main.rs', '%s$_exe', True),
            'lib': ('$root/src/lib%s/lib.rs', 'lib%s.rlib', False),
            'dylib': ('$root/src/lib%s/lib.rs', 'lib%s$_so', False),
            'staticlib': ('$root/src/lib%s/lib.rs', 'lib%s$_a', True),
            }[crate_type]

    output_name = output_template % crate_name
    src_file = src_file or src_template % crate_name

    return template('''
        build $b_native/%output_name: rustc_native_%crate_type %src_file $
            | %for d in deps% $b_native/lib%{d}.rlib %end% $
              %for d in dyn_deps% $b_native/lib%{d}$_so %end%
            crate_name = %crate_name
            crate_type = %crate_type
            rustflags = $rustflags_%build_type %extra_flags
    ''', **locals())
示例#30
0
def pack():
    extra_data = (
            'fonts.png', 'fonts_metrics.json',
            'day_night.json',
            'ui_atlas.png', 'ui_atlas.json',
            'client_data.bin',
            )

    return template('''
        rule build_pack
            command = $python3 $root/mk/misc/make_pack.py $root $b_data $b_data/outpost.pack
            description = PACK
            depfile = $b_data/outpost.pack.d

        build $b_data/outpost.pack: build_pack $
            | $root/mk/misc/make_pack.py $
                %for name in extra_data
                    $b_data/%{name} $
                %end
            || $b_data/stamp
    ''', **locals())
示例#31
0
def header(i):
    def b(*args):
        return os.path.normpath(os.path.join(i.build_dir, *args))

    return template('''
        # Root of the source tree.  This used to be called $src, but that would
        # be confusing now that $root/src is an actual directory.
        root = %{os.path.normpath(i.root_dir)}
        # Note: (1) `build` is a ninja keyword; (2) `builddir` is a special
        # variable that determines where `.ninja_log` is stored.
        builddir = %{os.path.normpath(i.build_dir)}
        dist = %{os.path.normpath(i.dist_dir)}
        prebuilt = %{os.path.normpath(i.prebuilt_dir or '')}

        _exe = %{'' if not i.win32 else '.exe'}
        _so = %{'.so' if not i.win32 else '.dll'}
        _a = .a

        b_native = %{b('native')}
        b_asmjs = %{b('asmjs')}
        b_data = %{b('data')}
        b_js = %{b('js')}
        b_scripts = %{b('scripts')}

        mods = %{','.join(i.mod_list)}

        rust_home = %{i.rust_home}
        bitflags_home = %{i.bitflags_home}

        rustc = %{i.rustc}
        cc = %{i.cc}
        cxx = %{i.cxx}
        python3 = %{i.python3}
        closure_compiler = closure-compiler
        yui_compressor = yui-compressor

        user_cflags = %{i.cflags or ''}
        user_cxxflags = %{i.cxxflags or ''}
        user_ldflags = %{i.ldflags or ''}
    ''', os=os, **locals())
示例#32
0
def process():
    data_files = ['%s_%s.json' % (f,s)
            for s in ('server', 'client')
            for f in ('structures', 'blocks', 'items', 'recipes',
                'animations', 'sprite_layers')]
    data_files.append('structure_parts_client.json')
    data_files.append('structure_verts_client.json')
    data_files.append('structure_shapes_client.json')
    data_files.append('sprite_graphics_client.json')
    data_files.append('loot_tables_server.json')
    data_files.append('extras_client.json')

    # `sprites0.png` is explicitly mentioned in the manifest, to be copied to
    # the uvedit directory.
    data_files.append('sprites/sprites0.png')

    deps = [
            '$root/src/gen/data_main.py',
            # Name font is embedded into the sprite sheet
            '$b_data/fonts/name.png',

            # Native modules
            '$b_native/equip_sprites_render$_so',
            ]

    return template('''
        rule process_data
            command = $python3 $root/src/gen/data_main.py --mods=$mods $
                    --src-dir=$root --output-dir=$b_data $
                    --native-lib-dir=$b_native
            description = DATA
            depfile = $b_data/data.d

        build $b_data/stamp $
            %for name in data_files
                $b_data/%{name} $
            %end
            $b_data/tiles.png $b_data/items.png: $
            process_data | %{' '.join(deps)}
    ''', **locals())
示例#33
0
def rules(i):
    return template('''
        rule process_font
            command = $python3 $root/src/gen/process_font.py $
                --font-image-in=$in $
                --first-char=$first_char $
                --font-image-out=$out_img $
                --font-metrics-out=$out_metrics
            description = GEN $out_img

        rule process_day_night
            command = $python3 $root/src/gen/gen_day_night.py $in >$out
            description = GEN $out

        rule gen_server_json
            command = $python3 $root/src/gen/gen_server_json.py >$out
            description = GEN $out

        rule gen_credits
            command = $python3 $root/src/gen/gen_credits.py $root $out $dep_files
            description = GEN $out
    ''', **locals())
示例#34
0
def process():
    data_files = [
        '%s_%s.json' % (f, s) for s in ('server', 'client')
        for f in ('structures', 'blocks', 'items', 'recipes', 'animations',
                  'attach_slots')
    ]
    data_files.append('loot_tables_server.json')
    data_files.append('extras_client.json')
    return template(
        '''
        rule process_data
            command = $python3 $root/src/gen/data_main.py --mods=$mods $
                    --src-dir=$root --output-dir=$b_data
            description = DATA
            depfile = $b_data/data.d

        build $b_data/stamp $
            %for name in data_files
                $b_data/%{name} $
            %end
            $b_data/tiles.png $b_data/items.png: $
            process_data | $root/src/gen/data_main.py
    ''', **locals())
示例#35
0
def rules(i):
    return template(
        '''
        rule process_font
            command = $python3 $root/src/gen/process_font.py $
                --font-image-in=$in $
                --first-char=$first_char $
                --font-image-out=$out_img $
                --font-metrics-out=$out_metrics
            description = GEN $out_img

        rule process_day_night
            command = $python3 $root/src/gen/gen_day_night.py $in >$out
            description = GEN $out

        rule gen_server_json
            command = $python3 $root/src/gen/gen_server_json.py >$out
            description = GEN $out

        rule gen_credits
            command = $python3 $root/src/gen/gen_credits.py $root $out $dep_files
            description = GEN $out
    ''', **locals())
示例#36
0
def rules(i):
    return template('''
        rule js_compile_modules
            command = $
                %if not i.debug
                $closure_compiler $
                    $$($python3 $root/mk/misc/collect_js_deps.py $in $out $depfile) $
                    --js_output_file=$out $
                    --language_in=ECMASCRIPT5_STRICT $
                    --compilation_level=ADVANCED_OPTIMIZATIONS $
                    --output_wrapper='(function(){%{}output%{}})();' $
                    --jscomp_error=undefinedNames $
                    --jscomp_error=undefinedVars $
                    --create_name_map_files $
                    --process_common_js_modules $
                    --common_js_entry_module=$entry_module $
                    --common_js_module_path_prefix=$module_dir $
                    --externs=$root/mk/misc/closure_externs.js
                %else
                $python3 $root/mk/misc/gen_js_loader.py $
                    $$($python3 $root/mk/misc/collect_js_deps.py $in $out $depfile) $
                    >$out
                %end
            description = MIN $out
            depfile = $out.d

        rule js_minify_file
            command = $
                %if not i.debug
                $yui_compressor --disable-optimizations --line-break 200 $
                    $in $filter >$out
                %else
                cp $in $out
                %end
            description = MIN $out
    ''', **locals())
示例#37
0
def rules(i):
    rustc_base = join('$rustc $in',
            '--out-dir $b_native',
            '--emit link,dep-info',
            '-L $b_native',
            maybe('-L %s', i.rust_extra_libdir),
            *('--extern %s' % x for x in i.rust_externs)
            )

    common_cflags = join(
            '-MMD -MF $out.d',
            '$picflag',
            cond(i.debug, '-ggdb', '-O3'),
            )

    return template('''
        rustflags_debug = -g
        rustflags_release = -g -C opt-level=3
        rustflags_default = %if i.debug% $rustflags_debug %else% $rustflags_release %end%
        # LTO temporarily disabled because it causes LLVM to crash
        # TODO: fix this after upgrading beyond rustc 1.3.0-dev (dc6e3bbb7 2015-07-27)
        #rustflags_lto = %if not i.debug%  -C lto  %end%
        rustflags_lto =

        # The `sed` invocations below are hacks to handle nondeterministic
        # depfile line order from rustc.
        # NB: If you remove the sed commands here, also remove the ones in asmjs.py
        rule rustc_native_bin
            command = %rustc_base --crate-name=$crate_name --crate-type=bin $
                $rustflags_lto $rustflags $
                && sed -i -e '\\,^$out: ,p;d' $b_native/$crate_name.d
            depfile = $b_native/$crate_name.d
            description = RUSTC $out

        rule rustc_native_lib
            command = %rustc_base --crate-name=$crate_name --crate-type=lib $rustflags $
                && sed -i -e '\\,^$out: ,p;d' $b_native/$crate_name.d
            depfile = $b_native/$crate_name.d
            description = RUSTC $out

        rule rustc_native_dylib
            command = %rustc_base --crate-name=$crate_name --crate-type=dylib $rustflags $
                && sed -i -e '\\,^$out: ,p;d' $b_native/$crate_name.d
            depfile = $b_native/$crate_name.d
            description = RUSTC $out

        rule rustc_native_staticlib
            command = %rustc_base --crate-name=$crate_name --crate-type=staticlib $
                $rustflags_lto $rustflags $
                && sed -i -e '\\,^$out: ,p;d' $b_native/$crate_name.d
            depfile = $b_native/$crate_name.d
            description = RUSTC $out

        rule c_obj
            command = $cc -c $in -o $out -std=c99 %common_cflags $cflags $user_cflags
            depfile = $out.d
            description = CC $out

        rule cxx_obj
            command = $cxx -c $in -o $out $
                %{i.cxx14_flag} %common_cflags $cxxflags $user_cxxflags
            depfile = $out.d
            description = CXX $out

        rule link_bin
            command = $cxx $in -o $out $ldflags $user_ldflags $libs
            description = LD $out

        rule link_shlib
            command = $cxx -shared $in -o $out $ldflags $user_ldflags $libs
            description = LD $out
    ''', **locals())
示例#38
0
def rules(i):
    fastcomp = lambda p: os.path.join(i.emscripten_fastcomp_prefix, 'bin', p) \
            if i.emscripten_fastcomp_prefix is not None else p

    compile_base = join('$rustc $in',
            '--out-dir $b_asmjs',
            '--cfg asmjs',
            '--cfg \'feature="no_std"\'',
            '--target=i686-unknown-linux-gnu',
            '-L $b_asmjs -L $b_native',
            # -C opt-level=3 is mandatory because it eliminates some constructs that cause problems
            # for emscripten-fastcomp.
            '-C opt-level=3',
            '-Z no-landing-pads -C no-stack-check',
            '-C no-vectorize-loops -C no-vectorize-slp')

    return template(r'''
        em_llvm_as = %{fastcomp('llvm-as')}
        em_opt = %{fastcomp('opt')}
        em_llc = %{fastcomp('llc')}


        # See comment in native.py about this sed command
        rule asm_compile_rlib
            command = %compile_base --emit=link,dep-info $
                --crate-type=rlib --crate-name=$crate_name $
                && sed -i -e '\,^$out: ,p;d' $b_asmjs/$crate_name.d
            depfile = $b_asmjs/$crate_name.d
            description = RUSTC $out

        rule asm_compile_ir
            # Like opt-level=3 above, lto is mandatory to prevent emscripten-fastcomp errors.
            command = %compile_base --emit=llvm-ir,dep-info --crate-type=staticlib -C lto $
                && sed -i -e '\,^$out: ,p;d' $b_asmjs/$crate_name.d
            depfile = $b_asmjs/$crate_name.d
            description = RUSTC $out

        rule asm_clean_ir
            command = sed <$in >$out $
                -e '/^target triple/s/i686-unknown-linux-gnu/asmjs-unknown-emscripten/'
            description = ASMJS $out

        rule asm_assemble_bc
            command = $em_llvm_as $in -o $out
            description = ASMJS $out


        rule asm_optimize_bc
            command = $em_opt $in $
                -strip-debug $
                -internalize -internalize-public-api-list="$$(cat $exports_file)" $
                -globaldce $
                -disable-loop-vectorization -disable-slp-vectorization $
                -vectorize-loops=false -vectorize-slp=false $
                -vectorize-slp-aggressive=false $
                -o $out
            description = ASMJS $out

        rule asm_convert_exports
            command = tr '\n' ',' <$in >$out
            description = ASMJS $out

        rule asm_generate_js
            command = $em_llc $in $
                -march=js -filetype=asm $
                -emscripten-assertions=1 $
                -emscripten-no-aliasing-function-pointers $
                -O0 $
                -o $out
            description = ASMJS $out

        rule asm_fill_template
            command = $python3 $root/mk/misc/asmjs_fill_template.py $in >$out
            description = ASMJS $out
    ''', **locals())
示例#39
0
def rules(i):
    fastcomp = lambda p: os.path.join(i.emscripten_fastcomp_prefix, 'bin', p) \
            if i.emscripten_fastcomp_prefix is not None else p
    passes = lambda p: os.path.join(i.emscripten_passes_prefix, p) \
            if i.emscripten_passes_prefix is not None else p

    compile_base = join(
        '$rustc $in',
        '--out-dir $b_asmjs',
        '--cfg asmjs',
        '--target=i686-unknown-linux-gnu',
        '-L $b_asmjs -L $b_native',
        maybe('-L %s', i.rust_extra_libdir),
        # -C opt-level=3 is mandatory because it eliminates some constructs that cause problems
        # for emscripten-fastcomp.
        '-C opt-level=3',
        '-Z no-landing-pads -C no-stack-check',
        '-C no-vectorize-loops -C no-vectorize-slp')

    return template(
        r'''
        em_llvm_as = %{fastcomp('llvm-as')}
        em_opt = %{fastcomp('opt')}
        em_llc = %{fastcomp('llc')}

        em_pass_remove_overflow_checks = %{passes('RemoveOverflowChecks.so')}
        em_pass_remove_assume = %{passes('RemoveAssume.so')}


        rule asm_compile_rlib
            command = %compile_base --emit=link,dep-info --crate-type=rlib
            depfile = $b_asmjs/$crate_name.d
            description = RUSTC $out

        rule asm_compile_ir
            # Like opt-level=3 above, lto is mandatory to prevent emscripten-fastcomp errors.
            command = %compile_base --emit=llvm-ir,dep-info --crate-type=staticlib -C lto
            depfile = $b_asmjs/$crate_name.d
            description = RUSTC $out

        rule asm_clean_ir
            command = sed <$in >$out $
                -e '/^target triple/s/i686-unknown-linux-gnu/asmjs-unknown-emscripten/'
            description = ASMJS $out

        rule asm_assemble_bc
            command = $em_llvm_as $in -o $out
            description = ASMJS $out


        rule asm_optimize_bc
            command = $em_opt $in $
                -load=$em_pass_remove_overflow_checks $
                -load=$em_pass_remove_assume $
                -strip-debug $
                -internalize -internalize-public-api-list="$$(cat $exports_file)" $
                -remove-overflow-checks $
                -remove-assume $
                -globaldce $
                -pnacl-abi-simplify-preopt -pnacl-abi-simplify-postopt $
                -enable-emscripten-cxx-exceptions $
                -o $out
            description = ASMJS $out

        rule asm_convert_exports
            command = tr '\n' ',' <$in >$out
            description = ASMJS $out

        rule asm_generate_js
            command = $em_llc $in $
                -march=js -filetype=asm $
                -emscripten-assertions=1 $
                -emscripten-no-aliasing-function-pointers $
                -O3 $
                -o $out
            description = ASMJS $out

        rule asm_add_function_tables
            command = $python3 $root/mk/misc/asmjs_function_tables.py <$in >$out
            description = ASMJS $out

        rule asm_insert_functions
            command = $python3 $root/mk/misc/asmjs_insert_functions.py $in >$out
            description = ASMJS $out
    ''', **locals())
示例#40
0
def copy(src, dest):
    return template('''
        build %dest: copy_file %src
    ''', **locals())
示例#41
0
 def add_build(*args, **kwargs):
     builds.append(template(*args, **kwargs))
示例#42
0
 def add_build(*args, **kwargs):
     builds.append(template(*args, **kwargs))
示例#43
0
def rules(i):
    fastcomp = lambda p: os.path.join(i.emscripten_fastcomp_prefix, 'bin', p) \
            if i.emscripten_fastcomp_prefix is not None else p
    passes = lambda p: os.path.join(i.emscripten_passes_prefix, p) \
            if i.emscripten_passes_prefix is not None else p

    compile_base = join('$rustc $in',
            '--out-dir $b_asmjs',
            '--cfg asmjs',
            '--target=i686-unknown-linux-gnu',
            '-L $b_asmjs -L $b_native',
            maybe('-L %s', i.rust_extra_libdir),
            # -C opt-level=3 is mandatory because it eliminates some constructs that cause problems
            # for emscripten-fastcomp.
            '-C opt-level=3',
            '-Z no-landing-pads -C no-stack-check',
            '-C no-vectorize-loops -C no-vectorize-slp')

    return template(r'''
        em_llvm_as = %{fastcomp('llvm-as')}
        em_opt = %{fastcomp('opt')}
        em_llc = %{fastcomp('llc')}

        em_pass_remove_overflow_checks = %{passes('RemoveOverflowChecks.so')}
        em_pass_remove_assume = %{passes('RemoveAssume.so')}


        rule asm_compile_rlib
            command = %compile_base --emit=link,dep-info --crate-type=rlib
            depfile = $b_asmjs/$crate_name.d
            description = RUSTC $out

        rule asm_compile_ir
            # Like opt-level=3 above, lto is mandatory to prevent emscripten-fastcomp errors.
            command = %compile_base --emit=llvm-ir,dep-info --crate-type=staticlib -C lto
            depfile = $b_asmjs/$crate_name.d
            description = RUSTC $out

        rule asm_clean_ir
            command = sed <$in >$out $
                -e '/^target triple/s/i686-unknown-linux-gnu/asmjs-unknown-emscripten/'
            description = ASMJS $out

        rule asm_assemble_bc
            command = $em_llvm_as $in -o $out
            description = ASMJS $out


        rule asm_optimize_bc
            command = $em_opt $in $
                -load=$em_pass_remove_overflow_checks $
                -load=$em_pass_remove_assume $
                -strip-debug $
                -internalize -internalize-public-api-list="$$(cat $exports_file)" $
                -remove-overflow-checks $
                -remove-assume $
                -globaldce $
                -pnacl-abi-simplify-preopt -pnacl-abi-simplify-postopt $
                -enable-emscripten-cxx-exceptions $
                -o $out
            description = ASMJS $out

        rule asm_convert_exports
            command = tr '\n' ',' <$in >$out
            description = ASMJS $out

        rule asm_generate_js
            command = $em_llc $in $
                -march=js -filetype=asm $
                -emscripten-assertions=1 $
                -emscripten-no-aliasing-function-pointers $
                -O3 $
                -o $out
            description = ASMJS $out

        rule asm_add_function_tables
            command = $python3 $root/mk/misc/asmjs_function_tables.py <$in >$out
            description = ASMJS $out

        rule asm_insert_functions
            command = $python3 $root/mk/misc/asmjs_insert_functions.py $in >$out
            description = ASMJS $out
    ''', **locals())
示例#44
0
def day_night(out_json, src_img):
    return template('''
        build %out_json: process_day_night %src_img $
            | $root/src/gen/gen_day_night.py
    ''', **locals())
示例#45
0
def server_json(out_json):
    return template('''
        build %out_json: gen_server_json | $root/src/gen/gen_server_json.py
    ''', **locals())
示例#46
0
def server_json(out_json):
    return template(
        '''
        build %out_json: gen_server_json | $root/src/gen/gen_server_json.py
    ''', **locals())
示例#47
0
def day_night(out_json, src_img):
    return template(
        '''
        build %out_json: process_day_night %src_img $
            | $root/src/gen/gen_day_night.py
    ''', **locals())