Commit b4135123 authored by Wez Furlong's avatar Wez Furlong Committed by Facebook Github Bot

fbcode_builder: getdeps: add NopBuilder

Summary:
this could do with a better name; the NopBuilder doesn't actually
build anything, but instead copies some files to the destination location.

This is used together with eg: cmake to install pre-built binaries downloaded
from a tarball.

Reviewed By: simpkins

Differential Revision: D14691015

fbshipit-source-id: a938e977aa4ec5a664bdb8085ff708319a204594
parent b09be4e0
......@@ -11,6 +11,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
import glob
import os
import shutil
import stat
import sys
from .envfuncs import Env, add_path_entry, path_search
......@@ -335,3 +336,45 @@ class Boost(BuilderBase):
],
cwd=self.src_dir,
)
class NopBuilder(BuilderBase):
def __init__(self, build_opts, ctx, manifest, src_dir, inst_dir):
super(NopBuilder, self).__init__(
build_opts, ctx, manifest, src_dir, None, inst_dir
)
def build(self, install_dirs, reconfigure):
print("Installing %s -> %s" % (self.src_dir, self.inst_dir))
parent = os.path.dirname(self.inst_dir)
if not os.path.exists(parent):
os.makedirs(parent)
install_files = self.manifest.get_section_as_ordered_pairs(
"install.files", self.ctx
)
if install_files:
for src_name, dest_name in self.manifest.get_section_as_ordered_pairs(
"install.files", self.ctx
):
full_dest = os.path.join(self.inst_dir, dest_name)
full_src = os.path.join(self.src_dir, src_name)
dest_parent = os.path.dirname(full_dest)
if not os.path.exists(dest_parent):
os.makedirs(dest_parent)
if os.path.isdir(full_src):
if not os.path.exists(full_dest):
shutil.copytree(full_src, full_dest)
else:
shutil.copyfile(full_src, full_dest)
shutil.copymode(full_src, full_dest)
# This is a bit gross, but the mac ninja.zip doesn't
# give ninja execute permissions, so force them on
# for things that look like they live in a bin dir
if os.path.dirname(dest_name) == "bin":
st = os.lstat(full_dest)
os.chmod(full_dest, st.st_mode | stat.S_IXUSR)
else:
if not os.path.exists(self.inst_dir):
shutil.copytree(self.src_dir, self.inst_dir)
......@@ -16,6 +16,7 @@ from .builder import (
CMakeBuilder,
MakeBuilder,
NinjaBootstrap,
NopBuilder,
OpenSSLBuilder,
)
from .expr import parse_expr
......@@ -333,6 +334,9 @@ class ManifestParser(object):
build_options, ctx, self, build_dir, src_dir, inst_dir
)
if builder == "nop":
return NopBuilder(build_options, ctx, self, src_dir, inst_dir)
if builder == "openssl":
return OpenSSLBuilder(
build_options, ctx, self, build_dir, src_dir, inst_dir
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment