diff --git a/build/fbcode_builder/getdeps.py b/build/fbcode_builder/getdeps.py index 1046397fc..0fde4c749 100755 --- a/build/fbcode_builder/getdeps.py +++ b/build/fbcode_builder/getdeps.py @@ -14,6 +14,8 @@ import os import subprocess import sys +from getdeps.buildopts import setup_build_options +from getdeps.load import resolve_manifest_path from getdeps.manifest import ManifestParser from getdeps.platform import HostType from getdeps.subcmd import SubCmd, add_subcommands, cmd @@ -45,6 +47,25 @@ class ShowHostType(SubCmd): return 0 +@cmd("fetch", "fetch the code for a given project") +class FetchCmd(SubCmd): + def setup_parser(self, parser): + parser.add_argument( + "project", + help=( + "name of the project or path to a manifest " + "file describing the project" + ), + ) + + def run(self, args): + opts = setup_build_options(args) + manifest_path = resolve_manifest_path(opts, args.project) + manifest = ManifestParser(manifest_path) + fetcher = manifest.create_fetcher(opts, ctx={}) + fetcher.update() + + def build_argparser(): common_args = argparse.ArgumentParser(add_help=False) common_args.add_argument( diff --git a/build/fbcode_builder/getdeps/load.py b/build/fbcode_builder/getdeps/load.py new file mode 100644 index 000000000..ffbca2b92 --- /dev/null +++ b/build/fbcode_builder/getdeps/load.py @@ -0,0 +1,19 @@ +# Copyright (c) 2019-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + +from __future__ import absolute_import, division, print_function, unicode_literals + +import os + + +def resolve_manifest_path(build_opts, project_name): + if "/" in project_name or "\\" in project_name: + # Assume this is a path already + return project_name + + # Otherwise, resolve it relative to the manifests dir + return os.path.join(build_opts.fbcode_builder_dir, "manifests", project_name)