• RuntimesGodot
  • Build GODOT version on Windows issues

I am attempting to build the code on Windows.

Following the instructions on this page.

https://esotericsoftware.com/spine-godot

Building without the c# requirements.

Exports build just fine. However when trying to build the editor I get the following error.

$ ./build-v4.sh
Building Godot without C# support
CPUS: 20
/c/work/Godot-Spine/spine-runtimes/spine-godot/godot /c/work/Godot-Spine/spine-runtimes/spine-godot/build /c/work/Godot-Spine/spine-runtimes/spine-godot/build
scons: Reading SConscript files ...
C:\work\Godot-Spine\spine-runtimes\spine-godot\godot\methods.py:1022: SyntaxWarning: invalid escape sequence '\)'
  "(?:(?<=version )|(?<=\) )|(?<=^))"
C:\work\Godot-Spine\spine-runtimes\spine-godot\godot\methods.py:1023: SyntaxWarning: invalid escape sequence '\d'
  "(?P<major>\d+)"
C:\work\Godot-Spine\spine-runtimes\spine-godot\godot\methods.py:1024: SyntaxWarning: invalid escape sequence '\.'
  "(?:\.(?P<minor>\d*))?"
C:\work\Godot-Spine\spine-runtimes\spine-godot\godot\methods.py:1025: SyntaxWarning: invalid escape sequence '\.'
  "(?:\.(?P<patch>\d*))?"
C:\work\Godot-Spine\spine-runtimes\spine-godot\godot\methods.py:1027: SyntaxWarning: invalid escape sequence '\+'
  "(?:\+(?P<metadata2>[0-9a-zA-Z-]*))?"
C:\work\Godot-Spine\spine-runtimes\spine-godot\godot\platform\linuxbsd\detect.py:451: SyntaxWarning: invalid escape sequence '\d'
  gnu_ld_version = re.search("^GNU ld [^$]*(\d+\.\d+)$", linker_version_str, re.MULTILINE)
C:\work\Godot-Spine\spine-runtimes\spine-godot\godot\platform\windows\detect.py:469: SyntaxWarning: invalid escape sequence '\w'
  env.Append(LINKFLAGS=["/NATVIS:platform\windows\godot.natvis"])

The code in that python files looks as follows.

def get_compiler_version(env):
    """
    Returns an array of version numbers as ints: [major, minor, patch].
    The return array should have at least two values (major, minor).
    """
    if not env.msvc:
        # Not using -dumpversion as some GCC distros only return major, and
        # Clang used to return hardcoded 4.2.1: # https://reviews.llvm.org/D56803
        try:
            version = subprocess.check_output([env.subst(env["CXX"]), "--version"]).strip().decode("utf-8")
        except (subprocess.CalledProcessError, OSError):
            print("Couldn't parse CXX environment variable to infer compiler version.")
            return None
    else:  # TODO: Implement for MSVC
        return None
    match = re.search(
        "(?:(?<=version )|(?<=\) )|(?<=^))"
        "(?P<major>\d+)"
        "(?:\.(?P<minor>\d*))?"
        "(?:\.(?P<patch>\d*))?"
        "(?:-(?P<metadata1>[0-9a-zA-Z-]*))?"
        "(?:\+(?P<metadata2>[0-9a-zA-Z-]*))?"
        "(?: (?P<date>[0-9]{8}|[0-9]{6})(?![0-9a-zA-Z]))?",
        version,
    )
    if match is not None:
        return match.groupdict()
    else:
        return None

The strings are not correctly specified should be a double \ I am not very knowledgeable about how the SCons build system works of even when those files are created/downlaoded from. I cant find them in the repo.

If I correct those escape characters I get a build issue later that I think is more of an issue perhaps environmental

Found MSVC version 14.2, arch x86_64
Building for platform "windows", architecture "x86_64", target "editor".
debug: 12204ms:MSCommon/vc.py:get_default_version#1275: msvc_version:14.2 msvs_version:14.2
debug: 12205ms:MSCommon/vc.py:get_host_target#577: HOST_ARCH:x86_64
debug: 12205ms:MSCommon/vc.py:get_host_target#585: TARGET_ARCH:amd64
KeyError: 0:
  File "C:\work\Godot-Spine\spine-runtimes\spine-godot\godot\SConstruct", line 960:
    methods.generate_vs_project(env, GetOption("num_jobs"), env["vsproj_name"])
  File "C:\work\Godot-Spine\spine-runtimes\spine-godot\godot\methods.py", line 780:
    batch_file = find_visual_c_batch_file(env)
  File "C:\work\Godot-Spine\spine-runtimes\spine-godot\godot\methods.py", line 732:
    return find_batch_file(env, version, host_platform, target_platform)[0]
  File "C:\Users\travi\scoop\apps\python\current\Lib\site-packages\SCons\Tool\MSCommon\vc.py", line 929:
    vernum = float(get_msvc_version_numeric(msvc_version))
  File "C:\Users\travi\scoop\apps\python\current\Lib\site-packages\SCons\Tool\MSCommon\vc.py", line 504:
    return ''.join([x for x in msvc_version if x in string_digits + '.'])
  File "C:\Users\travi\scoop\apps\python\current\Lib\site-packages\SCons\Environment.py", line 586:
    return self._dict[key]

This appears to be an issue finding MSVC bat file caused it would seam in the version code.

VC is installed and the build for the Exports works perfectly with it. Any clues where I could look to resolve this issue would be appreciated.

Related Discussions
...

I did a full reinstall of the visual studio environment and made sure to include all the C++ and C++ window features.

This seams to have solved the reg ex / issue. But not the issue shown below.

Found MSVC version 14.3, arch x86_64
Building for platform "windows", architecture "x86_64", target "editor".
debug: 05275ms:MSCommon/vc.py:get_default_version#1275: msvc_version:14.3 msvs_version:14.3
debug: 05276ms:MSCommon/vc.py:get_host_target#577: HOST_ARCH:x86_64
debug: 05276ms:MSCommon/vc.py:get_host_target#585: TARGET_ARCH:amd64
KeyError: 0:
  File "C:\work\Godot-Spine\spine-runtimes\spine-godot\godot\SConstruct", line 960:
    methods.generate_vs_project(env, GetOption("num_jobs"), env["vsproj_name"])
  File "C:\work\Godot-Spine\spine-runtimes\spine-godot\godot\methods.py", line 780:
    batch_file = find_visual_c_batch_file(env)
  File "C:\work\Godot-Spine\spine-runtimes\spine-godot\godot\methods.py", line 732:
    return find_batch_file(env, version, host_platform, target_platform)[0]
  File "C:\Users\travi\scoop\apps\python\current\Lib\site-packages\SCons\Tool\MSCommon\vc.py", line 929:
    vernum = float(get_msvc_version_numeric(msvc_version))
  File "C:\Users\travi\scoop\apps\python\current\Lib\site-packages\SCons\Tool\MSCommon\vc.py", line 504:
    return ''.join([x for x in msvc_version if x in string_digits + '.'])
  File "C:\Users\travi\scoop\apps\python\current\Lib\site-packages\SCons\Environment.py", line 586:
    return self._dict[key]

Upon further investigation into the python build files there appears to be this issue.

methods.py

def find_visual_c_batch_file(env):
    from SCons.Tool.MSCommon.vc import (
        get_default_version,
        get_host_target,
        find_batch_file,
    )

    # Syntax changed in SCons 4.4.0.
    from SCons import __version__ as scons_raw_version

    scons_ver = env._get_major_minor_revision(scons_raw_version)

    version = get_default_version(env)

    if scons_ver >= (4, 4, 0):
        (host_platform, target_platform, _) = get_host_target(env, version)
    else:
        (host_platform, target_platform, _) = get_host_target(env)

    return find_batch_file(env, version, host_platform, target_platform)[0]

The call to find_batch_file passes env, version, host_platform, target_platform

However in the version of vc.py the function has a different parameter signature.

def find_batch_file(msvc_version, host_arch, target_arch, pdir):
    """
    Find the location of the batch script which should set up the compiler
    for any TARGET_ARCH whose compilers were installed by Visual Studio/VCExpress

    In newer (2017+) compilers, make use of the fact there are vcvars
    scripts named with a host_target pair that calls vcvarsall.bat properly,
    so use that and return an empty argument.
    """

As can be seen the find_batch__file method does not take env as a first parameter.

This was changed in the following commit.

SCons/scons20412f3

Should I be using an older version of SCons perhaps. I will test that hypothesis.

Scons Versions
RELEASE 4.6.0 - Sun, 19 Nov 2023 17:22:20 -0700
RELEASE 4.5.2 - Sun, 21 Mar 2023 14:08:29 -0700

The change was pushed into the repo
@jcbrill jcbrill committed on May 4, 2023 and is tagged as 4.6

When using scoop to install (As recommended by godot build) you get 4.6.0 automatically.

travi@MSI MINGW64 /c/work/Godot-Spine/spine-runtimes/spine-godot/build (4.1)
$ scoop install scons
Installing 'scons' (4.6.0) [64bit] from main bucket
Loading scons-local-4.6.0.zip from cache
Checking hash of scons-local-4.6.0.zip ... ok.
Extracting scons-local-4.6.0.zip ... done.
Running pre_install script...
Linking ~\scoop\apps\scons\current => ~\scoop\apps\scons\4.6.0
Creating shim for 'scons'.
'scons' (4.6.0) was installed successfully!

Removing scons with scoop and installing the specific version with pip downgraded scons successfully.

travi@MSI MINGW64 /c/work/Godot-Spine/spine-runtimes/spine-godot/build (4.1)
$ scoop uninstall scons
Uninstalling 'scons' (4.6.0).
Removing shim 'scons'.
Removing shim 'scons.cmd'.
Removing shim 'scons.ps1'.
Unlinking ~\scoop\apps\scons\current
'scons' was uninstalled.

travi@MSI MINGW64 /c/work/Godot-Spine/spine-runtimes/spine-godot/build (4.1)
$ pip install scons==4.5.2
Collecting scons==4.5.2
  Downloading SCons-4.5.2-py3-none-any.whl.metadata (8.8 kB)
Requirement already satisfied: setuptools in c:\users\travi\scoop\apps\python\current\lib\site-packages (from scons==4.5.2) (69.1.1)
Downloading SCons-4.5.2-py3-none-any.whl (4.3 MB)
   ---------------------------------------- 4.3/4.3 MB 1.8 MB/s eta 0:00:00
Installing collected packages: scons
  Attempting uninstall: scons
    Found existing installation: SCons 4.6.0.post1
    Uninstalling SCons-4.6.0.post1:
      Successfully uninstalled SCons-4.6.0.post1
Successfully installed scons-4.5.2

This has solved the build error.

Sorry you had to suffer through this. Sadly, we can't really do anything about Godot's choice of SCons. The issues you ran into are purely related to Godot's build.

Maybe it makes sense to report these to Godot so they can update their docs?

Unless you build locally, e.g. because you want to add your own engine modules, I recommend using our GitHub workflow to build the Godot editor and export templates. See
https://esotericsoftware.com/spine-godot#Building-the-Godot-editor-and-export-templates-via-GitHub-Actions

    Mario I should have made that connection. I will definitely do that thank you.

    I tested for this issue on godot branch 4.2.1-stable that version of the godot code handles both scons 4.5.x and 4.6 just leaving this here for anyone else that happens upon this issue.

    Mario thank you for the GitHub action suggestion. Has made everything a lot simpler.

    3 ay sonra

    Mario if I want to compile with a PCK encryption key on Godot, do I have to build the export templates locally? i assume i would because the Godot docs warn "This will not work if you use official, precompiled export templates. It is absolutely required to compile your own export templates to use PCK encryption."

    I'm afraid I have zero experience with PCK encryption in relation to Godot. That's likely something you'll get a better answer for from the Godot community.

    If you have to build your own templates, you can still use the GitHub action as suggested above. You just need to figure out how to enable the encryption.

      Mario
      oh it's all good. i realized after looking at the workflow .yml files you guys provide on the runtime repo, there's a whole bunch of ENV variables in there, and i decided to try putting my own PCK env variable in there (using secrets ofc) and it worked!

      Awesome!