Skip to content

Commit

Permalink
Port to GDExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdera7mane committed May 6, 2023
1 parent 74cb8aa commit 9e3e106
Show file tree
Hide file tree
Showing 25 changed files with 293 additions and 510 deletions.
19 changes: 19 additions & 0 deletions .github/composite/scons/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: scons
description: Install SCons

runs:
using: "composite"
steps:
- name: Install SCons for Linux
if: runner.os == 'linux'
run: python -m pip install scons
shell: bash
- name: Install SCons for MacOS
if: runner.os == 'macos'
run: brew install scons
shell: bash
- name: Print versions
run: |
python --version
scons --version
shell: bash
96 changes: 22 additions & 74 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,88 +1,36 @@
name: Build CI

on: [push, pull_request, workflow_dispatch]
on: [push, pull_request, workflow_dispatch, workflow_call]

jobs:
linux-debug:
name: Linux debug build
runs-on: ubuntu-latest
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
target: [template_debug, template_release]
include:
- os: ubuntu-latest
platform: linux
- os: macos-latest
platform: macos
- target: template_debug
target-type: debug
- target: template_release
target-type: release
name: ${{ matrix.platform }} ${{ matrix.target-type }} build
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install SCons
run: |
python -m pip install scons
python --version
scons --version
uses: ./.github/composite/scons
- name: Build library
run: ./build_linux.sh debug
run: scons platform=${{ matrix.platform }} target=${{ matrix.target }}
- name: Upload artificat
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: linux-debug-${{ github.sha }}
name: ${{ matrix.platform }}-${{ matrix.target-type }}-${{ github.sha }}
if-no-files-found: error
path: bin/

linux-release:
name: Linux release build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install SCons
run: |
python -m pip install scons
python --version
scons --version
- name: Build library
run: ./build_linux.sh release
- name: Upload artificat
uses: actions/upload-artifact@v2
with:
name: linux-release-${{ github.sha }}
if-no-files-found: error
path: bin/

macos-debug:
name: MacOS debug build
runs-on: macos-11
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install SCons
run: |
brew install scons
python --version
scons --version
- name: Build library
run: ./build_mac.sh debug
- name: Upload artificat
uses: actions/upload-artifact@v2
with:
name: macos-debug-${{ github.sha }}
if-no-files-found: error
path: bin/

macos-release:
name: MacOS release build
runs-on: macos-11
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install SCons
run: |
brew install scons
python --version
scons --version
- name: Build library
run: ./build_mac.sh release
- name: Upload artificat
uses: actions/upload-artifact@v2
with:
name: macos-release-${{ github.sha }}
if-no-files-found: error
path: bin/
55 changes: 55 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Draft new release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'

jobs:
build:
uses: ./.github/workflows/build.yml
release:
name: Create release draft
needs: [build]
runs-on: ubuntu-latest
env:
package: godot-unix-socket-${{ github.ref_name }}.zip
steps:
- uses: actions/checkout@v3

- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: bin

- name: Generate addon files
shell: bash
run: |
DIR=addons/unix-socket
mkdir -p $DIR
cp -r bin/*/* $DIR
cat <<EOF > $DIR/lib.gdextension
[configuration]
entry_symbol = "unixsocket_library_init"
[libraries]
linux.debug.x86_64 = "$DIR/libunixsocket.linux.template_debug.x86_64.so"
linux.release.x86_64 = "$DIR/libunixsocket.linux.template_release.x86_64.so"
macos.debug = "$DIR/libunixsocket.macos.template_debug.framework"
macos.release = "$DIR/libunixsocket.macos.tempalte_release.framework"
EOF
zip $package -r $DIR
- name: Release
uses: softprops/action-gh-release@v1
with:
draft: true
name: Godot UNIX Socket ${{ github.ref_name }}
files: |
${{ env.package }}
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*.dblite

# Godot Serialisations
api.json
custom_api.json

# Visual Studio Cache
.vs/
Expand All @@ -28,6 +28,5 @@ build/
*.os
*.out

# Replit
.replit
.cquery
.ccls-cache
compile_commands.json
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "godot-cpp"]
path = godot-cpp
url = https://github.com/godotengine/godot-cpp
branch = 3.x
branch = master
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Abdera7mane
Copyright (c) 2021-present Abdera7mane

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
54 changes: 35 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
# Godot-UnixSocket

**GDNative** module for Unix sockets communications in [Godot Engine](https://github.com/godotengine/godot) under Linux and MacOS builds.

## Compiling
1. Install [Scons]() (`v3.0.1` and above is required)
Linux: `python -m pip install scons`
MacOS: `brew install scons`
2. Clone this repository with:
1. `git clone --recursive https://github.com/Abdera7mane/Godot-UnixSocket.git`
2. `cd Godot-UnixSocket`
3. `git submodule update --init --recursive`
3. Run the approperiate script according to your system to build the library:
Linux: `./build_linux.sh`
MacOS: `./build_mac.sh`
4. The binaries should be generated in `bin/` directory.
[GDExtension](https://docs.godotengine.org/en/stable/tutorials/scripting/gdextension/what_is_gdextension.html) module for UNIX domain sockets support in [Godot Engine](https://github.com/godotengine/godot) under Linux and MacOS builds.

## Build

### Prerequisites

1. [Python](https://www.python.org)
2. [SCons](https://scons.org)
3. C/C++ compiler

### Compiling

1. Clone the repository:
```
git clone --recursive https://github.com/Abdera7mane/Godot-UnixSocket.git
cd Godot-UnixSocket
git submodule update --init --recursive
```
2. Build with scons (outputs to `bin`):
#### debug build
```
scons target=template_debug
```
#### release build
```
scons target=template_release
```

## Documentation

### class StreamPeerUnix
**Inherits:**
[StreamPeerGDNative](https://docs.godotengine.org/en/3.6/classes/class_streampeergdnative.html) <
[StreamPeer](https://docs.godotengine.org/en/3.6/classes/class_streampeer.html)
[StreamPeerExtension](https://docs.godotengine.org/en/stable/classes/class_streampeerextension.html) <
[StreamPeer](https://docs.godotengine.org/en/stable/classes/class_streampeer.html) <
[RefCounted](https://docs.godotengine.org/en/stable/classes/class_refcounted.html) <
[Object](https://docs.godotengine.org/en/stable/classes/class_object.html)

### methods

Expand All @@ -31,7 +46,8 @@
| [String][class_string] | `get_path()` | Gets the current connected socket path |
| void | `close()` | Closes the socket connection |

[class_int]: https://docs.godotengine.org/en/3.6/classes/class_int.html
[class_bool]: https://docs.godotengine.org/en/3.6/classes/class_bool.html
[class_string]: https://docs.godotengine.org/en/3.6/classes/class_string.html
[class_int]: https://docs.godotengine.org/en/stable/classes/class_int.html
[class_bool]: https://docs.godotengine.org/en/stable/classes/class_bool.html
[class_string]: https://docs.godotengine.org/en/stable/classes/class_string.html


Loading

0 comments on commit 9e3e106

Please # to comment.