def main(): with BuckProject.from_current_dir() as project: buck_repo = BuckRepo(THIS_DIR, project) if 'clean' in sys.argv: buck_repo.kill_buckd() exit_code = buck_repo.launch_buck() sys.exit(exit_code)
def main(argv): try: java_home = os.getenv("JAVA_HOME", "") path = os.getenv("PATH", "") if java_home: pathsep = os.pathsep if sys.platform == 'cygwin': pathsep = ';' os.environ["PATH"] = os.path.join(java_home, 'bin') + pathsep + path tracing_dir = None build_id = str(uuid.uuid4()) with Tracing("main"): with BuckProject.from_current_dir() as project: tracing_dir = os.path.join(project.get_buck_out_log_dir(), 'traces') # Try to detect if we're running a PEX by checking if we were invoked # via a zip file. if zipfile.is_zipfile(argv[0]): from buck_package import BuckPackage buck_repo = BuckPackage(project) else: from buck_repo import BuckRepo buck_repo = BuckRepo(THIS_DIR, project) return buck_repo.launch_buck(build_id) finally: if tracing_dir: Tracing.write_to_dir(tracing_dir, build_id)
def main(argv): def get_repo(p): # Try to detect if we're running a PEX by checking if we were invoked # via a zip file. if zipfile.is_zipfile(argv[0]): from buck_package import BuckPackage return BuckPackage(p) else: from buck_repo import BuckRepo return BuckRepo(THIS_DIR, p) install_signal_handlers() try: tracing_dir = None build_id = str(uuid.uuid4()) with Tracing("main"): with BuckProject.from_current_dir() as project: tracing_dir = os.path.join(project.get_buck_out_log_dir(), 'traces') with get_repo(project) as buck_repo: # If 'kill' is the second argument, shut down the buckd process. if sys.argv[1:] == ['kill']: buck_repo.kill_buckd() return 0 return buck_repo.launch_buck(build_id) finally: if tracing_dir: Tracing.write_to_dir(tracing_dir, build_id)
def main(argv, reporter): # Change environment at startup to ensure we don't have any other threads # running yet. # We set BUCK_ROOT_BUILD_ID to ensure that if we're called in a nested fashion # from, say, a genrule, we do not reuse the UUID, and logs do not end up with # confusing / incorrect data # TODO: remove ability to inject BUCK_BUILD_ID completely. It mostly causes # problems, and is not a generally useful feature for users. if "BUCK_BUILD_ID" in os.environ and "BUCK_ROOT_BUILD_ID" not in os.environ: build_id = os.environ["BUCK_BUILD_ID"] else: build_id = str(uuid.uuid4()) if "BUCK_ROOT_BUILD_ID" not in os.environ: os.environ["BUCK_ROOT_BUILD_ID"] = build_id java_version_status_queue = Queue(maxsize=1) def get_repo(p): # Try to detect if we're running a PEX by checking if we were invoked # via a zip file. if zipfile.is_zipfile(argv[0]): from buck_package import BuckPackage return BuckPackage(p, reporter) else: from buck_repo import BuckRepo return BuckRepo(THIS_DIR, p, reporter) def kill_buck(reporter): buck_repo = get_repo(BuckProject.from_current_dir()) buck_repo.kill_buckd() return ExitCode.SUCCESS # Execute wrapper specific commands wrapper_specific_commands = [("kill", kill_buck), ("killall", killall_buck)] if "--help" not in argv and "-h" not in argv: for command_str, command_fcn in wrapper_specific_commands: if len(argv) > 1 and argv[1] == command_str: return ExitCodeCallable(command_fcn(reporter)) install_signal_handlers() try: tracing_dir = None reporter.build_id = build_id with Tracing("main"): with BuckProject.from_current_dir() as project: tracing_dir = os.path.join(project.get_buck_out_log_dir(), "traces") with get_repo(project) as buck_repo: required_java_version = buck_repo.get_buck_compiled_java_version() java_path = get_java_path(required_java_version) _try_to_verify_java_version_off_thread( java_version_status_queue, java_path, required_java_version ) return buck_repo.launch_buck(build_id, os.getcwd(), java_path, argv) finally: if tracing_dir: Tracing.write_to_dir(tracing_dir, build_id) _emit_java_version_warnings_if_any(java_version_status_queue)
def main(argv): install_signal_handlers() try: java_home = os.getenv("JAVA_HOME", "") path = os.getenv("PATH", "") if java_home: pathsep = os.pathsep os.environ["PATH"] = os.path.join(java_home, 'bin') + pathsep + path tracing_dir = None build_id = str(uuid.uuid4()) with Tracing("main"): with BuckProject.from_current_dir() as project: tracing_dir = os.path.join(project.get_buck_out_log_dir(), 'traces') # Try to detect if we're running a PEX by checking if we were invoked # via a zip file. if zipfile.is_zipfile(argv[0]): from buck_package import BuckPackage buck_repo = BuckPackage(project) else: from buck_repo import BuckRepo buck_repo = BuckRepo(THIS_DIR, project) # If 'kill' is the second argument, shut down the buckd process. if sys.argv[1:] == ['kill']: buck_repo.kill_buckd() return 0 return buck_repo.launch_buck(build_id) finally: if tracing_dir: Tracing.write_to_dir(tracing_dir, build_id)
def main(argv, reporter): # Change environment at startup to ensure we don't have any other threads # running yet. # We set BUCK_ROOT_BUILD_ID to ensure that if we're called in a nested fashion # from, say, a genrule, we do not reuse the UUID, and logs do not end up with # confusing / incorrect data # TODO: remove ability to inject BUCK_BUILD_ID completely. It mostly causes # problems, and is not a generally useful feature for users. if "BUCK_BUILD_ID" in os.environ and "BUCK_ROOT_BUILD_ID" not in os.environ: build_id = os.environ["BUCK_BUILD_ID"] else: build_id = str(uuid.uuid4()) if "BUCK_ROOT_BUILD_ID" not in os.environ: os.environ["BUCK_ROOT_BUILD_ID"] = build_id java_version_status_queue = Queue(maxsize=1) def get_repo(p): # Try to detect if we're running a PEX by checking if we were invoked # via a zip file. if zipfile.is_zipfile(argv[0]): from buck_package import BuckPackage return BuckPackage(p, reporter) else: from buck_repo import BuckRepo return BuckRepo(THIS_DIR, p, reporter) # If 'killall' is the second argument, shut down all the buckd processes if argv[1:] == ["killall"]: return killall_buck(reporter) install_signal_handlers() try: tracing_dir = None reporter.build_id = build_id with Tracing("main"): with BuckProject.from_current_dir() as project: tracing_dir = os.path.join(project.get_buck_out_log_dir(), "traces") with get_repo(project) as buck_repo: required_java_version = buck_repo.get_buck_compiled_java_version() java_path = get_java_path(required_java_version) _try_to_verify_java_version_off_thread( java_version_status_queue, java_path, required_java_version ) # If 'kill' is the second argument, shut down the buckd # process if argv[1:] == ["kill"]: buck_repo.kill_buckd() return ExitCode.SUCCESS return buck_repo.launch_buck(build_id, java_path, argv) finally: if tracing_dir: Tracing.write_to_dir(tracing_dir, build_id) _emit_java_version_warnings_if_any(java_version_status_queue)
def main(argv, reporter): # Change environment at startup to ensure we don't have any other threads # running yet. # We set BUCK_ROOT_BUILD_ID to ensure that if we're called in a nested fashion # from, say, a genrule, we do not reuse the UUID, and logs do not end up with # confusing / incorrect data # TODO: remove ability to inject BUCK_BUILD_ID completely. It mostly causes # problems, and is not a generally useful feature for users. if "BUCK_BUILD_ID" in os.environ and "BUCK_ROOT_BUILD_ID" not in os.environ: build_id = os.environ["BUCK_BUILD_ID"] else: build_id = str(uuid.uuid4()) if "BUCK_ROOT_BUILD_ID" not in os.environ: os.environ["BUCK_ROOT_BUILD_ID"] = build_id java_version_status_queue = Queue(maxsize=1) def get_repo(p): # Try to detect if we're running a PEX by checking if we were invoked # via a zip file. if zipfile.is_zipfile(argv[0]): from buck_package import BuckPackage return BuckPackage(p, reporter) else: from buck_repo import BuckRepo return BuckRepo(THIS_DIR, p, reporter) # If 'killall' is the second argument, shut down all the buckd processes if argv[1:] == ["killall"]: return killall_buck(reporter) install_signal_handlers() try: tracing_dir = None reporter.build_id = build_id with Tracing("main"): with BuckProject.from_current_dir() as project: tracing_dir = os.path.join(project.get_buck_out_log_dir(), "traces") with get_repo(project) as buck_repo: _try_to_verify_java_version_off_thread( java_version_status_queue, buck_repo.get_buck_compiled_java_version(), ) # If 'kill' is the second argument, shut down the buckd # process if argv[1:] == ["kill"]: buck_repo.kill_buckd() return ExitCode.SUCCESS return buck_repo.launch_buck(build_id, argv) finally: if tracing_dir: Tracing.write_to_dir(tracing_dir, build_id) _emit_java_version_warnings_if_any(java_version_status_queue)
def main(): with BuckProject.from_current_dir() as project: buck_repo = BuckRepo(THIS_DIR, project) if "--help" in sys.argv: print("Specify --kill to kill buckd.", file=sys.stderr) sys.exit(0) buck_repo.kill_buckd() if "--kill" in sys.argv: sys.exit(0) exit_code = buck_repo.launch_buckd() sys.exit(exit_code)
def main(): with BuckProject.from_current_dir() as project: buck_repo = BuckRepo(THIS_DIR, project) if '--help' in sys.argv: print("Specify --kill to kill buckd.", file=sys.stderr) sys.exit(0) buck_repo.kill_buckd() if '--kill' in sys.argv: sys.exit(0) exit_code = buck_repo.launch_buckd() sys.exit(exit_code)
def main(argv, reporter): java_version_status_queue = Queue(maxsize=1) required_java_version = "8" java10_test_mode_arg = "--java10-test-mode" java10_test_mode = java10_test_mode_arg in argv if java10_test_mode: argv.remove(java10_test_mode_arg) required_java_version = "10" _try_to_verify_java_version_off_thread(java_version_status_queue, required_java_version) def get_repo(p): # Try to detect if we're running a PEX by checking if we were invoked # via a zip file. if zipfile.is_zipfile(argv[0]): from buck_package import BuckPackage return BuckPackage(p, reporter) else: from buck_repo import BuckRepo return BuckRepo(THIS_DIR, p, reporter) # If 'killall' is the second argument, shut down all the buckd processes if argv[1:] == ["killall"]: return killall_buck(reporter) install_signal_handlers() try: tracing_dir = None build_id = os.environ.get("BUCK_BUILD_ID", str(uuid.uuid4())) reporter.build_id = build_id with Tracing("main"): with BuckProject.from_current_dir() as project: tracing_dir = os.path.join(project.get_buck_out_log_dir(), "traces") with get_repo(project) as buck_repo: # If 'kill' is the second argument, shut down the buckd # process if argv[1:] == ["kill"]: buck_repo.kill_buckd() return ExitCode.SUCCESS return buck_repo.launch_buck(build_id, argv, java10_test_mode) finally: if tracing_dir: Tracing.write_to_dir(tracing_dir, build_id) _emit_java_version_warnings_if_any(java_version_status_queue)
def main(argv): with BuckProject.from_current_dir() as project: # Try to detect if we're running a PEX by checking if we were invoked # via a zip file. if zipfile.is_zipfile(argv[0]): from buck_package import BuckPackage buck_repo = BuckPackage(project) else: from buck_repo import BuckRepo buck_repo = BuckRepo(THIS_DIR, project) if '--help' in argv: print("Specify --kill to kill buckd.", file=sys.stderr) return 0 buck_repo.kill_buckd() if '--kill' in sys.argv: return 0 return buck_repo.launch_buckd()
def main(argv): project = BuckProject.from_current_dir() buck_version = get_buck_version(project) repo = BuckRepo(THIS_DIR, project) build_success_file = os.path.join(repo.buck_dir, "build", "successful-build") if repo.is_git and buck_version is not None: revision = buck_version[0] branch = buck_version[1] if len(buck_version) > 1 else None if checkout(repo, revision, branch, build_success_file): run_ant_clean(repo, project) if not os.path.exists(build_success_file): sys.stderr.write( "Buck does not appear to have been built -- building Buck!\n") run_ant_build(repo, project) sys.stderr.write("All done, continuing with build.\n") os.execvp(os.path.join(repo.buck_dir, 'bin', 'buck'), sys.argv)
def main(argv): project = BuckProject.from_current_dir() buck_version = get_buck_version(project) repo = BuckRepo(THIS_DIR, project) build_success_file = os.path.join( repo.buck_dir, "build", "successful-build") if repo.is_git and buck_version is not None: revision = buck_version[0] branch = buck_version[1] if len(buck_version) > 1 else None if checkout(repo, revision, branch, build_success_file): run_ant_clean(repo, project) if not os.path.exists(build_success_file): sys.stderr.write( "Buck does not appear to have been built -- building Buck!\n") run_ant_build(repo, project) sys.stderr.write("All done, continuing with build.\n") os.execvp(os.path.join(repo.buck_dir, 'bin', 'buck'), sys.argv)
def main(argv, reporter): java_version_status_queue = Queue(maxsize=1) _try_to_verify_java_version_off_thread(java_version_status_queue) def get_repo(p): # Try to detect if we're running a PEX by checking if we were invoked # via a zip file. if zipfile.is_zipfile(argv[0]): from buck_package import BuckPackage return BuckPackage(p, reporter) else: from buck_repo import BuckRepo return BuckRepo(THIS_DIR, p, reporter) # If 'killall' is the second argument, shut down all the buckd processes if sys.argv[1:] == ["killall"]: return killall_buck(reporter) install_signal_handlers() try: tracing_dir = None build_id = os.environ.get("BUCK_BUILD_ID", str(uuid.uuid4())) reporter.build_id = build_id with Tracing("main"): with BuckProject.from_current_dir() as project: tracing_dir = os.path.join(project.get_buck_out_log_dir(), "traces") with get_repo(project) as buck_repo: # If 'kill' is the second argument, shut down the buckd # process if sys.argv[1:] == ["kill"]: buck_repo.kill_buckd() return ExitCode.SUCCESS return buck_repo.launch_buck(build_id) finally: if tracing_dir: Tracing.write_to_dir(tracing_dir, build_id) _emit_java_version_warnings_if_any(java_version_status_queue)
def main(argv, reporter): java_version = _get_java_version() if java_version and java_version != REQUIRED_JAVA_VERSION: _warn_about_wrong_java_version(REQUIRED_JAVA_VERSION, java_version) def get_repo(p): # Try to detect if we're running a PEX by checking if we were invoked # via a zip file. if zipfile.is_zipfile(argv[0]): from buck_package import BuckPackage return BuckPackage(p, reporter) else: from buck_repo import BuckRepo return BuckRepo(THIS_DIR, p, reporter) # If 'killall' is the second argument, shut down all the buckd processes if sys.argv[1:] == ['killall']: return killall_buck(reporter) install_signal_handlers() try: tracing_dir = None build_id = str(uuid.uuid4()) reporter.build_id = build_id with Tracing("main"): with BuckProject.from_current_dir() as project: tracing_dir = os.path.join(project.get_buck_out_log_dir(), 'traces') with get_repo(project) as buck_repo: # If 'kill' is the second argument, shut down the buckd # process if sys.argv[1:] == ['kill']: buck_repo.kill_buckd() return 0 return buck_repo.launch_buck(build_id) finally: if tracing_dir: Tracing.write_to_dir(tracing_dir, build_id)
def main(argv, reporter): _try_to_verify_java_version() def get_repo(p): # Try to detect if we're running a PEX by checking if we were invoked # via a zip file. if zipfile.is_zipfile(argv[0]): from buck_package import BuckPackage return BuckPackage(p, reporter) else: from buck_repo import BuckRepo return BuckRepo(THIS_DIR, p, reporter) # If 'killall' is the second argument, shut down all the buckd processes if sys.argv[1:] == ['killall']: return killall_buck(reporter) install_signal_handlers() try: tracing_dir = None build_id = os.environ.get('BUCK_BUILD_ID', str(uuid.uuid4())) reporter.build_id = build_id with Tracing("main"): with BuckProject.from_current_dir() as project: tracing_dir = os.path.join(project.get_buck_out_log_dir(), 'traces') with get_repo(project) as buck_repo: # If 'kill' is the second argument, shut down the buckd # process if sys.argv[1:] == ['kill']: buck_repo.kill_buckd() return ExitCode.SUCCESS return buck_repo.launch_buck(build_id) finally: if tracing_dir: Tracing.write_to_dir(tracing_dir, build_id)
def kill_buck(reporter): buck_repo = get_repo(BuckProject.from_current_dir()) buck_repo.kill_buckd() return ExitCode.SUCCESS