D語言模組
此模組提供與 D 程式語言相關的工具。
用法
要使用此模組,只需執行:dlang = import('dlang')
。當然,您可以將名稱 dlang
替換為任何其他名稱。
此模組只公開一個函式 generate_dub_file
,用於自動產生 Dub 組態檔案。
generate_dub_file()
此方法只有兩個必要參數:專案名稱和原始碼資料夾。您可以使用額外的關鍵字傳遞其他參數,它們會自動轉換為 json 並新增至 dub.json
檔案中。
結構
generate_dub_file("project name", "source/folder", key: "value" ...)
範例
dlang = import('dlang')
dlang.generate_dub_file(meson.project_name().to_lower(), meson.source_root(),
authors: 'Meson Team',
description: 'Test executable',
copyright: 'Copyright © 2018, Meson Team',
license: 'MIT',
sourceFiles: 'test.d',
targetType: 'executable',
dependencies: my_dep
)
您可以手動編輯 Meson 產生的 dub.json
檔案,或提供一個初始檔案。此模組只會更新 generate_dub_file()
中指定的值。
雖然不是必要的,如果您想在 D 套件註冊表 中發布套件,您將需要 description
和 license
。
搜尋結果為