macOS へのコンパイル¶
注釈
This page describes how to compile macOS editor and export template binaries from source. If you're looking to export your project to macOS instead, read Exporting for macOS.
必要条件¶
macOSでコンパイルするには、以下が必要です:
SCons 3.0+ build system.
Xcode (またはXcode用のより軽量なコマンドラインツール)。
オプション - yasm (WebM SIMD最適化用)。
注釈
Homebrew がインストールされている場合、次のコマンドを使用してSConsとyasmを簡単にインストールできます:
brew install scons yasm
Homebrewをインストールすると、Xcodeのコマンドラインツールがまだない場合は自動的に取得されます。
Similarly, if you have MacPorts installed, you can easily install SCons and yasm using the following command:
sudo port install scons yasm
参考
To get the Godot source code for compiling, see ソースの取得.
Godotにおける基本的なSconsの使い方については、ビルドシステムの説明を参照してください。
コンパイル¶
ターミナルを起動し、エンジンのソースコードのルートディレクトリに移動します。
To compile for Intel (x86-64) powered Macs, use:
scons platform=osx arch=x86_64
To compile for Apple Silicon (ARM64) powered Macs, use:
scons platform=osx arch=arm64
To support both architectures in a single "Universal 2" binary, run the above two commands and then use lipo
to bundle them together:
lipo -create bin/godot.osx.tools.x86_64 bin/godot.osx.tools.arm64 -output bin/godot.osx.tools.universal
すべてうまくいけば、結果のバイナリ実行可能ファイルは bin/
サブディレクトリに置かれます。この実行可能ファイルにはエンジン全体が含まれており、依存関係なしで実行されます。それを実行すると、プロジェクトマネージャーが表示されます。
注釈
If you want to use separate editor settings for your own Godot builds
and official releases, you can enable
自己完結型モード by creating a file called
._sc_
or _sc_
in the bin/
folder.
To create an .app
bundle like in the official builds, you need to use the
template located in misc/dist/osx_tools.app
. Typically, for an optimized
editor binary built with target=release_debug
:
cp -r misc/dist/osx_tools.app ./Godot.app
mkdir -p Godot.app/Contents/MacOS
cp bin/godot.osx.opt.tools.universal Godot.app/Contents/MacOS/Godot
chmod +x Godot.app/Contents/MacOS/Godot
Compiling a headless/server build¶
To compile a headless build which provides editor functionality to export projects in an automated manner, use:
scons platform=server tools=yes target=release_debug
To compile a debug server build which can be used with remote debugging tools, use:
scons platform=server tools=no target=release_debug
To compile a release server build which is optimized to run dedicated game servers, use:
scons platform=server tools=no target=release
エクスポートテンプレートの構築¶
To build macOS export templates, you have to compile with tools=no
(no
editor) and respectively for target=release
(release template) and
target=release_debug
.
Official templates are universal binaries which support both Intel x86_64 and
ARM64 architectures. You can also create export templates that support only one
of those two architectures by leaving out the lipo
step below.
For Intel x86_64:
scons platform=osx tools=no target=release arch=x86_64 scons platform=osx tools=no target=release_debug arch=x86_64
For ARM64 (Apple M1):
scons platform=osx tools=no target=release arch=arm64 scons platform=osx tools=no target=release_debug arch=arm64
To support both architectures in a single "Universal 2" binary, run the above
two commands blocks and then use lipo
to bundle them together:
lipo -create bin/godot.osx.opt.x86_64 bin/godot.osx.opt.arm64 -output bin/godot.osx.opt.universal
lipo -create bin/godot.osx.opt.debug.x86_64 bin/godot.osx.opt.debug.arm64 -output bin/godot.osx.opt.debug.universal
To create an .app
bundle like in the official builds, you need to use the
template located in misc/dist/osx_template.app
. The release and debug
builds should be placed in osx_template.app/Contents/MacOS
with the names
godot_osx_release.64
and godot_osx_debug.64
respectively. You can do so
with the following commands (assuming a universal build, otherwise replace the
.universal
extension with the one of your arch-specific binaries):
cp -r misc/dist/osx_template.app .
mkdir -p osx_template.app/Contents/MacOS
cp bin/godot.osx.opt.universal osx_template.app/Contents/MacOS/godot_osx_release.64
cp bin/godot.osx.opt.debug.universal osx_template.app/Contents/MacOS/godot_osx_debug.64
chmod +x osx_template.app/Contents/MacOS/godot_osx*
You can then zip the osx_template.app
folder to reproduce the osx.zip
template from the official Godot distribution:
zip -q -9 -r osx.zip osx_template.app
LinuxからのmacOSのクロスコンパイル¶
Linux環境でmacOS用にコンパイルすることが可能です(Linux用のWindows Subsystemを使用してWindowsでコンパイルすることもできます)。そのためには、macOSをターゲットとして使用できるように、OSXCross をインストールする必要があります。まず、指示に従ってインストールします:
OSXCross repository をマシン上のどこかにクローンします(またはzipファイルをダウンロードしてどこかに解凍します)。例:
git clone --depth=1 https://github.com/tpoechtrager/osxcross.git "$HOME/osxcross"
以下のURLの内容に従ってSDKをパッケージ化します:https://github.com/tpoechtrager/osxcross#packaging-the-sdk
OSXCrossをインストールするには、以下の手順に従ってください:https://github.com/tpoechtrager/osxcross#installation
その後、OSXCROSS_ROOT
をOSXCrossインストールへのパス(リポジトリをクローンした、またはzipを抽出したのと同じ場所)として定義する必要があります。例:
export OSXCROSS_ROOT="$HOME/osxcross"
これで、通常のようにSConsでコンパイルできます:
scons platform=osx
SConsビルドシステムで予期されているものとは異なるOSXCross SDKバージョンがある場合は、osxcross_sdk
引数でカスタムバージョンを指定できます:
scons platform=osx osxcross_sdk=darwin15