From 9776ea466037edcfc3ef6125bdaf0143bcea0aab Mon Sep 17 00:00:00 2001 From: karan bopche Date: Tue, 1 Jul 2025 20:16:54 +0530 Subject: [PATCH] Added support for Bazel build system --- .bazelrc | 0 .bazelversion | 1 + .gitignore | 4 ++++ BUILD.bazel | 42 ++++++++++++++++++++++++++++++++++++++++++ MODULE.bazel | 5 +++++ 5 files changed, 52 insertions(+) create mode 100644 .bazelrc create mode 100644 .bazelversion create mode 100644 BUILD.bazel create mode 100644 MODULE.bazel diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 0000000..e69de29 diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 0000000..4122521 --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +7.0.0 \ No newline at end of file diff --git a/.gitignore b/.gitignore index be760d1..5c29aa6 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,7 @@ README.md *.exe *.out *.app + +# bazel +bazel-* +MODULE.bazel.lock diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000..9aa04fa --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,42 @@ +cc_library( + name = "libco", + srcs = [ + "co_epoll.cpp", + "co_hook_sys_call.cpp", + "co_routine.cpp", + "coctx.cpp", + "coctx_swap.S", + ], + hdrs = [ + "co_closure.h", + "co_comm.h", + "co_epoll.h", + "co_routine.h", + "co_routine_inner.h", + "co_routine_specific.h", + "coctx.h", + ], + visibility = ["//visibility:public"], +) + +TEST_FILES = [ + "example_closure.cpp", + "example_thread.cpp", + "example_specific.cpp", + "example_setenv.cpp", + "example_poll.cpp", + "example_echosvr.cpp", + "example_echocli.cpp", + "example_copystack.cpp", + "example_cond.cpp", +] + +[ + cc_test( + name = TEST_FILE[:-3], + srcs = [TEST_FILE], + deps = [":libco"], + visibility = ["//visibility:private"], + ) + for TEST_FILE in TEST_FILES +] diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..02afca3 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,5 @@ +module( + name = "libco", + version = "1.0.0", + compatibility_level = 0, +)