Skip to content

Commit ac869e7

Browse files
authored
Linux build support local & actions. (#19)
* Docker compose for build/testing Linux builds. * Update SConstruct for linux linking. * Include ultralight resources & inspector. * Copy resources folder on build. * Linux able to build using clang.
1 parent d6722a8 commit ac869e7

File tree

1,725 files changed

+309036
-30
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,725 files changed

+309036
-30
lines changed

.github/workflows/builds.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
# See https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow
1616
target:
1717
[
18-
# { platform: linux, arch: x86_64, os: ubuntu-22.04 },
18+
{ platform: linux, arch: x86_64, os: ubuntu-22.04 },
1919
{ platform: windows, arch: x86_64, os: windows-latest },
2020
# { platform: windows, arch: x86_32, os: windows-latest }, # Ultralight does not support x32.
2121
# { platform: macos, arch: universal, os: macos-latest },
@@ -73,7 +73,7 @@ jobs:
7373
env:
7474
SCONS_CACHE: ${{ github.workspace }}/.scons-cache/
7575
run: |
76-
scons target=${{ matrix.target-type }} platform=${{ matrix.target.platform }} arch=${{ matrix.target.arch }} precision=${{ matrix.float-precision }}
76+
scons use_llvm=yes target=${{ matrix.target-type }} platform=${{ matrix.target.platform }} arch=${{ matrix.target.arch }} precision=${{ matrix.float-precision }}
7777
7878
# Sign the binary (macOS only)
7979
# - name: Mac Sign

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ bin
5959

6060
# Ultralight
6161
!ultralight/bin/
62+
!ultralight/bin/linux/*.so
6263
!ultralight/lib/*.lib
6364

6465
__pycache__

SConstruct

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,17 @@ filepath = ""
5454

5555
if env["platform"] == "windows":
5656
env.Append(LIBPATH=["ultralight/lib/"])
57-
env.Append(LIBS=["Ultralight"])
58-
env.Append(LIBS=["UltralightCore"])
59-
env.Append(LIBS=["WebCore"])
60-
env.Append(LIBS=["AppCore"])
61-
62-
if env["platform"] == "macos" or env["platform"] == "ios":
57+
elif env["platform"] == "linux":
58+
env.Append(LIBPATH=["ultralight/bin/linux/"])
59+
elif env["platform"] == "macos" or env["platform"] == "ios":
6360
filepath = "{}.framework/".format(env["platform"])
6461
file = "{}{}".format(libname, env["suffix"])
6562

63+
env.Append(LIBS=["Ultralight"])
64+
env.Append(LIBS=["UltralightCore"])
65+
env.Append(LIBS=["WebCore"])
66+
env.Append(LIBS=["AppCore"])
67+
6668
libraryfile = "bin/{}/{}{}".format(env["platform"], filepath, file)
6769
library = env.SharedLibrary(
6870
libraryfile,
@@ -74,22 +76,31 @@ copy = env.InstallAs("{}/addons/{}/bin/{}/{}{}".format(projectdir, libname, env[
7476
default_args = [library, copy]
7577
Default(*default_args)
7678

79+
if env["platform"] == "windows":
80+
Execute(Copy(
81+
f"{projectdir}/addons/{libname}/bin/windows/",
82+
[
83+
"ultralight/bin/windows/AppCore.dll",
84+
"ultralight/bin/windows/Ultralight.dll",
85+
"ultralight/bin/windows/UltralightCore.dll",
86+
"ultralight/bin/windows/WebCore.dll"
87+
]
88+
))
89+
elif env["platform"] == "linux":
90+
Execute(Copy(
91+
f"{projectdir}/addons/{libname}/bin/linux/",
92+
[
93+
"ultralight/bin/linux/libAppCore.so",
94+
"ultralight/bin/linux/libUltralight.so",
95+
"ultralight/bin/linux/libUltralightCore.so",
96+
"ultralight/bin/linux/libWebCore.so"
97+
]
98+
))
99+
77100
Execute(Copy(
78-
f"{projectdir}/addons/{libname}/bin/windows/",
79-
[
80-
"ultralight/bin/windows/AppCore.dll",
81-
"ultralight/bin/windows/Ultralight.dll",
82-
"ultralight/bin/windows/UltralightCore.dll",
83-
"ultralight/bin/windows/WebCore.dll"
101+
f"{projectdir}/addons/{libname}/resources/",
102+
[
103+
"ultralight/resources/cacert.pem",
104+
"ultralight/resources/icudt67l.dat"
84105
]
85106
))
86-
87-
# Execute(Copy(
88-
# f"{projectdir}/addons/{libname}/bin/linux/",
89-
# [
90-
# "ultralight/bin/linux/libAppCore.so",
91-
# "ultralight/bin/linux/libUltralight.so",
92-
# "ultralight/bin/linux/libUltralightCore.so",
93-
# "ultralight/bin/linux/libWebCore.so"
94-
# ]
95-
# ))

docker-compose.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
volumes:
2+
home:
3+
4+
services:
5+
webtop:
6+
image: lscr.io/linuxserver/webtop:ubuntu-kde
7+
container_name: gdextension-builder
8+
security_opt:
9+
- seccomp:unconfined
10+
environment:
11+
- PUID=1000
12+
- PGIP=1000
13+
- TZ=America/Chicago
14+
- TITLE=GDExtension Builder
15+
- DOCKER_MODS=linuxserver/mods:universal-package-install
16+
- INSTALL_PACKAGES=git|gh|nodejs|npm|zip|unzip|p7zip|python3.12|clang|lld|build-essential|scons|pkg-config|libx11-dev|libxcursor-dev|libxinerama-dev|libgl1-mesa-dev|libglu1-mesa-dev|libasound2-dev|libpulse-dev|libudev-dev|libxi-dev|libxrandr-dev|libwayland-dev
17+
volumes:
18+
- home:/config
19+
ports:
20+
- 3000:3000
21+
- 3001:3001
22+
# devices:
23+
# - /dev/dri:/dev/dri #optional
24+
shm_size: "1gb"
25+
restart: unless-stopped

src/ultralight/godot_font_loader.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
#define GFONTLOADER_H
33

44
#include <Ultralight/Ultralight.h>
5-
#include <AppCore/Platform.h>
6-
#include <JavaScriptCore/JavaScript.h>
75

86
#include <godot_cpp/classes/file_access.hpp>
7+
#include <godot_cpp/classes/os.hpp>
8+
#include <godot_cpp/classes/font.hpp>
9+
#include <godot_cpp/variant/utility_functions.hpp>
910

1011
namespace ultralight
1112
{
@@ -17,17 +18,22 @@ namespace ultralight
1718

1819
String fallback_font() const override
1920
{
20-
21+
auto system_fonts = godot::OS::get_singleton()->get_system_fonts();
22+
CRASH_COND_MSG(system_fonts.size() == 0, "No system fonts to fallback on.");
23+
return String(system_fonts[0].utf8().get_data());
2124
}
2225

23-
String fallback_font_for_characters(const String &characters, int weight, bool italic) const override
26+
String fallback_font_for_characters(const String &characters, int weight, bool italic) const override
2427
{
25-
28+
return fallback_font();
2629
}
2730

2831
RefPtr<FontFile> Load(const String &family, int weight, bool italic) override
2932
{
30-
33+
auto font_family = godot::String(family.utf8().data());
34+
auto font_path = godot::OS::get_singleton()->get_system_font_path(font_family, weight, 100, italic);
35+
auto font_file = FontFile::Create(String(font_path.utf8().get_data()));
36+
return font_file;
3137
}
3238

3339
};

ultralight/bin/linux/libAppCore.so

680 KB
Binary file not shown.
951 KB
Binary file not shown.
3.39 MB
Binary file not shown.

ultralight/bin/linux/libWebCore.so

72.9 MB
Binary file not shown.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright (C) 2019 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
* THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
WI.BlobUtilities = class BlobUtilities {
27+
static blobForContent(content, base64Encoded, mimeType)
28+
{
29+
if (base64Encoded)
30+
return BlobUtilities.decodeBase64ToBlob(content, mimeType);
31+
return BlobUtilities.textToBlob(content, mimeType);
32+
}
33+
34+
static decodeBase64ToBlob(base64Data, mimeType)
35+
{
36+
mimeType = mimeType || "";
37+
38+
const sliceSize = 1024;
39+
let byteCharacters = atob(base64Data);
40+
let bytesLength = byteCharacters.length;
41+
let slicesCount = Math.ceil(bytesLength / sliceSize);
42+
let byteArrays = new Array(slicesCount);
43+
44+
for (let sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
45+
let begin = sliceIndex * sliceSize;
46+
let end = Math.min(begin + sliceSize, bytesLength);
47+
48+
let bytes = new Array(end - begin);
49+
for (let offset = begin, i = 0; offset < end; ++i, ++offset)
50+
bytes[i] = byteCharacters[offset].charCodeAt(0);
51+
52+
byteArrays[sliceIndex] = new Uint8Array(bytes);
53+
}
54+
55+
return new Blob(byteArrays, {type: mimeType});
56+
}
57+
58+
static textToBlob(text, mimeType)
59+
{
60+
return new Blob([text], {type: mimeType});
61+
}
62+
63+
static blobAsText(blob, callback)
64+
{
65+
console.assert(blob instanceof Blob);
66+
let fileReader = new FileReader;
67+
fileReader.addEventListener("loadend", () => { callback(fileReader.result); });
68+
fileReader.readAsText(blob);
69+
}
70+
};

0 commit comments

Comments
 (0)