diff --git a/.gitignore b/.gitignore index 13ae2767ce2844c65a5d716a9763cecc36326501..95febbc9685d06acba7b155ea6222fb2c5c803c3 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ metrics thirdparty go/pkg/mod/ cmake-build-debug +build/cache +build/install +build/output \ No newline at end of file diff --git a/BUILD.bazel b/BUILD.bazel index ad9d6fa8a0612c42f40af3bab8572cdc84ba6bf8..9558334588fdad1b3ec151b60aa7bf00c18991dd 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,5 +1,59 @@ load("//bazel:yr.bzl", "COPTS", "cc_strip") + +load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake_variant") + +cmake_variant( + name = "zeromq_build", + lib_source = "@zeromq_src_archive//:all", + cmake_options = [ + "-DENABLE_CURVE=ON", + "-DWITH_LIBSODIUM=ON", + "-DCMAKE_BUILD_TYPE=Release", + "-DCMAKE_INSTALL_PREFIX=${PREFIX}", + ], + install_commands = [ + "cmake --build . --target install -- -j$(nproc)", + ], + variants = ["default"], + toolchain = "@rules_foreign_cc//toolchains:preinstalled_cmake_toolchain", + visibility = ["//visibility:public"], +) + +cc_library( + name = "datasystem_defs", + hdrs = glob([ + "src/datasystem/common/**/*.def", + ]), + strip_include_prefix = "src", + visibility = ["//visibility:private"], +) + +cc_library( + name = "datasystem", + srcs = glob([ + "src/datasystem/client/**/*.cpp", + "src/datasystem/client/**/*.h", + "src/datasystem/common/**/*.cpp", + "src/datasystem/common/**/*.h", + ]), + hdrs = glob([ + "include/**/*.h", + ]), + strip_include_prefix = "include", + includes = ["src"], + deps = [ + "@boost//:boost", + "@com_googlesource_code_re2//:re2", + ":datasystem_defs", + "@securec", + "@spdlog//:spdlog", + "@zmq", + ], + copts = [], + visibility = ["//visibility:public"], +) + cc_shared_library( name = "grpc_dynamic", shared_lib_name = "libgrpc_dynamic.so.1.65.4", @@ -89,7 +143,7 @@ cc_library( "@boringssl//:boringssl_sdk", "@com_github_grpc_grpc//:grpc++_public_hdrs", "@com_github_grpc_grpc//:grpc_core_credentials_header", - "@datasystem_sdk//:lib_datasystem_sdk", + "@datasystem//:datasystem", "@metrics_sdk//:lib_metrics_sdk", "@msgpack", "@nlohmann_json", @@ -143,7 +197,7 @@ cc_library( "//src/utility:yr_utils_hdrs", "@com_github_grpc_grpc//:grpc++_public_hdrs", "@com_github_grpc_grpc//:grpc_core_credentials_header", - "@datasystem_sdk//:lib_datasystem_sdk", + "@datasystem//:datasystem", "@metrics_sdk//:lib_metrics_sdk", "@securec", ], diff --git a/WORKSPACE b/WORKSPACE index e5074a12507381922a8107f24b6a4b611538cddd..be907a2ac61a4e88a2cf17b38b8045db31c123b1 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -114,9 +114,9 @@ http_archive( ) new_local_repository( - name = "datasystem_sdk", - build_file = "@//bazel:datasystem_sdk.bzl", - path = "./datasystem/output/sdk/", + name = "datasystem", + build_file = "@//bazel:datasystem.bzl", + path = "../yuanrong-datasystem/", ) new_local_repository( @@ -155,3 +155,27 @@ maybe( build_file = "@//bazel:securec.bzl", path = "../thirdparty/libboundscheck", ) + +http_archive( + name = "zeromq_src_archive", + urls = ["https://gitee.com/mirrors/libzmq/repository/archive/v4.3.5.zip"], + strip_prefix = "libzmq-v4.3.5", + sha256 = "e9a5db55f88f7214614b7e334d74ac501ad0726bcc54241205b7f4b11f132744", + build_file_content = """ +filegroup( + name = "all", + srcs = glob(["**"]), + visibility = ["//visibility:public"], +) +""", +) + +http_archive( + name = "rules_foreign_cc", + urls = ["https://github.com/bazelbuild/rules_foreign_cc/archive/refs/tags/0.6.0.zip"], + strip_prefix = "rules_foreign_cc-0.6.0", + sha256 = "REPLACE_WITH_REAL_SHA256", +) +load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") +rules_foreign_cc_dependencies() + diff --git a/api/cpp/BUILD.bazel b/api/cpp/BUILD.bazel index 6f14e44b17d6404cd06a21b7baf4f3aa7dab28ec..c57134d6f1a62e269acebb8d2ad39d8a70179f66 100644 --- a/api/cpp/BUILD.bazel +++ b/api/cpp/BUILD.bazel @@ -159,9 +159,6 @@ genrule( cp -rf $(locations :cpp_strip) $$CPP_SDK_DIR/bin/ && rm -rf $$CPP_SDK_DIR/bin/libyr-api.so cp -rf $$BASE_DIR/api/cpp/include $$CPP_SDK_DIR/ && - DATASYSTEM_DIR=$$BASE_DIR/external/datasystem_sdk/cpp && - cp -rf $$DATASYSTEM_DIR/include $$CPP_SDK_DIR && - cp -rf $$DATASYSTEM_DIR/lib $$CPP_SDK_DIR && METRICS_DIR=$$BASE_DIR/external/metrics_sdk && cp -rf $$METRICS_DIR/include/* $$CPP_SDK_DIR/include && cp -rf $$METRICS_DIR/lib/* $$CPP_SDK_DIR/lib && diff --git a/api/java/BUILD.bazel b/api/java/BUILD.bazel index 6a8ced20014024a7df0b13338aea8c4baae30c84..dbd52cc530621ac9ba36399c8d287754a41e27c8 100644 --- a/api/java/BUILD.bazel +++ b/api/java/BUILD.bazel @@ -254,7 +254,6 @@ genrule( "//src/proto:socket_java_proto", "//api/java/function-common/src/main/cpp:libruntime_lib_jni.so", "//:grpc_strip", - "@datasystem_sdk//:shared", "@metrics_sdk//:shared", ], outs = ["native_yr_api_sdk.jar"], @@ -278,7 +277,6 @@ genrule( # copy native lib to WORKING_DIR cd $$BASE_DIR - NATIVE_LIB=$$(echo $(locations @datasystem_sdk//:shared)) NATIVE_LIB=$$(echo $$NATIVE_LIB $(locations @metrics_sdk//:shared)) NATIVE_LIB=$$(echo $$NATIVE_LIB $(locations //:grpc_strip)) NATIVE_LIB=$$(echo $$NATIVE_LIB $(locations //api/java/function-common/src/main/cpp:libruntime_lib_jni.so)) @@ -360,9 +358,7 @@ genrule( chrpath -r '$$ORIGIN' $(locations :java_strip) && chrpath -d $(locations //:grpc_strip) cp -fr $(locations :java_strip) $(locations //:grpc_strip) $$JAVA_SERVICE_DIR/lib && - DATASYSTEM_DIR=$$BASE_DIR/external/datasystem_sdk && METRICS_DIR=$$BASE_DIR/external/metrics_sdk && - cp -rf $$DATASYSTEM_DIR/cpp/lib/* $$JAVA_SERVICE_DIR/lib && cp -rf $$METRICS_DIR/lib/* $$JAVA_SERVICE_DIR/lib && echo "$$BASE_DIR" > $@ """, diff --git a/api/python/BUILD.bazel b/api/python/BUILD.bazel index 004538e970dde409f264b70725120dca699a6a89..8f216b4c4a241fdae102a6884f75a5d8a1598f88 100644 --- a/api/python/BUILD.bazel +++ b/api/python/BUILD.bazel @@ -66,7 +66,6 @@ copy_file( srcs = [ "//src/proto:libruntime_py_proto", "@boringssl//:shared", - "@datasystem_sdk//:shared", "@metrics_sdk//:shared", ], dstdir = "api/python/yr", diff --git a/bazel/datasystem.bzl b/bazel/datasystem.bzl new file mode 100644 index 0000000000000000000000000000000000000000..720a13f69bccc5e54e67c3417658909ec53c6602 --- /dev/null +++ b/bazel/datasystem.bzl @@ -0,0 +1,50 @@ +load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake_external") + +cmake_external( + name = "zeromq_build", + lib_source = "@zeromq_src_archive//:all", # 或者其它 http_archive / local repo target + cmake_options = [ + "-DENABLE_CURVE=ON", + "-DWITH_LIBSODIUM=ON", + "-DCMAKE_BUILD_TYPE=Release", + "-DCMAKE_INSTALL_PREFIX=/usr", # 根据需要 + ], + install_commands = [ + "cmake --build . --target install -- -j$(nproc)", + ], + visibility = ["//visibility:public"], +) + +cc_library( + name = "datasystem_defs", + hdrs = glob([ + "src/datasystem/common/**/*.def", + ]), + strip_include_prefix = "src", + visibility = ["//visibility:private"], +) + +cc_library( + name = "datasystem", + srcs = glob([ + "src/datasystem/client/**/*.cpp", + "src/datasystem/client/**/*.h", + "src/datasystem/common/**/*.cpp", + "src/datasystem/common/**/*.h", + ]), + hdrs = glob([ + "include/**/*.h", + ]), + strip_include_prefix = "include", + includes = ["src"], + deps = [ + "@boost//:boost", + "@com_googlesource_code_re2//:re2", + ":datasystem_defs", + "@securec", + "@spdlog//:spdlog", + "@zmq", + ], + copts = [], + visibility = ["//visibility:public"], +) \ No newline at end of file diff --git a/bazel/preload_grpc.bzl b/bazel/preload_grpc.bzl index 6beb062d8fd46a08d299c02dc22c5474e0fddd8a..fc50d2564b03fb719736c789580cd8638a8f3e95 100644 --- a/bazel/preload_grpc.bzl +++ b/bazel/preload_grpc.bzl @@ -67,9 +67,9 @@ def preload_grpc(): http_archive( name = "com_googlesource_code_re2", - url = "https://gitee.com/mirrors/re2/repository/archive/2024-02-01.zip", - sha256 = "54bff0e995b101e1865dcea5d052ec10b3aadb6f8c57b5c03c9eeccddb00a08a", - strip_prefix = "re2-2024-02-01", + url = "https://gitee.com/mirrors/re2/repository/archive/2022-04-01.zip", + sha256 = "e7a7a796c5c207f1cd0a909799077640594c1aaa46518bd4eb5efbde62b7e753", + strip_prefix = "re2-2022-04-01", ) http_archive( diff --git a/bazel/zmq.bzl b/bazel/zmq.bzl new file mode 100644 index 0000000000000000000000000000000000000000..ba592b04b07870a4f9631cbc3f0d36a8b42f0914 --- /dev/null +++ b/bazel/zmq.bzl @@ -0,0 +1,14 @@ +cc_library( + name = "zmq", + srcs = glob([ + "src/**/*.cpp", + "src/**/*.hpp", + ]), + hdrs = glob(["include/*.h"]), + strip_include_prefix = "include", + copts = [], + deps = [ + + ], + visibility = ["//visibility:public"], +) \ No newline at end of file