Difference between revisions of "Building PSUnreal on macOS"

From PSwiki
Jump to navigation Jump to search
 
Line 19: Line 19:
  
 
* Step 3: Get the Unreal Engine source code.
 
* Step 3: Get the Unreal Engine source code.
** Get the source code with: '''git clone -b 4.24.3-release https://github.com/EpicGames/UnrealEngine.git'''.
+
** Get the source code with: '''git clone -b 4.25.2-release https://github.com/EpicGames/UnrealEngine.git'''.
 
** This will create an '''UnrealEngine''' sub-directory where you run the commands of the next step.
 
** This will create an '''UnrealEngine''' sub-directory where you run the commands of the next step.
  

Latest revision as of 18:46, 28 July 2020

Reference docs

Compiling Unreal Engine

Note: As of 2020-05-05, you need ~120GB of disk space for a compiled version of the Unreal Engine.

  • Step 1: Install the latest version of Xcode.
    • Install the latest version of Xcode from the App Store.
    • Install the Command Line Tools by running xcode-select --install from a Terminal.
  • Step 3: Get the Unreal Engine source code.
  • Step 4: Prepare the Xcode workspace.
    • In the UnrealEngine directory, run the script Setup.command. It downloads 11.5GB of dependencies and may take a while.
    • At the same location, run the script GenerateProjectFiles.command. It generates the UE4.xcworkspace Xcode workspace.
  • Step 5: Compile Unreal Engine with Xcode.
    • Load the UE4.xcworkspace into Xcode.
    • Select the UE4 blue icon for the project on the left, and click on "Project Navigator" icon (looks like a folder icon)
    • Click on "Signing and Capabilities" and leave "Team" empty, "Sign to run locally"
    • Click on "Build Settings", search "Signing Identity", remove everything there by clicking on "Others" and clearing the field. Or use Sign Run Locally. This way we disable the signing completely.
    • Select the ShaderCompileWorker > My Mac target in the title bar, then build with Product > Build menu item.
    • Wait for the build to complete.
    • Select the UE4 > My Mac target, and build again.
    • Compiling may take a long time, depending on your system specs.
    • After the compilation finishes, select the 'Product > Run' menu item to load the editor.
  • Step 6: set xcode tools
    • Open Xcode and go to Preferences>Locations and set the Command Line Tools or Unreal will give this error: "Xcode is not installed on this Mac ... Falling back to runtime text shaders, which are slower. "
  • Launch the Editor to test if it works
    • You can launch the editor with \UnrealEngine\Engine\Binaries\Mac\UE4Editor.app

If you get this error:

 xcode command codesign failed with exit code 1 

You need to access the project settings and set the code signing.

Obtaining PSUnreal

  • Create PSUnreal dir
 > cd \
 > mkdir PSUnreal
 > sudo port install subversion

Get the sources from the Planeshift repository.

  • Open a Terminal and go to you home directory with
 > cd ~. We will build from there; adapt if needed.
  • Checkout the sources from the PS Unreal repository with:
 > svn co svn://xxx.xxx.xxx/psunreal/PSUnreal PSUnreal

Building dependencies

MariaDB connector

  • Build the MariaDB Connector from source.
    • Install prerequisites: sudo port install cmake jemalloc judy openssl boost gnutls
    • Download the MariaDB Connector for C from https://downloads.mariadb.com/Connectors/c/connector-c-3.1.8/mariadb-connector-c-3.1.8-src.tar.gz.
    • Expand the tar.gz in your home directory. From your terminal, cd ~/mariadb-connector-c-3.1.8-src, to go to the directory that contain the MariaDB Connector sources.
    • move the sources in PSUnreal: mv * /Users/luke/PSUnreal/ThirdParty/MariaDB
    • Generate the makefiles with cmake . .
    • Build and install the connector in your PSUnreal source tree with make all install.

Wordnet

  • Build Wordnet
 > cd /Users/luke/PSUnreal/ThirdParty/Wordnet
 > gcc -shared -o Wordnet.dylib -fPIC *.c

libzip

 > git clone git@github.com:nih-at/libzip.git
  • In the newly created libzip directory, create a build sub-directory.
 > cd libzip
 > mkdir build
  • In libzip/build run cmake as follows (this turns off all the options we do not need):
 > cd build
 > cmake -DENABLE_COMMONCRYPTO=OFF -DENABLE_GNUTLS=OFF -DENABLE_MBEDTLS=OFF -DENABLE_OPENSSL=OFF -DENABLE_WINDOWS_CRYPTO=OFF -DENABLE_BZIP2=OFF -DENABLE_LZMA=OFF ..
  • Then build with:
 > make --build .
  • Copy the libzip library and headers to the third party subfolder of PSUnreal.
 > cp lib/libzip.5.3.dylib PSUnreal/ThirdParty/Libzip/Libraries/Mac/libzip.5.dylib
 > cp ../lib/zip.h PSUnreal/ThirdParty/Libzip/Includes/.
 > cp zipconf.h PSUnreal/ThirdParty/Libzip/Includes/Mac/.
  • Finalize the library.
 > cd PSUnreal/ThirdParty/Libzip/Libraries/Mac
 > install_name_tool

Build PS Unreal.

  • Generate project files:
 > /Users/luke/UnrealEngine/GenerateProjectFiles.command -project="/Users/luke/PSUnreal/PSUnreal.uproject" -game -engine
  • Launch XCode and open PSUnreal.xcworkspace
  • Select the UE4 blue icon for the project on the left, and click on "Project Navigator" icon (looks like a folder icon)
  • Click on "Signing and Capabilities" and leave "Team" empty, "Sign to run locally"
  • Click on "Build Settings", search "Signing Identity", remove everything there by clicking on "Others" and clearing the field. Or use Sign Run Locally. This way we disable the signing completely.
  • Build with Product > Build menu item.

Finalize PS Unreal

Note: The following should be added to the build process. To be done by hand for now.

  • Copy Wordnet.dylib, libmariadb.3.dylib, libmariadb.dylib to inside folder ./PSUnreal.app/Content/MacOS.
  • Modify the library paths in the main PSUnreal executable as follows:
    • install_name_tool -change /Users/luke/PSUnreal/ThirdParty/MariaDB/libmariadb/libmariadb.3.dylib @loader_path/libmariadb.3.dylib ./PSUnreal.app/Contents/MacOS/PSUnreal
    • install_name_tool -change Wordnet.dylib @loader_path/Wordnet.dylib ./PSUnreal.app/Contents/MacOS/PSUnreal
  • Add file serverlist.xml to inside folder ./PSUnreal.app/Contents/UE4/PSUnreal/Config. (Config directory needs to be created)
  • Finally, you can sign the app bundle with the following codesign -s <email> PSUnreal.app, where <email> is the E-mail for your Apple Development ID (check it in your Keychain Access app > My Certificates).

Troubleshooting

If there is a problem like:

 Unable to load module '/Users/luke/PSUnreal/Binaries/Mac/UE4Editor-PSUnreal.dylib' because the file couldn't be loaded by the OS.

You can use otool to see the dependencies

 otool -L /Users/luke/PSUnreal/Binaries/Mac/UE4Editor-PSUnreal.dylib

Running a local server

Prepare the server database

  • Connect to your database as root, create the planeshift database and user.
 > mysql -u root -p
 mysql> CREATE DATABASE planeshift;
 mysql> CREATE USER 'planeshift'@'localhost' IDENTIFIED WITH mysql_native_password BY 'planeshift';
 mysql> GRANT ALL PRIVILEGES ON planeshift.* TO 'planeshift'@'localhost';
 mysql> quit
  • Connect to the database as planeshift, populate the database (adapt psunreal_mysql_XXXXXXXX.sql to the currently available file).
 > cd PSUnreal\Scripts
 > mysql -u planeshift -pplaneshift
 mysql> USE planeshift;
 mysql> SOURCE psunreal_mysql_XXXXXXXX.sql;
 mysql> quit
  • If you need to upgrade your database, perform the following as root, and re-populate the database as done above.
 > mysql -u root -p
 mysql> DROP DATABASE planeshift;
 mysql> CREATE DATABASE planeshift;
 mysql> GRANT ALL PRIVILEGES ON planeshift.* TO 'planeshift'@'localhost';
 mysql> quit