Skip to content

Commit

Permalink
Add folly dependencies to shim (#79)
Browse files Browse the repository at this point in the history
Summary:
X-link: pytorch/executorch#3563

X-link: facebook/folly#2185

This needs more work, but this is a good start

X-link: facebook/folly#2185

Pulled By:
bigfootjon

Pull Request resolved: #79

bigfootjon

Differential Revision: D57006939
  • Loading branch information
bigfootjon authored and facebook-github-bot committed May 9, 2024
1 parent 5dc9099 commit 793bfd8
Show file tree
Hide file tree
Showing 42 changed files with 1,027 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ocaml-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ set -u

# Link 'third-party/ocaml/opam'.
if [ ! -L shim/third-party/ocaml/opam ]; then
(cd shim/third-party/ocaml && ln -s "$OPAM_SWITCH_PREFIX" opam)
(cd shim/third-party/ocaml && rm -rf opam && ln -s "$OPAM_SWITCH_PREFIX" opam)
else
echo "Link 'shim/third-party/ocaml/opam' exists. To overwrite it, first remove it and run $0 again"
fi
60 changes: 56 additions & 4 deletions shim/BUCK
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++17"],
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"],
)
17 changes: 17 additions & 0 deletions shim/antlir/fbpkg/fbpkg.bzl
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,
)
8 changes: 8 additions & 0 deletions shim/build_defs/auto_headers.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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",
)
13 changes: 13 additions & 0 deletions shim/build_defs/config.bzl
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,
)
9 changes: 9 additions & 0 deletions shim/build_defs/cpp_benchmark.bzl
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
10 changes: 10 additions & 0 deletions shim/build_defs/cpp_binary.bzl
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
10 changes: 10 additions & 0 deletions shim/build_defs/cpp_unittest.bzl
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
9 changes: 9 additions & 0 deletions shim/build_defs/custom_rule.bzl
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
11 changes: 11 additions & 0 deletions shim/build_defs/cython_library.bzl
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)
5 changes: 5 additions & 0 deletions shim/build_defs/export_files.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@
def export_file(visibility = ["PUBLIC"], **kwargs):
# @lint-ignore BUCKLINT: avoid "native is forbidden in fbcode"
native.export_file(visibility = visibility, **kwargs)

def export_files(files, visibility = ["PUBLIC"], **kwargs):
# @lint-ignore BUCKLINT: avoid "native is forbidden in fbcode"
for file in files:
native.export_file(name = file, visibility = visibility, **kwargs)
4 changes: 4 additions & 0 deletions shim/build_defs/native_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ def alias(actual, visibility = ["PUBLIC"], **kwargs):
if actual.startswith("//buck2/"):
actual = "root//" + actual.removeprefix("//buck2/")
native.alias(actual = actual, visibility = visibility, **kwargs)

def buck_sh_binary(visibility = ["PUBLIC"], **kwargs):
# @lint-ignore BUCKLINT: avoid "native is forbidden in fbcode"
native.sh_binary(visibility = visibility, **kwargs)
10 changes: 10 additions & 0 deletions shim/build_defs/prebuilt_cpp_library.bzl
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.

prelude = native

prebuilt_cpp_library = native.prebuilt_cxx_library
12 changes: 12 additions & 0 deletions shim/build_defs/python_library.bzl
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)
12 changes: 12 additions & 0 deletions shim/build_defs/python_unittest.bzl
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)

0 comments on commit 793bfd8

Please sign in to comment.