diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..40faf87f --- /dev/null +++ b/.gitmodules @@ -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 diff --git a/.releaserc.yaml b/.releaserc.yaml index 7703af4e..bb3c80c9 100644 --- a/.releaserc.yaml +++ b/.releaserc.yaml @@ -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" diff --git a/Makefile b/Makefile index 23c7cc57..c3fde88e 100644 --- a/Makefile +++ b/Makefile @@ -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\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) diff --git a/addons/.gitignore b/addons/.gitignore new file mode 100644 index 00000000..99eef491 --- /dev/null +++ b/addons/.gitignore @@ -0,0 +1,5 @@ +dbus/ +linuxthread/ +pty/ +unixsock/ +xlib/ diff --git a/addons/dbus/bin/libdbus.linux.template_debug.x86_64.so b/addons/dbus/bin/libdbus.linux.template_debug.x86_64.so deleted file mode 100755 index b9be28f2..00000000 Binary files a/addons/dbus/bin/libdbus.linux.template_debug.x86_64.so and /dev/null differ diff --git a/addons/dbus/bin/libdbus.linux.template_release.x86_64.so b/addons/dbus/bin/libdbus.linux.template_release.x86_64.so deleted file mode 100755 index 8546f0e0..00000000 Binary files a/addons/dbus/bin/libdbus.linux.template_release.x86_64.so and /dev/null differ diff --git a/addons/dbus/dbus.gdextension b/addons/dbus/dbus.gdextension deleted file mode 100644 index 3250ec23..00000000 --- a/addons/dbus/dbus.gdextension +++ /dev/null @@ -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" diff --git a/addons/linuxthread/bin/liblinuxthread.linux.template_debug.x86_64.so b/addons/linuxthread/bin/liblinuxthread.linux.template_debug.x86_64.so deleted file mode 100755 index c9e9b1ea..00000000 Binary files a/addons/linuxthread/bin/liblinuxthread.linux.template_debug.x86_64.so and /dev/null differ diff --git a/addons/linuxthread/bin/liblinuxthread.linux.template_release.x86_64.so b/addons/linuxthread/bin/liblinuxthread.linux.template_release.x86_64.so deleted file mode 100755 index a10f081e..00000000 Binary files a/addons/linuxthread/bin/liblinuxthread.linux.template_release.x86_64.so and /dev/null differ diff --git a/addons/linuxthread/linuxthread.gdextension b/addons/linuxthread/linuxthread.gdextension deleted file mode 100644 index ac6f371b..00000000 --- a/addons/linuxthread/linuxthread.gdextension +++ /dev/null @@ -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" diff --git a/addons/pty/bin/libpty.linux.template_debug.x86_64.so b/addons/pty/bin/libpty.linux.template_debug.x86_64.so deleted file mode 100755 index 998edce3..00000000 Binary files a/addons/pty/bin/libpty.linux.template_debug.x86_64.so and /dev/null differ diff --git a/addons/pty/bin/libpty.linux.template_release.x86_64.so b/addons/pty/bin/libpty.linux.template_release.x86_64.so deleted file mode 100755 index d5411527..00000000 Binary files a/addons/pty/bin/libpty.linux.template_release.x86_64.so and /dev/null differ diff --git a/addons/pty/pty.gdextension b/addons/pty/pty.gdextension deleted file mode 100644 index 7339bbfd..00000000 --- a/addons/pty/pty.gdextension +++ /dev/null @@ -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" diff --git a/addons/unixsock/bin/libunixsock.linux.template_debug.x86_64.so b/addons/unixsock/bin/libunixsock.linux.template_debug.x86_64.so deleted file mode 100755 index d4013081..00000000 Binary files a/addons/unixsock/bin/libunixsock.linux.template_debug.x86_64.so and /dev/null differ diff --git a/addons/unixsock/bin/libunixsock.linux.template_release.x86_64.so b/addons/unixsock/bin/libunixsock.linux.template_release.x86_64.so deleted file mode 100755 index ba626864..00000000 Binary files a/addons/unixsock/bin/libunixsock.linux.template_release.x86_64.so and /dev/null differ diff --git a/addons/unixsock/unixsock.gdextension b/addons/unixsock/unixsock.gdextension deleted file mode 100644 index b5d1bab7..00000000 --- a/addons/unixsock/unixsock.gdextension +++ /dev/null @@ -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" diff --git a/addons/xlib/bin/libxlib.linux.template_debug.x86_64.so b/addons/xlib/bin/libxlib.linux.template_debug.x86_64.so deleted file mode 100755 index 5394352f..00000000 Binary files a/addons/xlib/bin/libxlib.linux.template_debug.x86_64.so and /dev/null differ diff --git a/addons/xlib/bin/libxlib.linux.template_release.x86_64.so b/addons/xlib/bin/libxlib.linux.template_release.x86_64.so deleted file mode 100755 index 83ec99fc..00000000 Binary files a/addons/xlib/bin/libxlib.linux.template_release.x86_64.so and /dev/null differ diff --git a/addons/xlib/xlib.gdextension b/addons/xlib/xlib.gdextension deleted file mode 100644 index cd2ae2f1..00000000 --- a/addons/xlib/xlib.gdextension +++ /dev/null @@ -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" diff --git a/core/systems/hardware/hardware_manager.gd b/core/systems/hardware/hardware_manager.gd index cbdc8a28..e006376e 100644 --- a/core/systems/hardware/hardware_manager.gd +++ b/core/systems/hardware/hardware_manager.gd @@ -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 diff --git a/core/systems/utility/xdg.gd b/core/systems/utility/xdg.gd new file mode 100644 index 00000000..b999b35e --- /dev/null +++ b/core/systems/utility/xdg.gd @@ -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) diff --git a/docker/Dockerfile.addons b/docker/Dockerfile.addons new file mode 100644 index 00000000..70348ae8 --- /dev/null +++ b/docker/Dockerfile.addons @@ -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 diff --git a/export_presets.cfg b/export_presets.cfg index bed1f87d..7466aee1 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -13,14 +13,13 @@ 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 +debug/export_console_wrapper=1 +binary_format/embed_pck=false texture_format/bptc=true texture_format/s3tc=true texture_format/etc=false @@ -38,6 +37,7 @@ 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] @@ -54,13 +54,12 @@ 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 +78,7 @@ 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.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 diff --git a/gdext/.gdignore b/gdext/.gdignore new file mode 100644 index 00000000..e69de29b diff --git a/gdext/.gitignore b/gdext/.gitignore new file mode 100644 index 00000000..5b2d4627 --- /dev/null +++ b/gdext/.gitignore @@ -0,0 +1 @@ +.sconsign.dblite diff --git a/gdext/Makefile b/gdext/Makefile new file mode 100644 index 00000000..e540f8b0 --- /dev/null +++ b/gdext/Makefile @@ -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\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 diff --git a/gdext/README.md b/gdext/README.md new file mode 100644 index 00000000..e69de29b diff --git a/gdext/SConstruct b/gdext/SConstruct new file mode 100644 index 00000000..df56d6dd --- /dev/null +++ b/gdext/SConstruct @@ -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) diff --git a/gdext/godot-cpp b/gdext/godot-cpp new file mode 160000 index 00000000..d6e5286c --- /dev/null +++ b/gdext/godot-cpp @@ -0,0 +1 @@ +Subproject commit d6e5286cc19bbd5b2c626207d3b01a8f145c0f76 diff --git a/gdext/godot-dbus b/gdext/godot-dbus new file mode 160000 index 00000000..a8f62141 --- /dev/null +++ b/gdext/godot-dbus @@ -0,0 +1 @@ +Subproject commit a8f62141612046b9bfff9f3b7d153ab7a122c899 diff --git a/gdext/godot-linuxthread b/gdext/godot-linuxthread new file mode 160000 index 00000000..dbe78542 --- /dev/null +++ b/gdext/godot-linuxthread @@ -0,0 +1 @@ +Subproject commit dbe785424ed5eb62aca2ee33a87922f22c017641 diff --git a/gdext/godot-pty b/gdext/godot-pty new file mode 160000 index 00000000..cd3128ac --- /dev/null +++ b/gdext/godot-pty @@ -0,0 +1 @@ +Subproject commit cd3128ac07eb3407e877dacea4e93cc524039112 diff --git a/gdext/godot-unix-socket b/gdext/godot-unix-socket new file mode 160000 index 00000000..3ce07d78 --- /dev/null +++ b/gdext/godot-unix-socket @@ -0,0 +1 @@ +Subproject commit 3ce07d7868cc6cd1028ce0ec681b2f6789b04221 diff --git a/gdext/godot-xlib b/gdext/godot-xlib new file mode 160000 index 00000000..95e8237d --- /dev/null +++ b/gdext/godot-xlib @@ -0,0 +1 @@ +Subproject commit 95e8237dd472bbed6acb1d18fa8b9e9514cbd33b diff --git a/package/rpm/opengamepadui.spec b/package/rpm/opengamepadui.spec index 3a259e63..fced6e02 100644 --- a/package/rpm/opengamepadui.spec +++ b/package/rpm/opengamepadui.spec @@ -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/* diff --git a/rootfs/Makefile b/rootfs/Makefile index b4a0d4fd..b383453c 100644 --- a/rootfs/Makefile +++ b/rootfs/Makefile @@ -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