How to use ninja - 10 common examples

To help you get started, we’ve selected a few ninja examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aosp-mirror / platform_development / vndk / tools / sourcedr / ninja / list_ninja_build_dep.py View on Github external
def main():
    args = _parse_args()

    # Build lookup map
    manifest = ninja.load_manifest_from_args(args)
    graph = {}
    for build in manifest.builds:
        for path in build.explicit_outs:
            graph[path] = build
        for path in build.implicit_outs:
            graph[path] = build

    # List all transitive targets
    try:
        builds = collect_build_targets(graph, args.target)
    except KeyError:
        print('error: Failed to find the target {}'.format(arg.target),
              file=sys.stderr)
        sys.exit(1)

    # Print all targets
github pytorch / pytorch / tools / setup_helpers / ninja_builder.py View on Github external
def __init__(self, name):
        import ninja
        if not os.path.exists(BUILD_DIR):
            os.mkdir(BUILD_DIR)
        self.ninja_program = os.path.join(ninja.BIN_DIR, 'ninja')
        self.name = name
        self.filename = os.path.join(BUILD_DIR, 'build.{}.ninja'.format(name))
        self.writer = ninja.Writer(open(self.filename, 'w'))
        self.writer.rule('do_cmd', '$cmd')
        self.writer.rule('compile', '$cmd')
        self.compdb_targets = []
github onnx / onnx / tools / ninja_builder.py View on Github external
def __init__(self, name):
        import ninja
        if not os.path.exists(BUILD_DIR):
            os.mkdir(BUILD_DIR)
        self.ninja_program = os.path.join(ninja.BIN_DIR, 'ninja')
        self.name = name
        self.filename = os.path.join(BUILD_DIR, 'build.{}.ninja'.format(name))
        self.writer = ninja.Writer(open(self.filename, 'w'))
        self.writer.rule('do_cmd', '$cmd')
        self.writer.rule('compile', '$cmd')
        self.compdb_targets = []
github trezor / trezor-core / ninja / build.py View on Github external
w.build(
        "$builddir/genhdr/qstrdefs.generated.h",
        "qstr_generate",
        "$builddir/genhdr/qstrdefs.preprocessed.h",
    )

    w.variable("qstr", "$builddir/genhdr/qstrdefs.generated.h")


def build_object(path):
    base, ext = os.path.splitext(path)
    return "$builddir/%s.o" % base


with open("build_unix_debug.ninja", "w") as of:
    writer = ninja.Writer(of, 1024)
    common(writer)
    qstrings(writer)
    micropython(writer)
    extmod(writer)
    unix(writer)
    version(writer)
github aosp-mirror / platform_development / vndk / tools / sourcedr / ninja / list_source_file.py View on Github external
out_dir = posixpath.normpath(args.out_dir)
    out_dir_pattern = re.compile(re.escape(out_dir) + '/')
    out_host_dir_pattern = re.compile(re.escape(out_dir) + '/host/')
    out_product_dir = out_dir + '/target/product/[^/]+'

    def _normalize_path(path):
        if path.startswith(out_dir + '/target'):
            return path
        return posixpath.join(out_product_dir, path)

    installed_filter = [_normalize_path(path) for path in args.installed_filter]
    installed_filter = re.compile(
        '|'.join('(?:' + p + ')' for p in installed_filter))

    manifest = ninja.load_manifest_from_args(args)

    # Build lookup map
    graph = {}
    for build in manifest.builds:
        for path in build.explicit_outs:
            graph[path] = build
        for path in build.implicit_outs:
            graph[path] = build

    # Collect all matching outputs
    matched_files = [path for path in graph if installed_filter.match(path)]
    matched_files.sort()

    for path in matched_files:
        source_files = collect_source_files(
            graph, path, out_dir_pattern, out_host_dir_pattern)
github onnx / onnx / tools / ninja_builder.py View on Github external
def __init__(self, name):
        import ninja
        if not os.path.exists(BUILD_DIR):
            os.mkdir(BUILD_DIR)
        self.ninja_program = os.path.join(ninja.BIN_DIR, 'ninja')
        self.name = name
        self.filename = os.path.join(BUILD_DIR, 'build.{}.ninja'.format(name))
        self.writer = ninja.Writer(open(self.filename, 'w'))
        self.writer.rule('do_cmd', '$cmd')
        self.writer.rule('compile', '$cmd')
        self.compdb_targets = []
github slurps-mad-rips / brujeria / brujeria / mixin.py View on Github external
def build (self):
        yield
        self.writer.close()
        ninja_program = Path(ninja.BIN_DIR) / 'ninja'
        env = os.environ
        if not self.is_posix:
            # Add vcvarsall.bat to execution
            from distutils._msvccompiler import PLAT_TO_VCVARS, _get_vc_env
            from distutils.util import get_platform
            env = _get_vc_env(PLAT_TO_VCVARS[get_platform()])
        cmd = [str(ninja_program), '-f', str(self.writer.path)]
        import sys
        process = subprocess.Popen(cmd,
            env=env,
            universal_newlines=True,
            stdout=sys.stdout, #subprocess.PIPE,
            stderr=sys.stderr)#subprocess.PIPE)
        out, err = process.communicate()
        if process.returncode != 0:
            raise subprocess.CalledProcessError(
github pytorch / pytorch / tools / setup_helpers / ninja_builder.py View on Github external
def __init__(self, name):
        import ninja
        if not os.path.exists(BUILD_DIR):
            os.mkdir(BUILD_DIR)
        self.ninja_program = os.path.join(ninja.BIN_DIR, 'ninja')
        self.name = name
        self.filename = os.path.join(BUILD_DIR, 'build.{}.ninja'.format(name))
        self.writer = ninja.Writer(open(self.filename, 'w'))
        self.writer.rule('do_cmd', '$cmd')
        self.writer.rule('compile', '$cmd')
        self.compdb_targets = []
github slurps-mad-rips / brujeria / brujeria / ast.py View on Github external
def ninja_path (): return Path(ninja.BIN_DIR)
github adangert / JoustMania / ninja.py View on Github external
start = False
    no_rumble = time.time() + 1
    move_last_value = None
    move = common.get_move(move_serial, move_num)
    team_colors = common.generate_colors(team_num)
    #keep on looping while move is not dead
    ready = False
    move.set_leds(0,0,0)
    move.update_leds()
    time.sleep(1)

    death_time = 8
    time_of_death = time.time()


    move_opts[Opts.holding.value] = Holding.not_holding.value
    move_opts[Opts.selection.value] = Selections.nothing.value

    while True:
        if sum(force_color) != 0:
            no_rumble_time = time.time() + 5
            time.sleep(0.01)
            move.set_leds(*force_color)
            move.update_leds()
            move.set_rumble(0)
            no_rumble = time.time() + 0.5
        #if we are not dead
        elif dead_move.value == 1:
            if move.poll():
                ax, ay, az = move.get_accelerometer_frame(psmove.Frame_SecondHalf)
                total = sum([ax, ay, az])
                if move_last_value is not None:

ninja

Ninja is a small build system with a focus on speed

Apache-2.0
Latest version published 1 year ago

Package Health Score

83 / 100
Full package analysis