def launch_task(debugger, extras): """ Handles launching the application in obi go """ target = "" # Did the user specify a target? config_target = env.config.get("target", None) if config_target: target = os.path.join(env.project_dir, config_target) # TODO(jshrake): Consider nesting these conditionals # Look for a binary with name env.target_name in the build directory if not env.file_exists(target): target = os.path.join(env.build_dir, env.target_name) # Look for a binary with name env.target_name in the binary directory if not env.file_exists(target): target = os.path.join(env.project_dir, "bin", env.target_name) # Just give up -- can't find the target name if not env.file_exists(target): abort("Cannot find target binary to launch. Please specify the relative path to the binary via the target key") launch_args = env.config.get("launch-args", []) formatted_launch = "{0} {1} {2}".format( env.relpath(target), # {0} " ".join(extras), # {1} " ".join(launch_args) # {2} ) env_vars = env.config.get("env-vars", {}) env_vars = " ".join(["{0}={1}".format(key, val) for key, val in env_vars.items()]) with env.cd(env.project_dir): # Process pre-launch commands for cmd in env.config.get("pre-launch-cmds", []): env.run(cmd) if debugger: debug_cmd = debugger debuggers = env.config.get("debuggers", None) if debuggers: debug_cmd = debuggers.get(debugger, debug_cmd) default_launch = env.debug_launch_format_str.format(env_vars, debug_cmd, formatted_launch) launch_cmd = env.config.get("debug-launch-cmd", default_launch) env.background_run(launch_cmd) else: log_file = env.relpath(os.path.join(env.project_dir, env.target_name + ".log")) default_launch = env.launch_format_str.format(env_vars, formatted_launch, log_file) launch_cmd = env.config.get("launch-cmd", default_launch) env.background_run(launch_cmd) # Process the post-launch commands for cmd in env.config.get("post-launch-cmds", []): env.run(cmd)
def mkpath_if_doesnt_exist(path, use_sudo=False): """REMOTE PATHS ONLY. do not try to create local paths with this function unless your environment is a local machine """ if env.file_exists(path): print '* path already exists, not creating: %s' % path return cmd = "mkdir -p %s" % path return env.run(cmd, use_sudo=use_sudo)
def find_launch_target(): """ returns the absolute path to the binary we're going to launch """ target = "" # Did the user specify a target? config_target = env.config.get("target", None) if config_target: target = os.path.join(env.project_dir, config_target) # TODO(jshrake): Consider nesting these conditionals # Look for a binary with name env.target_name in the build directory if not env.file_exists(target): target = os.path.join(env.build_dir, env.target_name) # Look for a binary with name env.target_name in the binary directory if not env.file_exists(target): target = os.path.join(env.project_dir, "bin", env.target_name) # Just give up -- can't find the target name if not env.file_exists(target): abort( "Cannot find target binary to launch. Please specify the relative path to the binary via the target key" ) return target
def build_task(): """ obi build """ user_specified_build = env.config.get("build-cmd", None) if user_specified_build: env.run(user_specified_build) else: # Arguments for the cmake step cmake_args = env.config.get("cmake-args", []) cmake_args = " ".join(cmake_args) # Arguments for the build step build_args = env.config.get("build-args", []) build_args = " ".join(build_args) # If the build_dir does not exist, then then we need to create it # and configure cmake before building if not env.file_exists(env.build_dir): env.run("mkdir -p {0}".format(env.build_dir)) env.run("cmake -H\"{0}\" -B\"{1}\" {2}".format(env.project_dir, env.build_dir, cmake_args)) env.run("cmake --build \"{0}\" -- {1}".format(env.build_dir, build_args))