-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fill in missing pieces from macro layers for folly
Summary: I found these by repeatedly running `dotslash-oss ./buck2 targets ...` in the GitHub version of folly. (third-party changes are in the next diff, split for reviewability) These changes are just hacks to convert fbcode's macro layer to the buck2 prelude with the minimal work possible. bypass-github-export-checks Reviewed By: namanahuja Differential Revision: D57383968 fbshipit-source-id: 825335b6650a09bc6596f4bcc36fe6af7688a7e0
- Loading branch information
1 parent
ef02036
commit fc22004
Showing
19 changed files
with
1,011 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,57 @@ | ||
load("@prelude//toolchains:demo.bzl", "system_demo_toolchains") | ||
load("@prelude//toolchains:cxx.bzl", "system_cxx_toolchain") | ||
load("@prelude//toolchains:genrule.bzl", "system_genrule_toolchain") | ||
load("@prelude//toolchains:go.bzl", "system_go_toolchain") | ||
load("@prelude//toolchains:haskell.bzl", "system_haskell_toolchain") | ||
load("@prelude//toolchains:ocaml.bzl", "system_ocaml_toolchain") | ||
load("@prelude//toolchains:python.bzl", "system_python_bootstrap_toolchain", "system_python_toolchain") | ||
load("@prelude//toolchains:remote_test_execution.bzl", "remote_test_execution_toolchain") | ||
load("@prelude//toolchains:rust.bzl", "system_rust_toolchain") | ||
|
||
# All the default toolchains, suitable for a quick demo or early prototyping. | ||
# Most real projects should copy/paste the implementation to configure them. | ||
system_demo_toolchains() | ||
oncall("open_source") | ||
|
||
system_cxx_toolchain( | ||
name = "cxx", | ||
cxx_flags = ["-std=c++20"], | ||
visibility = ["PUBLIC"], | ||
) | ||
|
||
system_genrule_toolchain( | ||
name = "genrule", | ||
visibility = ["PUBLIC"], | ||
) | ||
|
||
system_go_toolchain( | ||
name = "go", | ||
visibility = ["PUBLIC"], | ||
) | ||
|
||
system_haskell_toolchain( | ||
name = "haskell", | ||
visibility = ["PUBLIC"], | ||
) | ||
|
||
system_ocaml_toolchain( | ||
name = "ocaml", | ||
visibility = ["PUBLIC"], | ||
) | ||
|
||
system_python_toolchain( | ||
name = "python", | ||
visibility = ["PUBLIC"], | ||
) | ||
|
||
system_python_bootstrap_toolchain( | ||
name = "python_bootstrap", | ||
visibility = ["PUBLIC"], | ||
) | ||
|
||
system_rust_toolchain( | ||
name = "rust", | ||
default_edition = "2021", | ||
visibility = ["PUBLIC"], | ||
) | ||
|
||
remote_test_execution_toolchain( | ||
name = "remote_test_execution", | ||
visibility = ["PUBLIC"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under both the MIT license found in the | ||
# LICENSE-MIT file in the root directory of this source tree and the Apache | ||
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory | ||
# of this source tree. | ||
|
||
def _builder(**_): | ||
pass | ||
|
||
def _buck_opts(**_): | ||
pass | ||
|
||
fbpkg = struct( | ||
builder = _builder, | ||
buck_opts = _buck_opts, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
load("@prelude//utils:buckconfig.bzl", "read_choice") | ||
|
||
AutoHeaders = struct( | ||
NONE = "none", | ||
# Uses a recursive glob to resolve all transitive headers under the given | ||
# directory. | ||
RECURSIVE_GLOB = "recursive_glob", | ||
# Infer headers from sources of the rule. | ||
SOURCES = "sources", | ||
) | ||
|
||
_VALUES = [ | ||
AutoHeaders.NONE, | ||
AutoHeaders.RECURSIVE_GLOB, | ||
AutoHeaders.SOURCES, | ||
] | ||
|
||
def get_auto_headers(auto_headers): | ||
""" | ||
Returns the level of auto-headers to apply to a rule. | ||
Args: | ||
auto_headers: One of the values in `AutoHeaders` | ||
Returns: | ||
The value passed in as auto_headers, or the value from configuration if | ||
`auto_headers` is None | ||
""" | ||
if auto_headers != None: | ||
if auto_headers not in _VALUES: | ||
fail("unexpected `auto_headers` value: {!r}".format(auto_headers)) | ||
return auto_headers | ||
return read_choice("cxx", "auto_headers", _VALUES, AutoHeaders.SOURCES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under both the MIT license found in the | ||
# LICENSE-MIT file in the root directory of this source tree and the Apache | ||
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory | ||
# of this source tree. | ||
|
||
def _get_build_mode(): | ||
return "" | ||
|
||
config = struct( | ||
get_build_mode = _get_build_mode, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under both the MIT license found in the | ||
# LICENSE-MIT file in the root directory of this source tree and the Apache | ||
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory | ||
# of this source tree. | ||
|
||
def cpp_benchmark(**_): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under both the MIT license found in the | ||
# LICENSE-MIT file in the root directory of this source tree and the Apache | ||
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory | ||
# of this source tree. | ||
|
||
load("//:shims.bzl", _cpp_binary = "cpp_binary") | ||
|
||
cpp_binary = _cpp_binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under both the MIT license found in the | ||
# LICENSE-MIT file in the root directory of this source tree and the Apache | ||
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory | ||
# of this source tree. | ||
|
||
load("//:shims.bzl", _cpp_unittest = "cpp_unittest") | ||
|
||
cpp_unittest = _cpp_unittest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under both the MIT license found in the | ||
# LICENSE-MIT file in the root directory of this source tree and the Apache | ||
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory | ||
# of this source tree. | ||
|
||
def custom_rule(**_): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under both the MIT license found in the | ||
# LICENSE-MIT file in the root directory of this source tree and the Apache | ||
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory | ||
# of this source tree. | ||
|
||
load("//build_defs:python_library.bzl", "python_library") | ||
|
||
def cython_library(name, visibility = ["PUBLIC"], **_): | ||
python_library(name = name, visibility = visibility) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under both the MIT license found in the | ||
# LICENSE-MIT file in the root directory of this source tree and the Apache | ||
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory | ||
# of this source tree. | ||
|
||
load("//:shims.bzl", _prebuilt_cpp_library = "prebuilt_cpp_library") | ||
|
||
prebuilt_cpp_library = _prebuilt_cpp_library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under both the MIT license found in the | ||
# LICENSE-MIT file in the root directory of this source tree and the Apache | ||
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory | ||
# of this source tree. | ||
|
||
def python_library(srcs = [], visibility = ["PUBLIC"], **kwargs): | ||
_unused = srcs # @unused | ||
|
||
# @lint-ignore BUCKLINT: avoid "Direct usage of native rules is not allowed." | ||
native.python_library(visibility = visibility, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under both the MIT license found in the | ||
# LICENSE-MIT file in the root directory of this source tree and the Apache | ||
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory | ||
# of this source tree. | ||
|
||
def python_unittest(srcs = [], **kwargs): | ||
_unused = srcs # @unused | ||
|
||
# @lint-ignore BUCKLINT: avoid "Direct usage of native rules is not allowed." | ||
native.python_test(**kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2017 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Skylib module containing functions that operate on dictionaries.""" | ||
|
||
def _add(*dictionaries): | ||
"""Returns a new `dict` that has all the entries of the given dictionaries. | ||
If the same key is present in more than one of the input dictionaries, the | ||
last of them in the argument list overrides any earlier ones. | ||
This function is designed to take zero or one arguments as well as multiple | ||
dictionaries, so that it follows arithmetic identities and callers can avoid | ||
special cases for their inputs: the sum of zero dictionaries is the empty | ||
dictionary, and the sum of a single dictionary is a copy of itself. | ||
Args: | ||
*dictionaries: Zero or more dictionaries to be added. | ||
Returns: | ||
A new `dict` that has all the entries of the given dictionaries. | ||
""" | ||
result = {} | ||
for d in dictionaries: | ||
result.update(d) | ||
return result | ||
|
||
dicts = struct( | ||
add = _add, | ||
) |
Oops, something went wrong.