Commit Graph

36 Commits

Author SHA1 Message Date
Wez Furlong
bd2688aae5 getdeps: allow satisfying deps from system packages
Summary:
From the outset, we wanted to be sure that getdeps was able
to source and build the dependencies so that we knew that we'd have
a repeatable build.  This came at the cost of build times: having
to build boost on each CI run is a bit of a chore.

This commit adds three new elements to the manifest files:

* `rpms` - a list of RPM names that are all required to be present
  in order to consider the dependency satisfied
* `debs` - like `rpms` above, but scoped to debian package names
* `preinstalled.env` - a list of environment variables that if they
  are all set and non-empty will satisfy the dependency.

A new `--allow-system-packages` option to getdeps enables the new
logic that looks for system packages; it is off by default, but
enabled in the generated GitHub Actions workflows.

A new `install-system-deps` subcommand is provided that will attempt
to install the system packages needed to satisfy the build.  This
typically needs to be run via sudo and is thus broken out separately
from the main getdeps build flow.

I made a pass over the manifest files and added package names that
satisfy the build on ubuntu-18 and fedora-31.

shri-khare: I renamed the `Python3.7.6` manifest to just `python` as
part of this change; the version of python that it pulls in through
the normal build is the same and I believe that an equal or newer
version of python3 is available in the GH actions builder.

The `preinstalled.env` is used only by the boost manifest: it references
the name of an environment variable that is set by the github
windows hosts and that points to a pre-built and pre-installed
copy of boost.  Since there is no package manager that we can
easily query for this sort of thing, probing from the environment
seems like a reasonable and fast way to check for this.  We
may need to evolve this over time to become more feature rich,
but this seems like a good starting point.

This commit has the potential to save 20 minutes of build time
from each public CI build just due to the boost dependency alone!

Refs: https://github.com/facebook/watchman/pull/797

Reviewed By: yfeldblum

Differential Revision: D20740410

fbshipit-source-id: 6c38019449c54465127656c3d18a6ff1f30adaea
2020-04-29 11:17:51 -07:00
Wez Furlong
4da863fe7d getdeps: allow setting per-project install prefix for DESTDIR installs
Summary:
We have a global `--install-prefix` argument that can be used to set
the prefix for all projects, but that is only suitable if you are running with
sufficient privileges to install each of the deps to that location during the
build.  Cmake dependency resolution won't work from the build directory in that
situation; it can only see the final installed location and it will error out
if those files are not present, or link against the currently installed version
instead of the version we just built; not great!

This commit adds a project specific `--project-install-prefix` that can be used
on just the leaf project in a set of deps.  That sidesteps the dependency
concern because only the last stage is built in that mode.  This option
can technically be applied to an arbitrary set of projects, but in light
of the above, in practice it only makes sense to use it for the final
cmake project.  Only the CMakeBuilder respects this option.

In the watchman repo, this commit adjusts the autogen.sh script to allow
specifying the installation prefix; it defaults to `/usr/local` as you
might expect.

refs: https://github.com/facebook/watchman/issues/760

Reviewed By: yfeldblum

Differential Revision: D20674439

fbshipit-source-id: 52799dbd47f3c295e2d6469ee2b74cedeaa20138
2020-03-31 12:10:45 -07:00
Wez Furlong
37d232db3c getdeps: embrace python3 a bit more
Summary:
Ensure that we are referencing python3 in the paths
that we generate for the github actions workflows, and remove
some shebangs that influence how our internal linters process
the python code.

Reviewed By: fanzeyi

Differential Revision: D20659747

fbshipit-source-id: 6f300f8e91edf7701bb27babc7b1418958cf0a10
2020-03-26 05:46:17 -07:00
Lukasz Piatkowski
07dd370f28 mononoke: add README.md and the missing pieces for supporting cargo (#13)
Summary:
Take the README.md from
7ead0e29e4/README.md
and apply it on Eden repo.

Re-add the Cargo.toml file that declares Cargo workspace.

Re-add fbcode_builder/getdeps manifest for Mononoke
Pull Request resolved: https://github.com/facebookexperimental/eden/pull/13

Test Plan:
./build/fbcode_builder/getdeps.py build mononoke
  ./build/fbcode_builder/getdeps.py test mononoke

Reviewed By: ahornby

Differential Revision: D19833059

Pulled By: lukaspiatkowski

fbshipit-source-id: fb37e13306c0b9969a7c4e52b05e1a66a577022f
2020-02-13 00:12:36 -08:00
Lukas Piatkowski
9e71027a0f opensource/fbcode_builder/getdeps.py: support cargo dependencies in cargo builds
Summary:
With this change the getdeps' CargoBuilder will support depencies between cargo builds.

The way how it works is documented in the code and required few assumptions about how a cargo project has to be defined in order to support this.

This change also adds the "mononoke" manifest and few Cargo.toml files to the mononoke project to prove that this new feature works.

Reviewed By: farnz

Differential Revision: D19468912

fbshipit-source-id: f299733cbbc2ec7bca399c898ec8d710334d0fa9
2020-01-20 23:01:17 -08:00
Shrikrishna Khare
dbb417440b fbcode_builder: getdeps: fboss: rename OpenBCM to OpenNSA
Summary:
Broadcom provides this library and they decided to rename it from OpenBCM to
OpenNSA. Thus, rename corresponding fbcode_builder code.

Reviewed By: wez

Differential Revision: D19396687

fbshipit-source-id: 8233dbf4de9342b5a0e54ae275d6c73d43abe6d0
2020-01-14 22:11:48 -08:00
Shrikrishna Khare
b4394c413d fbcode_builder: getdeps: fboss: OpenBCM depends on git-lfs
Summary:
OpenBCM libraries are stored with git LFS. As a result, fetcher fetches LFS pointers and not the contents. Use git-lfs to pull the real contents before copying to install dir using NoopBuilder.
In future, if more builders require git-lfs, we would consider installing
git-lfs as part of the sandcastle infra as against repeating similar
 logic for each builder that requires git-lfs.

Reviewed By: wez

Differential Revision: D18759806

fbshipit-source-id: f988a0460107bc0685e7aba107daba9ed88f71e7
2019-12-03 11:43:41 -08:00
Lukas Piatkowski
a8ebf55e26 fbcode_builder: add cargo builder for Rust projects
Summary: The cargo builder will be used to verify if an opensource Rust project passes Cargo build, test and (optionally) documentation build.

Reviewed By: markbt

Differential Revision: D18636934

fbshipit-source-id: e982e6a017eb32913e2994e7457c8add2e9d6b95
2019-11-28 04:59:38 -08:00
Wez Furlong
39cb261ced watchman: pass version info down to watchman build via environment
Summary:
This diff allows passing a watchman version number override
via the environment as well as via the cmake `WATCHMAN_VERSION_OVERRIDE`
option.

To help invalidate the build I've added a new section to the manifest
files that allows listing out additional env vars that the project
hashes should be sensitive to.  The effect of this is that we'll
re-run the cmake configure step if the listed env vars are changed.

Reviewed By: Ben0mega

Differential Revision: D17865896

fbshipit-source-id: 8ea5572b0b9b7af95ec5c310e494cb17a139ced4
2019-10-17 02:19:41 -07:00
Andres Suarez
4f5c1eb215 Relicense getdeps from BSD to MIT
Summary: See https://fb.workplace.com/groups/osssupport/permalink/2846876118694318/

Reviewed By: wez

Differential Revision: D17750243

fbshipit-source-id: 9e149df1f8e09203820f50d0fcac4a5cecf52e33
2019-10-10 13:20:05 -07:00
Zeyi (Rice) Fan
1cc2ea587a getdeps: throw exceptions when found duplicate manifests and name mismatches
Summary:
Throws an exception when:

* The name specified in the manifest mismatches the filename
* Duplicated manifest -- with the sub-directory support it is now able to have multiple manifest files with the same name

Reviewed By: chadaustin

Differential Revision: D17438460

fbshipit-source-id: ac7ad0b701beb15f0e91bb05cd1ec8fe378ad5b6
2019-09-19 15:24:26 -07:00
Adam Simpkins
1a5d1a6879 add a builder that can re-package python wheel files
Summary:
Add a new builder that can extract Python wheel files, and re-package them
for consumption by our add_fb_python_library() and add_fb_python_executable()
CMake functions.  This is useful for dependencies on packages from PyPI.

At the moment this code only handles architecture-independent pure-Python
packages.  It shouldn't be too hard to extend this to handle more complex
wheels, but for now I only need to use it for some pure-Python wheels and so I
haven't tested with more complex wheel files.

This also includes two new manifests for python-six and python-toml that take
use this new builder.

Reviewed By: wez

Differential Revision: D17401216

fbshipit-source-id: d6f74565887c3f004e1c06503dc9ec81599dd697
2019-09-19 11:33:35 -07:00
Wez Furlong
6fb1bb0764 getdeps: build all available boost libraries
Summary:
This should make it easier to eg: enable fbzmq on macos at a later
time, and also makes things more explicit about what is being built, and
importantly, by listing these in the manifest ensures that we have a
hash change if we change this list; we wouldn't trigger such a change
if the list were encoded solely in builder.py

Reviewed By: chadaustin

Differential Revision: D17133149

fbshipit-source-id: caf0dd45e262188eeefafe0868ef95ad257a4950
2019-09-06 14:34:19 -07:00
Adam Simpkins
fe4265172e fbcode_builder: fix the error message if we cannot find a project fetcher
Summary:
Fix printing the manifest context in the error message if we cannot find a
project fetcher.  Previously the context in the message would be printed as
something like `<getdeps.manifest.ManifestContext object at 0x7fcce987e610>`,
now it shows instead as something like
`{distro=ubuntu, distro_vers=18.04, fb=off, os=linux, test=off}`

Reviewed By: chadaustin

Differential Revision: D17089208

fbshipit-source-id: c16549b61030d813b7b5ff9f65966436dc1e1898
2019-08-28 13:12:59 -07:00
Adam Simpkins
3c5295f83b add a ManifestContext and ContextGenerator class
Summary:
Add a ContextGenerator class so that we actually use the correct per-project
context when loading projects and computing dependencies.

Previously commands like `build` and `test` would change the contexts for each
project as they iterated through and performed the build.  However, they did
not do this when first loading the projects.  This could cause them to use
different context values when loading dependencies than when performing the
build.  For instance, this could cause issues if a project depends on
`googletest` only when testing is enabled, as the code previously did not set
the "test" parameter when evaluating dependencies.

Reviewed By: pkaush

Differential Revision: D16477396

fbshipit-source-id: c1e055f07de1cb960861d19594e3bda20a2ccd87
2019-07-31 20:56:52 -07:00
Adam Simpkins
2a25e221d1 fail if unknown variables are used in a manifest
Summary:
Check that all variable names are valid when loading manifest files.
This ensures that getdeps.py will error out if someone makes a typo in a
variable name, rather than treating it as never equal to anything.

Reviewed By: pkaush

Differential Revision: D16477397

fbshipit-source-id: 030e0642ff4a08db8eb74a0a0223e03d53e4880f
2019-07-31 20:56:51 -07:00
Matt Glazar
cd61479fc5 Fix tests with Python 2.7
Summary:
Some people want to use getdeps with Python 2.7. This looks easy to do, so take a step toward Python 2.7 support by fixing getdeps' tests when run with Python 2.7.

For Python 3, this diff should not change behavior.

This diff should address https://github.com/facebook/bistro/issues/35.

Reviewed By: snarkmaster

Differential Revision: D16435667

fbshipit-source-id: f5c262b12995b609263341c4de26dac7f9b12b70
2019-07-24 11:44:11 -07:00
Shrikrishna Khare
7ddefe5e25 fbcode_builder: getdeps: fboss: add iproute2 fetcher
Summary:
This is towards getting open source FBOSS to build using fbcode_builder.
iproute2 is one of the dependencies for FBOSS. This patch adds a manifest file
to build the specific version of iproute2 needed for FBOSS.

Additionally, the default git clone depth of 100 is insufficient for the
version of iproute2 FBOSS depends on. Thus, this patch extends the git SCHEMA
to add optional argument depth. The default remains 100.

The usual /configure --prefix does not work for iproute2. Thus, we need to add
a custom builder that:
  - copies sources to build directory, builds, and
  - installs to installed directory using DEST_DIR.
  - it must also explicitly copy include from build dir to install dir

Reviewed By: wez

Differential Revision: D15588809

fbshipit-source-id: ac5eab24134e078d88b85b4be433c78b05ef8ce5
2019-06-05 15:35:52 -07:00
Wez Furlong
0ce8361867 fbcode_builder: getdeps: add sqlite3 builder
Summary:
Previously, we were using autoconf to build sqlite,
but that isn't available on Windows.  Instead, here's a builder
that generates a little cmake configuration for building and
installing sqlite.

Using cmake for this means that we can test the same builder
on all platforms that need to pull in sqlite.

Reviewed By: simpkins

Differential Revision: D15179387

fbshipit-source-id: fccf969182565982bd5be55545a2d2625aa99124
2019-05-03 15:59:45 -07:00
Wez Furlong
ce422057b1 fbcode_builder: getdeps: add LFS caching for ArchiveFetcher
Summary:
When running in FB infra, prefer to download from our local LFS
server rather than going out to the internet.

Fall back to a normal internet download if the LFS get fails for some reason.

Upload to LFS after successfully verifying the hash for the downloaded archive.

Add a subcommand that performs a fetch for all possible platforms so that it
is easier to ensure that the lfs-pointers file is up to date.

Reviewed By: simpkins

Differential Revision: D14978660

fbshipit-source-id: 240fc32fc7003d1e06c88b80d85054dae36e2f31
2019-05-03 15:59:45 -07:00
Wez Furlong
27776a83b1 fbcode_builder: getdeps: beef up hash computation
Summary:
previously, a relatively lame hash was computed to use
for the build directory based on some hash of the source directory.
That was good enough to get things off the ground, but in the
interest of being able to cache the build outputs and safely
invalidate them we need a slightly more rigorous implementation.

This diff computes a hash based on the manifest contents and
relevant environmental factors.

The hash is used to name the build directory which will ultimately
be cached eg: using the travis/appveyor cache directory configuration
and some other means for the FB internal CI.

The hash needs to be sufficient that we change the hash when
the manifests change.  We can tolerate a false positive change
in hash (it just means that a build will take longer), but
cannot tolerate a false negative (which would result in an
incorrect build).

Reviewed By: simpkins

Differential Revision: D14710332

fbshipit-source-id: ebc2e74eafc6f3305d4412a82195bc9fb9dfa615
2019-05-03 15:59:43 -07:00
Wez Furlong
e00b67a09c fbcode_builder: getdeps: add flag to use the real shipit
Summary:
This fixes a TODO; in our CI environment we want to use the
real shipit, so we'll use this flag to make that happen.

Reviewed By: simpkins

Differential Revision: D14695576

fbshipit-source-id: 64ee72c210e2472d295dcbd39c86549273b68452
2019-05-03 15:59:42 -07:00
Wez Furlong
99e2691544 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
2019-05-03 15:59:42 -07:00
Wez Furlong
5f8f6bfe0f fbcode_builder: getdeps: add Boost builder
Summary:
the boost builder knows how to perform the non-standard
configure and build for boost.

Ideally we'd just build this statically and be happy but there are
some nuances I've observed while building on different platforms:

* One of our projects (thrift or wangle) explicitly requests static
  boost linkage for reasons unspecified
* on darwin the install_name is broken when building dynamic libs

For the sake of expediency in getting getdeps up and running, the
solution for the moment is to build static on posix systems and
build both static and shared on windows systems.

Reviewed By: simpkins

Differential Revision: D14691009

fbshipit-source-id: 634770a6f53c3ada42d1877cc6c3dacc6eed7d18
2019-05-03 15:59:41 -07:00
Wez Furlong
b2bd703660 fbcode_builder: getdeps: add OpenSSL builder
Summary:
the openssl builder knows how to perform the non-standard
configuration and build steps to build openssl.

On Linux systems the manifests for our projects don't mention
openssl, causing them to pick up the system openssl.

On Mac, apple don't ship openssl headers so we need to build our own.
On Windows there is no standard openssl installation so we also need
to build our own.

As a result, this builder only works on windows and mac.

Reviewed By: simpkins

Differential Revision: D14691010

fbshipit-source-id: 9f8979f9eaeb5209c290cf4f43c97c0cb43d13a2
2019-05-03 15:59:41 -07:00
Wez Furlong
fc9da12b9c 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
2019-05-03 15:59:41 -07:00
Wez Furlong
1a5ebc8999 fbcode_builder: getdeps: add CMakeBuilder
Summary:
the cmake builder knows how to use cmake to configure a build
for (preferably) and out-of-src build.  The `cmake.defines` section of
the manifest is used to pass `-Dkey=value` options to the cmake configure
command line.

We prefer to use `ninja` to execute the build so that we can use more
cores than 1 on Windows and just for consistency across platforms
with mac and linux.

Reviewed By: simpkins

Differential Revision: D14690998

fbshipit-source-id: 8102e8b4a47da515ca001772788ed0e5f2645ad7
2019-05-03 15:59:41 -07:00
Wez Furlong
2e76bd33f8 fbcode_builder: getdeps: add AutoconfBuilder
Summary:
the autoconf builder performs an out-of-source build using
the autoconf suite to configure the build rules.

The `autoconf.args` section from the manifest is passed to the `./configure`
command line.

If an `autogen.sh` script is present then it will be used to regenerate
a missing `configure` script, otherwise we'll try `autoreconf`.

Reviewed By: simpkins

Differential Revision: D14691002

fbshipit-source-id: ab8cceafb833dab513d5a50c65f4c895a4f40047
2019-05-03 15:59:41 -07:00
Wez Furlong
3e89ba51f2 fbcode_builder: getdeps: add MakeBuilder
Summary:
the make builder runs `make` in the source directory.
The `make.args` section from the manifest is passed as arguments
to the `make` invocation.

Reviewed By: simpkins

Differential Revision: D14690996

fbshipit-source-id: 180d657ad05f0c0266a8c1d30979d8d1473958c9
2019-05-03 15:59:40 -07:00
Wez Furlong
9b87d8495d fbcode_builder: getdeps: add BuilderBase class
Summary:
a builder knows how to build and install a project.

Later diffs add concrete implementations of the BuilderBase

Reviewed By: simpkins

Differential Revision: D14691018

fbshipit-source-id: 89b14614b5160353cd7e59f27037afcdf6229eb7
2019-05-03 15:59:40 -07:00
Wez Furlong
749d6a25ca fbcode_builder: getdeps: add SimpleShipitTransformer fetcher
Summary:
This fetcher knows how to transform a 1st party project
from fbsource into approximately the same shape as ShipIt produces
for the github repo mirrors.  It does this by reading shipit
mapping information from the manifest file for the project.

Since this fetcher uses data in the manifest and is implemented
directly in the getdeps codebase, it is suitable for iterating
on the opensource builds directly out of fbsource on both devservers
and laptops inside FB.

Reviewed By: simpkins

Differential Revision: D14691012

fbshipit-source-id: 05f68a7be64a2e465937b24b8825d25d3348ed13
2019-05-03 15:59:40 -07:00
Wez Furlong
1487071305 fbcode_builder: getdeps: add ShipitTransformer fetcher
Summary:
This fetcher knows how to take a 1st party FB project
from fbsource and transform it to the same shape as our github
repos using ShipIt.  The transformation creates a transformed
mirror of the code in scratch space (rather than mutating fbsource
directly).

This can only be used in environments where shipit is available.
A later diff implements an alternative that works in more environments.

Reviewed By: simpkins

Differential Revision: D14691013

fbshipit-source-id: 539e307755c9fc0a098a235868ab622652061494
2019-05-03 15:59:39 -07:00
Wez Furlong
fbacd6695b fbcode_builder: getdeps: add ArchiveFetcher
Summary:
this fetcher knows how to download a URL that references
an archive and extract the sources from it.  Compressed tarballs
and zipfiles are supported.

Reviewed By: simpkins

Differential Revision: D14690994

fbshipit-source-id: ffbbd1d9479b0d5aa3e5cd13fe11a560e9d01c2a
2019-05-03 15:59:39 -07:00
Wez Furlong
56639c769f fbcode_builder: getdeps: add GitFetcher
Summary: this fetcher knows how to check out sources via git.

Reviewed By: simpkins

Differential Revision: D14691000

fbshipit-source-id: 60f1ffbfed7b32a019aef6aa70ae0903f2782451
2019-05-03 15:59:39 -07:00
Wez Furlong
681e3b5278 fbcode_builder: getdeps: define the Fetcher interface
Summary:
Fetchers are used to fetch a source directory from a
source defined in a manifest file.

More details can be found in comments on the various methods.

The Manifest class offers a create_fetcher method for constructing
an appropriate fetcher.  This is just a stub in this commit, but
will expand over the course of the next few diffs as concrete
fetcher instances are added.

Reviewed By: simpkins

Differential Revision: D14691001

fbshipit-source-id: 8c9038eacae3345e9403d5d1304bf979a9ee1555
2019-05-03 15:59:39 -07:00
Wez Furlong
f272c533f3 fbcode_builder: add manifest file parser
Summary:
Adds a parser for manifest files that describe projects
that may be either 1st party or 3rd party.

A selection of manifest files appears in a later diff in this stack.

This diff provides the raw parser and a couple of low level helpers.
It also defines a mechanism for validating the schema to help catch
structural (rather than semantic) issues with manifest file contents.

Later diffs in the stack add helpers for accessing the data in
a higher level way.

Reviewed By: sinancepel

Differential Revision: D14691003

fbshipit-source-id: 7d2930a3359ede0f6e21fdc45686b083ab7a9ffa
2019-05-03 15:59:37 -07:00