-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Linux (and maybe Windows?) support #69
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
May I suggest the following patch ? The compiler actually struggles with unresolved relative paths and discards those include paths. Using this patch fixes compilation without setting environment variables. --- a/Plugins/PDCPlugin/PDCPlugin.swift 2025-02-14 15:54:26.782547459 +0100
+++ b/Plugins/PDCPlugin/PDCPlugin.swift 2025-02-14 15:59:19.550330283 +0100
@@ -100,7 +100,7 @@
throw Tools.Error.armNoneEabiGCCNotFound
}
- let cFlags = gccIncludePaths.flatMap { ["-I", $0] }
+ let cFlags = gccIncludePaths.flatMap { ["-I", URL(fileURLWithPath: $0).standardized.path] }
let swiftFlags = cFlags.flatMap { ["-Xcc", $0] } + [
"-O", |
The following patch fixes simulator support. On linux, a shared object file ( --- a/Plugins/PDCPlugin/PDCPlugin.swift 2025-02-14 15:54:26.782547459 +0100
+++ b/Plugins/PDCPlugin/PDCPlugin.swift 2025-02-14 16:53:53.723881200 +0100
@@ -213,19 +213,18 @@
print("building pdex.dylib")
#if os(Linux)
- let linkerFlags = ["-Wl,--undefined=_eventHandlerShim", "-Wl,--undefined=_eventHandler"]
+ let linkerFlags = ["-Wl,--undefined=_eventHandlerShim", "-Wl,--undefined=_eventHandler", "-shared", "-o", sourcePath.appending(["pdex.so"]).string]
#else
- let linkerFlags = ["-Wl,-exported_symbol,_eventHandlerShim", "-Wl,-exported_symbol,_eventHandler"]
+ let linkerFlags = ["-Wl,-exported_symbol,_eventHandlerShim", "-Wl,-exported_symbol,_eventHandler", "-dynamiclib", "-rdynamic", "-o", sourcePath.appending(["pdex.dylib"]).string]
#endif
try tools.clang([
"-nostdlib", "-dead_strip"
] + linkerFlags + [
- module.modulePath(for: .simulator), "-dynamiclib", "-rdynamic", "-lc", "-lm",
+ module.modulePath(for: .simulator), "-lc", "-lm",
"-DTARGET_SIMULATOR=1", "-DTARGET_EXTENSION=1",
"-I", ".",
"-I", "\(playdateSDK)/C_API",
- "-o", sourcePath.appending(["pdex.dylib"]).string,
"\(playdateSDK)/C_API/buildsupport/setup.c"
])
case .productDependency: |
@FliiFe thanks for taking a look at this! Unfortunately this PR is a bit out of date with the current PDCPlugin, so will need some changes. I'm not set up at the moment to test in a linux env, so if you're interested and have time it would be great if you could open a new PR with any changes necessary to build on linux, and I'm happy to merge. Otherwise I'll try to get an env set up locally when I have some free time. |
just putting this here for reference, these are the commands I ran on a fresh linux install to get the build working last time I tried:
|
I'll look into it. For reference, with the two patches above and the following Dockerfile, everything builds correctly for simulator and device FROM swiftlang/swift:nightly-main-jammy
# Update apt cache and install dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
wget \
gcc-arm-none-eabi \
libnewlib-arm-none-eabi \
libstdc++-arm-none-eabi-newlib \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Fetch and extract the Playdate SDK
RUN mkdir -p /opt
WORKDIR /opt
RUN wget https://download.panic.com/playdate_sdk/Linux/PlaydateSDK-latest.tar.gz \
&& tar -zxvf PlaydateSDK-latest.tar.gz \
&& rm PlaydateSDK-latest.tar.gz \
&& mv PlaydateSDK-* PlaydateSDK \
&& chmod -R 755 /opt
# Set environment variables
ENV PLAYDATE_SDK_PATH=/opt/PlaydateSDK \
ARM_TOOLCHAIN_PATH=/usr/lib/gcc/arm-none-eabi/10.3.1/
RUN mkdir /.swiftpm /.cache && chmod 777 /.swiftpm /.cache
# Set default work directory
RUN mkdir -p /mnt
VOLUME /mnt
WORKDIR /mnt |
moved to #113 |
xcrun
(swift toolchain env var?).pdx
works on linux simulator + devicecloses #68