fix(GDExt): add gdextension module source

This commit is contained in:
William Edwards
2024-08-09 20:59:02 -07:00
parent 137d63785b
commit dacae43736
36 changed files with 450 additions and 123 deletions

19
.gitmodules vendored Normal file
View File

@@ -0,0 +1,19 @@
[submodule "gdext/godot-dbus"]
path = gdext/godot-dbus
url = https://github.com/ShadowBlip/godot-dbus.git
[submodule "gdext/godot-cpp"]
path = gdext/godot-cpp
url = https://github.com/godotengine/godot-cpp
branch = 4.2
[submodule "gdext/godot-linuxthread"]
path = gdext/godot-linuxthread
url = https://github.com/ShadowBlip/godot-linuxthread.git
[submodule "gdext/godot-pty"]
path = gdext/godot-pty
url = https://github.com/ShadowBlip/godot-pty.git
[submodule "gdext/godot-unix-socket"]
path = gdext/godot-unix-socket
url = https://github.com/ShadowBlip/godot-unix-socket.git
[submodule "gdext/godot-xlib"]
path = gdext/godot-xlib
url = https://github.com/ShadowBlip/godot-xlib.git

View File

@@ -43,7 +43,7 @@ plugins:
# Execute commands to build the project
- - "@semantic-release/exec"
- shell: true
prepareCmd: "make in-docker IMAGE_TAG=4.2.2 TARGET='import' && make in-docker IMAGE_TAG=4.2.2 TARGET='import dist'"
prepareCmd: "make in-docker IMAGE_TAG=4.2.2 TARGET='dist'"
# Publish artifacts as a GitHub release
- - "@semantic-release/github"

View File

@@ -1,26 +1,32 @@
PREFIX ?= $(HOME)/.local
CACHE_DIR ?= .cache
IMPORT_DIR := .godot
ROOTFS ?= $(CACHE_DIR)/rootfs
OGUI_VERSION ?= $(shell grep 'core = ' core/global/version.tres | cut -d '"' -f2)
GODOT ?= /usr/bin/godot
GODOT ?= godot
GODOT_VERSION ?= $(shell $(GODOT) --version | grep -o '[0-9].*[0-9]\.' | sed 's/.$$//')
GODOT_RELEASE ?= $(shell $(GODOT) --version | grep -oP '^[0-9].*?[a-z]\.' | grep -oP '[a-z]+')
GODOT_REVISION := $(GODOT_VERSION).$(GODOT_RELEASE)
GAMESCOPE ?= /usr/bin/gamescope
GAMESCOPE ?= gamescope
GAMESCOPE_CMD ?= $(GAMESCOPE) -e --xwayland-count 2 --
BUILD_TYPE ?= release
EXPORT_TEMPLATE ?= $(HOME)/.local/share/godot/export_templates/$(GODOT_REVISION)/linux_debug.x86_64
EXPORT_TEMPLATE ?= $(HOME)/.local/share/godot/export_templates/$(GODOT_REVISION)/linux_$(BUILD_TYPE).x86_64
#EXPORT_TEMPLATE_URL ?= https://downloads.tuxfamily.org/godotengine/$(GODOT_VERSION)/Godot_v$(GODOT_VERSION)-$(GODOT_RELEASE)_export_templates.tpz
EXPORT_TEMPLATE_URL ?= https://github.com/godotengine/godot/releases/download/$(GODOT_VERSION)-$(GODOT_RELEASE)/Godot_v$(GODOT_VERSION)-$(GODOT_RELEASE)_export_templates.tpz
ALL_ADDONS := ./addons/dbus/bin/libdbus.linux.template_$(BUILD_TYPE).x86_64.so ./addons/linuxthread/bin/liblinuxthread.linux.template_$(BUILD_TYPE).x86_64.so ./addons/pty/bin/libpty.linux.template_$(BUILD_TYPE).x86_64.so ./addons/unixsock/bin/libunixsock.linux.template_$(BUILD_TYPE).x86_64.so ./addons/xlib/bin/libxlib.linux.template_$(BUILD_TYPE).x86_64.so
ALL_ADDON_FILES := $(shell find ./addons -regex '.*\(\.cpp\|\.h\|\.hpp\)$$')
ALL_GDSCRIPT := $(shell find ./ -name '*.gd')
ALL_SCENES := $(shell find ./ -name '*.tscn')
ALL_RESOURCES := $(shell find ./ -regex '.*\(tres\|svg\|png\)$$')
PROJECT_FILES := $(ALL_GDSCRIPT) $(ALL_SCENES) $(ALL_RESOURCES)
ALL_RESOURCES := $(shell find ./ -regex '.*\(\.tres\|\.svg\|\.png\)$$')
PROJECT_FILES := $(ALL_ADDONS) $(ALL_GDSCRIPT) $(ALL_SCENES) $(ALL_RESOURCES)
# Docker image variables
IMAGE_NAME ?= ghcr.io/shadowblip/opengamepadui-builder
IMAGE_TAG ?= latest
ADDONS_IMAGE_NAME ?= ghcr.io/shadowblip/opengamepadui-addons-builder
ADDONS_IMAGE_TAG ?= latest
# Remote debugging variables
SSH_USER ?= deck
@@ -50,8 +56,8 @@ SYSEXT_VERSION_ID ?= 3.6.3
.PHONY: help
help: ## Display this help.
@echo "Godot Version: '$(GODOT_VERSION)'"
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
echo $(GODOT_VERSION)
.PHONY: install
install: rootfs ## Install OpenGamepadUI (default: ~/.local)
@@ -95,7 +101,7 @@ HEADLESS := --headless
endif
.PHONY: test
test: ## Run all unit tests
test: $(IMPORT_DIR) ## Run all unit tests
$(GAMESCOPE_CMD) $(GODOT) \
--position 320,140 \
--path $(PWD) $(HEADLESS) \
@@ -103,10 +109,10 @@ test: ## Run all unit tests
.PHONY: build
build: build/opengamepad-ui.x86_64 ## Build and export the project
build/opengamepad-ui.x86_64: $(PROJECT_FILES) $(EXPORT_TEMPLATE)
build/opengamepad-ui.x86_64: $(IMPORT_DIR) $(PROJECT_FILES) $(EXPORT_TEMPLATE)
@echo "Building OpenGamepadUI v$(OGUI_VERSION)"
mkdir -p build
$(GODOT) --headless --export-debug "Linux/X11"
$(GODOT) -v --headless --export-$(BUILD_TYPE) "Linux/X11"
.PHONY: metadata
metadata: build/metadata.json ## Build update metadata
@@ -122,14 +128,14 @@ build/metadata.json: build/opengamepad-ui.x86_64 assets/crypto/keys/opengamepadu
FILE_SIGS="$$FILE_SIGS\"$$lib\": {\"signature\": \"$$SIG\", \"hash\": \"$$HASH\"}, "; \
done; \
# Sign the binary files \
echo "Signing file: opengamepad-ui.sh"; \
SIG=$$(openssl dgst -sha256 -sign ../assets/crypto/keys/opengamepadui.key opengamepad-ui.sh | base64 -w 0); \
HASH=$$(sha256sum opengamepad-ui.sh | cut -d' ' -f1); \
FILE_SIGS="$$FILE_SIGS\"opengamepad-ui.sh\": {\"signature\": \"$$SIG\", \"hash\": \"$$HASH\"}, "; \
echo "Signing file: opengamepad-ui.x86_64"; \
SIG=$$(openssl dgst -sha256 -sign ../assets/crypto/keys/opengamepadui.key opengamepad-ui.x86_64 | base64 -w 0); \
HASH=$$(sha256sum opengamepad-ui.x86_64 | cut -d' ' -f1); \
FILE_SIGS="$$FILE_SIGS\"opengamepad-ui.x86_64\": {\"signature\": \"$$SIG\", \"hash\": \"$$HASH\"}}"; \
FILE_SIGS="$$FILE_SIGS\"opengamepad-ui.x86_64\": {\"signature\": \"$$SIG\", \"hash\": \"$$HASH\"}, "; \
echo "Signing file: opengamepad-ui.pck"; \
SIG=$$(openssl dgst -sha256 -sign ../assets/crypto/keys/opengamepadui.key opengamepad-ui.pck | base64 -w 0); \
HASH=$$(sha256sum opengamepad-ui.pck | cut -d' ' -f1); \
FILE_SIGS="$$FILE_SIGS\"opengamepad-ui.pck\": {\"signature\": \"$$SIG\", \"hash\": \"$$HASH\"}}"; \
# Write out the signatures to metadata.json \
echo "{\"version\": \"$(OGUI_VERSION)\", \"engine_version\": \"$(GODOT_REVISION)\", \"files\": $$FILE_SIGS}" > metadata.json
@@ -137,12 +143,21 @@ build/metadata.json: build/opengamepad-ui.x86_64 assets/crypto/keys/opengamepadu
.PHONY: import
import: ## Import project assets
import: $(IMPORT_DIR) ## Import project assets
$(IMPORT_DIR): $(ALL_ADDONS)
@echo "Importing project assets. This will take some time..."
timeout --foreground 60 $(GODOT) --headless --editor . > /dev/null 2>&1 || echo "Finished"
command -v $(GODOT) > /dev/null 2>&1
timeout --foreground 40 $(GODOT) --headless --editor . > /dev/null 2>&1 || echo "Finished"
touch $(IMPORT_DIR)
.PHONY: addons
addons: $(ALL_ADDONS) ## Build GDExtension addons
$(ALL_ADDONS) &: $(ALL_ADDON_FILES)
@echo "Building native GDExtension addons..."
cd ./gdext && $(MAKE) build
.PHONY: edit
edit: ## Open the project in the Godot editor
edit: $(IMPORT_DIR) ## Open the project in the Godot editor
$(GODOT) --editor .
.PHONY: clean
@@ -151,7 +166,8 @@ clean: ## Remove build artifacts
rm -rf $(ROOTFS)
rm -rf $(CACHE_DIR)
rm -rf dist
rm -rf .godot
rm -rf $(IMPORT_DIR)
cd ./gdext && $(MAKE) clean
.PHONY: run run-force
run: build/opengamepad-ui.x86_64 run-force ## Run the project in gamescope
@@ -169,20 +185,20 @@ $(EXPORT_TEMPLATE):
mv $(HOME)/.local/share/godot/export_templates/templates $(@D)
.PHONY: debug
debug: ## Run the project in debug mode in gamescope
debug: $(IMPORT_DIR) ## Run the project in debug mode in gamescope
$(GAMESCOPE) --xwayland-count 2 -- \
$(GODOT) --path $(PWD) --remote-debug tcp://127.0.0.1:6007 \
--position 320,140 res://entrypoint.tscn
.PHONY: debug-overlay
debug-overlay: ## Run the project in debug mode in gamescope with --overlay-mode
debug-overlay: $(IMPORT_DIR) ## Run the project in debug mode in gamescope with --overlay-mode
$(GAMESCOPE) --xwayland-count 2 -- \
$(GODOT) --path $(PWD) --remote-debug tcp://127.0.0.1:6007 \
--position 320,140 res://entrypoint.tscn --overlay-mode -- steam -gamepadui -steamos3 -steampal -steamdeck
.PHONY: docs
docs: docs/api/classes/.generated ## Generate docs
docs/api/classes/.generated: $(ALL_GDSCRIPT)
docs/api/classes/.generated: $(IMPORT_DIR) $(ALL_GDSCRIPT)
rm -rf docs/api/classes
$(GODOT) \
--editor \
@@ -195,7 +211,7 @@ docs/api/classes/.generated: $(ALL_GDSCRIPT)
$(MAKE) -C docs/api rst
.PHONY: inspect
inspect: ## Launch Gamescope inspector
inspect: $(IMPORT_DIR) ## Launch Gamescope inspector
$(GODOT) --path $(PWD) res://core/ui/menu/debug/gamescope_inspector.tscn
@@ -269,6 +285,7 @@ rootfs: build/opengamepad-ui.x86_64
mkdir -p $(ROOTFS)/usr/share/opengamepadui
cp -r build/*.so $(ROOTFS)/usr/share/opengamepadui
cp -r build/opengamepad-ui.x86_64 $(ROOTFS)/usr/share/opengamepadui
cp -r build/opengamepad-ui.pck $(ROOTFS)/usr/share/opengamepadui
touch $(ROOTFS)/.gdignore
@@ -395,6 +412,14 @@ release: ## Publish a release with semantic release
# E.g. make in-docker TARGET=build
.PHONY: in-docker
in-docker:
@# Build addons in a seperate container for glibc compatibility
docker run --rm \
-v $(PWD):/src \
--workdir /src \
-e PWD=/src \
--user $(shell id -u):$(shell id -g) \
$(ADDONS_IMAGE_NAME):$(ADDONS_IMAGE_TAG) \
make addons
@# Run the given make target inside Docker
docker run --rm \
-v $(PWD):/src \
@@ -403,7 +428,7 @@ in-docker:
-e PWD=/src \
--user $(shell id -u):$(shell id -g) \
$(IMAGE_NAME):$(IMAGE_TAG) \
make $(TARGET)
make GODOT=/usr/sbin/godot $(TARGET)
.PHONY: docker-builder
docker-builder:
@@ -415,3 +440,14 @@ docker-builder:
.PHONY: docker-builder-push
docker-builder-push: docker-builder
docker push $(IMAGE_NAME):$(IMAGE_TAG)
.PHONY: docker-builder-addons
docker-builder-addons:
@# Pull any existing image to cache it
docker pull $(ADDONS_IMAGE_NAME):$(ADDONS_IMAGE_TAG) || echo "No remote image to pull"
@# Build the Docker image that will build the project
docker build -t $(ADDONS_IMAGE_NAME):$(ADDONS_IMAGE_TAG) -f docker/Dockerfile.addons ./docker
.PHONY: docker-builder-addons-push
docker-builder-addons-push: docker-builder-addons
docker push $(ADDONS_IMAGE_NAME):$(ADDONS_IMAGE_TAG)

5
addons/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
dbus/
linuxthread/
pty/
unixsock/
xlib/

View File

@@ -1,9 +0,0 @@
[configuration]
entry_symbol = "dbus_library_init"
compatibility_minimum = 4.1
[libraries]
linux.debug.x86_64 = "res://addons/dbus/bin/libdbus.linux.template_debug.x86_64.so"
linux.release.x86_64 = "res://addons/dbus/bin/libdbus.linux.template_release.x86_64.so"

View File

@@ -1,9 +0,0 @@
[configuration]
entry_symbol = "linux_thread_library_init"
compatibility_minimum = 4.1
[libraries]
linux.debug.x86_64 = "res://addons/linuxthread/bin/liblinuxthread.linux.template_debug.x86_64.so"
linux.release.x86_64 = "res://addons/linuxthread/bin/liblinuxthread.linux.template_release.x86_64.so"

View File

@@ -1,9 +0,0 @@
[configuration]
entry_symbol = "pty_library_init"
compatibility_minimum = 4.1
[libraries]
linux.debug.x86_64 = "res://addons/pty/bin/libpty.linux.template_debug.x86_64.so"
linux.release.x86_64 = "res://addons/pty/bin/libpty.linux.template_release.x86_64.so"

View File

@@ -1,9 +0,0 @@
[configuration]
entry_symbol = "unixsock_library_init"
compatibility_minimum = 4.1
[libraries]
linux.debug.x86_64 = "res://addons/unixsock/bin/libunixsock.linux.template_debug.x86_64.so"
linux.release.x86_64 = "res://addons/unixsock/bin/libunixsock.linux.template_release.x86_64.so"

View File

@@ -1,9 +0,0 @@
[configuration]
entry_symbol = "xlib_library_init"
compatibility_minimum = 4.1
[libraries]
linux.debug.x86_64 = "res://addons/xlib/bin/libxlib.linux.template_debug.x86_64.so"
linux.release.x86_64 = "res://addons/xlib/bin/libxlib.linux.template_release.x86_64.so"

View File

@@ -6,9 +6,9 @@ class_name HardwareManager
## HardwareManager is responsible for providing a way to discover and query
## different aspects of the current hardware.
const pci_ids_path := "/usr/share/hwdata/pci.ids"
const amd_vendor_ids := ["AMD", "AuthenticAMD", 'AuthenticAMD Advanced Micro Devices, Inc.', "Advanced Micro Devices, Inc. [AMD/ATI]"]
const intel_vendor_ids := ["Intel", "GenuineIntel", "Intel Corporation"]
var pci_ids_path := Xdg.with_system_path("hwdata/pci.ids")
var amd_apu_database := load("res://core/platform/hardware/amd_apu_database.tres") as APUDatabase
var intel_apu_database := load("res://core/platform/hardware/intel_apu_database.tres") as APUDatabase
var dmi_overrides_apu_database := load("res://core/platform/hardware/dmi_overrides_apu_database.tres") as APUDatabase
@@ -175,6 +175,9 @@ func get_gpu_card(card_dir: String) -> DRMCardInfo:
return card_info
# Lookup the card details
if not FileAccess.file_exists(pci_ids_path):
logger.error("hwdata not found to look up GPU info:", pci_ids_path)
return null
var hwids := FileAccess.open(pci_ids_path, FileAccess.READ)
var vendor_found: bool = false
var device_found: bool = false

View File

@@ -0,0 +1,28 @@
extends RefCounted
class_name Xdg
## Fallback system data directory if XDG cannot be used
const XDG_DATA_DIR_FALLBACK := "/usr/share"
## Return a list of system data paths in load preference order.
static func get_data_dirs() -> PackedStringArray:
if not OS.has_environment("XDG_DATA_DIRS"):
return PackedStringArray()
var dirs := OS.get_environment("XDG_DATA_DIRS")
return dirs.split(":", false)
## Return the XDG system data path with the given relative path.
## For example, using `Xdg.with_system_path("hwdata")` will return
## "/usr/share/hwdata". If XDG is unable to determine the path,
## the fallback prefix of "/usr/share" will be used.
static func with_system_path(path: String) -> String:
var data_dirs := get_data_dirs()
for dir in data_dirs:
var full_path := dir.path_join(path)
if DirAccess.dir_exists_absolute(full_path) or FileAccess.file_exists(full_path):
return full_path
return XDG_DATA_DIR_FALLBACK.path_join(path)

33
docker/Dockerfile.addons Normal file
View File

@@ -0,0 +1,33 @@
FROM ubuntu:22.04
# Install GDExtension dependencies
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y \
build-essential \
python3-pip \
pkg-config \
libx11-dev \
libxcursor-dev \
libxinerama-dev \
libgl1-mesa-dev \
libglu-dev \
libasound2-dev \
libpulse-dev \
libudev-dev \
libxi-dev \
libxrandr-dev \
binutils \
git
# Install scons from pypi
RUN pip3 install scons
# Install DBus dependencies
RUN apt-get install -y \
libdbus-1-dev \
libdbus-c++-dev
# Install Xlib dependencies
RUN apt-get install -y \
libxres-dev \
libxtst-dev

View File

@@ -13,54 +13,12 @@ encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
script_encryption_key=""
[preset.0.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_script=2
binary_format/embed_pck=true
texture_format/bptc=true
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
binary_format/architecture="x86_64"
ssh_remote_deploy/enabled=false
ssh_remote_deploy/host="user@host_ip"
ssh_remote_deploy/port="22"
ssh_remote_deploy/extra_args_ssh=""
ssh_remote_deploy/extra_args_scp=""
ssh_remote_deploy/run_script="#!/usr/bin/env bash
export DISPLAY=:0
unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
\"{temp_dir}/{exe_name}\" {cmd_args}"
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
rm -rf \"{temp_dir}\""
[preset.1]
name="Linux/X11 (Update Pack)"
platform="Linux/X11"
runnable=false
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter="*.ini,*.profile,*.pub"
exclude_filter="rootfs,sandbox,plugins,*_test.tscn,*_test.gd,*.key"
export_path=""
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
script_encryption_key=""
[preset.1.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_script=2
debug/export_console_wrapper=1
binary_format/embed_pck=false
texture_format/bptc=true
texture_format/s3tc=true
@@ -79,6 +37,48 @@ unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
rm -rf \"{temp_dir}\""
debug/export_console_script=2
[preset.1]
name="Linux/X11 (Update Pack)"
platform="Linux/X11"
runnable=false
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter="*.ini,*.profile,*.pub"
exclude_filter="rootfs,sandbox,plugins,*_test.tscn,*_test.gd,*.key"
export_path=""
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
[preset.1.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_wrapper=1
binary_format/embed_pck=false
texture_format/bptc=true
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
binary_format/architecture="x86_64"
ssh_remote_deploy/enabled=false
ssh_remote_deploy/host="user@host_ip"
ssh_remote_deploy/port="22"
ssh_remote_deploy/extra_args_ssh=""
ssh_remote_deploy/extra_args_scp=""
ssh_remote_deploy/run_script="#!/usr/bin/env bash
export DISPLAY=:0
unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
\"{temp_dir}/{exe_name}\" {cmd_args}"
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
rm -rf \"{temp_dir}\""
debug/export_console_script=2
[preset.2]
@@ -95,13 +95,12 @@ encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
script_encryption_key=""
[preset.2.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_script=1
debug/export_console_wrapper=1
binary_format/embed_pck=false
texture_format/bptc=false
texture_format/s3tc=true
@@ -120,3 +119,4 @@ unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
rm -rf \"{temp_dir}\""
debug/export_console_script=1

0
gdext/.gdignore Normal file
View File

1
gdext/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.sconsign.dblite

129
gdext/Makefile Normal file
View File

@@ -0,0 +1,129 @@
NUM_CPU := $(shell nproc)
# Variables to define all the extensions to build. If a new extension is added,
# they should be added to these lists.
ADDONS_PATH = ../addons
ALL_EXT_PATHS = ../addons/dbus ../addons/linuxthread ../addons/pty ../addons/unixsock ../addons/xlib
ALL_CPP_FILES = $(shell find ./godot-cpp -regex '.*\(\.cpp\|\.h\|\.hpp\)$$') godot-cpp/SConstruct
ALL_SCONS_FILES = godot-cpp/SConstruct \
godot-dbus/SConstruct \
godot-linuxthread/SConstruct \
godot-pty/SConstruct \
godot-unix-socket/SConstruct \
godot-xlib/SConstruct
ALL_DEBUG_EXT = $(ADDONS_PATH)/dbus/bin/libdbus.linux.template_debug.x86_64.so \
$(ADDONS_PATH)/linuxthread/bin/liblinuxthread.linux.template_debug.x86_64.so \
$(ADDONS_PATH)/pty/bin/libpty.linux.template_debug.x86_64.so \
$(ADDONS_PATH)/unixsock/bin/libunixsock.linux.template_debug.x86_64.so \
$(ADDONS_PATH)/xlib/bin/libxlib.linux.template_debug.x86_64.so
ALL_RELEASE_EXT = $(ADDONS_PATH)/dbus/bin/libdbus.linux.template_release.x86_64.so \
$(ADDONS_PATH)/linuxthread/bin/liblinuxthread.linux.template_release.x86_64.so \
$(ADDONS_PATH)/pty/bin/libpty.linux.template_release.x86_64.so \
$(ADDONS_PATH)/unixsock/bin/libunixsock.linux.template_release.x86_64.so \
$(ADDONS_PATH)/xlib/bin/libxlib.linux.template_release.x86_64.so
ALL_GDEXT_FILES = $(ADDONS_PATH)/dbus/dbus.gdextension \
$(ADDONS_PATH)/linuxthread/linuxthread.gdextension \
$(ADDONS_PATH)/pty/pty.gdextension \
$(ADDONS_PATH)/unixsock/unixsock.gdextension \
$(ADDONS_PATH)/xlib/xlib.gdextension
##@ General
# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk commands is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
# More info on the usage of ANSI control characters for terminal formatting:
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php
.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
.PHONY: build
build: ## Build all GDExtensions
$(MAKE) release debug
.PHONY: release
release: $(ALL_RELEASE_EXT)
$(ALL_RELEASE_EXT) &: $(ALL_GDEXT_FILES) $(ALL_CPP_FILES)
scons platform=linux -j$(NUM_CPU) target=template_release
.PHONY: debug
debug: $(ALL_DEBUG_EXT)
$(ALL_DEBUG_EXT) &: $(ALL_GDEXT_FILES) $(ALL_CPP_FILES)
scons platform=linux -j$(NUM_CPU) target=template_debug
$(ALL_GDEXT_FILES) &: $(ALL_SCONS_FILES)
mkdir -p $(ALL_EXT_PATHS)
cp ./godot-dbus/addons/dbus/dbus.gdextension $(ADDONS_PATH)/dbus
cp ./godot-linuxthread/addons/linuxthread/linuxthread.gdextension $(ADDONS_PATH)/linuxthread
cp ./godot-pty/addons/pty/pty.gdextension $(ADDONS_PATH)/pty
cp ./godot-unix-socket/addons/unixsock/unixsock.gdextension $(ADDONS_PATH)/unixsock
cp ./godot-xlib/addons/xlib/xlib.gdextension $(ADDONS_PATH)/xlib
.PHONY: clean
clean: ## Clean all build artifacts
rm -rf $(ALL_EXT_PATHS)
find ./ -type f -name '*.o' -delete
find ./ -type f -name '*.a' -delete
find ./ -type f -name '*.os' -delete
find ./ -type f -name '*.so' -delete
godot-cpp/SConstruct:
git submodule update --init godot-cpp
godot-dbus/SConstruct:
git submodule update --init godot-dbus
godot-linuxthread/SConstruct:
git submodule update --init godot-linuxthread
godot-pty/SConstruct:
git submodule update --init godot-pty
godot-unix-socket/SConstruct:
git submodule update --init godot-unix-socket
godot-xlib/SConstruct:
git submodule update --init godot-xlib
##@ Updates
.PHONY: update-dbus
update-dbus: ## Update godot-dbus
cd godot-dbus
git fetch
git rebase origin/main
.PHONY: update-linuxthread
update-linuxthread: ## Update godot-linuxthread
cd godot-linuxthread
git fetch
git rebase origin/main
.PHONY: update-pty
update-pty: ## Update godot-pty
cd godot-pty
git fetch
git rebase origin/main
.PHONY: update-unixsock
update-unixsock: ## Update godot-unixsock
cd godot-unixsock
git fetch
git rebase origin/main
.PHONY: update-xlib
update-xlib: ## Update godot-xlib
cd godot-xlib
git fetch
git rebase origin/main

0
gdext/README.md Normal file
View File

114
gdext/SConstruct Normal file
View File

@@ -0,0 +1,114 @@
#!/usr/bin/env python
from SCons import __version__ as scons_raw_version
import os
import sys
# Define path to godot-cpp dependency
godot_cpp_path = "godot-cpp"
if 'GODOT_CPP_PATH' in os.environ:
godot_cpp_path = os.environ['GODOT_CPP_PATH']
# Setup a standard path to output the extension
EXT_PATH = "../addons/{}/bin/lib{}{}{}"
# Setup the environments from godot-cpp
env = SConscript(godot_cpp_path + "/SConstruct")
dbus_env = env.Clone()
thread_env = env.Clone()
pty_env = env.Clone()
unixsock_env = env.Clone()
xlib_env = env.Clone()
# --- godot-dbus ---
# tweak this if you want to use different folders, or more folders, to store your source code in.
dbus_env.Append(CPPPATH=["godot-dbus/src/"])
dbus_sources = Glob("godot-dbus/src/*.cpp")
# Include dependency libraries for dbus
if 'PKG_CONFIG_PATH' in os.environ:
dbus_env['ENV']['PKG_CONFIG_PATH'] = os.environ['PKG_CONFIG_PATH']
dbus_env.ParseConfig("pkg-config dbus-1 --cflags --libs")
# Build the shared library
libdbus = dbus_env.SharedLibrary(
EXT_PATH.format(
"dbus", "dbus", dbus_env["suffix"], dbus_env["SHLIBSUFFIX"]
),
source=dbus_sources,
)
Default(libdbus)
# --- godot-linuxthread ---
# tweak this if you want to use different folders, or more folders, to store your source code in.
thread_env.Append(CPPPATH=["godot-linuxthread/src/"])
thread_sources = Glob("godot-linuxthread/src/*.cpp")
# Build the shared library
libthread = thread_env.SharedLibrary(
EXT_PATH.format("linuxthread",
"linuxthread", thread_env["suffix"], thread_env["SHLIBSUFFIX"]),
source=thread_sources,
)
Default(libthread)
# --- godot-pty ---
# tweak this if you want to use different folders, or more folders, to store your source code in.
pty_env.Append(CPPPATH=["godot-pty/src/"])
pty_sources = Glob("godot-pty/src/*.cpp")
# Build the shared library
libpty = pty_env.SharedLibrary(
EXT_PATH.format("pty",
"pty", pty_env["suffix"], pty_env["SHLIBSUFFIX"]),
source=pty_sources,
)
Default(libpty)
# --- godot-unix-socket ---
# tweak this if you want to use different folders, or more folders, to store your source code in.
unixsock_env.Append(CPPPATH=["godot-unix-socket/src/"])
unixsock_sources = Glob("godot-unix-socket/src/*.cpp")
# Build the shared library
libunixsock = unixsock_env.SharedLibrary(
EXT_PATH.format("unixsock",
"unixsock", unixsock_env["suffix"], unixsock_env["SHLIBSUFFIX"]),
source=unixsock_sources,
)
Default(libunixsock)
# --- godot-unix-socket ---
# tweak this if you want to use different folders, or more folders, to store your source code in.
xlib_env.Append(CPPPATH=["godot-xlib/src/"])
xlib_sources = Glob("godot-xlib/src/*.cpp")
# Include dependency libraries for the extension
if 'PKG_CONFIG_PATH' in os.environ:
xlib_env['ENV']['PKG_CONFIG_PATH'] = os.environ['PKG_CONFIG_PATH']
xlib_env.ParseConfig("pkg-config x11 --cflags --libs")
xlib_env.ParseConfig("pkg-config xres --cflags --libs")
xlib_env.ParseConfig("pkg-config xtst --cflags --libs")
xlib_env.ParseConfig("pkg-config xi --cflags --libs")
# Build the shared library
libx11 = xlib_env.SharedLibrary(
EXT_PATH.format("xlib",
"xlib", xlib_env["suffix"], xlib_env["SHLIBSUFFIX"]),
source=xlib_sources,
)
Default(libx11)

1
gdext/godot-cpp Submodule

Submodule gdext/godot-cpp added at d6e5286cc1

1
gdext/godot-dbus Submodule

Submodule gdext/godot-dbus added at a8f6214161

1
gdext/godot-pty Submodule

Submodule gdext/godot-pty added at cd3128ac07

1
gdext/godot-xlib Submodule

Submodule gdext/godot-xlib added at 95e8237dd4

View File

@@ -30,6 +30,7 @@ make install PREFIX=%{buildroot}%{_prefix} INSTALL_PREFIX=%{_prefix}
/usr/share/opengamepadui/*.so
/usr/share/opengamepadui/scripts/*
/usr/share/opengamepadui/opengamepad-ui.x86_64
/usr/share/opengamepadui/opengamepad-ui.pck
/usr/share/applications/opengamepadui.desktop
/usr/share/icons/hicolor/scalable/apps/opengamepadui.svg
/usr/share/polkit-1/actions/*

View File

@@ -22,16 +22,12 @@ install: ## Install OpenGamepadUI (default: ~/.local)
install -Dm644 usr/share/icons/hicolor/scalable/apps/opengamepadui.svg \
$(PREFIX)/share/icons/hicolor/scalable/apps/opengamepadui.svg
mkdir -p $(PREFIX)/share/opengamepadui
install -Dm644 usr/share/opengamepadui/libdbus.linux.template_debug.x86_64.so \
$(PREFIX)/share/opengamepadui/libdbus.linux.template_debug.x86_64.so
install -Dm644 usr/share/opengamepadui/liblinuxthread.linux.template_debug.x86_64.so \
$(PREFIX)/share/opengamepadui/liblinuxthread.linux.template_debug.x86_64.so
install -Dm644 usr/share/opengamepadui/libpty.linux.template_debug.x86_64.so \
$(PREFIX)/share/opengamepadui/libpty.linux.template_debug.x86_64.so
install -Dm644 usr/share/opengamepadui/libxlib.linux.template_debug.x86_64.so \
$(PREFIX)/share/opengamepadui/libxlib.linux.template_debug.x86_64.so
install -Dm644 usr/share/opengamepadui/*.so \
$(PREFIX)/share/opengamepadui/
install -Dm755 usr/share/opengamepadui/opengamepad-ui.x86_64 \
$(PREFIX)/share/opengamepadui/opengamepad-ui.x86_64
install -Dm644 usr/share/opengamepadui/opengamepad-ui.pck \
$(PREFIX)/share/opengamepadui/opengamepad-ui.pck
setcap 'cap_sys_nice=eip' $(PREFIX)/share/opengamepadui/opengamepad-ui.x86_64 || true
mkdir -p $(PREFIX)/share/opengamepadui/scripts
install -Dm755 usr/share/opengamepadui/scripts/manage_input \
@@ -54,6 +50,7 @@ uninstall: ## Uninstall OpenGamepadUI
rm -rf $(PREFIX)/icons/hicolor/scalable/apps/opengamepadui.svg
rm -rf $(PREFIX)/bin/opengamepadui
rm -rf $(PREFIX)/share/opengamepadui/opengamepad-ui.x86_64
rm -rf $(PREFIX)/share/opengamepadui/opengamepad-ui.pck
rm -rf $(PREFIX)/share/opengamepadui/*.so
rm -rf $(PREFIX)/lib/systemd/user/systemd-sysext-updater.service
rm -rf $(PREFIX)/lib/systemd/user/ogui-overlay-mode.service