Skip to content

Commit

Permalink
change source to mpct
Browse files Browse the repository at this point in the history
  • Loading branch information
包仁义 committed Aug 11, 2022
1 parent b976dc6 commit 3dbff1f
Show file tree
Hide file tree
Showing 15 changed files with 128 additions and 5 deletions.
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
/.vscode/

# add symlinks
bazel-bin
bazel-mpc-toolkit
bazel-out
bazel-testlogs
bazel-testlogs

### Added by Hedron's Bazel Compile Commands Extractor: https://github.com/hedronvision/bazel-compile-commands-extractor
# The external link: Differs on Windows vs macOS/Linux, so we can't check it in. The pattern needs to not have a trailing / because it's a symlink on macOS/Linux.
/external
# Bazel output symlinks: Same reasoning as /external. You need the * because people can change the name of the directory your repository is cloned into, changing the bazel-<workspace_name> symlink.
/bazel-*
# Compiled output -> don't check in
/compile_commands.json
# Directory where clangd puts its indexing work
/.cache/
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
# mpc-toolkit
# mpc-toolkit

## 环境初始化

```bash
$ git clone https://github.com/baobaoyeye/mpc-toolkit.git
$ cd mpc-toolkit
```

bazel+clangd生成compile_commands.json
[compilation-database.html#bazel](https://sarcasm.github.io/notes/dev/compilation-database.html#bazel)
[bazel-compile-commands-extractor](https://github.com/hedronvision/bazel-compile-commands-extractor)

```bash
# 生成在根目录生成 compile_commands.json
$ bazel run @hedron_compile_commands//:refresh_all
```

## 编译构建

```bash
# 全部编译
$ bazel build //... -c dbg
```
16 changes: 16 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
workspace(name = "mpc-toolkit")

load("//bazel:repositories.bzl", "mpct_deps")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")


mpct_deps()

Expand All @@ -14,3 +16,17 @@ rules_foreign_cc_dependencies(
register_default_tools = False,
register_preinstalled_tools = True,
)

# Hedron's Compile Commands Extractor for Bazel
# https://github.com/hedronvision/bazel-compile-commands-extractor
http_archive(
name = "hedron_compile_commands",

# Replace the commit hash in both places (below) with the latest, rather than using the stale one here.
# Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README).
url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/d1e95ec162e050b04d0a191826f9bc478de639f7.tar.gz",
strip_prefix = "bazel-compile-commands-extractor-d1e95ec162e050b04d0a191826f9bc478de639f7",
# When you first run this tool, it'll recommend a sha256 hash to put here with a message like: "DEBUG: Rule 'hedron_compile_commands' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = ..."
)
load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup")
hedron_compile_commands_setup()
2 changes: 1 addition & 1 deletion bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def _com_github_gabime_spdlog():
strip_prefix = "spdlog-1.9.2",
type = "tar.gz",
sha256 = "6fff9215f5cb81760be4cc16d033526d1080427d236e86d70bb02994f85e3d38",
build_file = "@mpct-toolkit//bazel:spdlog.BUILD",
build_file = "@mpc-toolkit//bazel:spdlog.BUILD",
urls = [
"https://github.com/gabime/spdlog/archive/refs/tags/v1.9.2.tar.gz",
],
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/client.cpp → mpct/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <butil/logging.h>
#include <butil/time.h>
#include <brpc/channel.h>
#include "src/echo.pb.h"
#include "mpct/echo.pb.h"

DEFINE_string(attachment, "", "Carry this along with requests");
DEFINE_string(protocol, "baidu_std", "Protocol type. Defined in src/brpc/options.proto");
Expand Down
14 changes: 14 additions & 0 deletions mpct/common/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("//bazel:mpct.bzl", "mpct_cc_library")

package(default_visibility = ["//visibility:public"])

mpct_cc_library(
name = "task",
hdrs = ["task.hpp"],
)

mpct_cc_library(
name = "executor",
hdrs = ["executor.hpp"],
deps = [":task"],
)
22 changes: 22 additions & 0 deletions mpct/common/executor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include <vector>

#include "mpct/common/task.hpp"

class Executor {
public:
virtual ~Executor() = default;
virtual void execute(const Task& task);
virtual void executeAll(const Task& task);
};

class PlainExecutor : public Executor {
public:
virtual ~PlainExecutor() = default;
};

class SecureExecutor : public Executor {
public:
virtual ~SecureExecutor() = default;
};
5 changes: 5 additions & 0 deletions mpct/common/task.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

class Task {

};
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions mpct/network/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
load("//bazel:mpct.bzl", "mpct_cc_library")

package(default_visibility = ["//visibility:public"])

mpct_cc_library(
name = "party",
srcs = ["party.cpp"],
hdrs = ["party.hpp"],
deps = ["//mpct/common:executor"],
)
8 changes: 8 additions & 0 deletions mpct/network/party.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

#include "mpct/network/party.hpp"
#include "spdlog/spdlog.h"


Party::Party() {
SPDLOG_INFO("create party");
}
13 changes: 13 additions & 0 deletions mpct/network/party.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include <stdint.h>
#include "mpct/common/executor.hpp"

class Party {
public:
Party();
~Party();
private:
uint32_t party_id;
Executor* executor;
};
2 changes: 1 addition & 1 deletion src/server.cpp → mpct/server.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <gflags/gflags.h>
#include <butil/logging.h>
#include <brpc/server.h>
#include "src/echo.pb.h"
#include "mpct/echo.pb.h"

DEFINE_bool(echo_attachment, true, "Echo attachment as well");
DEFINE_int32(port, 8000, "TCP Port of this server");
Expand Down

0 comments on commit 3dbff1f

Please sign in to comment.