From d464c04707f88d1c75b1d7ab8cbe740061f48df3 Mon Sep 17 00:00:00 2001 From: nick Date: Tue, 20 Oct 2026 09:52:04 +0800 Subject: [PATCH] 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);