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
This commit is contained in:
Wez Furlong 2019-05-03 15:52:39 -07:00 committed by Facebook Github Bot
parent 0273305ebc
commit e81956ff66

View File

@ -135,6 +135,74 @@ class CleanCmd(SubCmd):
clean_dirs(opts) 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") @cmd("build", "build a given project")
class BuildCmd(SubCmd): class BuildCmd(SubCmd):
def run(self, args): def run(self, args):