Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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 = []
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 = []
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)
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)
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 = []
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(
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 = []
def ninja_path (): return Path(ninja.BIN_DIR)
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: