Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/v-sekai-godot/vsk-desync-4.4' i…
Browse files Browse the repository at this point in the history
…nto groups-staging-4.4
  • Loading branch information
fire committed Oct 16, 2024
2 parents f6225ec + 5e80072 commit 8fb6bd4
Show file tree
Hide file tree
Showing 176 changed files with 18,939 additions and 4 deletions.
20 changes: 16 additions & 4 deletions .github/actions/godot-deps/action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name: Setup Python and SCons
description: Setup Python, install the pip version of SCons.

name: Setup python, scons and golang
description: Setup python, install the pip version of scons and setup golang.
inputs:
python-version:
description: The Python version to use.
default: 3.x
python-arch:
description: The Python architecture.
default: x64
default: "x64"
go-version:
description: The Go version to use.
default: "1.22.3"
scons-version:
description: The SCons version to use.
default: 4.8.0
Expand All @@ -30,3 +32,13 @@ runs:
python -m pip install wheel
python -m pip install scons==${{ inputs.scons-version }}
scons --version
# Setup Golang
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ inputs.go-version }}

- name: Check Go version
shell: bash
run: go version
17 changes: 17 additions & 0 deletions modules/desync_otel/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Godot 4+ specific ignores
.godot/

# Godot-specific ignores
.import/
export.cfg
export_presets.cfg

# Imported translations (automatically generated from CSV files)
*.translation

# Mono-specific ignores
.mono/
data_*/
mono_crash.*.json

libdesync_c_interface.h
12 changes: 12 additions & 0 deletions modules/desync_otel/.gitrepo
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
; DO NOT EDIT (unless you know what you are doing)
;
; This subdirectory is a git "subrepo", and this file is maintained by the
; git-subrepo command. See https://github.com/ingydotnet/git-subrepo#readme
;
[subrepo]
remote = https://github.com/V-Sekai/godot-desync.git
branch = main
commit = 7f70d1f6c8a9f852c58783f8ddaeb3eb0840cfad
parent = f053c300009608eafe5faf205697508e8b9dde1d
method = merge
cmdver = 0.4.6
21 changes: 21 additions & 0 deletions modules/desync_otel/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023-present K. S. Ernest (iFire) Lee & V-Sekai Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
23 changes: 23 additions & 0 deletions modules/desync_otel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Godot Engine Open Telemetry & Desync (casync protocol)

```gdscript
extends Node3D
var otel: OpenTelemetry = Opentelemetry.new()
func _ready() -> void:
var error = otel.init_tracer_provider("godot", "localhost:4317", Engine.get_version_info())
print(error)
func _process(_delta) -> void:
var parent_span_id = otel.start_span("test-_ready")
var span_id = otel.start_span_with_parent("test-child", parent_span_id)
otel.add_event(span_id, "test-event")
otel.set_attributes(span_id, {"test-key": "test-value"})
otel.record_error(span_id, str(get_stack()))
otel.end_span(span_id)
otel.end_span(parent_span_id)
func _exit_tree() -> void:
otel.shutdown()
```
52 changes: 52 additions & 0 deletions modules/desync_otel/SCsub
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import subprocess
import os
from os.path import abspath, dirname

Import("env")

thirdparty_obj = []

current_dir = os.getcwd()
desync_dir = os.path.join(current_dir, "thirdparty/desync/cmd/desync")
os.chdir(desync_dir)
suffix = ".a"
env_desync = env.Clone()

if env.msvc:
env_desync.Append(CPPDEFINES=["_SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING"])
suffix = ".lib"
runtime = "desync_c_interface"
subprocess.run(
[
"go",
"build",
"-o",
f"../../../../lib{runtime}{suffix}",
"-buildmode=c-archive",
".",
],
check=True,
)
# https://github.com/ashtonmeuser/godot-wasm/blob/master/SCsub#L44C58-L48C1
os.chdir(current_dir)

env["LIBRUNTIMESUFFIX"] = ".a"

runtime_lib = env.File(
"{prefix}{runtime}{suffix}".format(
runtime=f"{runtime}",
prefix=env["LIBPREFIX"],
suffix=env.get("LIBRUNTIMESUFFIX", env["LIBSUFFIX"]),
)
)
env.Append(LIBS=[runtime_lib])
if env["platform"] == "macos" or env["platform"] == "linuxbsd":
env.Append(LIBS=["resolv"])

env_desync.add_source_files(env.modules_sources, "*.cpp")

module_obj = []
env_desync.add_source_files(module_obj, "*.cpp")
env_desync.modules_sources += module_obj

env.Depends(module_obj, thirdparty_obj)
38 changes: 38 additions & 0 deletions modules/desync_otel/casync.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**************************************************************************/
/* casync.cpp */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/

#include "casync.h"

void Casync::_bind_methods() {
ClassDB::bind_method(D_METHOD("untar", "store_url", "index_url", "output_dir_url", "cache_dir_url"), &Casync::untar);
}

Casync::Casync() {
}
60 changes: 60 additions & 0 deletions modules/desync_otel/casync.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**************************************************************************/
/* casync.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/

#ifndef CASYNC_H
#define CASYNC_H

#include "core/error/error_list.h"
#include "core/object/ref_counted.h"
#include "libdesync_c_interface.h"
#include <stdio.h>

class Casync : public RefCounted {
GDCLASS(Casync, RefCounted);

protected:
static void _bind_methods();

public:
Error untar(String p_store_url, String p_index_url, String p_output_dir_url, String p_cache_dir_url) {
int result = DesyncUntar(p_store_url.utf8().ptrw(),
p_index_url.utf8().ptrw(),
p_output_dir_url.utf8().ptrw(),
p_cache_dir_url.utf8().ptrw());
if (result != 0) {
printf("Error: storeUrl, indexUrl, and outputDir are required\n");
return ERR_INVALID_PARAMETER;
}
return OK;
}
Casync();
};

#endif // CASYNC_H
57 changes: 57 additions & 0 deletions modules/desync_otel/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import os
import subprocess


def can_build(env, platform):
try:
subprocess.check_output(["go", "--version"], stderr=subprocess.STDOUT)
except FileNotFoundError:
print("Go not found. desync build skipped.")
return False
except subprocess.CalledProcessError:
pass

if platform == "web":
return False
if platform == "ios":
return False
if platform == "android":
return False
if platform == "windows":
if os.name != "nt" and env["use_mingw"]:
return False
if not env["use_mingw"]:
return False
try:
mingw_version = subprocess.check_output(["gcc", "--version"])
print("MinGW is installed: ", mingw_version)
except Exception:
print("MinGW is not installed or not found in PATH")
return False
return True

if platform == "macos":
if env.get("arch", "") == "x86_64":
return False
return True


def get_doc_classes():
return [
"Casync",
"OpenTelemetry",
]


def configure(env):
try:
go_version = subprocess.check_output(["go", "version"])
print("Golang is installed: ", go_version)
except Exception:
print("Golang is not installed or not found in PATH")
return False
return True


def get_doc_path():
return "doc_classes"
2 changes: 2 additions & 0 deletions modules/desync_otel/demo/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf
3 changes: 3 additions & 0 deletions modules/desync_otel/demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Godot 4+ specific ignores
.godot/
vsekai_game_windows_x86_64/
1 change: 1 addition & 0 deletions modules/desync_otel/demo/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions modules/desync_otel/demo/icon.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://djhvloxmv0ek8"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
19 changes: 19 additions & 0 deletions modules/desync_otel/demo/node.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (c) 2018-present. This file is part of V-Sekai https://v-sekai.org/.
# SaracenOne & K. S. Ernest (Fire) Lee & Lyuma & MMMaellon & Contributors
# run_split.gd
# SPDX-License-Identifier: MIT
extends Node

var thread = Thread.new()

func _ready():
var callable: Callable = Callable(self, "_async_run")
callable = callable.bind(null)
print(thread.start(callable))

func _async_run(_userdata):
var desync = Desync.new()
var result = desync.untar("https://v-sekai.github.io/casync-v-sekai-game/store",
"https://github.com/V-Sekai/casync-v-sekai-game/raw/main/vsekai_game_windows_x86_64.caidx",
"vsekai_game_windows_x86_64",
String())
6 changes: 6 additions & 0 deletions modules/desync_otel/demo/node.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://cdw8d0qj60srw"]

[ext_resource type="Script" path="res://node.gd" id="1_mbnro"]

[node name="Node" type="Node"]
script = ExtResource("1_mbnro")
Loading

0 comments on commit 8fb6bd4

Please sign in to comment.