Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions include/BUILD

This file was deleted.

110 changes: 110 additions & 0 deletions openfeature/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package(
default_visibility = ["//visibility:public"],
)

cc_library(
name = "client",
hdrs = ["client.h"],
deps = [
":evaluation_context",
":features",
":metadata",
":provider_status",
],
)

cc_library(
name = "error_code",
hdrs = ["error_code.h"],
)

cc_library(
name = "evaluation_context",
hdrs = ["evaluation_context.h"],
)
Comment on lines +16 to +24

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve maintainability and reduce boilerplate, you can define the simple header-only libraries using a loop. This makes the BUILD file more concise and easier to manage as you add more header-only components.

For example, you could group error_code, evaluation_context, flag_metadata, metadata, provider_status, and reason like this, replacing their individual cc_library definitions:

[cc_library(
    name = lib,
    hdrs = [lib + ".h"],
) for lib in [
    "error_code",
    "evaluation_context",
    "flag_metadata",
    "metadata",
    "provider_status",
    "reason",
]]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following on that, I don't think loop is a good option, but I would consider grouping them more together.
Maybe we could add F.e.
error_code as part of resolution details library
metadata as part of provider

I'm not sure if that's best practice but wanted to consider that. @oxddr what do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, definitely don't follow this advice - it's wrong.


cc_library(
name = "feature_provider_status_manager",
srcs = ["feature_provider_status_manager.cpp"],
hdrs = ["feature_provider_status_manager.h"],
deps = [
"@abseil-cpp//absl/status",
"@abseil-cpp//absl/status:statusor",
":evaluation_context",
":provider",
":provider_status",
],
)

cc_library(
name = "features",
hdrs = ["features.h"],
deps = [
":evaluation_context",
],
)

cc_library(
name = "flag_metadata",
hdrs = ["flag_metadata.h"],
)

cc_library(
name = "metadata",
hdrs = ["metadata.h"],
)

cc_library(
name = "noop_provider",
srcs = ["noop_provider.cpp"],
hdrs = ["noop_provider.h"],
deps = [
":evaluation_context",
":metadata",
":provider",
":resolution_details",
],
)

cc_library(
name = "openfeature",
hdrs = ["openfeature.h"],
deps = [
":client",
":evaluation_context",
":metadata",
":provider",
],
)

cc_library(
name = "provider_status",
hdrs = ["provider_status.h"],
)

cc_library(
name = "provider",
hdrs = ["provider.h"],
deps = [
"@abseil-cpp//absl/status",
":evaluation_context",
":metadata",
":resolution_details",
],
)

cc_library(
name = "reason",
hdrs = ["reason.h"],
)

cc_library(
name = "resolution_details",
srcs = ["resolution_details.cpp"],
hdrs = ["resolution_details.h"],
deps = [
":error_code",
":flag_metadata",
":reason",
],
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/noop_provider.cpp → openfeature/noop_provider.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "include/openfeature/noop_provider.h"
#include "openfeature/noop_provider.h"

namespace openfeature {

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 0 additions & 42 deletions src/BUILD

This file was deleted.

24 changes: 12 additions & 12 deletions test/BUILD
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
cc_test(
name = "resolution_details_test",
srcs = ["resolution_details_test.cpp"],
deps = [
"//src:resolution_details",
"@googletest//:gtest_main",
],
)

cc_library(
name = "mock_feature_provider",
testonly = True,
hdrs = ["mocks/mock_feature_provider.h"],
visibility = ["//test:__pkg__"],
deps = [
"//include:openfeature_headers",
"//openfeature:provider",
"@googletest//:gtest",
],
)
Expand All @@ -23,7 +14,16 @@ cc_test(
srcs = ["feature_provider_status_manager_test.cpp"],
deps = [
":mock_feature_provider",
"//src:feature_provider_status_manager",
"//openfeature:feature_provider_status_manager",
"@googletest//:gtest_main",
],
)

cc_test(
name = "resolution_details_test",
srcs = ["resolution_details_test.cpp"],
deps = [
"//openfeature:resolution_details",
"@googletest//:gtest_main",
],
)
Expand All @@ -32,7 +32,7 @@ cc_test(
name = "noop_provider_test",
srcs = ["noop_provider_test.cpp"],
deps = [
"//src:noop_provider",
"//openfeature:noop_provider",
"@googletest//:gtest_main",
],
)