{"id":22441220,"url":"https://github.com/xr-stb/tinygamesvr","last_synced_at":"2026-05-05T05:39:53.195Z","repository":{"id":266595690,"uuid":"898489970","full_name":"XR-stb/tinygamesvr","owner":"XR-stb","description":"tinygamesvr base on grpc","archived":false,"fork":false,"pushed_at":"2025-01-24T02:26:15.000Z","size":3330,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-27T10:14:41.520Z","etag":null,"topics":["cpp","gameserver","golang"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/XR-stb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-04T13:43:02.000Z","updated_at":"2025-01-24T02:26:19.000Z","dependencies_parsed_at":"2024-12-20T11:18:32.598Z","dependency_job_id":"2d4b2a3d-ca1c-4de3-a072-930941620d6d","html_url":"https://github.com/XR-stb/tinygamesvr","commit_stats":null,"previous_names":["xr-stb/tinygamesvr"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XR-stb%2Ftinygamesvr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XR-stb%2Ftinygamesvr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XR-stb%2Ftinygamesvr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XR-stb%2Ftinygamesvr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/XR-stb","download_url":"https://codeload.github.com/XR-stb/tinygamesvr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245823315,"owners_count":20678173,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","gameserver","golang"],"created_at":"2024-12-06T02:13:27.306Z","updated_at":"2026-05-05T05:39:53.157Z","avatar_url":"https://github.com/XR-stb.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"## QuickStart\n```\ngit clone --recursive https://github.com/XR-stb/tinygamesvr\n# 如果clone子模块失败，可以再慢慢尝试 git submodule update --init --recursive\ncd tinygamesvr/third_party/grpc\n# install grpc, see this https://grpc.io/docs/languages/cpp/quickstart/\n\n./make genproto # 生成proto文件\n./make build gamesvr # 编译gamesvr\n./make run gamesvr # 运行gamesvr\n\ncd golang/cloud\ngo run ./test/vulcan # run test client\n```\n\n## Build\n\n### 1. 安装构建工具\n[Ubuntu安装bazel](https://shinley.gitbooks.io/bazel/content/an-zhuang-bazel/zai-ubuntu-shang-an-zhuang-bazel.html)\n```shell\necho \"deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8\" | sudo tee /etc/apt/sources.list.d/bazel.list\n\ncurl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -\n\nsudo apt-get update \u0026\u0026 sudo apt-get install bazel\n\nsudo apt-get upgrade bazel\n```\n\n安装cmake\n```\nsudo apt install cmake\n```\n\n安装golang\n```\nsudo apt install golang-go\ngo version # go version go1.22.2 linux/amd64\n\n# 若golang版本为1.23及以上 可能会出现：invalid go version '1.22.2': must match format 1.23\n# 将go.mod 里面的 go 1.22.2改成 go 1.23\n```\n\n准备grpc-cpp环境: https://grpc.io/docs/languages/cpp/quickstart/\nnote: grpc version v1.40.0\n```\nsudo apt install -y build-essential autoconf libtool pkg-config\ncd grpc\nmkdir -p cmake/build\npushd cmake/build\ncmake -DgRPC_INSTALL=ON \\\n      -DgRPC_BUILD_TESTS=OFF \\\n      -DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR \\\n      ../..\nmake -j 4\nmake install # permision denied 则使用 sudo make install\n```\n\n### 2. 编译和运行（更方便的做法是使用./make.py脚本，见下方）\n使用bazel\n```shell\n# 将制品输出到--symlink_prefix=build/bazel/\nbazel build //servers/gamesvr:gamesvr --symlink_prefix=build/bazel/\n\nbazel run //servers/gamesvr:gamesvr --symlink_prefix=build/bazel/\n```\n使用cmake\n```shell\ncmake .\n\nmake\n```\n### 3. bazel 构建制品清理\n```shell\nbazel clean \n\nrm -rf build/bazel/*\n```\n\n## 开发\n\n### Cmake 生成 compile_commands.json\n```shell\ncmake -DCMAKE_EXPORT_COMPILE_COMMANDS=on\n```\n\n### ./make.py 脚本使用\n先给权限\n```shell\nchmod +x ./make.py\n```\n\n编译\n```shell\n./make.py build # 编译全部target\n./make.py run # 运行全部target\n\n./make.py build gamesvr # 编译单个服务\n./make.py build gamesvr chatsvr # 编译多个服务\n\n# cpp target 默认使用cmake编译，使用bazle编译如下\n./make.py build gamesvr --with-bazel\n\n# 生成proto代码文件\n./make.py genproto\n```\n\n### 开发环境配置\n1. 安装clangd\n```shell\nsudo apt install clangd\n\nclangd --version # version \u003e= 14即可\n```\n2. 安装vscode clangd 插件，卸载vscode 微软 c++ 插件\n3. 安装clang-format，包括vscode插件(作者：Xaver Hellauer)\n```shell\nsudo apt install clang-format\n```\n4. 代码提示\n```shell\ncmake -DCMAKE_EXPORT_COMPILE_COMMANDS=on\n```\n\n5. 配置clang-format\n\n6. golang 下载protoc插件（用于生成proto go代码\nsee: https://grpc.io/docs/languages/go/quickstart/\n```shell \ngo install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28\ngo install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2\n\nvi ~/.bashrc \nexport PATH=\"$PATH:$(go env GOPATH)/bin\" # 添加到末尾\nsource ~/.bashrc\n```\n\n7. 安装对应的protoc 版本\n```shell\n# 如果遇到这个错误\nif(NOT \"${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}\" VERSION_EQUAL \"${Protobuf_VERSION}\")\n    message(WARNING \"Protobuf compiler version ${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}\"\n    \" doesn't match library version ${Protobuf_VERSION}\")\nendif()\n点击这个宏，然后去下载对应版本的protoc即可\n#if PROTOBUF_VERSION != 5026001\nhttps://github.com/protocolbuffers/protobuf/releases/\n其中protoc生成的 xx pb.h 中的版本号是 protoc的版本，由于我们已经安装了grpc，所以根据grpc的版本来安装\n点击xx pb.h文件中的这个宏，到grpc安装的那个目录看看版本是多少安装即可\n\n\n# 本项目使用的是以下版本\nwget https://github.com/protocolbuffers/protobuf/releases/download/v29.0/protoc-29.0-linux-x86_64.zip\nmv protoc-29.0-linux-x86_64.zip tinygamesvr/tools/proto \u0026\u0026 cd tinygamesvr/tools/proto\nunzip protoc-29.0-linux-x86_64.zip\n```\n\n关于protoc 生成golang代码可能遇到的问题\nhttps://stackoverflow.com/questions/57700860/error-protoc-gen-go-program-not-found-or-is-not-executable\n\n8. golang 升级相关\nhttps://ubuntuhandbook.org/index.php/2024/02/how-to-install-go-golang-1-22-in-ubuntu-22-04/\n\n9. bazel 编译grpc 相关报错 (TODO)\n```shell\nERROR: no such package '@@bazel_tools//platforms': BUILD file not found in directory 'platforms' of external repository @@bazel_tools. Add a BUILD file to a directory to mark it as a package.\nERROR: /home/tianbaosha/.cache/bazel/_bazel_tianbaosha/ad16b30a9f26716226dff8300c03eaa4/external/io_bazel_rules_go/go/toolchain/BUILD.bazel:8:20: no such package '@@bazel_tools//platforms': BUILD file not found in directory 'platforms' of external repository @@bazel_tools. Add a BUILD file to a directory to mark it as a package. and referenced by '@@io_bazel_rules_go//go/toolchain:linux'\nERROR: /home/tianbaosha/cpp_code/tinygamesvr/servers/gamesvr/BUILD:14:10: Analysis failed\nERROR: Analysis of target '//servers/gamesvr:gamesvr' failed; build aborted\n```\n\n10. 编译cpp target 报错：fatal error: google/protobuf/generated_message_table_driven.h: No such file or directory\n```\n未安装grpc\nhttps://grpc.io/docs/languages/cpp/quickstart/\n记得执行到最后的make install\n```\n11.  undefined reference to `absl::xxxx\n同样是grpc 安装有异常，重新完整走一遍安装流程\n\n12. 安装python black 插件 格式化python代码\n```\npython3 -m venv .pyenv #  Linux 发行版（如 Ubuntu）中，系统的 Python 环境 不能 直接安装包\npip install black\nsource .pyenv/bin/activate\npip install black\nblack . # 格式化当前目录\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxr-stb%2Ftinygamesvr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxr-stb%2Ftinygamesvr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxr-stb%2Ftinygamesvr/lists"}