Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make static libs too #202

Merged
merged 12 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/build_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,12 @@ jobs:
path: |
${{ github.workspace }}/bin/**/*.so
if-no-files-found: error

- name: Upload Static Artifact
uses: actions/upload-artifact@v4
with:
name: static-sandbox-android-${{ matrix.arch }}-${{ matrix.precision }}
path: |
${{ github.workspace }}/bin/**/*.a
${{ github.workspace }}/ext/godot-cpp/**/*.a
if-no-files-found: error
11 changes: 10 additions & 1 deletion .github/workflows/build_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,14 @@ jobs:
with:
name: godot-sandbox-ios-${{ matrix.arch }}-${{ matrix.precision }}
path: |
${{ github.workspace }}/bin/**/libgodot_riscv.ios.template_release${{ matrix.extension }}.arm64.framework/**
${{ github.workspace }}/bin/**/*.arm64
if-no-files-found: error

- name: Upload Artifact Static
uses: actions/upload-artifact@v4
with:
name: static-sandbox-ios-${{ matrix.arch }}-${{ matrix.precision }}
path: |
${{ github.workspace }}/bin/**/*.a
${{ github.workspace }}/ext/godot-cpp/**/*.a
if-no-files-found: error
11 changes: 10 additions & 1 deletion .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
submodules: true
fetch-depth: 0

- name: Compiler Fix
shell: bash
run: |
Expand All @@ -41,3 +41,12 @@ jobs:
path: |
${{ github.workspace }}/bin/**/*.so
if-no-files-found: error

- name: Upload Artifact Static
uses: actions/upload-artifact@v4
with:
name: static-sandbox-linux-${{ matrix.arch }}-${{ matrix.precision }}
path: |
${{ github.workspace }}/bin/**/*.a
${{ github.workspace }}/ext/godot-cpp/**/*.a
if-no-files-found: error
11 changes: 10 additions & 1 deletion .github/workflows/build_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,14 @@ jobs:
with:
name: godot-sandbox-macos-${{ matrix.arch }}-${{ matrix.precision }}
path: |
${{ github.workspace }}/bin/**/libgodot_riscv.macos.template_release${{ matrix.extension }}.universal.framework/**
${{ github.workspace }}/bin/**/*.universal
if-no-files-found: error

- name: Upload Artifact Static
uses: actions/upload-artifact@v4
with:
name: static-sandbox-macos-${{ matrix.arch }}-${{ matrix.precision }}
path: |
${{ github.workspace }}/bin/**/*.a
${{ github.workspace }}/ext/godot-cpp/**/*.a
if-no-files-found: error
43 changes: 0 additions & 43 deletions .github/workflows/build_module.yml

This file was deleted.

9 changes: 9 additions & 0 deletions .github/workflows/build_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,12 @@ jobs:
path: |
${{ github.workspace }}/bin/**/*.wasm
if-no-files-found: error

- name: Upload Artifact Static
uses: actions/upload-artifact@v4
with:
name: static-sandbox-web-${{ matrix.arch }}-${{ matrix.precision }}
path: |
${{ github.workspace }}/bin/**/*.a
${{ github.workspace }}/ext/godot-cpp/**/*.a
if-no-files-found: error
9 changes: 9 additions & 0 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,12 @@ jobs:
path: |
${{ github.workspace }}/bin/**/*.dll
if-no-files-found: error

- name: Upload Artifact Static
uses: actions/upload-artifact@v4
with:
name: static-sandbox-windows-${{ matrix.arch }}-${{ matrix.precision }}
path: |
${{ github.workspace }}/bin/**/*.a
${{ github.workspace }}/ext/godot-cpp/**/*.a
if-no-files-found: error
9 changes: 9 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ jobs:
merge-multiple: true
path: godot-sandbox
name: godot-sandbox
- name: Download artifacts static
uses: actions/download-artifact@v4
with:
pattern: static-sandbox-*
merge-multiple: true
path: static-sandbox
name: static-sandbox
- name: Delete draft release(s)
uses: hugo19941994/delete-draft-releases@v1.0.0
env:
Expand All @@ -25,12 +32,14 @@ jobs:
run: |
ls
zip -r "godot-sandbox.zip" godot-sandbox
zip -r "static-sandbox.zip" static-sandbox
- name: Release
uses: softprops/action-gh-release@v2
with:
name: Godot Sandbox Nightly
files: |
godot-sandbox.zip
static-sandbox.zip
generate_release_notes: true
draft: true
prerelease: true
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ jobs:
attestations: write
id-token: write

#build_module:
# needs: [lint]
# uses: ./.github/workflows/build_module.yml

merge:
runs-on: ubuntu-latest
name: Merge
Expand All @@ -60,6 +56,10 @@ jobs:
with:
name: godot-sandbox
pattern: godot-sandbox-*
- uses: actions/upload-artifact/merge@v4
with:
name: static-sandbox
pattern: static-sandbox-*

release:
name: Create Release
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ bin/addons/godot_sandbox/bin/*

# Ignore all CPP files in the bintr directory
src/bintr/*.cpp
*.pyc
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
url = https://github.com/fwsGonzo/libriscv.git
[submodule "godot-cpp"]
path = ext/godot-cpp
url = https://github.com/ughuuu/godot-cpp.git
url = https://github.com/godotengine/godot-cpp.git
[submodule "ext/Gut"]
path = ext/Gut
url = https://github.com/bitwes/Gut.git
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ set(SOURCES
src/docker.cpp
src/godot/script_instance.cpp
src/guest_variant.cpp
register_types.cpp
src/register_types.cpp
src/sandbox.cpp
src/sandbox_debug.cpp
src/sandbox_exception.cpp
Expand Down Expand Up @@ -58,7 +58,6 @@ add_subdirectory(ext)
add_library(godot-riscv SHARED ${SOURCES})
target_link_libraries(godot-riscv PUBLIC riscv godot-cpp)


if (STATIC_BUILD)
target_link_libraries(godot-riscv PUBLIC -static)
endif()
Expand Down
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,6 @@ Linting:
./scripts/clang-tidy.sh
```

Build as module:

```sh
# Build bindings in sandbox
scons generate_bindings=true build_library=no godot_repo=godot
# Clone godot
git clone https://github.com/godotengine/godot.git
# Make a symbolic link
cd ../godot/modules
ln -s /path/to/your/sandbox sandbox
# Build godot editor
scons verbose=True target=editor enable_sandbox_module=True disable_exceptions=False
```

## Icons

The script icon is built from the Godot icons. It's using the same font as the Godot Logo, which is Lilita One. The icons are then imported into Godot once in order to check the box `Scale With Editor` in the import panel.
Expand Down
88 changes: 85 additions & 3 deletions SConstruct
Original file line number Diff line number Diff line change
@@ -1,14 +1,82 @@
#!/usr/bin/env python
import os
import sys
from build_utils import add_compilation_flags, get_sources

ARGUMENTS["disable_exceptions"] = "0"
ARGUMENTS["use_mingw"] = "yes"

env = SConscript("ext/godot-cpp/SConstruct")
env = add_compilation_flags(env)
sources = get_sources(env)

env.Append(CPPDEFINES = ['RISCV_SYSCALLS_MAX=600', 'RISCV_BRK_MEMORY_SIZE=0x100000'])
env.Prepend(CPPPATH=["ext/libriscv/lib"])
env.Append(CPPPATH=["src/", "."])

sources = [Glob("src/*.cpp"), Glob("src/cpp/*.cpp"), Glob("src/rust/*.cpp"), Glob("src/zig/*.cpp"), Glob("src/elf/*.cpp"), Glob("src/godot/*.cpp"), ["src/tests/dummy_assault.cpp"], Glob("src/bintr/*.cpp")]

librisc_sources = [
# threaded fast-path:
"ext/libriscv/lib/libriscv/threaded_dispatch.cpp",

"ext/libriscv/lib/libriscv/cpu.cpp",
"ext/libriscv/lib/libriscv/debug.cpp",
"ext/libriscv/lib/libriscv/decode_bytecodes.cpp",
"ext/libriscv/lib/libriscv/decoder_cache.cpp",
"ext/libriscv/lib/libriscv/machine.cpp",
"ext/libriscv/lib/libriscv/machine_defaults.cpp",
"ext/libriscv/lib/libriscv/memory.cpp",
"ext/libriscv/lib/libriscv/memory_elf.cpp",
"ext/libriscv/lib/libriscv/memory_mmap.cpp",
"ext/libriscv/lib/libriscv/memory_rw.cpp",
"ext/libriscv/lib/libriscv/multiprocessing.cpp",
"ext/libriscv/lib/libriscv/native_libc.cpp",
"ext/libriscv/lib/libriscv/native_threads.cpp",
#"ext/libriscv/lib/libriscv/rv32i.cpp",
"ext/libriscv/lib/libriscv/rv64i.cpp",
"ext/libriscv/lib/libriscv/serialize.cpp",

# POSIX
"ext/libriscv/lib/libriscv/posix/socket_calls.cpp",
"ext/libriscv/lib/libriscv/posix/minimal.cpp",
"ext/libriscv/lib/libriscv/posix/signals.cpp",
"ext/libriscv/lib/libriscv/posix/threads.cpp",
"ext/libriscv/lib/libriscv/util/crc32c.cpp",

# Binary translator
"ext/libriscv/lib/libriscv/tr_api.cpp",
"ext/libriscv/lib/libriscv/tr_emit.cpp",
"ext/libriscv/lib/libriscv/tr_translate.cpp",
]

if env["platform"] == "windows":
librisc_sources += [
"ext/libriscv/lib/libriscv/win32/dlfcn.cpp",
"ext/libriscv/lib/libriscv/win32/system_calls.cpp",
"ext/libriscv/lib/libriscv/win32/tr_msvc.cpp",
]
else:
librisc_sources += [
"ext/libriscv/lib/libriscv/linux/system_calls.cpp",

# Binary translator - TCC
#"ext/libriscv/lib/libriscv/tr_tcc.cpp"
# Binary translator - System compiler
"ext/libriscv/lib/libriscv/tr_compiler.cpp",
]

if env["platform"] != "windows" or env["use_mingw"]:
env.Append(CXXFLAGS=["-std=c++20"])
else:
env.Append(CXXFLAGS=["/std:c++20"])

sources.extend(librisc_sources)

if env["platform"] == "windows":
env.Prepend(CPPPATH=["ext/libriscv/lib/libriscv/lib/win32"])
env.Prepend(LIBS=['ws2_32']) # for socket calls
elif env["platform"] == "macos":
env.Prepend(CPPPATH=["ext/libriscv/lib/libriscv/lib/macos"])
elif env["platform"] == "linux" or env["platform"] == "android":
env.Prepend(CPPPATH=["ext/libriscv/lib/libriscv/lib/linux"])

if env["platform"] == "macos" or env["platform"] == "ios":
library = env.SharedLibrary(
Expand All @@ -23,3 +91,17 @@ else:
source=sources,
)
Default(library)
# Static lib
if env["platform"] == "macos" or env["platform"] == "ios":
library = env.StaticLibrary(
"bin/addons/godot_sandbox/bin/libgodot_riscv{}.framework/libgodot_riscv{}{}".format(
env["suffix"], env["suffix"], env["LIBSUFFIX"]
),
source=sources,
)
else:
library = env.StaticLibrary(
"bin/addons/godot_sandbox/bin/libgodot_riscv{}{}".format(env["suffix"], env["LIBSUFFIX"]),
source=sources,
)
Default(library)
21 changes: 0 additions & 21 deletions SCsub

This file was deleted.

6 changes: 3 additions & 3 deletions bin/addons/godot_sandbox/ZIGScript.svg.import
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://cqvle38bxnums"
path="res://.godot/imported/ZIGScript.svg-c7ed841d4ab8a770c34b1982f253465c.ctex"
path="res://.godot/imported/ZigScript.svg-c7ed841d4ab8a770c34b1982f253465c.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}

[deps]

source_file="res://addons/godot_sandbox/ZIGScript.svg"
dest_files=["res://.godot/imported/ZIGScript.svg-c7ed841d4ab8a770c34b1982f253465c.ctex"]
source_file="res://addons/godot_sandbox/ZigScript.svg"
dest_files=["res://.godot/imported/ZigScript.svg-c7ed841d4ab8a770c34b1982f253465c.ctex"]

[params]

Expand Down
Loading