参考
2024年版から特に変更点はない。
Visual Studio
サポートバージョン
- 2019/01: [Misc #15347]: Require C99: Ruby 2.7でC99要求となり、Visual Studio 2013が最小バージョンとなった (C99 Usage Guidelines)
- 2023/11: [Feature #19982]: Bump required Visual Studio version to 2015 after 3.3: Ruby 3.4から
snprintf
のためにVisual Studio 2015が最小バージョンとなった
2025/08時点では、2015以降のVisual Studioのリリースは以下の4つあり、Visual Studio 2022が最新版である。
- Visual Studio 2015 (EOL: 2025/10/14)
- Visual Studio 2017 (EOL: 2027/04/13)
- Visual Studio 2019 (EOL: 2029/04/10)
- Visual Studio 2022 (EOL: 2032/01/13)
インストール
- Visual Studio 2022 > Community > Free download からダウンロード
- VisualStudioSetup.exe を起動し、Continue を押す
- インストール対象を選択する
- Workloads
- Desktop development with C++ (optional, ↓の一部を選んでくれる)
- Individual Components
- Code tools
- vcpkg package manager
- Compilers, build tools, and runtimes
- Windows Universal CRT SDK
- C++/CLI support for v143 build tools (Latest)
- MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)
- SDKs, libraries, and frameworks
- Windows 11 SDK (10.0.26100.4654)
- Code tools
- Language packs
- English
- Workloads
- Install, Continue を押す
起動
- Start > Search: Native > x64 Native Tools Command Prompt for VS 2022
cl
や nmake
が動けばOK。
scoop
- Start > Search: Power > Windows PowerShell
Quickstartにある通り、以下のスクリプトをPowerShellで実行する。
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
x64 Native Tools Command Prompt for VS 2022 を起動し直すと、scoopが使えるようになる。
git, ruby
x64 Native Tools Command Prompt for VS 2022 (素のcmd.exeやPowerShellでも多分OK) で以下を実行する。
scoop install git ruby
x64 Native Tools Command Prompt for VS 2022 を起動し直すと、gitとrubyが使えるようになる。
セットアップ
x64 Native Tools Command Prompt for VS 2022 で以下を実行する。
git clone https://github.com/ruby/ruby
cd ruby
# vcpkg.json に書いてある依存をインストール
vcpkg install --triplet=x64-windows
ビルド
# vcpkg_installed\x64-windows へのパスを合わせてconfigure
win32\configure.bat --without-ext=+,syslog --with-opt-dir=C:\Users\k0kubun\src\github.com\ruby\ruby\vcpkg_installed\x64-windows
# DLLをビルドディレクトリにsymlinkする。かわりに vcpkg_installed\x64-windows\bin をPATHの先頭に追加してもよい
nmake prepare-vcpkg
# ビルド
nmake
これでRubyがビルドされ、 nmake test-all
などが実行できるようになる。