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

getdeps: introduce `build --enable-tests` option

Summary:
This controls whether tests are built or not.
They are not built by default.  When `--enable-tests` is turned on,
tests are enabled for the named project only, not all of the deps.
This results in a faster build, because eg: the number of tests in
folly is very large and consumers of folly don't want to spend so
much time waiting to build tests when really all they want to do
is build their own project.

Reviewed By: strager

Differential Revision: D15246336

fbshipit-source-id: 2e22fd60c983b059f71639602712087f2a188ec6
parent 1bf2a1af
...@@ -222,6 +222,11 @@ class BuildCmd(SubCmd): ...@@ -222,6 +222,11 @@ class BuildCmd(SubCmd):
install_dirs = [] install_dirs = []
for m in projects: for m in projects:
ctx = dict(ctx)
if args.enable_tests and m.name == manifest.name:
ctx["test"] = "on"
else:
ctx["test"] = "off"
fetcher = m.create_fetcher(opts, ctx) fetcher = m.create_fetcher(opts, ctx)
if args.clean: if args.clean:
...@@ -287,6 +292,15 @@ class BuildCmd(SubCmd): ...@@ -287,6 +292,15 @@ class BuildCmd(SubCmd):
"slow up-to-date-ness checks" "slow up-to-date-ness checks"
), ),
) )
parser.add_argument(
"--enable-tests",
action="store_true",
default=False,
help=(
"For the named project, build tests so that the test command "
"is able to execute tests"
),
)
@cmd("test", "test a given project") @cmd("test", "test a given project")
...@@ -296,6 +310,7 @@ class TestCmd(SubCmd): ...@@ -296,6 +310,7 @@ class TestCmd(SubCmd):
manifest = load_project(opts, args.project) manifest = load_project(opts, args.project)
ctx = context_from_host_tuple() ctx = context_from_host_tuple()
ctx["test"] = "on"
projects = manifests_in_dependency_order(opts, manifest, ctx) projects = manifests_in_dependency_order(opts, manifest, ctx)
manifests_by_name = {m.name: m for m in projects} manifests_by_name = {m.name: m for m in projects}
......
...@@ -24,6 +24,12 @@ zstd ...@@ -24,6 +24,12 @@ zstd
[dependencies.any(os=windows, os=darwin)] [dependencies.any(os=windows, os=darwin)]
bison bison
[cmake.defines.test=on]
BUILD_TESTS=ON
[cmake.defines.test=off]
BUILD_TESTS=OFF
[shipit.pathmap] [shipit.pathmap]
fbcode/thrift/public_tld = . fbcode/thrift/public_tld = .
fbcode/thrift = thrift fbcode/thrift = thrift
......
...@@ -49,4 +49,9 @@ fbcode/folly = folly ...@@ -49,4 +49,9 @@ fbcode/folly = folly
[cmake.defines] [cmake.defines]
BUILD_SHARED_LIBS=OFF BUILD_SHARED_LIBS=OFF
[cmake.defines.test=on]
BUILD_TESTS=ON BUILD_TESTS=ON
[cmake.defines.test=off]
BUILD_TESTS=OFF
...@@ -11,8 +11,11 @@ repo_url = https://github.com/facebook/wangle.git ...@@ -11,8 +11,11 @@ repo_url = https://github.com/facebook/wangle.git
builder = cmake builder = cmake
subdir = wangle subdir = wangle
[cmake.defines] [cmake.defines.test=on]
BUILD_TESTS = ON BUILD_TESTS=ON
[cmake.defines.test=off]
BUILD_TESTS=OFF
[dependencies] [dependencies]
folly folly
......
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