Skip to content
Merged
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
19 changes: 16 additions & 3 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: CI
on:
push:
pull_request:
workflow_dispatch: {}

jobs:
build:
Expand All @@ -12,15 +13,26 @@ jobs:
os: [
[macos-latest, arm64],
[macos-15-intel, x86_64],
[ubuntu-latest, x86_64]
[ubuntu-latest, x86_64],
[windows-latest, x86_64],
]

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
Expand All @@ -44,7 +56,8 @@ jobs:

- 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
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 @@ -14,6 +14,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 @@ -68,11 +69,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 @@ -87,8 +84,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 @@ -99,7 +96,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
Loading