From 41a5043d1b3eddaf271301204982940a2a1c8ac7 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 3 May 2019 15:52:39 -0700 Subject: [PATCH] fbcode_builder: getdeps: add `show-inst-dir` and `show-source-dir` commands Summary: This prints out the installation or source prefix for a given project. This is useful in eg: packaging scripts to figure out where they can find the built artifacts. Reviewed By: simpkins Differential Revision: D14967378 fbshipit-source-id: 7e1b5de2ca7219af24cfb07b4b42de22aa410469 --- build/fbcode_builder/getdeps.py | 68 +++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/build/fbcode_builder/getdeps.py b/build/fbcode_builder/getdeps.py index 7c57dca6b..661edc2a4 100755 --- a/build/fbcode_builder/getdeps.py +++ b/build/fbcode_builder/getdeps.py @@ -135,6 +135,74 @@ class CleanCmd(SubCmd): clean_dirs(opts) +@cmd("show-inst-dir", "print the installation dir for a given project") +class ShowInstDirCmd(SubCmd): + def run(self, args): + opts = setup_build_options(args) + manifest = load_project(opts, args.project) + ctx = context_from_host_tuple() + projects = manifests_in_dependency_order(opts, manifest, ctx) + manifests_by_name = {m.name: m for m in projects} + + if args.recursive: + manifests = projects + else: + manifests = [manifest] + + for m in manifests: + fetcher = m.create_fetcher(opts, ctx) + dirs = opts.compute_dirs(m, fetcher, manifests_by_name, ctx) + inst_dir = dirs["inst_dir"] + print(inst_dir) + + def setup_parser(self, parser): + parser.add_argument( + "project", + help=( + "name of the project or path to a manifest " + "file describing the project" + ), + ) + parser.add_argument( + "--recursive", + help="print the transitive deps also", + action="store_true", + default=False, + ) + + +@cmd("show-source-dir", "print the source dir for a given project") +class ShowSourceDirCmd(SubCmd): + def run(self, args): + opts = setup_build_options(args) + manifest = load_project(opts, args.project) + ctx = context_from_host_tuple() + + if args.recursive: + manifests = manifests_in_dependency_order(opts, manifest, ctx) + else: + manifests = [manifest] + + for m in manifests: + fetcher = m.create_fetcher(opts, ctx) + print(fetcher.get_src_dir()) + + def setup_parser(self, parser): + parser.add_argument( + "project", + help=( + "name of the project or path to a manifest " + "file describing the project" + ), + ) + parser.add_argument( + "--recursive", + help="print the transitive deps also", + action="store_true", + default=False, + ) + + @cmd("build", "build a given project") class BuildCmd(SubCmd): def run(self, args):