Skip to content

Some improvements #19

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
59 changes: 40 additions & 19 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,49 @@ name: CI
on:
push:
pull_request:
workflow_dispatch: {}

jobs:
build:
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.os[0] }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest]

steps:
- uses: actions/checkout@v2
os: [[macos-latest, bash], [ubuntu-latest, bash], [windows-latest, msys2]]
fail-fast: false
defaults:
run:
shell: ${{ matrix.os[1] }} {0}

steps:
- uses: actions/checkout@v4

- name: Install MSYS2 packages
if: matrix.os[0] == 'windows-latest'
uses: msys2/setup-msys2@v2
with:
msystem: MINGW32
install: |
base-devel mingw-w64-i686-gcc
update: true

- name: Compile native versions
run: |
make --debug
make -j $(getconf _NPROCESSORS_ONLN) clean
make -j $(getconf _NPROCESSORS_ONLN) all

- name: Get short SHA
id: slug
run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)"
run: |
echo "sha8=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_OUTPUT

- name: Create tar archive (keep executable bit)
run: tar -zcvf ps2client-${{ steps.slug.outputs.sha8 }}-${{matrix.os}}.tar.gz bin
run: tar -zcvf ps2client-${{ steps.slug.outputs.sha8 }}-${{matrix.os[0]}}.tar.gz bin

- uses: actions/upload-artifact@v2
- name: Upload artefacts
if: matrix.os[0] != 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: ps2client-${{ steps.slug.outputs.sha8 }}-${{matrix.os}}
name: ps2client-${{ steps.slug.outputs.sha8 }}-${{matrix.os[0]}}
path: |
*tar.gz

Expand All @@ -36,20 +54,22 @@ jobs:
container: dockcross/windows-static-x86:latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Compile windows version with cross-compilator
run: |
make -f Makefile.mingw32 --trace
make -f Makefile.mingw32 -j $(getconf _NPROCESSORS_ONLN) clean
make -f Makefile.mingw32 -j $(getconf _NPROCESSORS_ONLN) all

- name: Get short SHA
id: slug
run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)"
run: |
echo "sha8=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_OUTPUT

- name: Create tar archive
run: tar -zcvf ps2client-${{ steps.slug.outputs.sha8 }}-windows-latest.tar.gz bin

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: ps2client-${{ steps.slug.outputs.sha8 }}-windows-latest
path: |
Expand All @@ -60,24 +80,25 @@ jobs:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Get short SHA
id: slug
run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)"
run: |
echo "sha8=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_OUTPUT

- name: Download Mac artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: ps2client-${{ steps.slug.outputs.sha8 }}-macos-latest

- name: Download Ubuntu artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: ps2client-${{ steps.slug.outputs.sha8 }}-ubuntu-latest

- name: Download Windows artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: ps2client-${{ steps.slug.outputs.sha8 }}-windows-latest

Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
CFLAGS += -O2
endif

ifneq "MINGW" "$(findstring MINGW,$(MSYSTEM))"
LIBS = -lpthread
else
ifeq ($(OS),Windows_NT)
LIBS = -lwsock32
else
LIBS = -lpthread
endif

ifeq "x$(PREFIX)" "x"
PREFIX = $(PS2DEV)
endif

ifeq "MINGW" "$(findstring MINGW,$(MSYSTEM))"
ifeq ($(OS),Windows_NT)
all:
$(MAKE) -f Makefile.mingw32 all

Expand Down
8 changes: 2 additions & 6 deletions src/fsclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,8 @@
// Check to make sure a command was actually supplied.
if (argc < 0) { printf("Error: No command was supplied.\n"); print_usage(); return -1; }

#ifdef _WIN32

// Startup network, under windows.
if (network_startup() < 0) { printf("Error: Could not start up winsock.\n"); return 1; }

#endif
// Startup network
if (network_startup() < 0) { printf("Error: Could not startup network.\n"); return 1; }

// Connect to the ps2netfs server.
if (ps2netfs_connect(hostname) < 0) { printf("Error: Could not connect to the ps2netfs server. (%s)\n", hostname); return -1; }
Expand Down
5 changes: 2 additions & 3 deletions src/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@
// NETWORK FUNCTIONS //
///////////////////////

#ifdef _WIN32
int network_startup(void) {
#ifdef _WIN32
WSADATA wsaData;

// Start up winsock.
if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) { return -1; }

#endif
// End function.
return 0;

}
#endif

int network_connect(char *hostname, int port, int type) { int sock = -1;
struct sockaddr_in sockaddr;
Expand Down
2 changes: 0 additions & 2 deletions src/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
// NETWORK FUNCTIONS //
///////////////////////

#ifdef _WIN32
int network_startup(void);
#endif

int network_connect(char *hostname, int port, int type);

Expand Down
10 changes: 2 additions & 8 deletions src/ps2client.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
#include <unistd.h>
#include "utility.h"
#include "ps2link.h"
#ifdef _WIN32
#include "network.h"
#endif

char hostname[256] = { "192.168.0.10" };

Expand Down Expand Up @@ -65,12 +63,8 @@
// Check to make sure a command was actually supplied.
if (argc < 0) { printf("Error: No command was supplied.\n"); print_usage(); return -1; }

#ifdef _WIN32

// Startup network, under windows.
if (network_startup() < 0) { printf("Error: Could not start up winsock.\n"); return 1; }

#endif
// Startup network.
if (network_startup() < 0) { printf("Error: Could not startup network.\n"); return 1; }

// Connect to the ps2link server.
if (ps2link_connect(hostname) < 0) { printf("Error: Could not connect to the ps2link server. (%s)\n", hostname); return -1; }
Expand Down
14 changes: 7 additions & 7 deletions src/ps2link.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#else
#include <windows.h>
#define sleep(x) Sleep(x * 1000)
#define pause() while (1) { Sleep(600000); }
#endif

#include "network.h"
Expand Down Expand Up @@ -59,11 +60,7 @@
command_socket = network_connect(hostname, 0x4712, SOCK_DGRAM);

// Delay for a moment to let ps2link finish setup.
#ifdef _WIN32
Sleep(1);
#else
sleep(1);
#endif

// End function.
return 0;
Expand All @@ -78,8 +75,8 @@
// If no timeout was given, timeout immediately.
if (timeout == 0) { return 0; }

// If timeout was never, loop forever.
if (timeout < 0) { for (;;) { sleep(600); } }
// If timeout was never, wait forever.
if (timeout < 0) { pause(); }

// Increment the timeout counter until timeout is reached.
while (ps2link_counter++ < timeout) { sleep(1); };
Expand All @@ -90,7 +87,10 @@
}

int ps2link_disconnect(void) {

// Kill created threads.
pthread_cancel(request_thread_id);
pthread_cancel(console_thread_id);

// Disconnect from the command port.
if (network_disconnect(command_socket) < 0) { return -1; }

Expand Down