Skip to content

Commit

Permalink
Merge pull request #4 from opencomputeproject/status_macros
Browse files Browse the repository at this point in the history
Release latest code from Google3
  • Loading branch information
karagog authored Jul 18, 2023
2 parents 9ef2f71 + 7bb7fc4 commit 065fc13
Show file tree
Hide file tree
Showing 126 changed files with 13,953 additions and 35 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
bazel-bin
bazel-ocp-diag-core-cpp
bazel-out
bazel-testlogs
bazel-*
13 changes: 7 additions & 6 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License
The MIT License

Copyright (c) 2023 Open Compute Project
Copyright 2022 Google LLC.
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -9,13 +10,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
4 changes: 3 additions & 1 deletion ocpdiag/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ exports_files(["LICENSE"])
config_setting(
name = "ovss",
values = {"define": "release=ovss"},
visibility = ["//ocpdiag:__subpackages__"],
visibility = [
"//ocpdiag:__subpackages__",
],
)
15 changes: 11 additions & 4 deletions ocpdiag/build_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ def load_deps(ocpdiag_package_name = "ocpdiag"):
Args:
ocpdiag_package_name: The name of the OCPDiag external package.
"""
maybe(
http_archive,
"boringssl",
url = "https://github.com/google/boringssl/archive/68e30993b3f3bdb18951f6cda462e99ea834ed2d.zip", # 2023-05-08
strip_prefix = "boringssl-68e30993b3f3bdb18951f6cda462e99ea834ed2d",
sha256 = "19146bba3d40ff263f07942e6a5b6e979d730363fb72fff8c6883551f2277724",
)

maybe(
http_archive,
"com_google_absl",
Expand Down Expand Up @@ -73,7 +81,6 @@ def load_deps(ocpdiag_package_name = "ocpdiag"):
http_archive,
"six_archive",
urls = [
"http://mirror.bazel.build/pypi.python.org/packages/source/s/six/six-1.16.0.tar.gz",
"https://pypi.python.org/packages/source/s/six/six-1.16.0.tar.gz",
],
strip_prefix = "six-1.16.0",
Expand Down Expand Up @@ -153,9 +160,9 @@ def load_deps(ocpdiag_package_name = "ocpdiag"):
maybe(
http_archive,
"com_google_ecclesia",
url = "https://github.com/google/ecclesia-machine-management/archive/47bd18ae21c019a19b697183c4eb792df8e4344b.zip", # 2023-04-28
strip_prefix = "ecclesia-machine-management-47bd18ae21c019a19b697183c4eb792df8e4344b",
sha256 = "ddd4b6f1ab9bd2ce9dc837ceb981617799058af35da02bcbc0629401d52ca638",
url = "https://github.com/google/ecclesia-machine-management/archive/2613485c22610d5bade43a6ef4022ae8341700b6.zip", # 2023-05-17
strip_prefix = "ecclesia-machine-management-2613485c22610d5bade43a6ef4022ae8341700b6",
sha256 = "96393d45fe63b12576ccd95c4fe61d894cf8588d33d489ff01075fa44bb74406",
)

maybe(
Expand Down
8 changes: 8 additions & 0 deletions ocpdiag/core/compat/status_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"

#ifndef RETURN_IF_ERROR
#define RETURN_IF_ERROR(s) \
{ \
auto c = (s); \
if (!c.ok()) return c; \
}
#endif

// `RETURN_IF_ERROR_WITH_MESSAGE` behave the same with RETURN_IF_ERROR in
// addition with a message.
Expand All @@ -30,6 +32,7 @@
//
// Returns a status: "INTERNAL: Failed to parse field.
// [ocpdiag/LoadConfig/main.cc#25='Failed to load config.']"
#ifndef RETURN_IF_ERROR_WITH_MESSAGE
#define RETURN_IF_ERROR_WITH_MESSAGE(s, msg) \
{ \
auto c = (s); \
Expand All @@ -42,12 +45,15 @@
return c; \
} \
}
#endif

#ifndef RETURN_VOID_IF_ERROR
#define RETURN_VOID_IF_ERROR(s) \
{ \
auto c = (s); \
if (!c.ok()) return; \
}
#endif

// Executes an expression `expr` that returns an `absl::StatusOr<T>`.
// On Ok, move its value into the variable defined by `var`,
Expand All @@ -60,9 +66,11 @@
// Example: Assigning to an existing variable:
// ValueType value;
// ASSIGN_OR_RETURN(value, MaybeGetValue(arg));
#ifndef ASSIGN_OR_RETURN
#define ASSIGN_OR_RETURN(var, expr) \
OCPDIAG_STATUS_MACROS_ASSIGN_OR_RETURN_IMPL( \
OCPDIAG_STATUS_MACROS_CONCAT(_status_or_expr, __LINE__), var, expr)
#endif

#define OCPDIAG_STATUS_MACROS_ASSIGN_OR_RETURN_IMPL(c, v, s) \
auto c = (s); \
Expand Down
Loading

0 comments on commit 065fc13

Please sign in to comment.