From 4e5b4b5948e7a6ff8020744501596d416d52b407 Mon Sep 17 00:00:00 2001 From: nick Date: Tue, 20 Oct 2026 09:47:02 +0800 Subject: [PATCH 1/2] refactor(deployment)!: consolidate assets and runtime helpers Group container recipes and Kubernetes examples under deployment and replace duplicated launch scripts with one foreground application interface per platform. Scope stop helpers to one explicit application PID and document migration. BREAKING CHANGE: update root Dockerfile, docker/ and kubernetes/ paths to deployment/. Replace rund and sample wrappers with run.{sh,bat} [runtime-directory]; the old implicit five-service daemon launch is removed. Stop helpers now require an explicit PID; use CMake clean instead of vc_clear.bat. --- .dockerignore | 3 +- build/README.md | 90 ++++++++----- build/README_CN.md | 53 ++++++++ build/kill.bat | 23 +++- build/kill.sh | 17 ++- build/mysql_sample.sh | 13 -- build/run.bat | 58 ++++----- build/run.sh | 55 ++++---- build/rund.bat | 32 ----- build/rund.sh | 29 ----- build/sample1.sh | 13 -- build/sample5http_test.sh | 13 -- build/vc_clear.bat | 14 -- Dockerfile => deployment/Dockerfile | 2 +- deployment/README.md | 29 +++++ deployment/README_CN.md | 23 ++++ {kubernetes => deployment}/ark_consul.yaml | 0 .../docker}/ark-alpine-build | 0 .../docker}/ark-alpine-runtime | 0 {kubernetes => deployment}/photon_config.yaml | 122 +++++++++--------- .../photon_game_deployment.yaml | 0 .../photon_master_deployment.yaml | 0 docs/project-layout.md | 2 + docs/project-layout_CN.md | 2 + docs/project/changelog.md | 12 ++ docs/project/changelog_CN.md | 11 ++ docs/reference/directory-structure.md | 2 + docs/reference/directory-structure_CN.md | 2 + tests/runtime/scripts.test.mjs | 83 ++++++++++++ 29 files changed, 423 insertions(+), 280 deletions(-) create mode 100644 build/README_CN.md delete mode 100644 build/mysql_sample.sh delete mode 100755 build/rund.bat delete mode 100755 build/rund.sh delete mode 100755 build/sample1.sh delete mode 100755 build/sample5http_test.sh delete mode 100755 build/vc_clear.bat rename Dockerfile => deployment/Dockerfile (91%) create mode 100644 deployment/README.md create mode 100644 deployment/README_CN.md rename {kubernetes => deployment}/ark_consul.yaml (100%) rename {docker => deployment/docker}/ark-alpine-build (100%) rename {docker => deployment/docker}/ark-alpine-runtime (100%) rename {kubernetes => deployment}/photon_config.yaml (60%) rename {kubernetes => deployment}/photon_game_deployment.yaml (100%) rename {kubernetes => deployment}/photon_master_deployment.yaml (100%) create mode 100644 tests/runtime/scripts.test.mjs diff --git a/.dockerignore b/.dockerignore index a29e81754..95f00e403 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,8 +7,7 @@ build/*.sh build/*.bat scripts -docker -kubernetes +deployment cmake-build-debug test examples diff --git a/build/README.md b/build/README.md index 2a528a67f..5345e85ef 100755 --- a/build/README.md +++ b/build/README.md @@ -1,39 +1,61 @@ -# Binary +# Runtime files -Build artifacts are written to `/bin`. Use separate -build directories for Release, Debug and sanitizer builds so their archives, -plugins and executables cannot overwrite each other: +[简体中文](README_CN.md) + +Build artifacts belong to `/bin`. Keep Release, Debug and +sanitizer builds in separate directories. Stage an application's executable and +plugins from the same build into a runtime directory containing `bin/`, `conf/` +and, when required, `resource/`. This source directory contains example +configuration, resources and tools; generated binaries are not checked in. + +## Run one application + +The shell and Windows helpers share one interface: + +```text +run.sh [runtime-directory] +run.bat [runtime-directory] +``` + +The default runtime directory is the script's directory. An explicit runtime path +is relative to the caller's working directory. The helper selects `bin/app` +(`app.exe` on Windows) for Release or `bin/app_d` (`app_d.exe`) for Debug, reads +`conf/.app.conf` and `conf/log.conf`, and runs in the foreground. The name +also becomes the application's `--name` value. Use the executable directly for +TOML manifests, a different process name or other launcher flags. + +After preparing the [Sample1 runtime](../docs/get-started/quick-start.md), run from +the repository root: ```sh -cmake -S . -B out/release -DCMAKE_BUILD_TYPE=Release -cmake --build out/release --parallel 2 +sh build/run.sh Release sample1 1.0.1.1 run/sample1 ``` -This build produces `out/release/bin/app` (`app.exe` on Windows) and the enabled -plugins in the same directory. `cmake -S . -B build` retains the `build/bin` -location. The Docker build copies its artifacts from `cmake-build/bin`. - -When staging a server, copy the chosen build's artifacts into the runtime -directory's `bin/` alongside its configuration and resources. The scripts below -use this runtime layout; they do not select a CMake build directory. - -This folder is the runtime folder, include - -- bin -- binlog -- bus_conf -- plugin_conf -- resource -- tools - -## Batch/shell - -| name | descriptor | -| -------- | ------------------------------------- | -| rund.bat | run debug version in Windows | -| run.bat | run release version in Windows | -| kill.bat | kill debug & release version in Linux | -| | | -| run.sh | run release version in Linux | -| rund.sh | run debug version in Linux | -| kill.sh | kill debug & release version in Linux | +On Windows, use `build\run.bat Release sample1 1.0.1.1 run\sample1`. +Check the application's initialization log before using it; the helper's path +checks do not validate plugins, business configuration or readiness. + +## Stop one application + +Prefer Ctrl+C on macOS/Linux or `exit` in the Windows application console. +For a process whose PID has been confirmed, `kill.sh ` requests `SIGTERM`; +`kill.bat ` forcibly terminates that PID. Both helpers reject other executable +names and require exactly one explicit PID. Recheck the PID's executable and +command line immediately before use; a PID can be reused after a process exits. +There is no process-name wildcard or machine-wide stop command. + +## Migrate old helper commands + +- Replace `rund.sh` / `rund.bat` with `run.sh Debug ...` / `run.bat Debug ...`. +- Replace `sample1.sh`, `mysql_sample.sh` and `sample5http_test.sh` with + `run.sh Debug `, using `sample1`, `mysql_sample` or `sample5`. +- The old no-argument five-service launch sequence used missing `plugin_conf/` + paths and inconsistent Release/Debug Bus IDs. Supply each application's name + and Bus ID explicitly, and arrange service startup separately for the target + environment. The helper no longer daemonizes applications. +- Replace `vc_clear.bat` with `cmake --build --target clean` + to clean a selected build directory. +- Container recipes and cluster examples now live under [deployment/](../deployment/README.md). + +The byte-preserved historical articles under `docs/site/legacy-source/` still show +their original `bin/rund.*` commands. Use the current commands above instead. diff --git a/build/README_CN.md b/build/README_CN.md new file mode 100644 index 000000000..fe10db852 --- /dev/null +++ b/build/README_CN.md @@ -0,0 +1,53 @@ +# 运行文件 + +[English](README.md) + +构建产物保存在 `/bin`。Release、Debug 和 sanitizer 构建使用 +独立目录。将同一次构建的程序和插件复制到运行目录的 `bin/`,并准备 `conf/`;使用 +业务资源的应用还需要 `resource/`。本目录保存示例配置、资源与工具,不追踪生成的二进制文件。 + +## 启动一个应用 + +Shell 和 Windows 脚本使用相同参数: + +```text +run.sh [runtime-directory] +run.bat [runtime-directory] +``` + +运行目录默认为脚本所在目录。显式传入的相对路径以调用者的工作目录为基准。 +Release 使用 `bin/app`(Windows 为 `app.exe`),Debug 使用 `bin/app_d` +(Windows 为 `app_d.exe`)。脚本读取 `conf/.app.conf` 和 `conf/log.conf`, +在前台运行应用;`name` 同时作为 `--name` 的值。使用 TOML 配置、不同的进程名称或 +其他启动参数时,直接调用程序。 + +按[Sample1 快速开始](../docs/get-started/quick-start_CN.md)准备运行目录后,在仓库根目录执行: + +```sh +sh build/run.sh Release sample1 1.0.1.1 run/sample1 +``` + +Windows 使用 `build\run.bat Release sample1 1.0.1.1 run\sample1`。 +使用应用前,检查初始化日志。脚本的路径检查不验证插件、业务配置或服务就绪状态。 + +## 停止一个应用 + +macOS/Linux 优先使用 Ctrl+C,Windows 优先在应用控制台输入 `exit`。 +确认目标进程的 PID 后,使用 `kill.sh ` 请求 `SIGTERM`;`kill.bat ` 会强制终止 +该 PID。两个脚本都只接受一个显式 PID,并拒绝其他可执行文件名。执行前重新确认 PID 的 +可执行文件与命令行;进程退出后,PID 可能被复用。脚本不按名称通配批量停止进程。 + +## 迁移旧命令 + +- 将 `rund.sh` / `rund.bat` 改为 `run.sh Debug ...` / `run.bat Debug ...`。 +- 将 `sample1.sh`、`mysql_sample.sh` 和 `sample5http_test.sh` 改为 + `run.sh Debug `;名称分别为 `sample1`、`mysql_sample`、`sample5`。 +- 旧版无参数五服务启动顺序引用了不存在的 `plugin_conf/`,Release 与 Debug 的总线 ID + 也不一致。现在需要显式传入每个应用的名称与总线 ID,并按目标环境安排启动顺序。 + 新脚本不再将应用转为守护进程。 +- 使用 `cmake --build --target clean` 清理选定构建目录, + 替代 `vc_clear.bat`。 +- 容器构建文件和集群示例已移至 [deployment/](../deployment/README_CN.md)。 + +`docs/site/legacy-source/` 按原始字节保留历史文章,其中的 `bin/rund.*` 命令不再适用, +请使用上面的当前命令。 diff --git a/build/kill.bat b/build/kill.bat index e033f71b3..a8be271ee 100755 --- a/build/kill.bat +++ b/build/kill.bat @@ -1,5 +1,20 @@ -cd /d %~dp0 - @echo off - -taskkill /f /im app* \ No newline at end of file +setlocal +if "%~1"=="" goto usage +if not "%~2"=="" goto usage +for /f "delims=0123456789" %%p in ("%~1") do goto usage +set "pid=%~1" +if "%pid:~0,1%"=="0" goto usage +if "%~1"=="1" goto usage +for /f "tokens=1 delims=," %%p in ('tasklist /fi "PID eq %~1" /fo csv /nh') do ( + if /i "%%~p"=="app.exe" goto stop + if /i "%%~p"=="app_d.exe" goto stop +) +echo PID %~1 is not an app.exe or app_d.exe process; refusing to stop it. 1>&2 +exit /b 1 +:stop +taskkill /f /pid %~1 +exit /b %errorlevel% +:usage +echo Usage: %~nx0 ^ 1>&2 +exit /b 2 diff --git a/build/kill.sh b/build/kill.sh index c492c2731..80711fce1 100755 --- a/build/kill.sh +++ b/build/kill.sh @@ -1,3 +1,16 @@ -kill -9 $(pidof *_server) +#!/bin/sh +set -eu -ps aux | grep *_server \ No newline at end of file +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " >&2 + exit 2 +fi +case "$1" in + ''|*[!0-9]*|0|1|0*) echo "Supply one application PID greater than 1" >&2; exit 2 ;; +esac +command_name=$(ps -p "$1" -o comm=) || exit 1 +command_name=${command_name##*/} +case "$command_name" in + app|app_d) kill -TERM "$1" ;; + *) echo "PID $1 is not an app or app_d process; refusing to stop it" >&2; exit 1 ;; +esac diff --git a/build/mysql_sample.sh b/build/mysql_sample.sh deleted file mode 100644 index 4984d3607..000000000 --- a/build/mysql_sample.sh +++ /dev/null @@ -1,13 +0,0 @@ -export LC_ALL="C" - -# The default zone is 1001 - -CHANNEL_ID=1 -ZONE_ID=1 - -echo Starting http_server... -./bin/app_d --busid=1.0.1.1 --name=mysql_sample --app_conf=conf/mysql_sample.app.conf - -echo All processes are launching... - -ps aux | grep app_d diff --git a/build/run.bat b/build/run.bat index db5bd8c76..6a750de4e 100755 --- a/build/run.bat +++ b/build/run.bat @@ -1,34 +1,26 @@ -cd /d %~dp0 - @echo off - -REM the default zone is 1001 - -set CHANNEL_ID=1 -set ZONE_ID=1 - -cd Release - -echo Starting master... -start "master" bin/app.exe -x --busid=1.0.1.1 --name=master_server --app_conf=plugin_conf/master.app.conf -choice /t 5 /d y /n >nul - -echo Starting world... -start "world" bin/app.exe -x --busid=1.1.30.1 --name=world_server --app_conf=plugin_conf/world.app.conf -choice /t 5 /d y /n >nul - -echo Starting login... -start "login" bin/app.exe -x --busid=1.1.31.1 --name=login_server --app_conf=plugin_conf/login.app.conf -choice /t 5 /d y /n >nul - -echo Starting proxy... -start "proxy" bin/app.exe -x --busid=1.1.32.1 --name=proxy_server --app_conf=plugin_conf/proxy.app.conf -choice /t 5 /d y /n >nul - -echo Starting game... -start "game" bin/app.exe -x --busid=1.1.33.1 --name=game_server --app_conf=plugin_conf/game.app.conf -choice /t 5 /d y /n >nul - -echo All processes are launching... - -cd \ No newline at end of file +setlocal +if "%~3"=="" goto usage +if not "%~5"=="" goto usage +set "binary=" +if "%~1"=="Release" set "binary=bin\app.exe" +if "%~1"=="Debug" set "binary=bin\app_d.exe" +if not defined binary goto usage +echo(%~2| findstr /r /x "[a-zA-Z0-9_-][a-zA-Z0-9_-]*" >nul || goto usage +set "runtime=%~dp0" +if not "%~4"=="" set "runtime=%~4" +pushd "%runtime%" || exit /b 1 +if not exist "%binary%" goto missing +if not exist "conf\%~2.app.conf" goto missing +if not exist "conf\log.conf" goto missing +"%binary%" "--busid=%~3" "--name=%~2" "--app_conf=conf/%~2.app.conf" --log_conf=conf/log.conf +set "result=%errorlevel%" +popd +exit /b %result% +:missing +echo Missing executable or configuration in "%CD%". 1>&2 +popd +exit /b 1 +:usage +echo Usage: %~nx0 ^ ^ ^ [runtime-directory] 1>&2 +exit /b 2 diff --git a/build/run.sh b/build/run.sh index 43fc62121..019cecf6d 100755 --- a/build/run.sh +++ b/build/run.sh @@ -1,29 +1,26 @@ -cd bin - -export LC_ALL="C" - -#The default zone is 1001 - -CHANNEL_ID=1 -ZONE_ID=1 - -echo Starting master... -./bin/app -d --busid=1.0.1.1 --name=master_server --app_conf=plugin_conf/master.app.conf - -echo Starting world... -./bin/app -d --busid=1.1.30.1 --name=world_server --app_conf=plugin_conf/world.app.conf - -echo Starting login... -./bin/app -d --busid=1.1.31.1 --name=login_server --app_conf=plugin_conf/login.app.conf - -echo Starting proxy... -./bin/app -d --busid=1.1.32.1 --name=proxy_server --app_conf=plugin_conf/proxy.app.conf - -echo Starting game... -./bin/app -d --busid=1.1.33.1 --name=game_server --app_conf=plugin_conf/game.app.conf - -echo All processes are launching... - -ps aux | grep app - -cd ../ \ No newline at end of file +#!/bin/sh +set -eu + +if [ "$#" -lt 3 ] || [ "$#" -gt 4 ]; then + echo "Usage: $0 [runtime-directory]" >&2 + exit 2 +fi +case "$1" in + Release) binary=./bin/app ;; + Debug) binary=./bin/app_d ;; + *) echo "Configuration must be Release or Debug" >&2; exit 2 ;; +esac +case "$2" in + ''|*[!a-zA-Z0-9_-]*) echo "Name must contain only letters, digits, _ or -" >&2; exit 2 ;; +esac +if [ "$#" -eq 4 ]; then + cd -- "$4" +else + CDPATH='' cd -- "$(dirname -- "$0")" +fi +[ -x "$binary" ] || { echo "Missing executable: $binary" >&2; exit 1; } +for config in "conf/$2.app.conf" conf/log.conf; do + [ -f "$config" ] || { echo "Missing configuration: $config" >&2; exit 1; } +done +export LC_ALL=C +exec "$binary" "--busid=$3" "--name=$2" "--app_conf=conf/$2.app.conf" --log_conf=conf/log.conf diff --git a/build/rund.bat b/build/rund.bat deleted file mode 100755 index 00e04dd0f..000000000 --- a/build/rund.bat +++ /dev/null @@ -1,32 +0,0 @@ -REM This file is generated by gcm tools. -REM Please DO NOT modify it manually. - -cd /d %~dp0 - -@echo off - -REM the default zone is 1001 - -echo Starting master... -start "master" bin/app_d.exe -x --busid=1.0.1.1 --name=master_server --app_conf=plugin_conf/master.app.conf -choice /t 5 /d y /n >nul - -echo Starting world... -start "world" bin/app_d.exe -x --busid=1.1.30.1 --name=world_server --app_conf=plugin_conf/world.app.conf -choice /t 5 /d y /n >nul - -echo Starting login... -start "login" bin/app_d.exe -x --busid=1.1.32.1 --name=login_server --app_conf=plugin_conf/login.app.conf -choice /t 5 /d y /n >nul - -echo Starting proxy... -start "proxy" bin/app_d.exe -x --busid=1.1.33.1 --name=proxy_server --app_conf=plugin_conf/proxy.app.conf -choice /t 5 /d y /n >nul - -echo Starting game... -start "game" bin/app_d.exe -x --busid=1.1.31.1 --name=game_server --app_conf=plugin_conf/game.app.conf -choice /t 5 /d y /n >nul - -echo All processes started... - -cd ../ \ No newline at end of file diff --git a/build/rund.sh b/build/rund.sh deleted file mode 100755 index 882c7e136..000000000 --- a/build/rund.sh +++ /dev/null @@ -1,29 +0,0 @@ -cd debug - -export LC_ALL="C" - -#The default zone is 1001 - -CHANNEL_ID=1 -ZONE_ID=1 - -echo Starting master... -./bin/app_d -d --busid=1.0.1.1 --name=master_server --app_conf=plugin_conf/master.app.conf - -echo Starting world... -./bin/app_d -d --busid=1.1.30.1 --name=world_server --app_conf=plugin_conf/world.app.conf - -echo Starting login... -./bin/app_d -d --busid=1.1.31.1 --name=login_server --app_conf=plugin_conf/login.app.conf - -echo Starting proxy... -./bin/app_d -d --busid=1.1.32.1 --name=proxy_server --app_conf=plugin_conf/proxy.app.conf - -echo Starting game... -./bin/app_d -d --busid=1.1.33.1 --name=game_server --app_conf=plugin_conf/game.app.conf - -echo All processes are launching... - -ps aux | grep app_d - -cd ../ \ No newline at end of file diff --git a/build/sample1.sh b/build/sample1.sh deleted file mode 100755 index d35eef3fe..000000000 --- a/build/sample1.sh +++ /dev/null @@ -1,13 +0,0 @@ -export LC_ALL="C" - -# The default zone is 1001 - -CHANNEL_ID=1 -ZONE_ID=1 - -echo Starting sample1... -./bin/app_d --busid=1.0.1.1 --name=sample1 --app_conf=conf/sample1.app.conf - -echo All processes are launching... - -ps aux | grep app_d diff --git a/build/sample5http_test.sh b/build/sample5http_test.sh deleted file mode 100755 index 953ddc873..000000000 --- a/build/sample5http_test.sh +++ /dev/null @@ -1,13 +0,0 @@ -export LC_ALL="C" - -# The default zone is 1001 - -CHANNEL_ID=1 -ZONE_ID=1 - -echo Starting http_server... -./bin/app_d -d --busid=1.0.1.1 --name=sample5 --app_conf=conf/Sample5.app.conf - -echo All processes are launching... - -ps aux | grep app_d diff --git a/build/vc_clear.bat b/build/vc_clear.bat deleted file mode 100755 index 1f671d376..000000000 --- a/build/vc_clear.bat +++ /dev/null @@ -1,14 +0,0 @@ -@echo off -echo clearing the building temp files, please wait for a while. - -del /f /q /s *.obj -del /f /q /s *.pdb -del /f /q /s *.idb -del /f /q /s *.pch -del /f /q /s *.ilk -del /f /q /s *.dll -del /f /q /s *.exe - - -echo clear finished -pause \ No newline at end of file diff --git a/Dockerfile b/deployment/Dockerfile similarity index 91% rename from Dockerfile rename to deployment/Dockerfile index 1b85181b8..5eb98f226 100644 --- a/Dockerfile +++ b/deployment/Dockerfile @@ -1,5 +1,5 @@ # --build-arg 来设置参数 -# docker build -t ark:escort --build-arg -f ./Dockerfile . +# From the repository root: docker build -t ark:escort -f deployment/Dockerfile . FROM docker/ark-alpine-build:latest AS Builder diff --git a/deployment/README.md b/deployment/README.md new file mode 100644 index 000000000..6c1112d06 --- /dev/null +++ b/deployment/README.md @@ -0,0 +1,29 @@ +# Deployment examples + +[简体中文](README_CN.md) + +This directory groups the existing container recipes and Kubernetes examples. +The YAML files retain their existing services, images, namespaces, settings and +resources; their in-tree plugin library stems follow the current build names. +External business-plugin names remain unchanged. Review these environment-specific +examples before use; moving them does not establish working deployment acceptance. + +Run image build commands from the repository root so `COPY .` keeps the source +checkout as its build context: + +```sh +docker build -t docker/ark-alpine-build:latest -f deployment/docker/ark-alpine-build . +docker build -t docker/ark-alpine-runtime:latest -f deployment/docker/ark-alpine-runtime . +docker build -t ark:escort -f deployment/Dockerfile . +``` + +The application Dockerfile still uses the build image for both stages. The +separate runtime recipe is retained as an existing alternative; it is not selected +by the application recipe. These recipes retain their pre-existing dependency +and image choices and have not been validated against a container engine here. + +Cluster example paths are now `deployment/ark_consul.yaml`, +`deployment/photon_config.yaml`, `deployment/photon_game_deployment.yaml` and +`deployment/photon_master_deployment.yaml`. Update external build commands that +used the root `Dockerfile`, `docker/` or `kubernetes/` paths. Runtime launch helpers +are documented in [build/README.md](../build/README.md). diff --git a/deployment/README_CN.md b/deployment/README_CN.md new file mode 100644 index 000000000..12bd7e4ca --- /dev/null +++ b/deployment/README_CN.md @@ -0,0 +1,23 @@ +# 部署示例 + +[English](README.md) + +本目录集中保存原有容器构建文件与 Kubernetes 示例。YAML 中的服务、镜像、命名空间、 +配置和资源保持原样;仓库内插件的动态库名称与当前构建名称对齐。外部业务插件名称 +保持原样。使用前需要检查目标环境;目录迁移不代表部署验收通过。 + +从仓库根目录执行镜像构建命令,使 `COPY .` 继续以源码仓库作为构建上下文: + +```sh +docker build -t docker/ark-alpine-build:latest -f deployment/docker/ark-alpine-build . +docker build -t docker/ark-alpine-runtime:latest -f deployment/docker/ark-alpine-runtime . +docker build -t ark:escort -f deployment/Dockerfile . +``` + +应用 Dockerfile 的两个阶段仍使用构建镜像。单独的 runtime 构建文件作为原有选项保留, +应用构建文件没有选用它。这些构建文件保留了原有依赖与镜像选择,本次未通过容器引擎验证。 + +集群示例路径改为 `deployment/ark_consul.yaml`、`deployment/photon_config.yaml`、 +`deployment/photon_game_deployment.yaml` 和 `deployment/photon_master_deployment.yaml`。 +外部构建命令中的根目录 `Dockerfile`、`docker/` 和 `kubernetes/` 路径需要同步更新。 +运行脚本说明见 [build/README_CN.md](../build/README_CN.md)。 diff --git a/kubernetes/ark_consul.yaml b/deployment/ark_consul.yaml similarity index 100% rename from kubernetes/ark_consul.yaml rename to deployment/ark_consul.yaml diff --git a/docker/ark-alpine-build b/deployment/docker/ark-alpine-build similarity index 100% rename from docker/ark-alpine-build rename to deployment/docker/ark-alpine-build diff --git a/docker/ark-alpine-runtime b/deployment/docker/ark-alpine-runtime similarity index 100% rename from docker/ark-alpine-runtime rename to deployment/docker/ark-alpine-runtime diff --git a/kubernetes/photon_config.yaml b/deployment/photon_config.yaml similarity index 60% rename from kubernetes/photon_config.yaml rename to deployment/photon_config.yaml index 486e2d38d..56fb6d36b 100644 --- a/kubernetes/photon_config.yaml +++ b/deployment/photon_config.yaml @@ -60,26 +60,26 @@ data: db.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\n" + name=\"ark_utility_plugin\" conf=\"\" />\n\t\t\n\t\t\n\t\t\n\t\n\n" dir.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\n" freebird.app.conf: |- - - - + + + game.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\n" http.plugin.conf: |- @@ -111,23 +111,23 @@ data: login.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\n" master.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\n" oss.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\n" + name=\"ark_utility_plugin\" conf=\"\" />\n\t\t\n\t\t\n\t\t\n\t\n\t\n\n" photon.example.app.conf: "\n\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n" photon.example.plugin.conf: |- @@ -135,9 +135,9 @@ data: photon.game.app.conf: "\n\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n" photon.game.plugin.conf: |- @@ -153,9 +153,9 @@ data: photon.master.app.conf: "\n\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n" photon.master.plugin.conf: |- @@ -173,52 +173,52 @@ data: physic.app.conf: "\n\t\n\t\t\n\t\n\n" + name=\"ark_physic_plugin\" conf=\"\" />\n\t\n\n" proxy.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\n" redis.plugin.conf: |- redis_sample.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\n\n" + name=\"ark_utility_plugin\" conf=\"\" />\n\t\t\n\t\t\n\t\n\n" remote_log.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\n" + name=\"ark_utility_plugin\" conf=\"\" />\n\t\t\n\t\t\n\t\t\n\t\n\n" router.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\n" + name=\"ark_utility_plugin\" conf=\"\" />\n\t\t\n\t\t\n\t\t\n\t\n\n" sample1.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\n\n" sample2.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\n\n" + name=\"ark_kernel_plugin\" conf=\"kernel.plugin.conf\" />\n\t\t\n\t\t\n\t\n\n" sample3.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\n\n" + name=\"ark_kernel_plugin\" conf=\"kernel.plugin.conf\" />\n\t\t\n\t\t\n\t\n\n" sample4.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\n\n" + name=\"ark_utility_plugin\" conf=\"\" />\n\t\t\n\t\t\n\t\n\n" sample5.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\n\n" + name=\"ark_utility_plugin\" conf=\"\" />\n\t\t\n\t\t\n\t\n\n" simulate.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\n" - world.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\n" + name=\"ark_physic_plugin\" conf=\"\" />\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\n" + world.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\n" kind: ConfigMap metadata: creationTimestamp: "2020-06-04T11:02:29Z" diff --git a/kubernetes/photon_game_deployment.yaml b/deployment/photon_game_deployment.yaml similarity index 100% rename from kubernetes/photon_game_deployment.yaml rename to deployment/photon_game_deployment.yaml diff --git a/kubernetes/photon_master_deployment.yaml b/deployment/photon_master_deployment.yaml similarity index 100% rename from kubernetes/photon_master_deployment.yaml rename to deployment/photon_master_deployment.yaml diff --git a/docs/project-layout.md b/docs/project-layout.md index 1a766366d..e3eebb29f 100644 --- a/docs/project-layout.md +++ b/docs/project-layout.md @@ -27,6 +27,8 @@ build's artifacts into the runtime's `bin/` directory. | `tests/network/` | Network and logging regressions | | `tests/consumer/` | An independent project consuming the public SDK | | `examples/` | Application examples | +| `build/` | Runtime configuration, resources, tools and [launch helpers](../build/README.md) | +| `deployment/` | Container recipes and Kubernetes examples | Include public headers as `` or ``. Do not add implementation directories to an application's include path. Generated diff --git a/docs/project-layout_CN.md b/docs/project-layout_CN.md index 1b68005dc..eef556230 100644 --- a/docs/project-layout_CN.md +++ b/docs/project-layout_CN.md @@ -25,6 +25,8 @@ ark 使用 C++20。核心与官方插件放在本仓库,业务插件放在应 | `tests/network/` | 网络与日志回归测试 | | `tests/consumer/` | 独立使用公开 SDK 的示例项目 | | `examples/` | 应用示例 | +| `build/` | 运行配置、资源、工具与[启动脚本](../build/README_CN.md) | +| `deployment/` | 容器构建文件与 Kubernetes 示例 | 使用 ``、`` 等公开路径包含头文件, 不需要把实现目录加入应用的包含路径。Protobuf 生成文件位于构建目录,由 `ark::proto` 提供。 diff --git a/docs/project/changelog.md b/docs/project/changelog.md index 8139213f2..f0774e1ae 100644 --- a/docs/project/changelog.md +++ b/docs/project/changelog.md @@ -1,5 +1,17 @@ # changelogs +## Unreleased + +### Upgrade notes + +- Container recipes and Kubernetes examples now live in `deployment/`. Use + `docker build -f deployment/Dockerfile .` from the repository root, and update + external references to the former `docker/` and `kubernetes/` directories. +- Runtime helpers now launch one foreground application with explicit build mode, + name and Bus ID. Replace `rund.*` and sample wrappers with `run.* Debug ...`; + stop helpers require one explicit PID. See [runtime migration](../../build/README.md#migrate-old-helper-commands) + for the removed five-service sequence and Visual Studio cleanup command. + ## version 0.9 - Fix `HeartBeatManager` remove mistake(Thanks @sks) diff --git a/docs/project/changelog_CN.md b/docs/project/changelog_CN.md index 519ebfbf9..5bbe191ce 100644 --- a/docs/project/changelog_CN.md +++ b/docs/project/changelog_CN.md @@ -1,5 +1,16 @@ # Changelogs +## 未发布 + +### 升级说明 + +- 容器构建文件与 Kubernetes 示例已集中到 `deployment/`。从仓库根目录执行 + `docker build -f deployment/Dockerfile .`,并更新外部命令中的旧 `docker/`、 + `kubernetes/` 路径。 +- 运行脚本现在按显式构建模式、名称和总线 ID 启动一个前台应用。将 `rund.*` 与示例包装 + 脚本改为 `run.* Debug ...`;停止脚本要求显式传入一个 PID。旧五服务启动顺序与 + Visual Studio 清理命令的替代方式见[运行脚本迁移](../../build/README_CN.md#迁移旧命令)。 + ### version 0.9 - Fix `HeartBeatManager` remove mistake(Thanks @sks) diff --git a/docs/reference/directory-structure.md b/docs/reference/directory-structure.md index 3c48dd4a2..f355d1b4a 100644 --- a/docs/reference/directory-structure.md +++ b/docs/reference/directory-structure.md @@ -21,6 +21,8 @@ Build artifacts belong to each CMake build directory: `cmake -S . -B out/release | `tests/network/` | Network and logging regressions | | `tests/consumer/` | An independent project consuming the public SDK | | `examples/` | Application examples | +| `build/` | Runtime configuration, resources, tools and [launch helpers](../../build/README.md) | +| `deployment/` | Container recipes and Kubernetes examples | Include public headers as `` or ``. Do not add implementation directories to an application's include path. Generated diff --git a/docs/reference/directory-structure_CN.md b/docs/reference/directory-structure_CN.md index 9519e41d2..3fd3ea075 100644 --- a/docs/reference/directory-structure_CN.md +++ b/docs/reference/directory-structure_CN.md @@ -20,6 +20,8 @@ ark 使用 C++20。核心与官方插件放在本仓库,业务插件放在应 | `tests/network/` | 网络与日志回归测试 | | `tests/consumer/` | 独立使用公开 SDK 的示例项目 | | `examples/` | 应用示例 | +| `build/` | 运行配置、资源、工具与[启动脚本](../../build/README_CN.md) | +| `deployment/` | 容器构建文件与 Kubernetes 示例 | 使用 ``、`` 等公开路径包含头文件, 不需要把实现目录加入应用的包含路径。Protobuf 生成文件位于构建目录,由 `ark::proto` 提供。 diff --git a/tests/runtime/scripts.test.mjs b/tests/runtime/scripts.test.mjs new file mode 100644 index 000000000..ab2a8090c --- /dev/null +++ b/tests/runtime/scripts.test.mjs @@ -0,0 +1,83 @@ +import assert from 'node:assert/strict'; +import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, realpathSync, rmSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join, resolve } from 'node:path'; +import { spawnSync } from 'node:child_process'; +import { test } from 'node:test'; + +const root = resolve(import.meta.dirname, '../..'); +const run = join(root, 'build/run.sh'); +const stop = join(root, 'build/kill.sh'); + +function fixture(t) { + const dir = mkdtempSync(join(tmpdir(), 'ark runtime ')); + t.after(() => rmSync(dir, { recursive: true, force: true })); + mkdirSync(join(dir, 'bin')); + mkdirSync(join(dir, 'conf')); + writeFileSync(join(dir, 'conf/sample1.app.conf'), ''); + writeFileSync(join(dir, 'conf/log.conf'), ''); + const binary = '#!/bin/sh\nprintf "%s\\n" "$PWD" "$LC_ALL" "$0" "$@"\nexit 17\n'; + for (const name of ['app', 'app_d']) { + writeFileSync(join(dir, 'bin', name), binary, { mode: 0o755 }); + } + return dir; +} + +for (const [configuration, binary] of [['Release', 'app'], ['Debug', 'app_d']]) { + test(`${configuration} selects one application in the explicit runtime directory`, (t) => { + const dir = fixture(t); + const result = spawnSync('sh', [run, configuration, 'sample1', '1.0.1.1', dir], { + cwd: tmpdir(), encoding: 'utf8', + }); + assert.equal(result.status, 17, result.stderr); + const [cwd, locale, executable, ...args] = result.stdout.trim().split('\n'); + assert.equal(realpathSync(cwd), realpathSync(dir)); + assert.equal(locale, 'C'); + assert.equal(realpathSync(resolve(cwd, executable)), realpathSync(join(dir, 'bin', binary))); + assert.deepEqual(args, [ + '--busid=1.0.1.1', '--name=sample1', '--app_conf=conf/sample1.app.conf', + '--log_conf=conf/log.conf', + ]); + }); +} + +test('default runtime is the script directory and ignores the caller working directory', (t) => { + const dir = fixture(t); + writeFileSync(join(dir, 'run.sh'), readFileSync(run)); + const result = spawnSync('sh', [join(dir, 'run.sh'), 'Release', 'sample1', '1.0.1.1'], { + cwd: tmpdir(), encoding: 'utf8', + }); + assert.equal(result.status, 17, result.stderr); + assert.match(result.stdout, /--app_conf=conf\/sample1\.app\.conf/); +}); + +test('missing configuration or executable fails before launching', (t) => { + const dir = fixture(t); + rmSync(join(dir, 'conf/log.conf')); + let result = spawnSync('sh', [run, 'Release', 'sample1', '1.0.1.1', dir], { encoding: 'utf8' }); + assert.equal(result.status, 1); + assert.match(result.stderr, /Missing configuration/); + rmSync(join(dir, 'bin/app')); + result = spawnSync('sh', [run, 'Release', 'sample1', '1.0.1.1', dir], { encoding: 'utf8' }); + assert.equal(result.status, 1); + assert.match(result.stderr, /Missing executable/); +}); + +test('invalid arguments are rejected before starting or stopping a process', () => { + for (const args of [[], ['Other', 'sample1', '1.0.1.1'], ['Release', '../sample1', '1.0.1.1']]) { + assert.equal(spawnSync('sh', [run, ...args]).status, 2); + } + for (const args of [[], ['0'], ['1'], ['-1'], ['00123'], ['all'], ['123', '456']]) { + assert.equal(spawnSync('sh', [stop, ...args]).status, 2); + } +}); + +test('stop refuses another executable without sending a signal', (t) => { + const dir = fixture(t); + writeFileSync(join(dir, 'bin/ps'), '#!/bin/sh\nprintf "unrelated-service\\n"\n', { mode: 0o755 }); + const result = spawnSync('sh', [stop, '12345'], { + env: { ...process.env, PATH: `${join(dir, 'bin')}:${process.env.PATH}` }, encoding: 'utf8', + }); + assert.equal(result.status, 1); + assert.match(result.stderr, /refusing to stop/); +}); From d464c04707f88d1c75b1d7ab8cbe740061f48df3 Mon Sep 17 00:00:00 2001 From: nick Date: Tue, 20 Oct 2026 09:52:04 +0800 Subject: [PATCH 2/2] refactor(plugins)!: standardize shared-library names Use lowercase snake_case library stems and targets for official, server and sample plugins. Update manifests and current documentation, retain platform extensions and Debug postfixes, and reject mixed-case declarations. BREAKING CHANGE: update legacy AF*Plugin and Sample*Plugin build targets and manifest library names to the corresponding snake_case stems. --- AGENTS.md | 4 + build/conf/db.app.conf | 8 +- build/conf/dir.app.conf | 10 +- build/conf/freebird.app.conf | 6 +- build/conf/game.app.conf | 12 +- build/conf/http_client_sample.app.conf | 10 +- build/conf/login.app.conf | 10 +- build/conf/master.app.conf | 10 +- build/conf/mysql_sample.app.conf | 4 +- build/conf/oss.app.conf | 8 +- build/conf/physic.app.conf | 2 +- build/conf/proxy.app.conf | 12 +- build/conf/realm.example.app.conf | 6 +- build/conf/realm.game.app.conf | 8 +- build/conf/realm.master.app.conf | 6 +- build/conf/redis_sample.app.conf | 6 +- build/conf/remote_log.app.conf | 8 +- build/conf/router.app.conf | 8 +- build/conf/sample1.app.conf | 4 +- build/conf/sample1.app.toml | 4 +- build/conf/sample2.app.conf | 6 +- build/conf/sample3.app.conf | 6 +- build/conf/sample4.app.conf | 6 +- build/conf/sample5.app.conf | 6 +- build/conf/simulate.app.conf | 12 +- build/conf/terraria.game.app.conf | 8 +- build/conf/world.app.conf | 12 +- docs/concepts/application-architecture.md | 6 +- docs/concepts/application-architecture_CN.md | 6 +- docs/get-started/quick-start.md | 4 +- docs/get-started/quick-start_CN.md | 4 +- docs/guides/applications.md | 18 ++- docs/guides/applications_CN.md | 18 ++- docs/reference/build-options.md | 2 +- docs/reference/build-options_CN.md | 2 +- docs/service-manifests.md | 12 +- docs/service-manifests_CN.md | 12 +- examples/CMakeLists.txt | 7 +- examples/http_client/CMakeLists.txt | 2 +- examples/mysql_sample/CMakeLists.txt | 2 +- examples/redis_sample/CMakeLists.txt | 2 +- examples/sample1/CMakeLists.txt | 2 +- examples/sample2/CMakeLists.txt | 2 +- examples/sample3/CMakeLists.txt | 2 +- examples/sample4/CMakeLists.txt | 4 +- examples/sample5/CMakeLists.txt | 2 +- include/ark/plugin_manager.hpp | 5 +- kubernetes/photon_config.yaml | 122 +++++++++---------- src/plugins/CMakeLists.txt | 7 ++ src/plugins/bus/CMakeLists.txt | 8 +- src/plugins/consul/CMakeLists.txt | 6 +- src/plugins/etcd_client/CMakeLists.txt | 2 +- src/plugins/http/CMakeLists.txt | 2 +- src/plugins/kafka/CMakeLists.txt | 4 +- src/plugins/kernel/CMakeLists.txt | 6 +- src/plugins/mysql/CMakeLists.txt | 2 +- src/plugins/net/CMakeLists.txt | 6 +- src/plugins/osssdk/CMakeLists.txt | 2 +- src/plugins/physic/CMakeLists.txt | 6 +- src/plugins/redis/CMakeLists.txt | 4 +- src/plugins/utility/CMakeLists.txt | 6 +- src/server/CMakeLists.txt | 9 +- src/server/dir/CMakeLists.txt | 2 +- src/server/game/CMakeLists.txt | 2 +- src/server/login/CMakeLists.txt | 2 +- src/server/master/CMakeLists.txt | 2 +- src/server/proxy/CMakeLists.txt | 2 +- src/server/router/CMakeLists.txt | 2 +- src/server/simulate/CMakeLists.txt | 2 +- src/server/world/CMakeLists.txt | 2 +- tests/ci/plugin-names.test.mjs | 36 ++++++ tests/core/application_manifest.cpp | 4 +- 72 files changed, 314 insertions(+), 250 deletions(-) create mode 100644 tests/ci/plugin-names.test.mjs diff --git a/AGENTS.md b/AGENTS.md index 86316890d..b88509f89 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -67,6 +67,10 @@ branch or worktree when the existing checkout contains uncommitted changes. - Use C++20 and consistent `snake_case` names, including types, functions and members (`ark::plugin_manager`, `find_module()`, `module_name_`). Do not manually edit generated protobuf output; change the schema or generation source. +- Use lowercase `snake_case` for plugin CMake targets and shared-library stems, + including official, server and sample plugins (`ark_mysql_plugin`, + `sample1_plugin`). Keep application manifests, launch scripts and documentation + aligned with the generated names; retain platform extensions and Debug `_d`. - Follow `.clang-format` and the repository formatting scripts with clang-format 18. Keep function opening braces on the declaration line, expand short function bodies, and use braces for control statements. diff --git a/build/conf/db.app.conf b/build/conf/db.app.conf index 4df670a9d..612ccff67 100755 --- a/build/conf/db.app.conf +++ b/build/conf/db.app.conf @@ -1,8 +1,8 @@ - - - - + + + + diff --git a/build/conf/dir.app.conf b/build/conf/dir.app.conf index 304220ab3..675b4c02e 100755 --- a/build/conf/dir.app.conf +++ b/build/conf/dir.app.conf @@ -1,9 +1,9 @@ - - - - - + + + + + diff --git a/build/conf/freebird.app.conf b/build/conf/freebird.app.conf index dc5f60797..113e61b16 100644 --- a/build/conf/freebird.app.conf +++ b/build/conf/freebird.app.conf @@ -1,6 +1,6 @@ - - - + + + diff --git a/build/conf/game.app.conf b/build/conf/game.app.conf index 82b7d0115..2b8def3cb 100755 --- a/build/conf/game.app.conf +++ b/build/conf/game.app.conf @@ -1,11 +1,11 @@ - - - - - - + + + + + + diff --git a/build/conf/http_client_sample.app.conf b/build/conf/http_client_sample.app.conf index 0b0250617..39342eb1b 100644 --- a/build/conf/http_client_sample.app.conf +++ b/build/conf/http_client_sample.app.conf @@ -1,9 +1,9 @@ - - - - - + + + + + diff --git a/build/conf/login.app.conf b/build/conf/login.app.conf index 252e72f47..c33856e6c 100755 --- a/build/conf/login.app.conf +++ b/build/conf/login.app.conf @@ -1,10 +1,10 @@ - - - - - + + + + + diff --git a/build/conf/master.app.conf b/build/conf/master.app.conf index 9c2d76479..80b821aea 100755 --- a/build/conf/master.app.conf +++ b/build/conf/master.app.conf @@ -1,10 +1,10 @@ - - - - - + + + + + diff --git a/build/conf/mysql_sample.app.conf b/build/conf/mysql_sample.app.conf index a0d6d2dc1..16df5a18c 100644 --- a/build/conf/mysql_sample.app.conf +++ b/build/conf/mysql_sample.app.conf @@ -1,6 +1,6 @@ - - + + diff --git a/build/conf/oss.app.conf b/build/conf/oss.app.conf index 70fe8e595..504fafba6 100755 --- a/build/conf/oss.app.conf +++ b/build/conf/oss.app.conf @@ -1,9 +1,9 @@ - - - - + + + + diff --git a/build/conf/physic.app.conf b/build/conf/physic.app.conf index 5843796ff..f83c4707b 100644 --- a/build/conf/physic.app.conf +++ b/build/conf/physic.app.conf @@ -1,5 +1,5 @@ - + diff --git a/build/conf/proxy.app.conf b/build/conf/proxy.app.conf index e8d20db59..4a05e50de 100755 --- a/build/conf/proxy.app.conf +++ b/build/conf/proxy.app.conf @@ -1,10 +1,10 @@ - - - - - - + + + + + + diff --git a/build/conf/realm.example.app.conf b/build/conf/realm.example.app.conf index 2aaf263c8..3235e7396 100644 --- a/build/conf/realm.example.app.conf +++ b/build/conf/realm.example.app.conf @@ -1,9 +1,9 @@ - - - + + + \ No newline at end of file diff --git a/build/conf/realm.game.app.conf b/build/conf/realm.game.app.conf index bcfb21652..45cfac228 100644 --- a/build/conf/realm.game.app.conf +++ b/build/conf/realm.game.app.conf @@ -1,10 +1,10 @@ - - - + + + - + \ No newline at end of file diff --git a/build/conf/realm.master.app.conf b/build/conf/realm.master.app.conf index 2e64317d3..a614e657b 100644 --- a/build/conf/realm.master.app.conf +++ b/build/conf/realm.master.app.conf @@ -1,9 +1,9 @@ - - - + + + \ No newline at end of file diff --git a/build/conf/redis_sample.app.conf b/build/conf/redis_sample.app.conf index 91325771c..330f950ea 100644 --- a/build/conf/redis_sample.app.conf +++ b/build/conf/redis_sample.app.conf @@ -1,7 +1,7 @@ - - - + + + diff --git a/build/conf/remote_log.app.conf b/build/conf/remote_log.app.conf index 4df670a9d..612ccff67 100755 --- a/build/conf/remote_log.app.conf +++ b/build/conf/remote_log.app.conf @@ -1,8 +1,8 @@ - - - - + + + + diff --git a/build/conf/router.app.conf b/build/conf/router.app.conf index 4df670a9d..612ccff67 100755 --- a/build/conf/router.app.conf +++ b/build/conf/router.app.conf @@ -1,8 +1,8 @@ - - - - + + + + diff --git a/build/conf/sample1.app.conf b/build/conf/sample1.app.conf index d5c00eb1c..3a7822bc8 100755 --- a/build/conf/sample1.app.conf +++ b/build/conf/sample1.app.conf @@ -1,6 +1,6 @@ - - + + diff --git a/build/conf/sample1.app.toml b/build/conf/sample1.app.toml index 6457bfcf3..4ce08b0ce 100644 --- a/build/conf/sample1.app.toml +++ b/build/conf/sample1.app.toml @@ -3,8 +3,8 @@ plugin_library_dir = "bin/" plugin_config_dir = "conf/" [[plugins]] -name = "AFUtilityPlugin" +name = "ark_utility_plugin" config = "" [[plugins]] -name = "Sample1Plugin" +name = "sample1_plugin" diff --git a/build/conf/sample2.app.conf b/build/conf/sample2.app.conf index 3612b3312..5346734d8 100755 --- a/build/conf/sample2.app.conf +++ b/build/conf/sample2.app.conf @@ -1,7 +1,7 @@ - - - + + + diff --git a/build/conf/sample3.app.conf b/build/conf/sample3.app.conf index fba58dc22..c96df84c4 100755 --- a/build/conf/sample3.app.conf +++ b/build/conf/sample3.app.conf @@ -1,7 +1,7 @@ - - - + + + diff --git a/build/conf/sample4.app.conf b/build/conf/sample4.app.conf index 1ee68d045..d5bd887c3 100644 --- a/build/conf/sample4.app.conf +++ b/build/conf/sample4.app.conf @@ -1,7 +1,7 @@ - - - + + + diff --git a/build/conf/sample5.app.conf b/build/conf/sample5.app.conf index cd56ffcea..c7f6dbcc1 100644 --- a/build/conf/sample5.app.conf +++ b/build/conf/sample5.app.conf @@ -1,7 +1,7 @@ - - - + + + diff --git a/build/conf/simulate.app.conf b/build/conf/simulate.app.conf index b4603589e..86a41f1b2 100644 --- a/build/conf/simulate.app.conf +++ b/build/conf/simulate.app.conf @@ -1,10 +1,10 @@ - - - - - - + + + + + + diff --git a/build/conf/terraria.game.app.conf b/build/conf/terraria.game.app.conf index fc4b866b9..ea664f12b 100644 --- a/build/conf/terraria.game.app.conf +++ b/build/conf/terraria.game.app.conf @@ -1,9 +1,9 @@ - - - - + + + + diff --git a/build/conf/world.app.conf b/build/conf/world.app.conf index 7a77ac2f2..4b3c0eaab 100755 --- a/build/conf/world.app.conf +++ b/build/conf/world.app.conf @@ -1,11 +1,11 @@ - - - - - - + + + + + + diff --git a/docs/concepts/application-architecture.md b/docs/concepts/application-architecture.md index da14ba200..723420006 100644 --- a/docs/concepts/application-architecture.md +++ b/docs/concepts/application-architecture.md @@ -11,8 +11,8 @@ The launcher receives `--busid`, `--name` and `--app_conf`. The application mani ```xml - - + + ``` @@ -21,7 +21,7 @@ New application manifests can use TOML; the equivalent [sample1.app.toml](https: The loader loads each library and calls its exported plugin entry. `sample1_plugin::install()` registers `sample1_module`; the utility plugin provides services such as timers. A module resolves those services with `find_module()`, rather than creating another copy of the utility plugin. -The manifest's names are runtime library names. Existing `AFUtilityPlugin` / `Sample1Plugin` names do not follow the C++ class spelling and must match the built artifacts. Debug libraries use the configured `_d` postfix. An empty `conf` supplies no configuration filename; the loader itself does not parse plugin-specific content. +The manifest's names are runtime library names. Existing `ark_utility_plugin` / `sample1_plugin` names do not follow the C++ class spelling and must match the built artifacts. Debug libraries use the configured `_d` postfix. An empty `conf` supplies no configuration filename; the loader itself does not parse plugin-specific content. ## Paths and a runnable starting point diff --git a/docs/concepts/application-architecture_CN.md b/docs/concepts/application-architecture_CN.md index 6057773da..2c2957103 100644 --- a/docs/concepts/application-architecture_CN.md +++ b/docs/concepts/application-architecture_CN.md @@ -11,8 +11,8 @@ ark 应用是由选定插件库组成的进程。一个插件可以注册多个 ```xml - - + + ``` @@ -21,7 +21,7 @@ ark 应用是由选定插件库组成的进程。一个插件可以注册多个 加载器依次加载库并调用导出的插件入口。`sample1_plugin::install()` 注册 `sample1_module`,Utility 插件提供定时器等服务。模块通过 `find_module()` 获取这些服务,不需要再创建一份 Utility 插件。 -清单名称是运行时库名。现有 `AFUtilityPlugin`、`Sample1Plugin` 不等同于 C++ 类名拼写,必须与构建产物匹配。Debug 库使用配置的 `_d` 后缀。空 `conf` 不提供配置文件名,加载器本身不解析插件专属内容。 +清单名称是运行时库名。现有 `ark_utility_plugin`、`sample1_plugin` 不等同于 C++ 类名拼写,必须与构建产物匹配。Debug 库使用配置的 `_d` 后缀。空 `conf` 不提供配置文件名,加载器本身不解析插件专属内容。 ## 路径与运行入口 diff --git a/docs/get-started/quick-start.md b/docs/get-started/quick-start.md index 272215190..180ad786a 100644 --- a/docs/get-started/quick-start.md +++ b/docs/get-started/quick-start.md @@ -1,6 +1,6 @@ # Quick start -Run Sample1 to check that the application can load plugins and enter the module lifecycle. It uses `AFUtilityPlugin` and `Sample1Plugin`; it does not require Consul, a database service or Excel configuration generation. +Run Sample1 to check that the application can load plugins and enter the module lifecycle. It uses `ark_utility_plugin` and `sample1_plugin`; it does not require Consul, a database service or Excel configuration generation. ## Build the application and plugins @@ -30,7 +30,7 @@ The required runtime files are: ```text run/sample1/ -├── bin/ app + AFUtilityPlugin + Sample1Plugin from the same build +├── bin/ app + ark_utility_plugin + sample1_plugin from the same build └── conf/ ├── sample1.app.conf └── log.conf diff --git a/docs/get-started/quick-start_CN.md b/docs/get-started/quick-start_CN.md index 4c2bde2a0..59b90fd98 100644 --- a/docs/get-started/quick-start_CN.md +++ b/docs/get-started/quick-start_CN.md @@ -1,6 +1,6 @@ # 快速开始 -运行 Sample1,确认应用能够加载插件并进入模块生命周期。它只使用 `AFUtilityPlugin` 和 `Sample1Plugin`,不需要 Consul、数据库服务或 Excel 配置生成步骤。 +运行 Sample1,确认应用能够加载插件并进入模块生命周期。它只使用 `ark_utility_plugin` 和 `sample1_plugin`,不需要 Consul、数据库服务或 Excel 配置生成步骤。 ## 编译应用和插件 @@ -30,7 +30,7 @@ Copy-Item build/conf/sample1.app.conf, build/conf/log.conf run/sample1/conf/ ```text run/sample1/ -├── bin/ 同一次构建的 app、AFUtilityPlugin 和 Sample1Plugin +├── bin/ 同一次构建的 app、ark_utility_plugin 和 sample1_plugin └── conf/ ├── sample1.app.conf └── log.conf diff --git a/docs/guides/applications.md b/docs/guides/applications.md index 3d6ee2908..e74a9e7eb 100644 --- a/docs/guides/applications.md +++ b/docs/guides/applications.md @@ -29,7 +29,7 @@ Relative paths resolve from the process working directory. Moving the executable | --- | --- | --- | | Application manifest | `--app_conf` | `conf/sample1.app.conf` | | Logger settings | `--log_conf`, or its default | `conf/log.conf` | -| Plugin libraries | TOML `plugin_library_dir` or XML `plugin_lib_dir`, plus the library filename | `bin/Sample1Plugin.dylib` on macOS Release | +| Plugin libraries | TOML `plugin_library_dir` or XML `plugin_lib_dir`, plus the library filename | `bin/sample1_plugin.dylib` on macOS Release | | Per-plugin settings | TOML `plugin_config_dir` + `config`, or XML `plugin_conf_dir` + `conf` | `conf/my-plugin.conf` when the filename is `my-plugin.conf` | | Kernel metadata and configuration | The Kernel's `resource/` directory | `resource/meta/entity_class.config`, `resource/server/item.config` | @@ -45,14 +45,22 @@ plugin_library_dir = "bin/" plugin_config_dir = "conf/" [[plugins]] -name = "AFUtilityPlugin" +name = "ark_utility_plugin" [[plugins]] -name = "Sample1Plugin" +name = "sample1_plugin" ``` Pass `--app_conf=conf/sample1.app.toml` to select it. The application table is required; directory fields are optional strings. Each plugin requires a unique, nonempty `name`; its optional `config` string selects a per-plugin file. See [Application manifests](../service-manifests.md) for validation rules and format boundaries. Bus, logger and business-resource configuration formats are unchanged. +### Plugin library names + +Plugin targets and library stems use lowercase `snake_case`: `ark_utility_plugin`, +`ark_mysql_plugin` and `sample1_plugin`. Manifest names must match these stems; +the loader adds the platform extension and the Debug `_d` suffix automatically. +Update existing manifests and build commands that use `AFUtilityPlugin`, +`AFMysqlPlugin` or `Sample1Plugin`; the old library filenames are no longer emitted. + ### Existing XML manifests The checked-in [Sample1 manifest](https://github.com/OpenArkStudio/ark/blob/main/build/conf/sample1.app.conf) loads a utility plugin and one sample plugin: @@ -60,8 +68,8 @@ The checked-in [Sample1 manifest](https://github.com/OpenArkStudio/ark/blob/main ```xml - - + + ``` diff --git a/docs/guides/applications_CN.md b/docs/guides/applications_CN.md index e12914b7b..3568f627d 100644 --- a/docs/guides/applications_CN.md +++ b/docs/guides/applications_CN.md @@ -29,7 +29,7 @@ | --- | --- | --- | | 应用配置 | `--app_conf` | `conf/sample1.app.conf` | | 日志配置 | `--log_conf`,或使用默认值 | `conf/log.conf` | -| 插件动态库 | TOML `plugin_library_dir` 或 XML `plugin_lib_dir` 加动态库文件名 | macOS Release 使用 `bin/Sample1Plugin.dylib` | +| 插件动态库 | TOML `plugin_library_dir` 或 XML `plugin_lib_dir` 加动态库文件名 | macOS Release 使用 `bin/sample1_plugin.dylib` | | 插件配置 | TOML `plugin_config_dir` + `config`,或 XML `plugin_conf_dir` + `conf` | 配置文件名为 `my-plugin.conf` 时,对应 `conf/my-plugin.conf` | | Kernel 元数据和配置 | Kernel 使用的 `resource/` 目录 | `resource/meta/entity_class.config`、`resource/server/item.config` | @@ -45,14 +45,22 @@ plugin_library_dir = "bin/" plugin_config_dir = "conf/" [[plugins]] -name = "AFUtilityPlugin" +name = "ark_utility_plugin" [[plugins]] -name = "Sample1Plugin" +name = "sample1_plugin" ``` 通过 `--app_conf=conf/sample1.app.toml` 选择该文件。`application` 表必须存在,目录字段为可省略的字符串。每个插件的 `name` 必须非空且唯一;可选的 `config` 字符串指定插件配置文件。字段校验和格式边界见[应用配置清单](../service-manifests_CN.md)。Bus、日志和业务资源配置格式保持现有约定。 +### 插件库命名 + +插件构建目标和库文件名统一使用小写 `snake_case`,例如 `ark_utility_plugin`、 +`ark_mysql_plugin` 和 `sample1_plugin`。配置中的插件名必须与库文件名一致; +加载器自动添加平台扩展名和 Debug 的 `_d` 后缀。 +已有配置和构建命令中的 `AFUtilityPlugin`、`AFMysqlPlugin`、`Sample1Plugin` 需要更新, +构建不再生成这些旧文件名。 + ### 兼容已有 XML 配置 仓库中的 [Sample1 应用配置](https://github.com/OpenArkStudio/ark/blob/main/build/conf/sample1.app.conf)加载工具插件和一个示例插件: @@ -60,8 +68,8 @@ name = "Sample1Plugin" ```xml - - + + ``` diff --git a/docs/reference/build-options.md b/docs/reference/build-options.md index bcbeec72a..bee2fae90 100644 --- a/docs/reference/build-options.md +++ b/docs/reference/build-options.md @@ -33,5 +33,5 @@ With the dependencies from the installation guide available, build both optional ```sh cmake -S . -B build -DARK_BUILD_PLUGIN_MYSQL=ON -DARK_BUILD_PLUGIN_REDIS=ON -DARKNET_ENABLE_SSL=ON -cmake --build build --target AFMysqlPlugin AFRedisPlugin +cmake --build build --target ark_mysql_plugin ark_redis_plugin ``` diff --git a/docs/reference/build-options_CN.md b/docs/reference/build-options_CN.md index 51def3c96..e5818daab 100644 --- a/docs/reference/build-options_CN.md +++ b/docs/reference/build-options_CN.md @@ -33,5 +33,5 @@ ```sh cmake -S . -B build -DARK_BUILD_PLUGIN_MYSQL=ON -DARK_BUILD_PLUGIN_REDIS=ON -DARKNET_ENABLE_SSL=ON -cmake --build build --target AFMysqlPlugin AFRedisPlugin +cmake --build build --target ark_mysql_plugin ark_redis_plugin ``` diff --git a/docs/service-manifests.md b/docs/service-manifests.md index 8f2560b97..6c1020236 100644 --- a/docs/service-manifests.md +++ b/docs/service-manifests.md @@ -12,11 +12,11 @@ plugin_library_dir = "bin/" plugin_config_dir = "conf/" [[plugins]] -name = "AFUtilityPlugin" +name = "ark_utility_plugin" config = "" [[plugins]] -name = "Sample1Plugin" +name = "sample1_plugin" ``` | Field | Type and default | Meaning | @@ -25,7 +25,7 @@ name = "Sample1Plugin" | `application.plugin_library_dir` | String, `""` | Prefix for plugin library names. | | `application.plugin_config_dir` | String, `""` | Prefix for plugin configuration names. | | `plugins` | Array of tables, empty | Omission and a top-level `plugins = []` both select no plugins. | -| `plugins[].name` | Required nonempty string | Unique library stem, such as `Sample1Plugin`; platform extensions and the Debug `_d` suffix remain automatic. | +| `plugins[].name` | Required nonempty string | Unique library stem, such as `sample1_plugin`; platform extensions and the Debug `_d` suffix remain automatic. | | `plugins[].config` | String, `""` | Configuration filename; omission and `""` retain empty-configuration behavior. | Unknown fields, incorrect types, duplicate or empty plugin names, invalid TOML/UTF-8 and embedded NUL characters are rejected before plugin startup. Diagnostics contain the path and available line/column, without printing configuration values. @@ -36,7 +36,7 @@ The order of `[[plugins]]` entries does **not** define module initialization ord ## Run sample1 -Follow the [application build instructions](networking.md) to build `app`, `AFUtilityPlugin` and `Sample1Plugin`. For a build directory named `out`, run these commands from the repository root: +Follow the [application build instructions](networking.md) to build `app`, `ark_utility_plugin` and `sample1_plugin`. For a build directory named `out`, run these commands from the repository root: ```sh cp -R build/conf out/conf @@ -53,8 +53,8 @@ The existing wrapper and attributes remain valid: ```xml - - + + ``` diff --git a/docs/service-manifests_CN.md b/docs/service-manifests_CN.md index e2239ad30..a0bcbb51c 100644 --- a/docs/service-manifests_CN.md +++ b/docs/service-manifests_CN.md @@ -12,11 +12,11 @@ plugin_library_dir = "bin/" plugin_config_dir = "conf/" [[plugins]] -name = "AFUtilityPlugin" +name = "ark_utility_plugin" config = "" [[plugins]] -name = "Sample1Plugin" +name = "sample1_plugin" ``` | 字段 | 类型及默认值 | 含义 | @@ -25,7 +25,7 @@ name = "Sample1Plugin" | `application.plugin_library_dir` | 字符串,`""` | 插件库名称前的路径前缀。 | | `application.plugin_config_dir` | 字符串,`""` | 插件配置文件名的路径前缀。 | | `plugins` | 表数组,空 | 省略或在顶层设置 `plugins = []` 均表示不加载插件。 | -| `plugins[].name` | 非空字符串,必填 | 唯一的动态库名称,例如 `Sample1Plugin`,不含扩展名;平台后缀及 Debug 的 `_d` 后缀仍由加载器补充。 | +| `plugins[].name` | 非空字符串,必填 | 唯一的动态库名称,例如 `sample1_plugin`,不含扩展名;平台后缀及 Debug 的 `_d` 后缀仍由加载器补充。 | | `plugins[].config` | 字符串,`""` | 配置文件名;省略或设置 `""` 均保留原有的空配置语义。 | 类型错误、未知字段、重复或空插件名、无效 TOML / UTF-8 和嵌入的 NUL 字符都会在插件启动前被拒绝。错误信息包含清单路径及可用的行列位置,不输出配置值。 @@ -36,7 +36,7 @@ name = "Sample1Plugin" ## 运行 sample1 -按[应用构建说明](networking_CN.md)构建 `app`、`AFUtilityPlugin` 和 `Sample1Plugin`。假设构建目录为 `out`,从仓库根目录执行: +按[应用构建说明](networking_CN.md)构建 `app`、`ark_utility_plugin` 和 `sample1_plugin`。假设构建目录为 `out`,从仓库根目录执行: ```sh cp -R build/conf out/conf @@ -53,8 +53,8 @@ Debug 构建使用 `app_d`。日志仍读取 `conf/log.conf`;总线、日志 ```xml - - + + ``` diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 6ef761b2a..834ffaf49 100755 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,5 +1,6 @@ #Define server plugin building macro function(BUILD_PLUGIN_MACRO project_name) + ark_validate_plugin_name("${project_name}") aux_source_directory(. PLUGIN_SRC) if(UNIX AND (NOT APPLE)) @@ -15,17 +16,17 @@ function(BUILD_PLUGIN_MACRO project_name) if(WIN32) add_definitions(-D_USRDLL) - target_link_libraries(${project_name} + target_link_libraries(${project_name} debug AFProto_d.lib optimized AFProto.lib ${PROTOBUF_LIBRARIES}) elseif(APPLE) - target_link_libraries(${project_name} + target_link_libraries(${project_name} debug ${BIN_OUTPUT_DIR}/AFProto_d.a optimized ${BIN_OUTPUT_DIR}/AFProto.a ${PROTOBUF_LIBRARIES}) else(UNIX) - target_link_libraries(${project_name} + target_link_libraries(${project_name} debug :AFProto_d.a optimized :AFProto.a ${PROTOBUF_LIBRARIES} diff --git a/examples/http_client/CMakeLists.txt b/examples/http_client/CMakeLists.txt index 4310d2d9f..3fb85b3ed 100644 --- a/examples/http_client/CMakeLists.txt +++ b/examples/http_client/CMakeLists.txt @@ -1 +1 @@ -BUILD_PLUGIN_MACRO(HttpClientSamplePlugin) \ No newline at end of file +BUILD_PLUGIN_MACRO(http_client_sample_plugin) \ No newline at end of file diff --git a/examples/mysql_sample/CMakeLists.txt b/examples/mysql_sample/CMakeLists.txt index 7d9562737..ec7f3b4c7 100644 --- a/examples/mysql_sample/CMakeLists.txt +++ b/examples/mysql_sample/CMakeLists.txt @@ -1 +1 @@ -BUILD_PLUGIN_MACRO(MysqlSamplePlugin) +BUILD_PLUGIN_MACRO(mysql_sample_plugin) diff --git a/examples/redis_sample/CMakeLists.txt b/examples/redis_sample/CMakeLists.txt index 4dcafba35..c486e2ac8 100644 --- a/examples/redis_sample/CMakeLists.txt +++ b/examples/redis_sample/CMakeLists.txt @@ -1 +1 @@ -BUILD_PLUGIN_MACRO(RedisSamplePlugin arknet::arknet) +BUILD_PLUGIN_MACRO(redis_sample_plugin arknet::arknet) diff --git a/examples/sample1/CMakeLists.txt b/examples/sample1/CMakeLists.txt index b3dd864a0..ccfd326f3 100755 --- a/examples/sample1/CMakeLists.txt +++ b/examples/sample1/CMakeLists.txt @@ -1 +1 @@ -BUILD_PLUGIN_MACRO("Sample1Plugin") \ No newline at end of file +BUILD_PLUGIN_MACRO("sample1_plugin") \ No newline at end of file diff --git a/examples/sample2/CMakeLists.txt b/examples/sample2/CMakeLists.txt index b596d3130..f2fccb67e 100755 --- a/examples/sample2/CMakeLists.txt +++ b/examples/sample2/CMakeLists.txt @@ -1 +1 @@ -BUILD_PLUGIN_MACRO("Sample2Plugin") \ No newline at end of file +BUILD_PLUGIN_MACRO("sample2_plugin") \ No newline at end of file diff --git a/examples/sample3/CMakeLists.txt b/examples/sample3/CMakeLists.txt index 1bacb9346..86e965753 100755 --- a/examples/sample3/CMakeLists.txt +++ b/examples/sample3/CMakeLists.txt @@ -1 +1 @@ -BUILD_PLUGIN_MACRO("Sample3Plugin") \ No newline at end of file +BUILD_PLUGIN_MACRO("sample3_plugin") \ No newline at end of file diff --git a/examples/sample4/CMakeLists.txt b/examples/sample4/CMakeLists.txt index f7c043699..ff108fd50 100644 --- a/examples/sample4/CMakeLists.txt +++ b/examples/sample4/CMakeLists.txt @@ -1,4 +1,4 @@ include_directories( ${ROOT_DIR}/3rdparty/physX/include) - -BUILD_PLUGIN_MACRO("Sample4Plugin") \ No newline at end of file + +BUILD_PLUGIN_MACRO("sample4_plugin") \ No newline at end of file diff --git a/examples/sample5/CMakeLists.txt b/examples/sample5/CMakeLists.txt index 2c0093e52..06ddcd2ba 100644 --- a/examples/sample5/CMakeLists.txt +++ b/examples/sample5/CMakeLists.txt @@ -1,2 +1,2 @@ include_directories(${ROOT_DIR}/3rdparty/BeastHttp/BeastHttp/include) -BUILD_PLUGIN_MACRO(Sample5Plugin) \ No newline at end of file +BUILD_PLUGIN_MACRO(sample5_plugin) \ No newline at end of file diff --git a/include/ark/plugin_manager.hpp b/include/ark/plugin_manager.hpp index 862d2de57..8d361ada4 100644 --- a/include/ark/plugin_manager.hpp +++ b/include/ark/plugin_manager.hpp @@ -375,9 +375,8 @@ class plugin_manager final : private noncopyable protected: void register_plugin(plugin* plugin, std::string const& plugin_name, std::string const& runtime_plugin_name) { check_registration(); - // e.g. plugin_name = class ark::AFKernelPlugin - // It's a runtime name, so we cannot use it to find the plugin.conf file. - //std::string plugin_name = plugin->GetPluginName(); + // The library stem selects configuration; the runtime name identifies + // the C++ plugin type registered by its entry point. ARK_ASSERT_RET_NONE(find_plugin(plugin_name) == nullptr); diff --git a/kubernetes/photon_config.yaml b/kubernetes/photon_config.yaml index 486e2d38d..56fb6d36b 100644 --- a/kubernetes/photon_config.yaml +++ b/kubernetes/photon_config.yaml @@ -60,26 +60,26 @@ data: db.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\n" + name=\"ark_utility_plugin\" conf=\"\" />\n\t\t\n\t\t\n\t\t\n\t\n\n" dir.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\n" freebird.app.conf: |- - - - + + + game.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\n" http.plugin.conf: |- @@ -111,23 +111,23 @@ data: login.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\n" master.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\n" oss.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\n" + name=\"ark_utility_plugin\" conf=\"\" />\n\t\t\n\t\t\n\t\t\n\t\n\t\n\n" photon.example.app.conf: "\n\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n" photon.example.plugin.conf: |- @@ -135,9 +135,9 @@ data: photon.game.app.conf: "\n\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n" photon.game.plugin.conf: |- @@ -153,9 +153,9 @@ data: photon.master.app.conf: "\n\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n" photon.master.plugin.conf: |- @@ -173,52 +173,52 @@ data: physic.app.conf: "\n\t\n\t\t\n\t\n\n" + name=\"ark_physic_plugin\" conf=\"\" />\n\t\n\n" proxy.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\n" redis.plugin.conf: |- redis_sample.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\n\n" + name=\"ark_utility_plugin\" conf=\"\" />\n\t\t\n\t\t\n\t\n\n" remote_log.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\n" + name=\"ark_utility_plugin\" conf=\"\" />\n\t\t\n\t\t\n\t\t\n\t\n\n" router.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\n" + name=\"ark_utility_plugin\" conf=\"\" />\n\t\t\n\t\t\n\t\t\n\t\n\n" sample1.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\n\n" sample2.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\n\n" + name=\"ark_kernel_plugin\" conf=\"kernel.plugin.conf\" />\n\t\t\n\t\t\n\t\n\n" sample3.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\n\n" + name=\"ark_kernel_plugin\" conf=\"kernel.plugin.conf\" />\n\t\t\n\t\t\n\t\n\n" sample4.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\n\n" + name=\"ark_utility_plugin\" conf=\"\" />\n\t\t\n\t\t\n\t\n\n" sample5.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\n\n" + name=\"ark_utility_plugin\" conf=\"\" />\n\t\t\n\t\t\n\t\n\n" simulate.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\n" - world.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\n" + name=\"ark_physic_plugin\" conf=\"\" />\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\n" + world.app.conf: "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\n" kind: ConfigMap metadata: creationTimestamp: "2020-06-04T11:02:29Z" diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 1dfde9324..cec32eeed 100755 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -1,4 +1,11 @@ +function(ark_validate_plugin_name plugin_name) + if(NOT plugin_name MATCHES "^[a-z][a-z0-9]*(_[a-z0-9]+)*$") + message(FATAL_ERROR "Plugin library names must use lowercase snake_case: ${plugin_name}") + endif() +endfunction() + function(BUILD_PLUGIN_MACRO project_name) + ark_validate_plugin_name("${project_name}") if(UNIX AND NOT APPLE) set(CMAKE_INSTALL_RPATH ".") set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) diff --git a/src/plugins/bus/CMakeLists.txt b/src/plugins/bus/CMakeLists.txt index 4566863a1..510df05cd 100755 --- a/src/plugins/bus/CMakeLists.txt +++ b/src/plugins/bus/CMakeLists.txt @@ -1,15 +1,15 @@ if(WIN32) - BUILD_PLUGIN_MACRO(AFBusPlugin - debug AFProto_d.lib + BUILD_PLUGIN_MACRO(ark_bus_plugin + debug AFProto_d.lib optimized AFProto.lib ${PROTOBUF_LIBRARIES}) elseif(APPLE) - BUILD_PLUGIN_MACRO(AFBusPlugin + BUILD_PLUGIN_MACRO(ark_bus_plugin debug ${BIN_OUTPUT_DIR}/AFProto_d.a optimized ${BIN_OUTPUT_DIR}/AFProto.a ${PROTOBUF_LIBRARIES}) else(UNIX) - BUILD_PLUGIN_MACRO(AFBusPlugin + BUILD_PLUGIN_MACRO(ark_bus_plugin debug :AFProto_d.a optimized :AFProto.a ${PROTOBUF_LIBRARIES}) diff --git a/src/plugins/consul/CMakeLists.txt b/src/plugins/consul/CMakeLists.txt index 7d69d7943..489e28d87 100755 --- a/src/plugins/consul/CMakeLists.txt +++ b/src/plugins/consul/CMakeLists.txt @@ -1,15 +1,15 @@ if(WIN32) - BUILD_PLUGIN_MACRO(AFConsulPlugin + BUILD_PLUGIN_MACRO(ark_consul_plugin debug AFProto_d.lib optimized AFProto.lib ${PROTOBUF_LIBRARIES}) elseif(APPLE) - BUILD_PLUGIN_MACRO(AFConsulPlugin + BUILD_PLUGIN_MACRO(ark_consul_plugin debug ${BIN_OUTPUT_DIR}/AFProto_d.a optimized ${BIN_OUTPUT_DIR}/AFProto.a ${PROTOBUF_LIBRARIES}) else(UNIX) - BUILD_PLUGIN_MACRO(AFConsulPlugin + BUILD_PLUGIN_MACRO(ark_consul_plugin debug :AFProto_d.a optimized :AFProto.a ${PROTOBUF_LIBRARIES}) diff --git a/src/plugins/etcd_client/CMakeLists.txt b/src/plugins/etcd_client/CMakeLists.txt index 1789f56a7..6a92bfff6 100755 --- a/src/plugins/etcd_client/CMakeLists.txt +++ b/src/plugins/etcd_client/CMakeLists.txt @@ -1 +1 @@ -BUILD_PLUGIN_MACRO(AFEtcdClientPlugin) +BUILD_PLUGIN_MACRO(ark_etcd_client_plugin) diff --git a/src/plugins/http/CMakeLists.txt b/src/plugins/http/CMakeLists.txt index 1ec15c3fd..8136e9ad2 100755 --- a/src/plugins/http/CMakeLists.txt +++ b/src/plugins/http/CMakeLists.txt @@ -1 +1 @@ -BUILD_PLUGIN_MACRO(AFHttpPlugin) +BUILD_PLUGIN_MACRO(ark_http_plugin) diff --git a/src/plugins/kafka/CMakeLists.txt b/src/plugins/kafka/CMakeLists.txt index 897f1c48f..5e35083d5 100644 --- a/src/plugins/kafka/CMakeLists.txt +++ b/src/plugins/kafka/CMakeLists.txt @@ -2,7 +2,7 @@ if (WIN32) include_directories( ) - BUILD_PLUGIN_MACRO(AFKafkaPlugin + BUILD_PLUGIN_MACRO(ark_kafka_plugin ) else () find_package(librdkafka REQUIRED) @@ -20,7 +20,7 @@ else () ${ZLIB_INCLUDE_DIRS} ) - BUILD_PLUGIN_MACRO(AFKafkaPlugin + BUILD_PLUGIN_MACRO(ark_kafka_plugin ${LIBRDKAFKA_CPP_LIBRARIES} ${LIBRDKAFKA_LIBRARIES} ${OPENSSL_LIBRARIES} diff --git a/src/plugins/kernel/CMakeLists.txt b/src/plugins/kernel/CMakeLists.txt index 5b9550306..0b0ff7c1a 100755 --- a/src/plugins/kernel/CMakeLists.txt +++ b/src/plugins/kernel/CMakeLists.txt @@ -1,15 +1,15 @@ if(WIN32) - BUILD_PLUGIN_MACRO(AFKernelPlugin + BUILD_PLUGIN_MACRO(ark_kernel_plugin debug AFProto_d.lib optimized AFProto.lib ${PROTOBUF_LIBRARIES}) elseif(APPLE) - BUILD_PLUGIN_MACRO(AFKernelPlugin + BUILD_PLUGIN_MACRO(ark_kernel_plugin debug ${BIN_OUTPUT_DIR}/AFProto_d.a optimized ${BIN_OUTPUT_DIR}/AFProto.a ${PROTOBUF_LIBRARIES}) else(UNIX) - BUILD_PLUGIN_MACRO(AFKernelPlugin + BUILD_PLUGIN_MACRO(ark_kernel_plugin debug :AFProto_d.a optimized :AFProto.a ${PROTOBUF_LIBRARIES}) diff --git a/src/plugins/mysql/CMakeLists.txt b/src/plugins/mysql/CMakeLists.txt index b7c122476..ab3b0c4e8 100644 --- a/src/plugins/mysql/CMakeLists.txt +++ b/src/plugins/mysql/CMakeLists.txt @@ -1,4 +1,4 @@ if(NOT ARKNET_ENABLE_SSL) message(FATAL_ERROR "The native MySQL plugin requires ARKNET_ENABLE_SSL for authentication and TLS") endif() -BUILD_PLUGIN_MACRO(AFMysqlPlugin arknet::arknet) +BUILD_PLUGIN_MACRO(ark_mysql_plugin arknet::arknet) diff --git a/src/plugins/net/CMakeLists.txt b/src/plugins/net/CMakeLists.txt index ffd4b68a1..66bafd5c0 100755 --- a/src/plugins/net/CMakeLists.txt +++ b/src/plugins/net/CMakeLists.txt @@ -1,15 +1,15 @@ if (WIN32) - BUILD_PLUGIN_MACRO(AFNetPlugin + BUILD_PLUGIN_MACRO(ark_net_plugin debug AFProto_d.lib optimized AFProto.lib ${PROTOBUF_LIBRARIES}) elseif (APPLE) - BUILD_PLUGIN_MACRO(AFNetPlugin + BUILD_PLUGIN_MACRO(ark_net_plugin debug ${BIN_OUTPUT_DIR}/AFProto_d.a optimized ${BIN_OUTPUT_DIR}/AFProto.a ${PROTOBUF_LIBRARIES}) else (UNIX) - BUILD_PLUGIN_MACRO(AFNetPlugin + BUILD_PLUGIN_MACRO(ark_net_plugin debug :AFProto_d.a optimized :AFProto.a ${PROTOBUF_LIBRARIES}) diff --git a/src/plugins/osssdk/CMakeLists.txt b/src/plugins/osssdk/CMakeLists.txt index 91df2d6ca..d282f128c 100644 --- a/src/plugins/osssdk/CMakeLists.txt +++ b/src/plugins/osssdk/CMakeLists.txt @@ -1 +1 @@ -BUILD_PLUGIN_MACRO(AFOssSDKPlugin) \ No newline at end of file +BUILD_PLUGIN_MACRO(ark_oss_sdk_plugin) \ No newline at end of file diff --git a/src/plugins/physic/CMakeLists.txt b/src/plugins/physic/CMakeLists.txt index 87f634273..9bcd8d18d 100644 --- a/src/plugins/physic/CMakeLists.txt +++ b/src/plugins/physic/CMakeLists.txt @@ -2,7 +2,7 @@ include_directories(${ROOT_DIR}/3rdparty/physX/include) set(PHYSIC_LIB_DIR ${ROOT_DIR}/3rdparty/physX/lib) if(WIN32) - BUILD_PLUGIN_MACRO(AFPhysicPlugin + BUILD_PLUGIN_MACRO(ark_physic_plugin debug ${PHYSIC_LIB_DIR}/PxPvdSDKDEBUG_x64.lib debug ${PHYSIC_LIB_DIR}/LowLevelDEBUG.lib debug ${PHYSIC_LIB_DIR}/LowLevelAABBDEBUG.lib @@ -20,7 +20,7 @@ if(WIN32) debug ${PHYSIC_LIB_DIR}/PsFastXmlDEBUG_x64.lib debug ${PHYSIC_LIB_DIR}/PhysX3DEBUG_x64.lib debug ${PHYSIC_LIB_DIR}/SimulationControllerDEBUG.lib - + optimized ${PHYSIC_LIB_DIR}/PxPvdSDK_x64.lib optimized ${PHYSIC_LIB_DIR}/LowLevel.lib optimized ${PHYSIC_LIB_DIR}/LowLevelAABB.lib @@ -39,7 +39,7 @@ if(WIN32) optimized ${PHYSIC_LIB_DIR}/PhysX3_x64.lib optimized ${PHYSIC_LIB_DIR}/SimulationController.lib) else(UNIX) - BUILD_PLUGIN_MACRO(AFPhysicPlugin + BUILD_PLUGIN_MACRO(ark_physic_plugin debug ${PHYSIC_LIB_DIR}/libLowLevelDEBUG.a debug ${PHYSIC_LIB_DIR}/libLowLevelAABBDEBUG.a debug ${PHYSIC_LIB_DIR}/libLowLevelClothDEBUG.a diff --git a/src/plugins/redis/CMakeLists.txt b/src/plugins/redis/CMakeLists.txt index 3f546a6bf..a32c7d029 100644 --- a/src/plugins/redis/CMakeLists.txt +++ b/src/plugins/redis/CMakeLists.txt @@ -1,2 +1,2 @@ -BUILD_PLUGIN_MACRO(AFRedisPlugin arknet::arknet) -target_include_directories(AFRedisPlugin PRIVATE "${ROOT_DIR}/src/plugins") +BUILD_PLUGIN_MACRO(ark_redis_plugin arknet::arknet) +target_include_directories(ark_redis_plugin PRIVATE "${ROOT_DIR}/src/plugins") diff --git a/src/plugins/utility/CMakeLists.txt b/src/plugins/utility/CMakeLists.txt index b114fcb6c..a6084272e 100755 --- a/src/plugins/utility/CMakeLists.txt +++ b/src/plugins/utility/CMakeLists.txt @@ -6,7 +6,7 @@ include_directories(${ZSTD_INCLUDE_DIRS}) find_package(ZLIB REQUIRED) if (ZLIB_FOUND) - mark_as_advanced(ZLIB_FOUND ZLIB_LIBRARIES ZLIB_INCLUDE_DIR) + mark_as_advanced(ZLIB_FOUND ZLIB_LIBRARIES ZLIB_INCLUDE_DIR) message(STATUS "Found ZLib add_library: ${ZLIB_LIBRARIES}") message(STATUS "Found ZLib headers: ${ZLIB_INCLUDE_DIR}") else() @@ -15,5 +15,5 @@ endif(ZLIB_FOUND) include_directories(${ZLIB_INCLUDE_DIRS}) -BUILD_PLUGIN_MACRO(AFUtilityPlugin ${ZSTD_LIBRARIES} ${ZLIB_LIBRARIES}) -# BUILD_PLUGIN_MACRO(AFUtilityPlugin ${LZ4_LIBRARY}) \ No newline at end of file +BUILD_PLUGIN_MACRO(ark_utility_plugin ${ZSTD_LIBRARIES} ${ZLIB_LIBRARIES}) +# BUILD_PLUGIN_MACRO(ark_utility_plugin ${LZ4_LIBRARY}) \ No newline at end of file diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt index 686f1767b..a6df9244f 100755 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -1,4 +1,5 @@ function(BUILD_SERVER_MACRO project_name) + ark_validate_plugin_name("${project_name}") if(UNIX AND (NOT APPLE)) #Set rpath set(CMAKE_INSTALL_RPATH ".") @@ -13,17 +14,17 @@ function(BUILD_SERVER_MACRO project_name) if(WIN32) add_definitions(-D_USRDLL) - target_link_libraries(${project_name} + target_link_libraries(${project_name} debug AFProto_d.lib optimized AFProto.lib ${PROTOBUF_LIBRARIES}) elseif(APPLE) - target_link_libraries(${project_name} + target_link_libraries(${project_name} debug ${BIN_OUTPUT_DIR}/AFProto_d.a optimized ${BIN_OUTPUT_DIR}/AFProto.a ${PROTOBUF_LIBRARIES}) else() - target_link_libraries(${project_name} + target_link_libraries(${project_name} debug :AFProto_d.a optimized :AFProto.a ${PROTOBUF_LIBRARIES}) @@ -48,4 +49,4 @@ add_subdirectory(world) add_subdirectory(master) add_subdirectory(dir) add_subdirectory(router) -#add_subdirectory(simulate) \ No newline at end of file +#add_subdirectory(simulate) diff --git a/src/server/dir/CMakeLists.txt b/src/server/dir/CMakeLists.txt index c33db220c..b26a2cb86 100755 --- a/src/server/dir/CMakeLists.txt +++ b/src/server/dir/CMakeLists.txt @@ -1 +1 @@ -BUILD_SERVER_MACRO(AFDirPlugin) \ No newline at end of file +BUILD_SERVER_MACRO(ark_dir_plugin) \ No newline at end of file diff --git a/src/server/game/CMakeLists.txt b/src/server/game/CMakeLists.txt index a59714849..1108d8000 100755 --- a/src/server/game/CMakeLists.txt +++ b/src/server/game/CMakeLists.txt @@ -1 +1 @@ -BUILD_SERVER_MACRO(AFGamePlugin) \ No newline at end of file +BUILD_SERVER_MACRO(ark_game_plugin) \ No newline at end of file diff --git a/src/server/login/CMakeLists.txt b/src/server/login/CMakeLists.txt index f4a8d7dbe..d5a4089bc 100755 --- a/src/server/login/CMakeLists.txt +++ b/src/server/login/CMakeLists.txt @@ -1 +1 @@ -BUILD_SERVER_MACRO(AFLoginPlugin) \ No newline at end of file +BUILD_SERVER_MACRO(ark_login_plugin) \ No newline at end of file diff --git a/src/server/master/CMakeLists.txt b/src/server/master/CMakeLists.txt index 022162b28..63b76cccd 100755 --- a/src/server/master/CMakeLists.txt +++ b/src/server/master/CMakeLists.txt @@ -1 +1 @@ -BUILD_SERVER_MACRO(AFMasterPlugin) \ No newline at end of file +BUILD_SERVER_MACRO(ark_master_plugin) \ No newline at end of file diff --git a/src/server/proxy/CMakeLists.txt b/src/server/proxy/CMakeLists.txt index 3709b6446..d8afe9299 100755 --- a/src/server/proxy/CMakeLists.txt +++ b/src/server/proxy/CMakeLists.txt @@ -1 +1 @@ -BUILD_SERVER_MACRO(AFProxyPlugin) \ No newline at end of file +BUILD_SERVER_MACRO(ark_proxy_plugin) \ No newline at end of file diff --git a/src/server/router/CMakeLists.txt b/src/server/router/CMakeLists.txt index 00b0910f9..7ce5da8a4 100755 --- a/src/server/router/CMakeLists.txt +++ b/src/server/router/CMakeLists.txt @@ -1 +1 @@ -BUILD_SERVER_MACRO(AFRouterPlugin) \ No newline at end of file +BUILD_SERVER_MACRO(ark_router_plugin) \ No newline at end of file diff --git a/src/server/simulate/CMakeLists.txt b/src/server/simulate/CMakeLists.txt index 975bdeb26..c281086f6 100644 --- a/src/server/simulate/CMakeLists.txt +++ b/src/server/simulate/CMakeLists.txt @@ -2,4 +2,4 @@ include_directories( ${ROOT_DIR}/3rdparty/physX/include ${ROOT_DIR}/3rdparty/msgpack/include) -BUILD_SERVER_MACRO(AFSimulatePlugin) +BUILD_SERVER_MACRO(ark_simulate_plugin) diff --git a/src/server/world/CMakeLists.txt b/src/server/world/CMakeLists.txt index d2674921d..1957c05ed 100755 --- a/src/server/world/CMakeLists.txt +++ b/src/server/world/CMakeLists.txt @@ -1 +1 @@ -BUILD_SERVER_MACRO(AFWorldPlugin) \ No newline at end of file +BUILD_SERVER_MACRO(ark_world_plugin) \ No newline at end of file diff --git a/tests/ci/plugin-names.test.mjs b/tests/ci/plugin-names.test.mjs new file mode 100644 index 000000000..330dfeef7 --- /dev/null +++ b/tests/ci/plugin-names.test.mjs @@ -0,0 +1,36 @@ +import assert from 'node:assert/strict'; +import { readFileSync, readdirSync } from 'node:fs'; +import { fileURLToPath } from 'node:url'; +import { resolve } from 'node:path'; +import test from 'node:test'; + +const root = fileURLToPath(new URL('../../', import.meta.url)); + +function pluginDeclarations(directory) { + const names = []; + for (const entry of readdirSync(directory, { withFileTypes: true })) { + const file = resolve(directory, entry.name); + if (entry.isDirectory()) { + names.push(...pluginDeclarations(file)); + } else if (entry.name === 'CMakeLists.txt') { + const source = readFileSync(file, 'utf8').replace(/^\s*#.*$/gm, ''); + for (const match of source.matchAll(/\bBUILD_(?:PLUGIN|SERVER)_MACRO\(\s*"?([A-Za-z0-9_]+)/g)) { + if (match[1] !== 'project_name') names.push({ name: match[1], file }); + } + } + } + return names; +} + +test('official, server and example shared plugin targets use snake_case library stems', () => { + const declarations = ['src/plugins', 'src/server', 'examples'].flatMap(directory => + pluginDeclarations(resolve(root, directory))); + assert.ok(declarations.length > 0, 'No plugin declarations were inspected'); + for (const { name, file } of declarations) { + assert.match(name, /^[a-z][a-z0-9]*(_[a-z0-9]+)*$/, file); + } + const names = new Set(declarations.map(entry => entry.name)); + for (const expected of ['ark_mysql_plugin', 'ark_redis_plugin', 'ark_utility_plugin', 'sample1_plugin']) { + assert.ok(names.has(expected), `Missing declared target ${expected}`); + } +}); diff --git a/tests/core/application_manifest.cpp b/tests/core/application_manifest.cpp index 0d2dcbeec..d71e8236f 100644 --- a/tests/core/application_manifest.cpp +++ b/tests/core/application_manifest.cpp @@ -79,8 +79,8 @@ DOCTEST_TEST_CASE("TOML and XML samples produce equivalent owning application ma DOCTEST_CHECK(toml.plugin_library_dir == "bin/"); DOCTEST_CHECK(toml.plugin_config_dir == "conf/"); DOCTEST_REQUIRE(toml.plugins.size() == 2); - DOCTEST_CHECK(toml.plugins.at("AFUtilityPlugin").empty()); - DOCTEST_CHECK(toml.plugins.at("Sample1Plugin").empty()); + DOCTEST_CHECK(toml.plugins.at("ark_utility_plugin").empty()); + DOCTEST_CHECK(toml.plugins.at("sample1_plugin").empty()); DOCTEST_CHECK(toml.plugin_library_dir == xml.plugin_library_dir); DOCTEST_CHECK(toml.plugin_config_dir == xml.plugin_config_dir); DOCTEST_CHECK(toml.plugins == xml.plugins);