-
Notifications
You must be signed in to change notification settings - Fork 135
Patch Doom and Quake to Buildroot #698
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
Draft
ChinYikMing
wants to merge
2
commits into
sysprog21:master
Choose a base branch
from
ChinYikMing:patch-doom-quake-br
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+93
−4
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule doom_riscv
added at
f34854
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -26,6 +26,15 @@ mkdir -p $OUTPUT_DIR | |||||
|
|
||||||
| BR_PKG_RTC_DIR=./tests/system/br_pkgs/rtc | ||||||
|
|
||||||
| # RTC | ||||||
| BR_RTC_PKG_DIR=./tests/system/br_pkgs/rtc | ||||||
|
|
||||||
| # Doom | ||||||
| BR_DOOM_PKG_DIR=./tests/system/br_pkgs/doom_riscv | ||||||
|
|
||||||
| # Quake | ||||||
| BR_QUAKE_PKG_DIR=./tests/system/br_pkgs/quake | ||||||
|
|
||||||
| function create_br_pkg_config() | ||||||
| { | ||||||
| local pkg_name=$1 | ||||||
|
|
@@ -43,6 +52,9 @@ function create_br_pkg_makefile() | |||||
| { | ||||||
| local pkg_name=$1 | ||||||
| local output_path=$2 | ||||||
| local output_bin_prefix=${3-} | ||||||
| local makefile_prefix=${4-} | ||||||
| local artifact=${5-} | ||||||
|
|
||||||
| cat << EOF > "${output_path}" | ||||||
| ################################################################################ | ||||||
|
|
@@ -56,11 +68,12 @@ ${pkg_name^^}_SITE = package/${pkg_name}/src | |||||
| ${pkg_name^^}_SITE_METHOD = local | ||||||
|
|
||||||
| define ${pkg_name^^}_BUILD_CMDS | ||||||
| \$(MAKE) CC="\$(TARGET_CC)" LD="\$(TARGET_LD)" -C \$(@D) | ||||||
| \$(MAKE) CROSS="\$(TARGET_CROSS)" CC="\$(TARGET_CC)" LD="\$(TARGET_LD)" -C \$(@D)/${makefile_prefix} | ||||||
| endef | ||||||
|
|
||||||
| define ${pkg_name^^}_INSTALL_TARGET_CMDS | ||||||
| \$(INSTALL) -D -m 0755 \$(@D)/${pkg_name} \$(TARGET_DIR)/usr/bin | ||||||
| \$(INSTALL) -D -m 0755 \$(@D)/${output_bin_prefix}/${pkg_name} \$(TARGET_DIR)/usr/bin | ||||||
| cp -a \$(@D)/${artifact} \$(TARGET_DIR)/root | ||||||
| endef | ||||||
|
|
||||||
| \$(eval \$(generic-package)) | ||||||
|
|
@@ -96,14 +109,73 @@ function update_br_pkg_config() | |||||
| local source_line=" source \"package/${pkg_name}/Config.in\"" | ||||||
|
|
||||||
| # Only append if this package's isn't already present in the menu | ||||||
| if ! grep -q "${pkg_name}" "${br_pkg_config_file}"; then | ||||||
| if ! grep -q "/${pkg_name}/" "${br_pkg_config_file}"; then | ||||||
| sed -i '/^menu "Custom packages"/,/^endmenu$/{ | ||||||
| /^endmenu$/i\ | ||||||
| '"${source_line}"' | ||||||
| }' "${br_pkg_config_file}" | ||||||
| fi | ||||||
| } | ||||||
|
|
||||||
| function do_patch_doom | ||||||
| { | ||||||
| # Need to sed -i --specs=nano.spec to avoid nanolibc and -Bstatic to avoid static linking | ||||||
| sed -i 's/--specs=nano\.specs//g' ${BR_DOOM_PKG_DIR}/src/riscv/Makefile | ||||||
| sed -i 's/-Bstatic//g' ${BR_DOOM_PKG_DIR}/src/riscv/Makefile | ||||||
| # rename output binary from doom-riscv.elf to doom | ||||||
| sed -i 's/doom-riscv\.elf/doom/g' ${BR_DOOM_PKG_DIR}/src/riscv/Makefile | ||||||
|
|
||||||
| local pkg_name="doom" | ||||||
|
|
||||||
| mkdir -p ${SRC_DIR}/buildroot/package/${pkg_name} | ||||||
|
|
||||||
| # download and unzip Doom artifact(DOOM1.WAD) to buildroot Doom package src | ||||||
| if [[ ! -f shareware_doom_iwad.zip ]]; then | ||||||
| wget \ | ||||||
| --user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0" \ | ||||||
| --referer="https://www.doomworld.com/" \ | ||||||
| --show-progress \ | ||||||
| --continue \ | ||||||
| http://www.doomworld.com/3ddownloads/ports/shareware_doom_iwad.zip | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Using HTTP instead of HTTPS for downloading files is a security risk. Consider using Prompt for AI agents
Suggested change
|
||||||
| unzip -d ${SRC_DIR}/buildroot/package/${pkg_name}/src shareware_doom_iwad.zip | ||||||
| fi | ||||||
|
|
||||||
| create_br_pkg_config ${pkg_name} ${SRC_DIR}/buildroot/package/${pkg_name}/Config.in | ||||||
| create_br_pkg_makefile ${pkg_name} ${SRC_DIR}/buildroot/package/${pkg_name}/${pkg_name}.mk "riscv" "riscv" "DOOM1.WAD" | ||||||
| # cp Doom submodule's src to buildroot Doom package src | ||||||
| mkdir -p ${SRC_DIR}/buildroot/package/${pkg_name}/src | ||||||
| cp -rf ${BR_DOOM_PKG_DIR}/src ${SRC_DIR}/buildroot/package/${pkg_name}/ | ||||||
|
|
||||||
| update_br_pkg_config ${pkg_name} | ||||||
| } | ||||||
|
|
||||||
| function do_patch_quake | ||||||
| { | ||||||
| local pkg_name="quake" | ||||||
|
|
||||||
| mkdir -p ${SRC_DIR}/buildroot/package/${pkg_name} | ||||||
|
|
||||||
| # download and unzip Quake artifact(id1/pak0.pak) to buildroot Quake package src | ||||||
| if [[ ! -f quakesw-1.0.6.zip ]]; then | ||||||
| wget -q --show-progress --continue https://www.libsdl.org/projects/quake/data/quakesw-1.0.6.zip | ||||||
| unzip -d ${SRC_DIR}/buildroot/package/${pkg_name}/src quakesw-1.0.6.zip | ||||||
| fi | ||||||
|
|
||||||
| create_br_pkg_config ${pkg_name} ${SRC_DIR}/buildroot/package/${pkg_name}/Config.in | ||||||
| create_br_pkg_makefile ${pkg_name} ${SRC_DIR}/buildroot/package/${pkg_name}/${pkg_name}.mk "port/boards/rv32emu" "" "id1/" | ||||||
| # cmake to generate Makefile | ||||||
| cd ${BR_QUAKE_PKG_DIR} | ||||||
| cmake -DCMAKE_TOOLCHAIN_FILE=./port/boards/rv32emu/toolchain.cmake \ | ||||||
| -DCROSS_COMPILE=riscv32-buildroot-linux-gnu- \ | ||||||
| -DCMAKE_BUILD_TYPE=RELEASE -DBOARD_NAME=rv32emu . | ||||||
| cd - | ||||||
| # cp Quake submodule's src to buildroot Quake package src | ||||||
| mkdir -p ${SRC_DIR}/buildroot/package/${pkg_name}/src | ||||||
| cp -rf ${BR_QUAKE_PKG_DIR}/* ${SRC_DIR}/buildroot/package/${pkg_name}/src | ||||||
|
|
||||||
| update_br_pkg_config ${pkg_name} | ||||||
| } | ||||||
|
|
||||||
| # This function patches the packages when building the rootfs.cpio from scratch | ||||||
| function do_patch_buildroot | ||||||
| { | ||||||
|
|
@@ -117,7 +189,8 @@ endmenu | |||||
| EOF | ||||||
| fi | ||||||
|
|
||||||
| for c in $(find ${BR_PKG_RTC_DIR} -type f); do | ||||||
| # RTC self-contained C files | ||||||
| for c in $(find ${BR_RTC_PKG_DIR} -type f); do | ||||||
| local basename="$(basename ${c})" | ||||||
| local pkg_name="${basename%.*}" | ||||||
|
|
||||||
|
|
@@ -129,6 +202,10 @@ EOF | |||||
|
|
||||||
| update_br_pkg_config ${pkg_name} | ||||||
| done | ||||||
|
|
||||||
| do_patch_doom | ||||||
|
|
||||||
| do_patch_quake | ||||||
| } | ||||||
|
|
||||||
| function do_buildroot | ||||||
|
|
||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
P1: When
artifactis empty (as it is for RTC packages called without the 5th argument), this line becomescp -a $(@D)/ $(TARGET_DIR)/root, which copies the entire build directory to/root. This should be conditional on artifact being non-empty.Prompt for AI agents