Skip to content
This repository was archived by the owner on May 16, 2023. It is now read-only.

Commit d1490a0

Browse files
committed
Part 2 of eliminating most of the per-project boilerplate
Summary: After this lands, adding new `fbcode_builder` projects will be much easier. **Bistro configs before:** ``` bistro/build/ci$ wc * 51 124 1863 build_steps.py wc: fbcode_builder: Is a directory 0 0 0 fbcode_builder 30 97 855 make_docker_context.py 17 85 593 README 15 61 611 travis_docker_build.sh 144 490 5045 total ``` **Bistro configs after:** ``` public_tld/build$ wc * 41 113 1376 fbcode_builder_config.py 10 45 397 README.md 64 200 2220 total ``` Reviewed By: sdwilsh Differential Revision: D4511822 fbshipit-source-id: 471d6f312f3688ef0114bc5f96fb28271cfef1f4
1 parent 300e6f9 commit d1490a0

28 files changed

+288
-140
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
*~
22
*.pyc
3-

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ script:
2121
- sudo apt-get install python2.7
2222
# We don't want to write the script inline because of Travis kludginess --
2323
# it looks like it escapes " and \ in scripts when using `matrix:`.
24-
- ./build/travis_docker_build.sh
24+
- ./build/fbcode_builder/travis_docker_build.sh

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ The CLI tools and web UI will be shipping shortly.
4141
Bistro needs a 64-bit Linux, Folly, FBThrift, Proxygen, boost, and
4242
libsqlite3. You need 2-3GB of RAM to build, as well as GCC 4.9 or above.
4343

44-
`bistro/build/ci/README` documents the usage of Docker-based scripts that
45-
build Bistro on Ubuntu 14.04, 16.04, and Debian 8.6. You should be able to
46-
follow very similar steps on most modern Linux distributions.
44+
`build/README.md` documents the usage of Docker-based scripts that build
45+
Bistro on Ubuntu 14.04, 16.04, and Debian 8.6. You should be able to follow
46+
very similar steps on most modern Linux distributions.
4747

48-
If you run into dependency problems, look at bistro/build/CMakeLists.txt for
48+
If you run into dependency problems, look at `bistro/cmake/setup.cmake` for
4949
a full list of Bistro's external dependencies (direct and indirect). We
5050
gratefully accept patches that improve Bistro's builds, or add support for
5151
various flavors of Linux and Mac OS.
5252

53-
The binaries will be in bistro/build/{Debug,Release}. Available build
53+
The binaries will be in bistro/cmake/{Debug,Release}. Available build
5454
targets are explained here:
5555
http://cmake.org/Wiki/CMake_Useful_Variables#Compilers_and_Tools
5656
You can start Bistro's unit tests by running `ctest` in those directories.
@@ -88,13 +88,13 @@ Open two terminals, one for the scheduler, and one for the worker.
8888
# In both terminals
8989
cd bistro/bistro
9090
# Start the scheduler in one terminal
91-
./build/Debug/server/bistro_scheduler \
91+
./cmake/Debug/server/bistro_scheduler \
9292
--server_port=6789 --http_server_port=6790 \
9393
--config_file=scripts/test_configs/simple --clean_statuses \
9494
--CAUTION_startup_wait_for_workers=1 --instance_node_name=scheduler
9595
# Start the worker in another
9696
mkdir /tmp/bistro_worker
97-
./build/Debug/worker/bistro_worker --server_port=27182 --scheduler_host=:: \
97+
./cmake/Debug/worker/bistro_worker --server_port=27182 --scheduler_host=:: \
9898
--scheduler_port=6789 --worker_command="$HOME/demo_bistro_task.sh" \
9999
--data_dir=/tmp/bistro_worker
100100
```
@@ -113,7 +113,7 @@ put the SQLite database, via `--data_dir=/tmp/bistro_scheduler` and
113113

114114
```
115115
mkdir /tmp/bistro_scheduler
116-
./build/Debug/server/bistro_scheduler \
116+
./cmake/Debug/server/bistro_scheduler \
117117
--server_port=6789 --http_server_port=6790 \
118118
--config_file=scripts/test_configs/simple \
119119
--data_dir=/tmp/bistro_scheduler --status_table=task_statuses \
@@ -140,7 +140,7 @@ less scripts/test_configs/simple
140140
For debugging, we typically invoke the binaries like this:
141141

142142
```
143-
gdb build/Debug/worker/bistro_worker -ex "r ..." 2>&1 | tee WORKER.txt
143+
gdb cmake/Debug/worker/bistro_worker -ex "r ..." 2>&1 | tee WORKER.txt
144144
```
145145

146146
When configuring a real deployment, be sure to carefully review the `--help`

bistro/build/ci/build_steps.py

-51
This file was deleted.

bistro/build/ci/fbcode_builder

-1
This file was deleted.

bistro/build/ci/make_docker_context.py

-30
This file was deleted.
File renamed without changes.

bistro/build/fbinclude/common/fb303/cpp/FacebookBase2.h bistro/cmake/fbinclude/common/fb303/cpp/FacebookBase2.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, Facebook, Inc.
2+
* Copyright (c) 2015-present, Facebook, Inc.
33
* All rights reserved.
44
*
55
* This source code is licensed under the BSD-style license found in the

bistro/build/run-cmake.sh bistro/cmake/run-cmake.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#
1010

1111
#
12-
# Runs `cmake` for Bistro, directing output to build/Release/ or build/Debug/.
12+
# Runs `cmake` for Bistro, directing output to cmake/Release/ or cmake/Debug/.
1313
#
1414
# If Bistro's dependencies are installed in a non-default prefix, it will
1515
# need some help finding them:
@@ -87,10 +87,10 @@ fetch_gtest
8787

8888
# Hacky way to build Thrift until we have a proper CMake module to do it.
8989
cd "$build_dir/.."
90-
update_thrift if if/*.thrift build/fbinclude/common/fb303/if/fb303.thrift
91-
./build/targets_to_cmake_lists.py .
90+
update_thrift if if/*.thrift cmake/fbinclude/common/fb303/if/fb303.thrift
91+
./cmake/targets_to_cmake_lists.py .
9292

93-
# Put our artifacts in build/{Debug,Release}
93+
# Put our artifacts in cmake/{Debug,Release}
9494
make_dir="$build_dir/$build_type"
9595
mkdir -p "$make_dir"
9696
cd "$make_dir"

bistro/build/setup.cmake bistro/cmake/setup.cmake

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
# of patent rights can be found in the PATENTS file in the same directory.
88
#
99

10-
# Do NOT use this -- run build/run-cmake.sh instead & read its docblock.
10+
# Do NOT use this -- run cmake/run-cmake.sh instead & read its docblock.
1111

1212
include_directories(
1313
# Our includes start with "bistro/bistro/"
1414
"${PROJECT_SOURCE_DIR}/../.."
1515
# A hack to include a stub for some FB-specific includes under "common/".
16-
"${PROJECT_SOURCE_DIR}/build/fbinclude"
16+
"${PROJECT_SOURCE_DIR}/cmake/fbinclude"
1717
"${CMAKE_INSTALL_PREFIX}/include"
1818
)
1919

@@ -59,7 +59,7 @@ macro(bistro_link_libraries name)
5959
)
6060
endmacro(bistro_link_libraries)
6161

62-
add_subdirectory(build/deps/gtest-1.7.0)
62+
add_subdirectory(cmake/deps/gtest-1.7.0)
6363
enable_testing()
6464
include_directories("${gtest_SOURCE_DIR}/include" "${gtest_SOURCE_DIR}")
6565

bistro/build/targets_to_cmake_lists.py bistro/cmake/targets_to_cmake_lists.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def cpp_library(name, **kwargs):
111111
_validate_keys(kwargs, 'cpp_library', {
112112
'srcs', # Handled above
113113
'deps', # Handled above
114-
'external_deps', # Handled in build/CMakeLists.txt
114+
'external_deps', # Handled in cmake/setup.cmake
115115
'headers', # CMake handles headers automatically
116116
})
117117

@@ -195,5 +195,5 @@ def make_cmake_dir_recursive(root_path):
195195

196196
make_cmake_dir_recursive(sys.argv[1]).write_cmake_lists(
197197
setup_lines='cmake_minimum_required(VERSION 2.8)\n'
198-
'include("build/setup.cmake")\n',
198+
'include("cmake/setup.cmake")\n',
199199
)

bistro/scripts/run_local_test.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ if [[ -x "$BISTRO_BINARY" ]] ; then
3030
else
3131
PHABRICATOR_DOMAIN="[YOUR PHABRICATOR DOMAIN]"
3232
# Try the release binary, then default to the debug binary
33-
BISTRO_BINARY="$D/../build/Release/bistro/bistro/server/bistro_scheduler"
33+
BISTRO_BINARY="$D/../cmake/Release/bistro/bistro/server/bistro_scheduler"
3434
if [[ ! -x "$BISTRO_BINARY" ]] ; then
35-
BISTRO_BINARY="$D/../build/Debug/bistro/bistro/server/bistro_scheduler"
35+
BISTRO_BINARY="$D/../cmake/Debug/bistro/bistro/server/bistro_scheduler"
3636
fi
3737
fi
3838

File renamed without changes.

build/fbcode_builder/docker_builder.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
import os
1919
import tempfile
2020

21-
from .fbcode_builder import FBCodeBuilder
22-
from .shell_quoting import raw_shell, shell_comment, shell_join, ShellQuoted
23-
from .utils import recursively_flatten_list, run_command
21+
from fbcode_builder import FBCodeBuilder
22+
from shell_quoting import (
23+
raw_shell, shell_comment, shell_join, ShellQuoted
24+
)
25+
from utils import recursively_flatten_list, run_command
2426

2527

2628
class DockerFBCodeBuilder(FBCodeBuilder):

build/fbcode_builder/fbcode_builder.py

+2-13
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,14 @@
3737
shell script that runs outside of a container. Or maybe even
3838
synchronously executes the shell commands, `make`-style.
3939
40-
- Support for dependencies. This was not built since FB projects'
41-
dependency chains are simple, so a linear sequence of steps was enough.
42-
4340
- A "Makefile" generator. That might make iterating on builds even quicker
4441
than what you can currently get with Docker build caching.
4542
4643
'''
4744

4845
import os
4946

50-
from .shell_quoting import path_join, shell_join, ShellQuoted
47+
from shell_quoting import path_join, shell_join, ShellQuoted
5148

5249

5350
class FBCodeBuilder(object):
@@ -99,7 +96,7 @@ def render(self, steps):
9996
raise RuntimeError(
10097
'Unused options: {0} -- please check if you made a typo '
10198
'in any of them. Those that are truly not useful should '
102-
'be removed so that this typo detection can be useful.'
99+
'be not be set so that this typo detection can be useful.'
103100
.format(unused_options)
104101
)
105102
return res
@@ -260,14 +257,6 @@ def make_and_install(self, make_vars=None):
260257
)),
261258
]
262259

263-
def zstd_make_and_install(self):
264-
'Zstd is a special snowflake, so make it easy to built it correctly'
265-
return self.step('Build and install zstd', [
266-
self.make_and_install(make_vars={
267-
'PREFIX': self.option('prefix'),
268-
})
269-
])
270-
271260
def autoconf_install(self, name):
272261
return self.step('Build and install {0}'.format(name), [
273262
self.run(ShellQuoted('autoreconf -ivf')),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python
2+
from __future__ import absolute_import
3+
from __future__ import division
4+
from __future__ import print_function
5+
from __future__ import unicode_literals
6+
'Demo config, so that `make_docker_context.py --help` works in this directory.'
7+
8+
config = {
9+
'fbcode_builder_spec': lambda _builder: {
10+
'depends_on': [],
11+
'steps': [],
12+
},
13+
'github_project': 'demo/project',
14+
}

0 commit comments

Comments
 (0)