Skip to content

Commit

Permalink
SCons: Enable wasm64 support on web builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Repiteo committed Feb 3, 2025
1 parent f60f69a commit 8cd52ea
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 54 deletions.
28 changes: 8 additions & 20 deletions .github/workflows/web_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,13 @@ env:
jobs:
web-template:
runs-on: ubuntu-24.04
name: ${{ matrix.name }}
name: web-template-${{ matrix.arch }}-${{ matrix.threads }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- name: Template w/ threads (target=template_release, threads=yes)
cache-name: web-template
target: template_release
sconsflags: threads=yes
tests: false
artifact: true

- name: Template w/o threads (target=template_release, threads=no)
cache-name: web-nothreads-template
target: template_release
sconsflags: threads=no
tests: false
artifact: true
arch: [wasm32, wasm64, wasm64lld]
threads: [threads, nothreads]

steps:
- name: Checkout
Expand Down Expand Up @@ -60,20 +48,20 @@ jobs:
- name: Compilation
uses: ./.github/actions/godot-build
with:
sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }}
sconsflags: ${{ env.SCONSFLAGS }} arch=${{ matrix.arch }} threads=${{ matrix.threads == 'threads'}}
platform: web
target: ${{ matrix.target }}
tests: ${{ matrix.tests }}
target: template_release
tests: false
scons-cache-limit: 0.5

- name: Save Godot build cache
uses: ./.github/actions/godot-cache-save
with:
cache-name: ${{ matrix.cache-name }}
cache-name: web-template-${{ matrix.arch }}-${{ matrix.threads }}
continue-on-error: true

- name: Upload artifact
uses: ./.github/actions/upload-artifact
if: matrix.artifact
with:
name: ${{ matrix.cache-name }}
name: web-template-${{ matrix.arch }}-${{ matrix.threads }}
5 changes: 2 additions & 3 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ if not env["platform"]:
env["platform"] = "windows"

if env["platform"]:
print(f'Automatically detected platform: {env["platform"]}')
print(f"Automatically detected platform: {env['platform']}")

# Deprecated aliases kept for compatibility.
if env["platform"] in compatibility_platform_aliases:
Expand Down Expand Up @@ -998,8 +998,7 @@ if env["disable_3d"]:
if env["disable_advanced_gui"]:
if env.editor_build:
print_error(
"Build option `disable_advanced_gui=yes` cannot be used for editor builds, "
"only for export template builds."
"Build option `disable_advanced_gui=yes` cannot be used for editor builds, only for export template builds."
)
Exit(255)
else:
Expand Down
8 changes: 4 additions & 4 deletions doc/tools/make_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
# Ascendants
if class_def.inherits:
inherits = class_def.inherits.strip()
f.write(f'**{translate("Inherits:")}** ')
f.write(f"**{translate('Inherits:')}** ")
first = True
while inherits is not None:
if not first:
Expand All @@ -947,7 +947,7 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
inherited.append(c.name)

if len(inherited):
f.write(f'**{translate("Inherited By:")}** ')
f.write(f"**{translate('Inherited By:')}** ")
for i, child in enumerate(inherited):
if i > 0:
f.write(", ")
Expand Down Expand Up @@ -1496,7 +1496,7 @@ def resolve_type(link_type: str) -> str:
return f"``{link_type}``"

if klass.endswith("[]"): # Typed array, strip [] to link to contained type.
return f":ref:`Array<class_Array>`\\[{resolve_type(klass[:-len('[]')])}\\]"
return f":ref:`Array<class_Array>`\\[{resolve_type(klass[: -len('[]')])}\\]"

if klass.startswith("Dictionary["): # Typed dictionary, split elements to link contained types.
parts = klass[len("Dictionary[") : -len("]")].partition(", ")
Expand Down Expand Up @@ -2542,7 +2542,7 @@ def format_table(f: TextIO, data: List[Tuple[Optional[str], ...]], remove_empty_
for i, text in enumerate(row):
if column_sizes[i] == 0 and remove_empty_columns:
continue
row_text += f' {(text or "").ljust(column_sizes[i])} |'
row_text += f" {(text or '').ljust(column_sizes[i])} |"
row_text += "\n"

f.write(f" {row_text}")
Expand Down
2 changes: 1 addition & 1 deletion gles3_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def build_gles3_header(
fd.write("\t\t};\n\n")
variant_count = len(header_data.variant_defines)
else:
fd.write("\t\tstatic const char **_variant_defines[]={" "};\n")
fd.write('\t\tstatic const char **_variant_defines[]={" "};\n')

if header_data.texunits:
fd.write("\t\tstatic TexUnitPair _texunit_pairs[]={\n")
Expand Down
11 changes: 5 additions & 6 deletions methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import subprocess
import sys
from collections import OrderedDict
from io import StringIO, TextIOWrapper
from io import StringIO, TextIOBase
from pathlib import Path
from typing import Generator, List, Optional, Union, cast

Expand Down Expand Up @@ -1201,7 +1201,7 @@ def get_dependencies(file, env, exts, headers, sources, others):
vsconf = ""
for a in vs_configuration["arches"]:
if arch == a["architecture"]:
vsconf = f'{target}|{a["platform"]}'
vsconf = f"{target}|{a['platform']}"
break

condition = "'$(GodotConfiguration)|$(GodotPlatform)'=='" + vsconf + "'"
Expand All @@ -1217,7 +1217,7 @@ def get_dependencies(file, env, exts, headers, sources, others):
properties.append(
"<ActiveProjectItemList_%s>;%s;</ActiveProjectItemList_%s>" % (x, ";".join(itemlist[x]), x)
)
output = f'bin\\godot{env["PROGSUFFIX"]}'
output = f"bin\\godot{env['PROGSUFFIX']}"

with open("misc/msvs/props.template", "r", encoding="utf-8") as file:
props_template = file.read()
Expand Down Expand Up @@ -1453,7 +1453,7 @@ def generated_wrapper(
guard: Optional[bool] = None,
prefix: str = "",
suffix: str = "",
) -> Generator[TextIOWrapper, None, None]:
) -> Generator[TextIOBase, None, None]:
"""
Wrapper class to automatically handle copyright headers and header guards
for generated scripts. Meant to be invoked via `with` statement similar to
Expand All @@ -1475,8 +1475,7 @@ def generated_wrapper(
if isinstance(path, list):
if len(path) > 1:
print_warning(
"Attempting to use generated wrapper with multiple targets; "
f"will only use first entry: {path[0]}"
f"Attempting to use generated wrapper with multiple targets; will only use first entry: {path[0]}"
)
path = path[0]
if not hasattr(path, "get_abspath"):
Expand Down
20 changes: 10 additions & 10 deletions modules/text_server_adv/gdextension_build/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ if env["thorvg_enabled"] and env["freetype_enabled"]:
env.Append(CPPDEFINES=["MODULE_SVG_ENABLED"])

lib = env_tvg.Library(
f'tvg_builtin{env["suffix"]}{env["LIBSUFFIX"]}',
f"tvg_builtin{env['suffix']}{env['LIBSUFFIX']}",
thirdparty_tvg_sources,
)
env.Append(LIBS=[lib])
Expand Down Expand Up @@ -155,7 +155,7 @@ if env["msdfgen_enabled"] and env["freetype_enabled"]:
env.Append(CPPDEFINES=["MODULE_MSDFGEN_ENABLED"])

lib = env_msdfgen.Library(
f'msdfgen_builtin{env["suffix"]}{env["LIBSUFFIX"]}',
f"msdfgen_builtin{env['suffix']}{env['LIBSUFFIX']}",
thirdparty_msdfgen_sources,
)
env.Append(LIBS=[lib])
Expand Down Expand Up @@ -284,7 +284,7 @@ if env["freetype_enabled"]:
env.Append(CPPDEFINES=["MODULE_FREETYPE_ENABLED"])

lib = env_freetype.Library(
f'freetype_builtin{env["suffix"]}{env["LIBSUFFIX"]}',
f"freetype_builtin{env['suffix']}{env['LIBSUFFIX']}",
thirdparty_freetype_sources,
)
env.Append(LIBS=[lib])
Expand Down Expand Up @@ -418,7 +418,7 @@ if env["freetype_enabled"]:
env.Append(CPPPATH=["../../../thirdparty/harfbuzz/src"])

lib = env_harfbuzz.Library(
f'harfbuzz_builtin{env["suffix"]}{env["LIBSUFFIX"]}',
f"harfbuzz_builtin{env['suffix']}{env['LIBSUFFIX']}",
thirdparty_harfbuzz_sources,
)
env.Prepend(LIBS=[lib])
Expand Down Expand Up @@ -478,7 +478,7 @@ if env["graphite_enabled"] and env["freetype_enabled"]:
)

lib = env_graphite.Library(
f'graphite_builtin{env["suffix"]}{env["LIBSUFFIX"]}',
f"graphite_builtin{env['suffix']}{env['LIBSUFFIX']}",
thirdparty_graphite_sources,
)
env.Append(LIBS=[lib])
Expand Down Expand Up @@ -737,7 +737,7 @@ env.Append(CPPPATH=["../../../thirdparty/icu4c/common/", "../../../thirdparty/ic
if env["platform"] == "windows":
env.Append(LIBS=["advapi32"])

lib = env_icu.Library(f'icu_builtin{env["suffix"]}{env["LIBSUFFIX"]}', thirdparty_icu_sources)
lib = env_icu.Library(f"icu_builtin{env['suffix']}{env['LIBSUFFIX']}", thirdparty_icu_sources)
env.Append(LIBS=[lib])

env.Append(CPPDEFINES=["GDEXTENSION"])
Expand All @@ -746,18 +746,18 @@ sources = Glob("../*.cpp")

if env["platform"] == "macos":
methods.write_macos_plist(
f'./bin/libtextserver_advanced.macos.{env["target"]}.framework',
f'libtextserver_advanced.macos.{env["target"]}',
f"./bin/libtextserver_advanced.macos.{env['target']}.framework",
f"libtextserver_advanced.macos.{env['target']}",
"org.godotengine.textserver_advanced",
"ICU / HarfBuzz / Graphite Text Server",
)
library = env.SharedLibrary(
f'./bin/libtextserver_advanced.macos.{env["target"]}.framework/libtextserver_advanced.macos.{env["target"]}',
f"./bin/libtextserver_advanced.macos.{env['target']}.framework/libtextserver_advanced.macos.{env['target']}",
source=sources,
)
else:
library = env.SharedLibrary(
f'./bin/libtextserver_advanced{env["suffix"]}{env["SHLIBSUFFIX"]}',
f"./bin/libtextserver_advanced{env['suffix']}{env['SHLIBSUFFIX']}",
source=sources,
)

Expand Down
14 changes: 7 additions & 7 deletions modules/text_server_fb/gdextension_build/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ if env["thorvg_enabled"] and env["freetype_enabled"]:
env.Append(CPPDEFINES=["MODULE_SVG_ENABLED"])

lib = env_tvg.Library(
f'tvg_builtin{env["suffix"]}{env["LIBSUFFIX"]}',
f"tvg_builtin{env['suffix']}{env['LIBSUFFIX']}",
thirdparty_tvg_sources,
)
env.Append(LIBS=[lib])
Expand Down Expand Up @@ -150,7 +150,7 @@ if env["msdfgen_enabled"] and env["freetype_enabled"]:
env.Append(CPPDEFINES=["MODULE_MSDFGEN_ENABLED"])

lib = env_msdfgen.Library(
f'msdfgen_builtin{env["suffix"]}{env["LIBSUFFIX"]}',
f"msdfgen_builtin{env['suffix']}{env['LIBSUFFIX']}",
thirdparty_msdfgen_sources,
)
env.Append(LIBS=[lib])
Expand Down Expand Up @@ -279,7 +279,7 @@ if env["freetype_enabled"]:
env.Append(CPPDEFINES=["MODULE_FREETYPE_ENABLED"])

lib = env_freetype.Library(
f'freetype_builtin{env["suffix"]}{env["LIBSUFFIX"]}',
f"freetype_builtin{env['suffix']}{env['LIBSUFFIX']}",
thirdparty_freetype_sources,
)
env.Append(LIBS=[lib])
Expand All @@ -291,18 +291,18 @@ sources = Glob("../*.cpp")

if env["platform"] == "macos":
methods.write_macos_plist(
f'./bin/libtextserver_fallback.macos.{env["target"]}.framework',
f'libtextserver_fallback.macos.{env["target"]}',
f"./bin/libtextserver_fallback.macos.{env['target']}.framework",
f"libtextserver_fallback.macos.{env['target']}",
"org.godotengine.textserver_fallback",
"Fallback Text Server",
)
library = env.SharedLibrary(
f'./bin/libtextserver_fallback.macos.{env["target"]}.framework/libtextserver_fallback.macos.{env["target"]}',
f"./bin/libtextserver_fallback.macos.{env['target']}.framework/libtextserver_fallback.macos.{env['target']}",
source=sources,
)
else:
library = env.SharedLibrary(
f'./bin/libtextserver_fallback{env["suffix"]}{env["SHLIBSUFFIX"]}',
f"./bin/libtextserver_fallback{env['suffix']}{env['SHLIBSUFFIX']}",
source=sources,
)

Expand Down
6 changes: 5 additions & 1 deletion platform/web/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def get_flags():

def configure(env: "SConsEnvironment"):
# Validate arch.
supported_arches = ["wasm32"]
supported_arches = ["wasm32", "wasm64", "wasm64lld"]
validate_arch(env["arch"], get_name(), supported_arches)

try:
Expand Down Expand Up @@ -256,6 +256,10 @@ def configure(env: "SConsEnvironment"):
env.extra_suffix = ".dlink" + env.extra_suffix

env.Append(LINKFLAGS=["-sWASM_BIGINT"])
env.Append(
CCFLAGS=[memory64 := f"-sMEMORY64={0 if env['arch'] == 'wasm32' else 1 if env['arch'] == 'wasm64' else 2}"]
)
env.Append(LINKFLAGS=[memory64])

# Run the main application in a web worker
if env["proxy_to_pthread"]:
Expand Down
14 changes: 13 additions & 1 deletion platform_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,19 @@
}

# CPU architecture options.
architectures = ["x86_32", "x86_64", "arm32", "arm64", "rv64", "ppc32", "ppc64", "wasm32", "loongarch64"]
architectures = [
"x86_32",
"x86_64",
"arm32",
"arm64",
"rv64",
"ppc32",
"ppc64",
"wasm32",
"wasm64",
"wasm64lld",
"loongarch64",
]
architecture_aliases = {
"x86": "x86_32",
"x64": "x86_64",
Expand Down
6 changes: 5 additions & 1 deletion thirdparty/jolt_physics/Jolt/Core/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@
#elif defined(JPH_PLATFORM_WASM)
// WebAssembly CPU architecture
#define JPH_CPU_WASM
#define JPH_CPU_ADDRESS_BITS 32
#if defined(__wasm64__)
#define JPH_CPU_ADDRESS_BITS 64
#else
#define JPH_CPU_ADDRESS_BITS 32
#endif
#define JPH_VECTOR_ALIGNMENT 16
#define JPH_DVECTOR_ALIGNMENT 32
#ifdef __wasm_simd128__
Expand Down

0 comments on commit 8cd52ea

Please sign in to comment.