-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
Add native docker images w/ build workflow #316
Conversation
I'm debugging and streamlining the workflows on my fork. I'll convert this to a draft for now until that process is complete. Sorry for the noise! |
d2c638f
to
328de48
Compare
This is ready now. Please take a look! |
Rebased, cleaned-up version of PR Stephane-D#292, which adds Docker images that do not rely on Wine, with a GitHub Actions workflow to build and push Docker images to ghcr.io. Compared with Stephane-D#292, this: - is based on 4397ac2 (2024-03-06) instead of d84d456 (2023-07-31) - has no changes to newline styless, so the diff is easier to read - adds instructions to readme.md on building deps/gcc.Dockerfile - fix case on gcc docker image (must be lowercase apparently) - fixes typos - streamlines and simplifies the GitHub Actions workflow - disables arm64 image builds because they keep hanging in the GitHub Actions environment Resolves Stephane-D#290 Resolves Stephane-D#304
Nice, could you add git to the second stage image. Thanks |
makefile.gen
Outdated
SRC_S= $(wildcard *.s) | ||
SRC_S+= $(wildcard $(SRC)/*.s) | ||
SRC_S+= $(wildcard $(SRC)/*/*.s) | ||
SRC_S+= $(wildcard $(SRC)/*/*/*.s) | ||
SRC_S:= $(filter-out $(SRC)/boot/sega.s,$(SRC_S)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why it was removed ? this line is important so we can add a specific rule to build boot/sega.s file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm reverting this. See also my other replies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments in Dockerfile and mekafile.gen
makefile.gen
Outdated
$(CC) $(DEFAULT_FLAGS) -c $< -o $@ | ||
|
||
$(SRC)/boot/sega.s: $(SRC_LIB)/boot/sega.s | ||
$(OUT)/boot/sega.s: $(SRC_LIB)/boot/sega.s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you moved boot/sega.s to OUT folder ? The file make be customized (interrupt callback, bootstrap..) so i think it's important to keep it in SRC folder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I inherited most of these changes from the original PR. I just tried to clean it up for review and fix the workflows.
I'm guessing the original author thought that generated files should go to OUT as a rule, and didn't realize that it could be customized. I would have made the same mistake.
I'll revert this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have run into one problem with these generated sources, though, which I will try to resolve. If I rebuild SGDK, my existing src/boot/rom_head.c gets overwritten when I rebuild my ROM because the one in SRC_LIB is newer. I only noticed because I had already customized my rom_head.c file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted sega.s moving to OUT. Fixed overwritten boot files.
Dockerfile
Outdated
WORKDIR $SGDK_PATH/tools/apj/src | ||
RUN javac sgdk/aplib/*.java | ||
RUN jar cfe $SGDK_PATH/bin/apj.jar sgdk.aplib.Launcher sgdk/aplib/*.class | ||
|
||
# Building lz4w.jar | ||
WORKDIR $SGDK_PATH/tools/lz4w/src | ||
RUN javac sgdk/lz4w/*.java | ||
RUN jar cfe $SGDK_PATH/bin/lz4w.jar sgdk.lz4w.Launcher sgdk/lz4w/*.class | ||
|
||
# Building sizebnd.jar | ||
WORKDIR $SGDK_PATH/tools/sizebnd/src | ||
RUN javac sgdk/sizebnd/*.java | ||
RUN jar cfe $SGDK_PATH/bin/sizebnd.jar sgdk.sizebnd.Launcher sgdk/sizebnd/*.class | ||
|
||
# Building rescomp.jar | ||
WORKDIR $SGDK_PATH/tools/rescomp/src | ||
ENV CLASSPATH="$SGDK_PATH/bin/apj.jar:$SGDK_PATH/bin/lz4w.jar:$SGDK_PATH/tools/rescomp/src" | ||
RUN cp -r $SGDK_PATH/tools/commons/src/sgdk . | ||
RUN find . -name "*.java" | ||
RUN find . -name "*.java" | xargs javac | ||
RUN echo -e "Main-Class: sgdk.rescomp.Launcher\nClass-Path: apj.jar lz4w.jar" > Manifest.txt | ||
RUN jar cfm $SGDK_PATH/bin/rescomp.jar Manifest.txt . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any interest in rebuilding the JAR file here instead of just copying them from the SGDK repo ? JAR should be portable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll look into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This already seems to rebuild the jar from scratch. I deleted the jar from my local repo, reran the Docker build, and everything is fine.
With this Dockerfile, I can delete all .exe, .dll, and .jar files from the repo and be perfectly happy in Linux. Everything built from source, no Wine. Deleting those from the repo would resolve #297, but I'm not sure if that would have negative consequences for Windows users. Should I do it here? In a follow-up PR? Not at all?
Thanks!
I would like to keep this PR focused. When it is merged, and we have build pipelines that automatically publish new Docker images, you could always follow up with a PR to add git. And ultimately, it will be @Stephane-D who decides whether or not to allow that. |
makefile.gen
Outdated
|
||
out/sega.o: $(SRC)/boot/sega.s out/rom_head.bin | ||
$(CC) -x assembler-with-cpp -Wa,--register-prefix-optional,--bitwise-or $(AFLAGS) -c $(SRC)/boot/sega.s -o $@ | ||
$(OUT)/sega.o: $(OUT)/boot/sega.s $(OUT)/rom_head.bin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't actually seem to depend on rom_head.bin, so I'm removing that dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I stand corrected. sega.s references rom_head.bin. I didn't realize. I'll add a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
makefile.gen
Outdated
|
||
clean: cleanobj cleanres cleanlst cleandep | ||
$(RM) -f out.lst out/cmd_ out/symbol.txt out/rom.nm out/rom.wch out/rom.bin | ||
$(RM) -f out.lst $(OUT)/cmd_ $(OUT)/symbol.txt $(OUT)/rom.nm $(OUT)/rom.wch $(OUT)/rom.bin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what out.lst is exactly, but it looks like it belongs in $(OUT), so I'm moving it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Dockerfile
Outdated
ENV GDK=/sgdk | ||
ENV SGDK_DOCKER=y | ||
WORKDIR /sgdk | ||
COPY . . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm reorganizing the steps so more of them can be cached. When I change any one file in SGDK and rebuild, everything past this point must be rerun because the source folder changed and the cache of this step and those after it become stale.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@Stephane-D, I believe I have addressed all the feedback so far. My only outstanding question for you is this: This Dockerfile can regenerate all binaries. I can delete all .exe, .dll, .jar, and .a files from the repo and everything still works from source natively on Linux. Deleting those from the repo would resolve #297, but I'm not sure if that would have negative consequences for Windows users. Should I do it here? In a follow-up PR? Not at all? Thanks! |
@joeyparrish Thanks for taking the time to fix all that ! |
Those steps (building tools, jars, etc) will only run when someone runs "docker build ..." to create the image from SGDK source. The GitHub Actions workflow will build images every time you push to the When a user wants to compile their ROM with SGDK using Docker, the tools will not be rebuilt. It will start at "ENTRYPOINT". Does this answer your concern? |
@Stephane-D, let me know if you have other concerns or if you would like me to make other changes. I believe the PR is in a good state. Everything is rebuilt from source at Docker build time in the automated workflow. Each change to the |
@joeyparrish , any thoughts on using crosstool-ng and bulding the latest gcc 13.2.0? Also, Sjasm sources are included under tools as a submodule. There is no need to clone independently. |
Looks like it would be useful. I could explore redoing the GCC Dockerfile with crosstool-ng after this PR is merged. Or you could send a PR yourself if you already have experience with crosstool-ng. (I have none.) |
I have the Dockerfile specific to building the tools using crosstool-ng but I may need some assistance integrating it. Maybe a collaboration? Take a look at the Dockerfile here iratahack@ba9fc47 |
@iratahack, I was hoping to get this PR merged as a baseline before I moved on to improvements, so I would at least be able to refer to the official Docker image from ghcr.io for my own project. But since this hasn't been re-reviewed, I'll take a look at your work and try to integrate it if I can. It may be days to weeks before I have the time, though. Thank you for your offer of collaboration! |
Rebased, cleaned-up version of PR #292, which adds Docker images that do not rely on Wine, with a GitHub Actions workflow to build and push Docker images to ghcr.io.
Compared with #292, this:
Resolves #290
Resolves #304