No announcement yet.

Setting up Emscripten environment for HTML5

  • Filter
  • Time
  • Show
Clear All
new posts

    Setting up Emscripten environment for HTML5

    In the wake up the 4.5 preview release, I decided to give the HTML5 build a whirl, but I ran into some troubles with getting UBT to detect the active Emscripten version. The active version is not reliably detected because of some breakdowns in the process for setting up the environment.

    Currently the documentation states:

    Updating Emscripten
    Emscripten provides a bootstrap tool titled emsdk located in the root of the installation folder.
    With this tool, you can easily update to the latest version of the Emscripten SDK by running the following commands: 
        emsdk update emsdk 
        install latest
        emsdk activate latest
    The problem with this is that it will only update the Emscripten environment for the current command line session as per this issue reported to the emscripten project:

    The solution there was to add another command line option to elevate privileges and write to the global environment, though I would recommend against adding to the global path if possible.

        emsdk update emsdk 
        install latest
        emsdk activate --global latest

    Alas, another solution supplies itself; Emscripten also provides a command that will enable the Emscripten environment temporarily that could be detected and run before executing UBT or any other operation that needs the Emscripten environment.
        Adding directories to PATH:
        PATH += C:\Program Files\Emscripten\clang\e1.22.0_64bit
        PATH += C:\Program Files\Emscripten\spidermonkey\30.0.0_64bit
        PATH += C:\Program Files\Emscripten\git\1.8.3\bin;C:\Program Files\Emscripten\gi
        Setting environment variables:
        EMSCRIPTEN = C:\Program Files\Emscripten\emscripten\1.21.0
        Setting up Unreal Engine 4 project files...
        Binding IntelliSense data... 100%
        Writing project files... 100%

    Making it automatic


    @echo off
    cmd.exe /v /c "%~dp0Engine\Build\BatchFiles\CopyVisualizers.bat"
    if not exist "%~dp0Engine\Build\BatchFiles\GenerateProjectFiles.bat" goto Error_BatchFileInWrongLocation
    REM Set up the Emscripen Environment
    for %%X in (emsdk_env.bat) do (set EMSDKPATH=%%~$PATH:X)
    if defined EMSDKPATH call emsdk_env.bat
    call "%~dp0Engine\Build\BatchFiles\GenerateProjectFiles.bat" %*
    goto Exit
    echo GenerateProjectFiles ERROR: The batch file does not appear to be located in the root UE4 directory.  This script must be run from within that directory.
    goto Exit

    And build.bat
    @echo off
    REM The %~dp0 specifier resolves to the path to the directory where this .bat is located in.
    REM We use this so that regardless of where the .bat file was executed from, we can change to
    REM directory relative to where we know the .bat is stored.
    pushd "%~dp0\..\..\Source"
    REM %1 is the game name
    REM %2 is the platform name
    REM %3 is the configuration name
    REM Set up the Emscripen Environment
    for %%X in (emsdk_env.bat) do (set EMSDKPATH=%%~$PATH:X)
    if defined EMSDKPATH call emsdk_env.bat
    IF EXIST ..\..\Engine\Binaries\DotNET\UnrealBuildTool.exe (
             ..\..\Engine\Binaries\DotNET\UnrealBuildTool.exe %* -DEPLOY
    ) ELSE (
    	ECHO UnrealBuildTool.exe not found in ..\..\Engine\Binaries\DotNET\UnrealBuildTool.exe 
    	EXIT /B 999
    Last edited by james0x0A; 09-23-2014, 12:52 AM.

    Hello I have apparently the same problem with the environment variables.
    as I don't have :

    I really don't know how to setup them and I can't find anything, after getting trough the 1.22 version, the locked dll and other bugs


      Hey Denis, those variables appear in the .emscripten file in your user directory. Something like "C:\Users\You\.emscripten". This should be updated when you run "emsdk activate latest" or whatever sdk version you want to use.

      The emsdk_env batch file simply pulls the active environment settings from file and enables them for the current execution. The emscripten installer sets the global environment at install time but that leaves you with a reference to the initial installed version only.

      My solution here is just a little hack so that I don't have to reinstall when moving between 4.4 and 4.5 or patch anything extra on to my global path.
      Last edited by james0x0A; 09-23-2014, 09:23 PM.