Commit Graph

27 Commits

Author SHA1 Message Date
Adam Simpkins
d2aeffb44d getdeps: update FBPythonBinary.cmake to generate executable files on Windows
Summary:
On Windows, compile a small C executable to prepend to the zip file, to allow
the resulting executable files to be run directly on Windows, without needing
to explicitly invoke the Python interpreter to run the output file.

Reviewed By: wez

Differential Revision: D17733616

fbshipit-source-id: 989a93851412d0bbe1e7857aa9111db082f67a4c
2019-11-18 18:41:00 -08:00
wez@fb.com
5293f4631b getdeps: add an add_fb_python_unittest() function
Summary:
Add a function for defining Python unit tests.  This creates the test
executable, and also emits logic to perform test discovery for ctest.

Reviewed By: simpkins

Differential Revision: D17610034

fbshipit-source-id: cdf15b0b04acc1d3e906a1e2a95eb327951176ba
2019-09-30 10:46:18 -07:00
wez@fb.com
76de96dacf getdeps: export a property that contains the path to the output executable
Summary:
Export a property that indicates the path to the test executable.  This is
useful for callers that want to install the binary or run it from other CMake
rules.

Reviewed By: simpkins

Differential Revision: D17647146

fbshipit-source-id: b32e2694e44a07d7c234e53a7a5c8443cb144487
2019-09-30 10:46:18 -07:00
Adam Simpkins
eaf1da018f update make_fbpy_archive.py to replace the output on Windows
Summary:
Update the code to use `os.replace()` rather than `os.rename()` so that it
won't fail on Windows if the destination path already exists.

Reviewed By: chadaustin

Differential Revision: D17462716

fbshipit-source-id: cbc06319ccb2d73868f80ab1874890ebec5a621b
2019-09-18 20:05:01 -07:00
Adam Simpkins
e286e4c888 fix the thrift CMake rules to add dependencies on the thrift compiler
Summary:
Update the thrift C++ and Python CMake rules to indicate that the output also
depends on the thrift compiler itself.

Previously the C++ rule indicated that the output depended on the thrift
template files, which caught most cases when the thrift compiler was updated,
but wasn't fully correct.  The thrift templates were also removed and baked
into the thrift compiler binary in D16356056.

Reviewed By: yfeldblum, chadaustin

Differential Revision: D17401217

fbshipit-source-id: ae5cde7a7e5e07a74406a1b6f4469124187bc12f
2019-09-16 21:10:01 -07:00
Chad Austin
23363ac68e fbcode_builder: add a license header to FBBuildOptions.cmake
Summary:
Add a license header to satisfy the open source linter. Use the same
header the other .cmake files have.

Reviewed By: mhlakhani

Differential Revision: D17404782

fbshipit-source-id: 66679d72c9e680f8bb8b27869e981a046b3520cf
2019-09-16 15:41:57 -07:00
Hasnain Lakhani
267fddccc8 Add CMake option to fetch deps statically
Summary:
We would like to build a version of proxygen that has minimal
dependencies on dynamic libraries.

Reviewed By: yfeldblum

Differential Revision: D17228181

fbshipit-source-id: cfd61afdfa978c49a536184f426502196241fb8a
2019-09-12 23:35:45 -07:00
Adam Simpkins
a7f2d733a4 fbcode_builder: update FBPythonBinary.cmake to work on Windows
Summary:
On Windows we have to explicitly invoke `make_fbpy_archive.py` with python.
Therefore use CMake's built-in `FindPythonInterp` module to find the python
executable and use that when invoking `make_fbpy_archive.py`

This is slightly complicated by the effort required to find python with older
versions of CMake.  We ideally still want to support versions of CMake back to
at least 3.8, which means we need to still support finding Python with the
older `FindPythonInterp.cmake` module

Reviewed By: wez

Differential Revision: D17128606

fbshipit-source-id: 3f4beff76848b8a362ebdf21198e7a8bf1b0537f
2019-09-11 11:34:17 -07:00
Yedidya Feldblum
3347cc797f Bake templates into the compiler binary
Summary: [Thrift] Bake templates into the compiler binary rather than having to package the templates with the compiler.

Reviewed By: stevegury, vitaut

Differential Revision: D16356056

fbshipit-source-id: b971dce7aada8dc2a26587fbf818e661acd0c555
2019-09-07 16:04:50 -07:00
Wez Furlong
3091c60805 getdeps: allow aliasing sources for add_fb_python_executable
Summary:
* Fix a minor issue with `add_fb_python_executable` where it would
  emit `--main` even if `MAIN_MODULE` had not been specified
* Introduce the ability to rename python sources in the manifest so
  that they have a different install path.
* Note that this changes the DEPENDS parameters to reference abs_sources;
  previously these were using relative paths to the sources pulled directly
  from the SOURCES arguments, but since those can now contain aliasing
  operations we need to pre-process the list.  I switched to abs_sources
  because that was already being maintained.  If for some reason the
  DEPENDS list needs to be relative paths, this will need to be adjusted.

Reviewed By: simpkins

Differential Revision: D17147417

fbshipit-source-id: d0825bfbdad6be658c078aaac6645e6926a1530f
2019-09-06 07:44:35 -07:00
John Strizich
19784e4aa7 add generated constant definitions to library
Summary: when trying to build openr with `getDeps.py` constant definitions where not available since they were not part of the generated thrift lib. this fixes it.

Reviewed By: chadaustin

Differential Revision: D16064417

fbshipit-source-id: ee2b3e061caf67235f4a873405cf6cd6fb663ef4
2019-09-03 16:39:48 -07:00
Adam Simpkins
2fd1d16ba9 fbcode_builder: add a FBThriftLibrary.cmake file
Summary:
This module provides a `add_fbthrift_library()` convenience function that can
be used to generate thrift libraries for multiple languages with a single
call.

Reviewed By: wez

Differential Revision: D16742275

fbshipit-source-id: c13120cf9e051629951282141eb22f3e085782f9
2019-08-29 22:05:44 -07:00
Adam Simpkins
ea8f788011 fbcode_builder: add an FBThriftPyLibrary.cmake module
Summary:
This module helps generate Python libraries from thrift files.
It is the Python equivalent of `FBThriftCppLibrary.cmake`

Reviewed By: wez

Differential Revision: D16742274

fbshipit-source-id: ef0dc7f24eb1c7375d2587ee6b71fd25bd6f35a7
2019-08-29 22:05:44 -07:00
Adam Simpkins
aa1aefa0f2 fbcode_builder: fix a minor bug in THRIFT_INCLUDE_DIR argument parsing
Summary:
Fix a minor bug in the argument parsing for `add_fbthrift_cpp_library()`:
only a single value should be supplied for the `THRIFT_INCLUDE_DIR` argument.
This parameter should not accept a list of arguments.

Reviewed By: strager

Differential Revision: D17125810

fbshipit-source-id: 31f354e4d6299d3626a94f3b4b5ff8c58bb0cf7b
2019-08-29 20:12:04 -07:00
Adam Simpkins
6b5f79c0d2 fbcode_builder: rename add_thrift_cpp2_library() to add_fbthrift_cpp_library()
Summary:
Rename the `ThriftCppLibrary.cmake` file to `FBThriftCppLibrary.cmake`, and
also rename `add_thrift_cpp2_library()` to `add_fbthrift_cpp_library()`.

Explicitly calling this `fbthrift` helps clearly distinguish that this is
intended for use with fbthrift (https://github.com/facebook/fbthrift/), as
opposed to Apache thrift.

Reviewed By: wez

Differential Revision: D16738440

fbshipit-source-id: 9b255e06b71c98ad74a34989f564a211958dcdd5
2019-08-29 16:45:12 -07:00
Adam Simpkins
ea23555faf fbcode_builder: fix install_fb_python_library() to work with old CMake versions
Summary:
Update install_fb_python_library() to work with CMake versions older than 3.7.

Previously the code used a generator expression in the directory argument
supplied to `install(DIRECTORY)`.  Support for generators in this parameter
was only added in CMake 3.5, but it was buggy and did not correctly handle
absolute paths until 3.7.

This updates the code to avoid using a generator expression.  This does
require that the corresponding `add_fb_python_library()` statement appear
before the `install_fb_python_library()` statement, but this seems like a
pretty reasonable restriction.

Reviewed By: chadaustin

Differential Revision: D17103597

fbshipit-source-id: 54d6af93a3f530373cfe3137db99436d8484f308
2019-08-28 21:00:27 -07:00
Adam Simpkins
3a3c1f8978 fbcode_builder: minor fixup to normalize python installation paths
Summary:
This just strips off a trailing '/' from the `INSTALL_DIR` property that we
set on python targets, to avoid having double-slashes in the paths that we use
during installation.  This shouldn't really have any material difference other
than cleaning up the paths that get printed during the installation phase.

Reviewed By: chadaustin

Differential Revision: D17089207

fbshipit-source-id: ab36bb76c19fa60fe037f7a5290ccfd6bdbf13b0
2019-08-28 13:12:58 -07:00
Adam Simpkins
83516bb83a use ThriftCppLibrary.cmake from fbcode_builder
Summary:
Update fboss to use `ThriftCppLibrary.cmake` directly from fbcode_builder
rather than maintaining its own copy of this file.

Reviewed By: chadaustin

Differential Revision: D17005421

fbshipit-source-id: a64df426118df6088b47f09410dad7b8b7e79a43
2019-08-28 11:58:02 -07:00
Adam Simpkins
2e09bbac2a fbcode_builder: cmake: propagate thrift include dependencies correctly
Summary:
Update `add_thrift_cpp2_library()` to pass in the correct `-I` flags when
invoking the thrift compiler so that it can find all of the other thrift files
that this library depends on.

D16062657 was a previous attempt to do this, but suffered from a few problems:
- It required all dependencies to be defined before
  `add_thrift_cpp2_library()` was called.  This requires users to carefully
  order their CMake files and subdirectory include ordering.
- It only handled one level of dependencies, and did not propagate include
  paths for deeper dependencies.
- It set the include path for dependencies to the source directory path where
  the dependency was originally built, rather than the directory where the
  thrift file for that dependency would be installed.

This change does require CMake 3.8+.  Previous versions of CMake do not
support using generator expressions to generate multiple arguments for a
custom command.

Reviewed By: strager

Differential Revision: D17005381

fbshipit-source-id: 31190beba94b4d1010445375a5e2791450230f7d
2019-08-28 11:58:01 -07:00
Adam Simpkins
6d9b66c90d fbcode_builder: support installing thrift generated header files
Summary:
Update add_thrift_cpp2_library() to add a PUBLIC_HEADER property to the
generated library target, so that the generated headers can be installed using
an `install()` call.  Also add a `HEADER_INSTALL_DIR` property which indicates
the directory they should be installed into.  A `INCLUDE_DIR` argument was
added to customize the include installation path, should anyone care to do so.

This also removes code that was previously incorrectly installing the
generated headers into the source tree.

Reviewed By: wez

Differential Revision: D16853404

fbshipit-source-id: 6f640b2bd347c99804e074fca0209dda37c8a9cf
2019-08-26 15:40:28 -07:00
Adam Simpkins
369050f9e6 fbcode_builder: ThriftCppLibrary: the output depends on the thrift templates
Summary:
Update ThriftCppLibrary.cmake to record that the output depends on the thrift
`cpp2` template files.  The `THRIFT_TEMPLATE_FILES` variable was defined in
D16062657 but doesn't appear to be used anywhere.  This uses it, and also
updates it to only match the C++ template files.

Reviewed By: wez

Differential Revision: D16738442

fbshipit-source-id: aa4097e9ec1d009ef1e3ee2efd03ffa19a82ed12
2019-08-24 19:47:09 -07:00
Adam Simpkins
3675eda973 fbcode_builder: minor style cleanup in ThriftCppLibrary.cmake
Summary:
Add explicit double quotes around arguments that are intended to be exactly a
single parameter.  Also line wrap to 80 characters.

Reviewed By: wez

Differential Revision: D16738443

fbshipit-source-id: b8c9b6d50da72b44e23eaf5effbc384b6cbbc1c0
2019-08-24 19:47:09 -07:00
Adam Simpkins
d3914e39c1 fbcode_builder: update ThriftCppLibrary to use fb_cmake_parse_args()
Summary:
Change ThriftCppLibrary to use `fb_cmake_parse_args()`

This code doesn't really care much about handling empty arguments, so we could
use the standard `cmake_parse_arguments()` function here instead of
`fb_cmake_parse_args()`.  However, it is slightly more convenient that
`fb_cmake_parse_args()` automatically errors out on unhandled arguments, so
that we don't have to check for this ourselves.

Reviewed By: wez

Differential Revision: D16738445

fbshipit-source-id: 67b9761f2ceaf7665bd336290bb44af32fec6f4a
2019-08-24 19:47:08 -07:00
Adam Simpkins
53f8ded39e fbcode_builder: CMake functions for building standalone python programs
Summary:
Add some CMake functions for building standalone executables from Python
source files.  This generates executables similar to PEX
(https://github.com/pantsbuild/pex).

In the future this could potentially be leveraged to directly build XAR files
(https://github.com/facebookincubator/xar).

The main advantages of these functions is that they allow easily defining
"libraries" of python files, and their dependencies, which can then be used
and packaged as part of multiple different standalone executables.

Reviewed By: wez

Differential Revision: D16722499

fbshipit-source-id: e1d829b911dc428e5438b5cf9cebf99b3fb6ce24
2019-08-19 11:08:34 -07:00
Chad Austin
a3acb9bb15 transitively carry thrift dependencies forward
Summary: eden.thrift includes fb303_core.thrift, so any cmake target that depends on eden.thrift should pull in fb303_core.thrift's include directories and libraries. Implement that machinery in CppThriftLibrary.cmake.

Reviewed By: wez

Differential Revision: D16062657

fbshipit-source-id: d5d962960e767a138a9b634a12aebccf72d6ef43
2019-07-17 11:29:24 -07:00
Chad Austin
4a3e7b5648 fbcode_builder: use build interface generator expression for thrift include directories
Summary:
Fix an error about source directories being included in the include
path in add_thrift_cpp2_library. I don't know why this was failing for
fb303 and not for other projects, but adding a generation expression
appears to fix the issue.

Reviewed By: strager

Differential Revision: D15725024

fbshipit-source-id: 6c02fed6c6703733cf9e0b130c0f90b70e3ea300
2019-07-16 12:25:35 -07:00
Adam Simpkins
bcad7419bf add fbcode_builder sources
Summary:
Initial commit to include the fbcode_builder sources in the
eden github repository.

fbshipit-source-id: 49098cecda04a7e9dd9dcc0b569fffc96f0f719b
2019-04-26 11:31:58 -07:00