Skip to content

Commit

Permalink
Move GateEngineDependencies inside GateEngine package
Browse files Browse the repository at this point in the history
  • Loading branch information
STREGA committed May 2, 2023
1 parent d041fa8 commit 388255f
Show file tree
Hide file tree
Showing 109 changed files with 88,978 additions and 6 deletions.
64 changes: 58 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ let package = Package(
],
dependencies: [
// GateEngine
.package(url: "https://github.com/STREGAsGate/GateEngineDependencies.git", branch: "main"),
.package(url: "https://github.com/STREGAsGate/GameMath.git", branch: "master"),

// Official
Expand All @@ -25,11 +24,8 @@ let package = Package(
targets: [
.target(name: "GateEngine",
dependencies: [
"GameMath",
.product(name: "Shaders", package: "GateEngineDependencies"),
.product(name: "TrueType", package: "GateEngineDependencies"),
.product(name: "libspng", package: "GateEngineDependencies"),
.product(name: "Vorbis", package: "GateEngineDependencies", condition: .when(platforms: [
"GameMath", "Shaders", "TrueType", "libspng",
.byNameItem(name: "Vorbis", condition: .when(platforms: [
.macOS, .windows, .linux, .iOS, .tvOS, .android
])),

Expand All @@ -53,6 +49,62 @@ let package = Package(
linkerSettings: [
.linkedLibrary("GameMath", .when(platforms: [.windows])),
]),

.target(name: "Shaders", dependencies: ["GameMath"]),

// MARK: - GateEngineDependencies

// LinuxSupport
.target(name: "LinuxSupport",
dependencies: ["LinuxImports", "LinuxExtensions"],
path: "Sources/GateEngineDependencies/LinuxSupport/LinuxSupport"),
.target(name: "LinuxExtensions",
path: "Sources/GateEngineDependencies/LinuxSupport/LinuxExtensions"),
.systemLibrary(name: "LinuxImports",
path: "Sources/GateEngineDependencies/LinuxSupport/LinuxImports"),

// Vorbis
.target(name: "Vorbis",
path: "Sources/GateEngineDependencies/Vorbis",
publicHeadersPath: "include",
cSettings: [
.unsafeFlags(["-Wno-everything"]),
.define("extern", to: "__declspec(dllexport) extern", .when(platforms: [.windows]))
],
linkerSettings: [
// SR-14728
.linkedLibrary("swiftCore", .when(platforms: [.windows])),
]),

// libspng
.target(name: "libspng",
path: "Sources/GateEngineDependencies/libspng",
cSettings: [
.unsafeFlags(["-Wno-everything"]),
.define("SPNG_USE_MINIZ"),
.define("extern", to: "__declspec(dllexport) extern", .when(platforms: [.windows])),
.define("_CRT_SECURE_NO_WARNINGS", .when(platforms: [.windows])), // Silence warnings
],
linkerSettings: [
// SR-14728\
.linkedLibrary("swiftCore", .when(platforms: [.windows])),
]),

// TrueType
.target(name: "TrueType",
path: "Sources/GateEngineDependencies/TrueType",
cSettings: [
.unsafeFlags(["-Wno-everything"]),
.define("STB_TRUETYPE_IMPLEMENTATION"), .define("STB_RECT_PACK_IMPLEMENTATION"),
.define("extern", to: "__declspec(dllexport) extern", .when(platforms: [.windows])),
.define("_CRT_SECURE_NO_WARNINGS", .when(platforms: [.windows])), // Silence warnings
],
linkerSettings: [
// SR-14728
.linkedLibrary("swiftCore", .when(platforms: [.windows])),
]),

// MARK: - Tests
.testTarget(name: "GateEngineTests", dependencies: ["GateEngine"]),
]
)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "X11/Xlib.h"

// Non-variadic wrappers
XIC XCreateIC_Ext(XIM im, Window window);
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <sys/ioctl.h>

// Non-variadic wrappers
int ioctl_value(int fd, int request, int value);
int ioctl_ptr(int fd, int request, void* ptr);

int EVIOCGBIT(int ev, int len);
int EVIOCGABS(int abs);
int EVIOCGKEY(int len);
int EVIOCGID();
12 changes: 12 additions & 0 deletions Sources/GateEngineDependencies/LinuxSupport/LinuxExtensions/X11.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

// Window & Rendering
#include "Include/X11.h"

// X11 Non-variadic wrapper
XIC XCreateIC_Ext(XIM im, Window window) {
return XCreateIC(im,
XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
XNClientWindow, window,
XNFocusWindow, window,
NULL);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Game Controllers
#include "Include/ioctl.h"
#include <linux/types.h>

struct input_absinfo {
int value;
__s32 minimum;
__s32 maximum;
__s32 fuzz;
__s32 flat;
__s32 resolution;
};

struct input_id {
__u16 bustype;
__u16 vendor;
__u16 product;
__u16 version;
};

int ioctl_ptr(int fd, int request, void* ptr) {
return ioctl(fd, request, ptr);
}
int ioctl_value(int fd, int request, int value) {
return ioctl(fd, request, value);
}

int EVIOCGBIT(int ev, int len) {
return _IOC(_IOC_READ, 'E', 0x20 + (ev), len);
}

int EVIOCGABS(int abs) {
return _IOR('E', 0x40 + (abs), struct input_absinfo);
}

int EVIOCGKEY(int len) {
return _IOC(_IOC_READ, 'E', 0x18, len);
}

int EVIOCGID() {
return _IOR('E', 0x02, struct input_id);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module LinuxImportsGFX [system] {
header "shim.h"
link "X11"
link "GLX"
export *
}
20 changes: 20 additions & 0 deletions Sources/GateEngineDependencies/LinuxSupport/LinuxImports/shim.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Window & Rendering
#include <GL/glx.h>
#include <X11/Xlib.h>

/* This isn't defined in older Linux kernel headers */
#ifndef SYN_DROPPED
#define SYN_DROPPED 3
#endif
#ifndef BTN_DPAD_UP
#define BTN_DPAD_UP 0x220
#endif
#ifndef BTN_DPAD_DOWN
#define BTN_DPAD_DOWN 0x221
#endif
#ifndef BTN_DPAD_LEFT
#define BTN_DPAD_LEFT 0x222
#endif
#ifndef BTN_DPAD_RIGHT
#define BTN_DPAD_RIGHT 0x223
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@_exported import Glibc
@_exported import LinuxImports
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import LinuxExtensions

@_transparent
public func XCreateIC(_ im: XIM, _ window: Window) -> XIC {
return XCreateIC_Ext(im, window)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import LinuxExtensions

@_transparent
public func ioctl(_ fd: Int32, _ request: Int32, _ ptr: UnsafeMutableRawPointer) -> Int32 {
return ioctl_ptr(fd, request, ptr)
}

@_transparent
public func ioctl(_ fd: Int32, _ request: Int32, _ value: Int32) -> Int32 {
return ioctl_value(fd, request, value)
}

@_transparent
public func EVIOCGBIT(_ ev: Int32, _ len: Int32) -> Int32 {
return LinuxExtensions.EVIOCGBIT(ev, len)
}

@_transparent
public func EVIOCGABS(_ abs: Int32) -> Int32 {
return LinuxExtensions.EVIOCGABS(abs)
}

@_transparent
public func EVIOCGKEY(_ len: Int32) -> Int32 {
return LinuxExtensions.EVIOCGKEY(len)
}

public let EVIOCGID: Int32 = LinuxExtensions.EVIOCGID()
Loading

0 comments on commit 388255f

Please sign in to comment.