Xmake は、Lua に基づく軽量のクロスプラットフォーム ビルド ツールです。
Lua ランタイムが組み込まれているため、非常に軽量で依存関係がありません。
xmake.lua を使用してプロジェクトの構築を維持します. makefile/CMakeLists.txt と比較して、構成構文はより簡潔で直感的です. 初心者には非常にフレンドリーです. 短時間ですぐに開始できるため、ユーザーはより集中できます.実際のプロジェクト開発の上司。
これを使用して、Make/Ninja などのプロジェクトを直接コンパイルしたり、CMake/Meson などのプロジェクト ファイルを生成したりできます。また、ユーザーが C/C++ 依存ライブラリの統合使用の問題を解決するのに役立つ組み込みのパッケージ管理システムも備えています。
現在、Xmake は主に C/C++ プロジェクトのビルドに使用されていますが、他のネイティブ言語の構築もサポートしており、C/C++ との混合コンパイルを実現でき、コンパイル速度も非常に高速で、それに匹敵する可能性があります。忍者の。
Xmake = Build backend + Project Generator + Package Manager + [Remote|Distributed] Build + Cache
あまり正確ではありませんが、Xmake は次のように理解できます。
Xmake ≈ Make/Ninja + CMake/Meson + Vcpkg/Conan + distcc + ccache/sccache
新機能の紹介
Verilog シミュレータのサポート
iVerilog シミュレーター
構成を通じて、iverilog ツールチェーン パッケージを自動的にプルし、自動バインディング ツールチェーンを使用してプロジェクトをコンパイルできます。 add_requires("iverilog")
set_toolchains("@iverilog")
add_requires("iverilog")
target("hello")
add_rules("iverilog.binary")
set_toolchains("@iverilog")
add_files("src/*.v")
抽象構成の設定
add_requires("iverilog")
target("hello")
add_rules("iverilog.binary")
set_toolchains("@iverilog")
add_files("src/*.v")
add_defines("TEST")
add_includedirs("inc")
set_languages("v1800-2009")
Verilog を切り替えるための言語標準を で設定できます。 set_languages("v1800-2009")
現在サポートされている値とマッピングは次のとおりです。
["v1364-1995"] = "-g1995"
["v1364-2001"] = "-g2001"
["v1364-2005"] = "-g2005"
["v1800-2005"] = "-g2005-sv"
["v1800-2009"] = "-g2009"
["v1800-2012"] = "-g2012"
カスタム フラグを設定する
add_requires("iverilog")
target("hello")
add_rules("iverilog.binary")
set_toolchains("@iverilog")
add_files("src/*.v")
add_values("iverilogs.flags", "-DTEST")
建設計画
$ xmake
checking for iverilog ... iverilog
checking for vvp ... vvp
[ 50%]: linking.iverilog hello.vvp
[100%]: build ok!
プログラムを実行する
$ xmake run
hello world!
LXT2 info: dumpfile hello.vcd opened for output.
src/main.v:6: $finish called at 0 (1s)
より完全な例: iVerilog の例
ベリレーターエミュレーター
構成を通じて、ベリレーター ツールチェーン パッケージを自動的にプルし、ツールチェーンへの自動バインドを使用してプロジェクトをコンパイルできます。 add_requires("verilator")
set_toolchains("@verilator")
add_requires("verilator")
target("hello")
add_rules("verilator.binary")
set_toolchains("@verilator")
add_files("src/*.v")
add_files("src/*.cpp")
verilator プロジェクトでは、プログラムのエントリ コードとして、コンパイルに参加するための追加のファイルが必要です。 sim_main.cpp
#include "hello.h"
#include "verilated.h"
int main(int argc, char** argv) {
VerilatedContext* contextp = new VerilatedContext;
contextp->commandArgs(argc, argv);
hello* top = new hello{contextp};
while (!contextp->gotFinish()) { top->eval(); }
delete top;
delete contextp;
return 0;
}
抽象構成の設定
add_requires("verilator")
target("hello")
add_rules("verilator.binary")
set_toolchains("@verilator")
add_files("src/*.v")
add_defines("TEST")
add_includedirs("inc")
set_languages("v1800-2009")
Verilog を切り替えるための言語標準を で設定できます。 set_languages("v1800-2009")
現在サポートされている値とマッピングは次のとおりです。
-- Verilog
["v1364-1995"] = "+1364-1995ext+v",
["v1364-2001"] = "+1364-2001ext+v",
["v1364-2005"] = "+1364-2005ext+v",
-- SystemVerilog
["v1800-2005"] = "+1800-2005ext+v",
["v1800-2009"] = "+1800-2009ext+v",
["v1800-2012"] = "+1800-2012ext+v",
["v1800-2017"] = "+1800-2017ext+v",
カスタム フラグを設定する
add_requires("verilator")
target("hello")
add_rules("verilator.binary")
set_toolchains("@verilator")
add_files("src/*.v")
add_files("src/*.cpp")
add_values("verilator.flags", "--trace", "--timing")
建設計画
$ xmake
[ 0%]: compiling.verilog src/main.v
[ 15%]: cache compiling.release /Users/ruki/.xmake/packages/v/verilator/2023.1.10/cd2268409c1d44799288c7759b3cbd56/share/verilator/include/verilated.cpp
[ 15%]: cache compiling.release build/.gens/hello/macosx/x86_64/release/rules/verilator/hello___024root__Slow.cpp
[ 15%]: cache compiling.release build/.gens/hello/macosx/x86_64/release/rules/verilator/hello___024root__DepSet_h9053a130__0__Slow.cpp
[ 15%]: cache compiling.release build/.gens/hello/macosx/x86_64/release/rules/verilator/hello.cpp
[ 15%]: cache compiling.release /Users/ruki/.xmake/packages/v/verilator/2023.1.10/cd2268409c1d44799288c7759b3cbd56/share/verilator/include/verilated_threads.cpp
[ 15%]: cache compiling.release build/.gens/hello/macosx/x86_64/release/rules/verilator/hello__Syms.cpp
[ 15%]: cache compiling.release build/.gens/hello/macosx/x86_64/release/rules/verilator/hello___024root__DepSet_h07139e86__0.cpp
[ 15%]: cache compiling.release src/sim_main.cpp
[ 15%]: cache compiling.release build/.gens/hello/macosx/x86_64/release/rules/verilator/hello___024root__DepSet_h9053a130__0.cpp
[ 84%]: linking.release hello
[100%]: build ok!
プログラムを実行する
$ xmake run
ruki-2:hello ruki$ xmake run
hello world!
- src/main.v:4: Verilog $finish
より完全な例: Verilator
C++ モジュール配布のサポート
新しいバージョンでの C++ モジュールに対する xmake のサポートの改善に継続的に協力してくれたArthapzに感謝します。
これで、C++ モジュールをパッケージとして配布し、それらを他のプロジェクトにすばやく統合して再利用できるようになりました。
これは、 p2473r1のモジュール配布用のドラフト設計に基づくプロトタイプ実装です。
配布用 C++ モジュール パッケージを作成する
最初に xmake.lua を使用してメンテナンス モジュールをビルドし、外部配布のためにどのモジュール ファイルをインストールする必要があるかを xmake に指定して伝えます。 {install = true}
add_rules("mode.release", "mode.debug")
set_languages("c++20")
target("foo")
set_kind("static")
add_files("*.cpp")
add_files("*.mpp", { install = true })
次に、xmake-repoウェアハウスに送信できるパッケージにします。もちろん、ローカル パッケージまたはプライベート ウェアハウス パッケージに直接作成することもできます。
ここでは、テスト検証の便宜上、ローカル パッケージにします。 set_sourcedir
package("foo")
set_sourcedir(path.join(os.scriptdir(), "src"))
on_install(function(package)
import("package.tools.xmake").install(package, {})
end)
統合 C++ モジュール パッケージ
次に、パッケージ統合インターフェイスを使用して、C++ モジュール パッケージをすばやく統合して使用します。 add_requires("foo")
foo のモジュール パッケージはプライベート ウェアハウスで定義されているため、独自のパッケージ ウェアハウスをインポートします。 add_repositories("my-repo my-repo")
パッケージが xmake-repo の公式ウェアハウスに提出されている場合は、追加の構成を行う必要はありません。
add_rules("mode.release", "mode.debug")
set_languages("c++20")
add_repositories("my-repo my-repo")
add_requires("foo", "bar")
target("packages")
set_kind("binary")
add_files("src/*.cpp")
add_packages("foo", "bar")
set_policy("build.c++.modules", true)
パッケージが統合されたら、コマンドを実行して、ワンクリックで C++ モジュール パッケージをダウンロード、コンパイル、および統合できます。 xmake
$ xmake
checking for platform ... linux
checking for architecture ... x86_64
note: install or modify (m) these packages (pass -y to skip confirm)?
in my-repo:
-> foo latest
-> bar latest
please input: y (y/n/m)
=> install bar latest .. ok
=> install foo latest .. ok
[ 0%]: generating.module.deps src/main.cpp
[ 0%]: generating.module.deps /mnt/xmake/tests/projects/c++/modules/packages/build/.packages/b/bar/latest/4e0143c97b65425b855ad5fd03038b6a/modules/bar/bar.mpp
[ 0%]: generating.module.deps /mnt/xmake/tests/projects/c++/modules/packages/build/.packages/f/foo/latest/4e0143c97b65425b855ad5fd03038b6a/modules/foo/foo.mpp
[ 14%]: compiling.module.release bar
[ 14%]: compiling.module.release foo
[ 57%]: compiling.release src/main.cpp
[ 71%]: linking.release packages
[100%]: build ok!
注: 各パッケージがインストールされると、メンテナンス モジュールのメタ情報ファイルがパッケージ パスに格納されます. これはで合意されたフォーマット仕様です. おそらく最終的な標準ではありませんが, これは私たちが使用することに影響しません.モジュールが配布されました。 p2473r1.pdf
$ cat ./build/.packages/f/foo/latest/4e0143c97b65425b855ad5fd03038b6a/modules/foo/foo.mpp.meta-info
{"_VENDOR_extension":{"xmake":{"name":"foo","file":"foo.mpp"}},"definitions":{},"include_paths":{}}
完全なサンプル プロジェクトについては、C++ モジュール パッケージ配布サンプルプロジェクトを参照してください。
C++23 標準モジュールのサポート
Arthapz は、C++23 標準モジュールのサポートの改善にも貢献しました。
それをサポートする 3 つのコンパイラの現在の進捗状況:
Msvc
最新の Visual Studio 17.5 プレビューでは既にサポートされており、非標準の ifc std モジュールは非推奨になります。
標準の C++23 std モジュールについては、このように導入しました。
import std;
ifc std モジュールの場合は、次のように記述する必要があります。
import std.core;
これは C++23 標準ではなく、msvc によってのみ提供されており、他のコンパイラとは互換性がなく、今後 msvc の新しいバージョンでは徐々に破棄される予定です。したがって、Xmake の新しいバージョンは C++23 std モジュールのみをサポートし、廃止された ifc std モジュールをサポートしなくなります。
クラン
現在、最新の clang は C++23 std モジュールを完全にはサポートしていないようで、まだドラフト パッチの状態#D135507です。
ただし、Xmake もサポートしているので、試してみたい場合は、このパッチを自分で組み込み、xmake を使用してテストすることができます。
さらに、clang の下位バージョンには、非標準 std モジュールの実験的サポートもあります。
xmake を使用して、clang の下位バージョンで std モジュールを構築することを試みることはできますが、これはおもちゃのようなものである可能性があります (多くの問題が発生する可能性があります)。
関連する議論を参照してください: #3255
Gcc
まだサポートされていません。
Xrepo オートコンプリートのサポート
以前は、不完全な xmake コマンドのみをサポートしていましたが、新しいバージョンでは、不完全なコマンドもサポートし、 xmake-repoウェアハウス内のパッケージを自動的に検索して、インストール コマンドを完成させることができます。 xrepo install
@glcraft の貢献に感謝します。
$ xrepo install libp
libpaper libpfm libpng libpqxx libpthread-stubs
libpcap libplist libpq libpsl
コンテンツを更新する
新機能
- #3228 : C++ モジュールのリリースをインストールし、パッケージから C++ モジュールのサポートをインポートします
- # 3257 : iverilog と verilator のサポートを追加
- XPとVC6.0をサポート
- #3214 : xrepo インストールのオートコンプリートのサポート
向上
- #3255 : clang libc++ モジュールのサポートを改善
- mingw を使用した xmake のコンパイルをサポート
- win xp での xmake の互換性を改善する
- 外部依存関係が有効になっている場合は、json モジュールを純粋な lua 実装に切り替え、lua-cjson への依存関係を削除します
バグの修正
- #3229 : vs2015 で rc.exe が見つからない問題を修正
- #3271 : スペースを含むマクロ定義のサポートを修正
- #3273 : nim リンクエラーを修正
- #3286 : clangd の compile_commands サポートを修正