Skip to content

Commit

Permalink
Add fizz_cpp_* and additional fixes
Browse files Browse the repository at this point in the history
Summary: These will be used later. But putting them up now.

Reviewed By: zertosh

Differential Revision: D67952849

fbshipit-source-id: 3369dd5df32cb5b05a88ad5a8e62db57135a7322
  • Loading branch information
mzlee authored and facebook-github-bot committed Jan 9, 2025
1 parent 0557471 commit 86a71d8
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion fizz/defs.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
load("@fbcode_macros//build_defs:cpp_binary.bzl", "cpp_binary")
load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")
load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest")
load("@fbsource//tools/build_defs:buckconfig.bzl", "read", "read_bool")
load("@fbsource//tools/build_defs:cell_defs.bzl", "get_fbsource_cell")
load("@fbsource//tools/build_defs:fb_xplat_cxx_binary.bzl", "fb_xplat_cxx_binary")
Expand Down Expand Up @@ -100,25 +102,32 @@ def _compute_header_namespace():

def fizz_cpp_library(
name,
srcs = [],
# cpp_library API
headers = [],
private_headers = [],
srcs = [],
modular_headers = None,
deps = None,
exported_deps = None,
external_deps = None,
exported_external_deps = None,
propagated_pp_flags = (),
# fb_xplat API
enable_static_variant = True,
**kwargs):
"""Translate a simpler declartion into the more complete library target"""
if get_fbsource_cell() == "fbcode":
cpp_library(
name = name,
headers = headers,
private_headers = private_headers,
modular_headers = modular_headers,
srcs = srcs,
deps = deps,
exported_deps = exported_deps,
external_deps = external_deps,
exported_external_deps = exported_external_deps,
propagated_pp_flags = propagated_pp_flags,
)
else:
converted_deps = deps_map_utils.convert_all_to_fbsource_deps(
Expand All @@ -132,8 +141,10 @@ def fizz_cpp_library(
exported_headers = headers,
headers = private_headers,
srcs = srcs,
exported_preprocessor_flags = propagated_pp_flags,
deps = converted_deps.deps,
exported_deps = converted_deps.exported_deps,
enable_static_variant = enable_static_variant,
**kwargs
)

Expand Down Expand Up @@ -186,6 +197,19 @@ def fizz_cxx_library(
**kwargs
)

def fizz_cpp_binary(name, deps, **kwargs):
if get_fbsource_cell() == "fbcode":
cpp_binary(name = name, **kwargs)
else:
converted_deps = deps_map_utils.convert_all_to_fbsource_deps(
deps = deps,
)
fizz_cxx_binary(
name = name,
deps = converted_deps.deps,
**kwargs
)

def fizz_cxx_binary(name, **kwargs):
fb_xplat_cxx_binary(
name = name,
Expand All @@ -194,6 +218,31 @@ def fizz_cxx_binary(name, **kwargs):
**kwargs
)

def fizz_cpp_unittest(
name,
deps,
external_deps = (),
supports_static_listing = True,
**kwargs):
if get_fbsource_cell() == "fbcode":
cpp_unittest(
name = name,
supports_static_listing = supports_static_listing,
deps = deps,
external_deps = external_deps,
**kwargs
)
else:
converted_deps = deps_map_utils.convert_all_to_fbsource_deps(
deps = deps,
external_deps = external_deps,
)
fizz_cxx_test(
name = name,
deps = converted_deps.deps,
**kwargs
)

def fizz_cxx_test(name, **kwargs):
fb_xplat_cxx_test(
name = name,
Expand Down

0 comments on commit 86a71d8

Please sign in to comment.