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

fbcode_builder: getdeps: add NinjaBootstrap builder

Summary:
this builder is used to bootstrap the ninja build tool.

On Windows and mac the manifest for ninja is set to download a pre-built executable.
While pre-built executables are available for linux they aren't portable enough
for our purposes so we need to be able to build it for ourselves.

Reviewed By: simpkins

Differential Revision: D14690992

fbshipit-source-id: b60fd02ad04f58dc7c2931280341791270609737
parent 1f158eff
......@@ -11,6 +11,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
import glob
import os
import shutil
import sys
from .envfuncs import Env, add_path_entry, path_search
from .runcmd import run_cmd
......@@ -220,3 +221,20 @@ class CMakeBuilder(BuilderBase):
],
env=env,
)
class NinjaBootstrap(BuilderBase):
def __init__(self, build_opts, ctx, manifest, build_dir, src_dir, inst_dir):
super(NinjaBootstrap, self).__init__(
build_opts, ctx, manifest, src_dir, build_dir, inst_dir
)
def _build(self, install_dirs, reconfigure):
self._run_cmd([sys.executable, "configure.py", "--bootstrap"], cwd=self.src_dir)
src_ninja = os.path.join(self.src_dir, "ninja")
dest_ninja = os.path.join(self.inst_dir, "bin/ninja")
bin_dir = os.path.dirname(dest_ninja)
if not os.path.exists(bin_dir):
os.makedirs(bin_dir)
shutil.copyfile(src_ninja, dest_ninja)
shutil.copymode(src_ninja, dest_ninja)
......@@ -10,7 +10,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
import io
from .builder import AutoconfBuilder, CMakeBuilder, MakeBuilder
from .builder import AutoconfBuilder, CMakeBuilder, MakeBuilder, NinjaBootstrap
from .expr import parse_expr
from .fetcher import (
ArchiveFetcher,
......@@ -318,4 +318,9 @@ class ManifestParser(object):
build_options, ctx, self, src_dir, build_dir, inst_dir, defines
)
if builder == "ninja_bootstrap":
return NinjaBootstrap(
build_options, ctx, self, build_dir, src_dir, inst_dir
)
raise KeyError("project %s has no known builder" % (self.name))
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