From bd7a896e48e25559ef8cfb49ed2c39cbd85c3b88 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 24 Aug 2025 11:20:02 +0100 Subject: [PATCH] Use flake.nix instead of flake.nix (#1244) --- .envrc | 1 + Jenkinsfile | 2 +- SETUP.md | 10 +- configure | 2 +- flake.lock | 183 +++++++++ flake.nix | 248 ++++++++++++ install_deps.sh | 24 +- shell.nix | 108 ------ tools/configure/default.nix | 63 +++ tools/configure/lock.aarch64-darwin.json | 364 ++++++++++++++++++ tools/configure/lock.x86_64-linux.json | 364 ++++++++++++++++++ tools/configure/pyproject.toml | 10 + .../configure/requirements.txt | 1 + .../configure/requirements_extra.txt | 0 .../src/configure/main.py} | 59 +-- tools/crunch64.nix | 23 ++ tools/pigment64.nix | 22 ++ 17 files changed, 1338 insertions(+), 146 deletions(-) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix delete mode 100644 shell.nix create mode 100644 tools/configure/default.nix create mode 100644 tools/configure/lock.aarch64-darwin.json create mode 100644 tools/configure/lock.x86_64-linux.json create mode 100644 tools/configure/pyproject.toml rename requirements.txt => tools/configure/requirements.txt (94%) rename requirements_extra.txt => tools/configure/requirements_extra.txt (100%) rename tools/{build/configure.py => configure/src/configure/main.py} (97%) create mode 100644 tools/crunch64.nix create mode 100644 tools/pigment64.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000000..3550a30f2d --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/Jenkinsfile b/Jenkinsfile index 431e0fdf93..0da4b386fe 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,7 +17,7 @@ pipeline { sh 'curl -L "https://github.com/decompals/mips-binutils-2.6/releases/download/main/binutils-2.6-linux.tar.gz" | tar zx -C tools/build/cc/gcc2.7.2' sh 'curl -L "https://github.com/decompals/mips-binutils-egcs-2.9.5/releases/latest/download/mips-binutils-egcs-2.9.5-linux.tar.gz" | tar zx -C tools/build/cc/egcs' sh 'curl -L "https://github.com/decompals/mips-gcc-egcs-2.91.66/releases/latest/download/mips-gcc-egcs-2.91.66-linux.tar.gz" | tar zx -C tools/build/cc/egcs' - sh 'pip install -U -r requirements.txt --break-system-packages' + sh 'pip install -U -r tools/configure/requirements.txt --break-system-packages' sh 'cargo install pigment64' sh 'cargo install crunch64-cli' sh './configure' diff --git a/SETUP.md b/SETUP.md index 61e4d1642e..dcb6e27185 100644 --- a/SETUP.md +++ b/SETUP.md @@ -63,9 +63,15 @@ If you have Visual Studio Code, you can type `code .` to open the repo within it ## Nix 1. Install [Nix](https://nixos.org/download.html) +1. [Enable nix-command and flakes experimental features](https://nix.dev/manual/nix/2.25/command-ref/conf-file#conf-experimental-features) 2. Clone the repository and `cd` into it -3. Enter a shell with `NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 NIX_BUILD_CORES=0 nix-shell` -4. Continue with [building](#building) +3. Add **all** baseroms to the store: + * `nix store add --mode flat --name papermario.us.z64 --hash-algo sha1 path/to/papermario.us.z64` + * `nix store add --mode flat --name papermario.jp.z64 --hash-algo sha1 path/to/papermario.jp.z64` + * `nix store add --mode flat --name papermario.pal.z64 --hash-algo sha1 path/to/papermario.pal.z64` + * `nix store add --mode flat --name papermario.ique.z64 --hash-algo sha1 path/to/papermario.ique.z64` +4. Enter a shell with `nix develop` +5. Continue with [building](#building) (ignore baserom instructions) # Building diff --git a/configure b/configure index e7e5102321..ab61a37510 100755 --- a/configure +++ b/configure @@ -1,2 +1,2 @@ #!/usr/bin/env bash -python3 tools/build/configure.py "$@" +python3 tools/configure/src/configure/main.py "$@" diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000000..9108ddef5f --- /dev/null +++ b/flake.lock @@ -0,0 +1,183 @@ +{ + "nodes": { + "dream2nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "purescript-overlay": "purescript-overlay", + "pyproject-nix": "pyproject-nix" + }, + "locked": { + "lastModified": 1753366881, + "narHash": "sha256-jsoTEhkmn3weESMNRMLNk/ROW3fcHCr8Wgf5amzs5z8=", + "owner": "nix-community", + "repo": "dream2nix", + "rev": "e6566e4ce924a8258499c379ee9552dba1883bce", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "dream2nix", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1753489912, + "narHash": "sha256-uDCFHeXdRIgJpYmtcUxGEsZ+hYlLPBhR83fdU+vbC1s=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "13e8d35b7d6028b7198f8186bc0347c6abaa2701", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-binutils-2_39": { + "locked": { + "lastModified": 1676239704, + "narHash": "sha256-eKJDKTzI/uHNmfOX1Ln7Y1cjyA9XAkf5vyWdz03EXAA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "55070e598e0e03d1d116c49b9eff322ef07c6ac6", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "55070e598e0e03d1d116c49b9eff322ef07c6ac6", + "type": "github" + } + }, + "purescript-overlay": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": [ + "dream2nix", + "nixpkgs" + ], + "slimlock": "slimlock" + }, + "locked": { + "lastModified": 1728546539, + "narHash": "sha256-Sws7w0tlnjD+Bjck1nv29NjC5DbL6nH5auL9Ex9Iz2A=", + "owner": "thomashoneyman", + "repo": "purescript-overlay", + "rev": "4ad4c15d07bd899d7346b331f377606631eb0ee4", + "type": "github" + }, + "original": { + "owner": "thomashoneyman", + "repo": "purescript-overlay", + "type": "github" + } + }, + "pyproject-nix": { + "inputs": { + "nixpkgs": [ + "dream2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1752481895, + "narHash": "sha256-luVj97hIMpCbwhx3hWiRwjP2YvljWy8FM+4W9njDhLA=", + "owner": "pyproject-nix", + "repo": "pyproject.nix", + "rev": "16ee295c25107a94e59a7fc7f2e5322851781162", + "type": "github" + }, + "original": { + "owner": "pyproject-nix", + "repo": "pyproject.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "dream2nix": "dream2nix", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "nixpkgs-binutils-2_39": "nixpkgs-binutils-2_39" + } + }, + "slimlock": { + "inputs": { + "nixpkgs": [ + "dream2nix", + "purescript-overlay", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1688756706, + "narHash": "sha256-xzkkMv3neJJJ89zo3o2ojp7nFeaZc2G0fYwNXNJRFlo=", + "owner": "thomashoneyman", + "repo": "slimlock", + "rev": "cf72723f59e2340d24881fd7bf61cb113b4c407c", + "type": "github" + }, + "original": { + "owner": "thomashoneyman", + "repo": "slimlock", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000000..e91ded23ed --- /dev/null +++ b/flake.nix @@ -0,0 +1,248 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; + + # This commit uses binutils 2.39. We don't want binutils 2.40+ because of a performance regression in ld. + nixpkgs-binutils-2_39.url = "github:NixOS/nixpkgs/55070e598e0e03d1d116c49b9eff322ef07c6ac6"; + + flake-utils.url = "github:numtide/flake-utils"; + + dream2nix.url = "github:nix-community/dream2nix"; + dream2nix.inputs.nixpkgs.follows = "nixpkgs"; + }; + nixConfig = { + extra-substituters = [ + "https://papermario-dx.cachix.org" + ]; + extra-trusted-public-keys = [ + "papermario-dx.cachix.org-1:VTXILrqiajck9s5U2O3nDJH0pAI64GAJK41b2pt1JIk=" + ]; + }; + outputs = { + nixpkgs, + nixpkgs-binutils-2_39, + flake-utils, + dream2nix, + ... + }: + flake-utils.lib.eachDefaultSystem ( + system: let + crossSystem = { + config = "mips-linux-gnu"; + }; + pkgs = import nixpkgs {inherit system;}; + pkgsCross = import nixpkgs {inherit system crossSystem;}; + binutils2_39 = (import nixpkgs-binutils-2_39 {inherit system crossSystem;}).buildPackages.binutilsNoLibc; + + hashFromVersion = version: builtins.elemAt (builtins.match "([a-f0-9]+) .*" (builtins.readFile ./ver/${version}/checksum.sha1)) 0; + requireBaseRom = version: + pkgs.requireFile rec { + name = "papermario.${version}.z64"; + message = '' + papermario requires a base ROM. + + Please add it to the Nix store using + nix store add --mode flat --name ${name} --hash-algo sha1 path/to/${name} + ''; + sha1 = hashFromVersion version; + }; + + configure = dream2nix.lib.evalModules { + packageSets.nixpkgs = pkgs; + modules = [ + ./tools/configure/default.nix + { + paths = { + projectRoot = ./.; + projectRootFile = "flake.nix"; + package = ./tools/configure; + }; + } + ]; + }; + commonBuildInputs = with pkgs; [ + configure + configure.pyEnv + ninja + zlib + libyaml + python3 + ccache + git + iconv + gcc # for n64crc + (callPackage ./tools/pigment64.nix {}) + (callPackage ./tools/crunch64.nix {}) + ]; + commonCompilers = let + isLinux = pkgs.stdenv.isLinux; + osGcc = + if isLinux + then "linux" + else "mac"; + osIdo = + if isLinux + then "ubuntu" + else "macos"; + in { + gcc = [ + (pkgs.fetchzip { + name = "gcc-papermario"; + version = "master"; + url = "https://github.com/pmret/gcc-papermario/releases/download/master/${osGcc}.tar.gz"; + sha256 = + if isLinux + then "sha256-bFlt13n13a7UZulwkcdrwRbXfXRWkUTqszAczzAs8Ac=" + else "sha256-mkBPLgGPg/tKKRwnVXLVULzd4HuuZabZJccy/t7a2ZI="; + stripRoot = false; + }) + (pkgs.fetchzip { + name = "binutils-papermario"; + version = "master"; + url = "https://github.com/pmret/binutils-papermario/releases/download/master/${osGcc}.tar.gz"; + sha256 = + if isLinux + then "sha256-HdVaaOjFBJYywA/+uQ2wsqmJrEwBEuFSdo9jPb4qceE=" + else "sha256-sqpEhIypLleEnJJIAw0+JR7mg8cESWUhr4Umh8GURNE="; + stripRoot = false; + }) + ]; + "gcc2.7.2" = [ + (pkgs.fetchzip { + name = "mips-gcc"; + version = "2.7.2"; + url = "https://github.com/decompals/mips-gcc-2.7.2/releases/download/main/gcc-2.7.2-${osGcc}.tar.gz"; + sha256 = + if isLinux + then "sha256-0orDbWWom581bJ60SvE96ct5H9Mua0c3gyMHbY7DzRE=" + else "sha256-A7CH2JNLlY6aFgI/L6AvvsnRJrAu3KYZFWwmqJ6ZWWA="; + stripRoot = false; + }) + (pkgs.fetchzip { + name = "mips-binutils"; + version = "2.6"; + url = "https://github.com/decompals/mips-binutils-2.6/releases/download/main/binutils-2.6-${osGcc}.tar.gz"; + sha256 = + if isLinux + then "sha256-237UECnNLGSBZEyLJr9rEHC3cT2m5pS0ApDjgkL3WqM=" + else "sha256-1hbEAXjN00+tnfXqbeMX1D8OWordLoeWXf++KF7YsMM="; + stripRoot = false; + }) + ]; + "ido5.3" = [ + (pkgs.fetchzip { + name = "ido"; + version = "5.3"; + url = "https://github.com/decompals/ido-static-recomp/releases/download/v0.2/ido-5.3-recomp-${osIdo}-latest.tar.gz"; + sha256 = + if isLinux + then "sha256-LvEmsxIeF+JFZFLjIBBbHjDb1ZuvFB5XParZDqamVhE=" + else "sha256-5P93jXkgj2kQP+54gXvtDMLyRI5JvJcjsCBEVCQMKTg="; + stripRoot = false; + }) + ]; + }; + iqueCompilers = + if pkgs.stdenv.isDarwin + then {} + else { + "egcs" = [ + (pkgs.fetchzip { + name = "egcs-gcc"; + version = "2.91.66"; + url = "https://github.com/decompals/mips-gcc-egcs-2.91.66/releases/latest/download/mips-gcc-egcs-2.91.66-linux.tar.gz"; + sha256 = "sha256-nEr2btiRvUnciBK8Rh42JyJmseT3PAZvhs/UUiMLvH4="; + stripRoot = false; + }) + (pkgs.fetchzip { + name = "egcs-binutils"; + version = "2.9.5"; + url = "https://github.com/decompals/mips-binutils-egcs-2.9.5/releases/latest/download/mips-binutils-egcs-2.9.5-linux.tar.gz"; + sha256 = "sha256-v8KAW4OoLtxyPMeO1Uw5bTXFxOaEUi8ZN52J8l/Zols="; + stripRoot = false; + }) + ]; + }; + mkCompilerScript = compilers: let + lib = pkgs.lib; + in + pkgs.writeShellScript "setup-compilers.sh" (lib.concatStringsSep "\n" (lib.mapAttrsToList ( + name: paths: let + quotedPaths = lib.concatStringsSep " " (map (p: "\"${p}\"") paths); + in + '' + rm -rf tools/build/cc/${name}/* + mkdir -p tools/build/cc/${name} + + for path in ${quotedPaths}; do + cp -r "$path"/* tools/build/cc/${name}/ + done + '' + + lib.optionalString pkgs.stdenv.isLinux '' + # Fix 'cannot execute: required file not found' errors + for bin in tools/build/cc/${name}/*; do + ${pkgs.patchelf}/bin/patchelf --set-interpreter "${pkgs.glibc}/lib/ld-linux-x86-64.so.2" $bin 2>/dev/null || true + done + '' + ) + compilers)); + + mkVersion = { + version, + compilers ? commonCompilers, + }: { + "papermario_${version}" = pkgsCross.ccacheStdenv.mkDerivation { + name = "papermario"; + inherit version; + src = ./.; + nativeBuildInputs = commonBuildInputs; + configurePhase = '' + rm -f ver/${version}/baserom.z64 && cp ${requireBaseRom version} ver/${version}/baserom.z64 + . ${mkCompilerScript compilers} + configure --ccache + ''; + buildPhase = '' + ninja + ''; + installPhase = '' + cp ver/${version}/build/papermario.elf $out + ''; + dontStrip = true; + enableParallelBuilding = true; + outputHashMode = "flat"; + outputHashAlgo = "sha256"; + PAPERMARIO_LD = "${binutils2_39}/bin/mips-linux-gnu-ld"; + }; + }; + in { + packages = + { + inherit configure; # for `nix run ".#configure.lock"` to update python lockfile + } + // mkVersion {version = "us";} + // mkVersion {version = "jp";} + // mkVersion {version = "pal";} + // mkVersion { + version = "ique"; + compilers = commonCompilers // iqueCompilers; + }; + devShells = { + default = pkgsCross.mkShell { + name = "papermario"; + venvDir = "./venv"; + packages = commonBuildInputs; + shellHook = '' + rm -f ./ver/us/baserom.z64 && cp ${requireBaseRom "us"} ./ver/us/baserom.z64 + rm -f ./ver/jp/baserom.z64 && cp ${requireBaseRom "jp"} ./ver/jp/baserom.z64 + rm -f ./ver/pal/baserom.z64 && cp ${requireBaseRom "pal"} ./ver/pal/baserom.z64 + rm -f ./ver/ique/baserom.z64 && cp ${requireBaseRom "ique"} ./ver/ique/baserom.z64 + + . ${mkCompilerScript (commonCompilers // iqueCompilers)} + ''; + PAPERMARIO_LD = "${binutils2_39}/bin/mips-linux-gnu-ld"; + }; + }; + formatter = pkgs.alejandra; + } + ); +} diff --git a/install_deps.sh b/install_deps.sh index 9f50d19959..5175321938 100755 --- a/install_deps.sh +++ b/install_deps.sh @@ -21,12 +21,12 @@ if [[ "$uname" == "Darwin" ]]; then # Install packages brew install md5sha1sum ninja gcc bates64/brew/mips-linux-gnu-binutils bates64/brew/mips-linux-gnu-gcc || exit 1 - python3 -m pip install -U -r requirements.txt || exit 1 + python3 -m pip install -U -r tools/configure/requirements.txt || exit 1 cp tools/precommit_check_no_assets.sh "$(git rev-parse --git-path hooks)/pre-commit" || exit 1 if [[ $1 == "--extra" ]]; then echo "Installing extra" - python3 -m pip install -U -r requirements_extra.txt || exit 1 + python3 -m pip install -U -r tools/configure/requirements_extra.txt || exit 1 fi exit 0 fi @@ -38,13 +38,13 @@ if cat /etc/os-release | grep -E 'ID=debian|ID_LIKE=(.*)debian' &> /dev/null; th echo "Installing packages for Debian or derivative (apt)" ${SUDO} apt install -y curl git python3 python3-pip python3-setuptools build-essential binutils-mips-linux-gnu zlib1g-dev libyaml-dev ninja-build cpp-mips-linux-gnu gcc-mips-linux-gnu || exit 1 - python3 -m pip install -U -r requirements.txt + python3 -m pip install -U -r tools/configure/requirements.txt cp tools/precommit_check_no_assets.sh "$(git rev-parse --git-path hooks)/pre-commit" || exit 1 if [[ $1 == "--extra" ]]; then echo "Installing extra" ${SUDO} apt install -y clang-tidy astyle doxygen || exit 1 - python3 -m pip install -U -r requirements_extra.txt || exit 1 + python3 -m pip install -U -r tools/configure/requirements_extra.txt || exit 1 fi fi @@ -88,13 +88,13 @@ if cat /etc/os-release | grep -E ID=fedora &> /dev/null; then # go back to old dir cd "${RETURNDIR}" fi - python3 -m pip install -U -r requirements.txt + python3 -m pip install -U -r tools/configure/requirements.txt cp tools/precommit_check_no_assets.sh "$(git rev-parse --git-path hooks)/pre-commit" || exit 1 if [[ $1 == "--extra" ]]; then echo "Installing extra" ${SUDO} dnf install -y clang-tools-extra astyle doxygen || exit 1 - python3 -m pip install -U -r requirements_extra.txt || exit 1 + python3 -m pip install -U -r tools/configure/requirements_extra.txt || exit 1 fi fi @@ -109,7 +109,7 @@ if cat /etc/os-release | grep -E 'ID=arch|ID_LIKE="?arch"?' &> /dev/null; then # Install dependencies ${SUDO} pacman -S --noconfirm --needed curl git python python-pip python-setuptools base-devel zlib libyaml ninja || exit 1 - python3 -m pip install -U -r requirements.txt + python3 -m pip install -U -r tools/configure/requirements.txt cp tools/precommit_check_no_assets.sh "$(git rev-parse --git-path hooks)/pre-commit" || exit 1 # Install binutils if required @@ -135,7 +135,7 @@ if cat /etc/os-release | grep -E 'ID=arch|ID_LIKE="?arch"?' &> /dev/null; then if [[ $1 == "--extra" ]]; then echo "Installing extra" ${SUDO} pacman -S --noconfirm --needed clang astyle doxygen || exit 1 - python3 -m pip install -U -r requirements_extra.txt || exit 1 + python3 -m pip install -U -r tools/configure/requirements_extra.txt || exit 1 fi fi @@ -164,13 +164,13 @@ if cat /etc/os-release | grep ID=opensuse &> /dev/null; then ${SUDO} ln -s /usr/bin/mips-suse-linux-strings /usr/bin/mips-linux-gnu-strings ${SUDO} ln -s /usr/bin/mips-suse-linux-strip /usr/bin/mips-linux-gnu-strip - python3 -m pip install -U -r requirements.txt + python3 -m pip install -U -r tools/configure/requirements.txt cp tools/precommit_check_no_assets.sh "$(git rev-parse --git-path hooks)/pre-commit" || exit 1 if [[ $1 == "--extra" ]]; then echo "Installing extra" ${SUDO} zypper -n install clang astyle doxygen || exit 1 - python3 -m pip install -U -r requirements_extra.txt || exit 1 + python3 -m pip install -U -r tools/configure/requirements_extra.txt || exit 1 fi fi @@ -187,7 +187,7 @@ if cat /etc/os-release | grep ID=alpine &> /dev/null; then # Install dependencies ${SUDO} apk add --no-cache bash curl wget git python3 python3-dev py3-pip build-base zlib-dev yaml-dev ninja - python3 -m pip install -U -r requirements.txt + python3 -m pip install -U -r tools/configure/requirements.txt cp tools/precommit_check_no_assets.sh "$(git rev-parse --git-path hooks)/pre-commit" || exit 1 # Install binutils if required @@ -226,7 +226,7 @@ if cat /etc/os-release | grep ID=alpine &> /dev/null; then if [[ $1 == "--extra" ]]; then echo "Installing extra" ${SUDO} apk add --no-cache clang-extra-tools astyle doxygen || exit 1 - python3 -m pip install -U -r requirements_extra.txt || exit 1 + python3 -m pip install -U -r tools/configure/requirements_extra.txt || exit 1 fi fi diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 66ed89b0d3..0000000000 --- a/shell.nix +++ /dev/null @@ -1,108 +0,0 @@ -{ pkgsNative ? import {} -, pkgsCross ? import { crossSystem = { config = "mips-linux-gnu"; }; } -, pkgsCrossOld ? import (builtins.fetchTarball { - # This commit uses binutils 2.39. We don't want binutils 2.40+ because of a performance regression in ld. - url = "https://github.com/NixOS/nixpkgs/archive/55070e598e0e03d1d116c49b9eff322ef07c6ac6.tar.gz"; - }) { crossSystem = { config = "mips-linux-gnu"; }; } -}: - -let - gcc-papermario = builtins.fetchurl { - url = - "https://github.com/pmret/gcc-papermario/releases/download/master/linux.tar.gz"; - sha256 = "1156cf0d6a88a64c20e2a10fc9445d99cb9a38518f432b1669528dfa82ebb45f"; - }; - - binutils-papermario = builtins.fetchurl { - url = - "https://github.com/pmret/binutils-papermario/releases/download/master/linux.tar.gz"; - sha256 = "c3cd88db47ac41f78b557042c7e7ad47ac9c04cee6f0d1069a489c1c9e8c103c"; - }; - - mips-gcc-272 = builtins.fetchurl { - url = - "https://github.com/decompals/mips-gcc-2.7.2/releases/download/main/gcc-2.7.2-linux.tar.gz"; - sha256 = "ff3e299c1d952c0a5cb39f7790a208d0c547cf93986eb5607f820c935cedc288"; - }; - - mips-binutils-26 = builtins.fetchurl { - url = - "https://github.com/decompals/mips-binutils-2.6/releases/download/main/binutils-2.6-linux.tar.gz"; - sha256 = "405a7ddb29a0b2eb472b167e8f15472223df1eff3093a5ff31d6e545d3a6c670"; - }; - - egcs-binutils = builtins.fetchurl { - url = - "https://github.com/decompals/mips-binutils-egcs-2.9.5/releases/latest/download/mips-binutils-egcs-2.9.5-linux.tar.gz"; - sha256 = "1gxwgcr4jls6krrp5a63rwvn3ayn87zl1iz5il25d6dwryf29ssl"; - }; - - egcs-gcc = builtins.fetchurl { - url = - "https://github.com/decompals/mips-gcc-egcs-2.91.66/releases/latest/download/mips-gcc-egcs-2.91.66-linux.tar.gz"; - sha256 = "1aqmlwkisyvd3nwkmaw3j5fqk9qxszs03yx3v90bm3yipb6czf27"; - }; - - ido = builtins.fetchurl { - url = - "https://github.com/decompals/ido-static-recomp/releases/download/v0.2/ido-5.3-recomp-ubuntu-latest.tar.gz"; - sha256 = "65b42b9673b6f439e45e5dafab1eca4fc006a68cda87bdb55681f027d9fb903c"; - }; -in pkgsCross.mkShell { - nativeBuildInputs = (with pkgsNative; [ - ninja - zlib - libyaml - patchelf - glibc - gcc - python3 - python3Packages.virtualenv - cargo - rustc - ]); - buildInputs = (with pkgsCross; [ - gcc - pkgsCrossOld.binutils - ]); - - shellHook = '' - # Install compilers - # TODO: use pkgs.stdenv.mkDerivation instead of extracting here - tar zx -C tools/build/cc/gcc -f ${gcc-papermario} - tar zx -C tools/build/cc/gcc -f ${binutils-papermario} - tar zx -C tools/build/cc/gcc2.7.2 -f ${mips-gcc-272} - tar zx -C tools/build/cc/gcc2.7.2 -f ${mips-binutils-26} - tar zx -C tools/build/cc/ido5.3 -f ${ido} - tar zx -C tools/build/cc/egcs -f ${egcs-binutils} - tar zx -C tools/build/cc/egcs -f ${egcs-gcc} - - # Fix 'file not found' errors since we're using a newer glibc - for dir in $(find tools/build/cc -type d); do - for f in $(find $dir -type f); do - # Silence errors instead of thinking hard about this - ${pkgsNative.patchelf}/bin/patchelf --set-interpreter "${pkgsNative.glibc}/lib/ld-linux-x86-64.so.2" $f 2>/dev/null - done - done - - # Install pigment64 - export PATH=$HOME/.cargo/bin:$PATH - cargo install pigment64 - - # Install python packages - virtualenv venv - source venv/bin/activate - pip install -r ${./requirements.txt} - pip install -r ${./requirements_extra.txt} - - # Use old ld (but not the rest of binutils) - BINUTILS=$(find /nix/store -maxdepth 1 -name '*-mips-linux-gnu-binutils-2.39' | head -n 1) - export PAPERMARIO_LD="$BINUTILS/bin/mips-linux-gnu-ld" - - # Confirm that ld is 2.39 - LD_VERSION=$($PAPERMARIO_LD --version | head -n 1) - if [[ $LD_VERSION != *2.39* ]]; then - echo "Expected $PAPERMARIO_LD to be 2.39, got $LD_VERSION" - fi - ''; -} diff --git a/tools/configure/default.nix b/tools/configure/default.nix new file mode 100644 index 0000000000..1f52e32eb8 --- /dev/null +++ b/tools/configure/default.nix @@ -0,0 +1,63 @@ +{ + config, + lib, + dream2nix, + ... +}: +{ + imports = [ + dream2nix.modules.dream2nix.pip + ]; + + deps = + { nixpkgs, ... }: + { + python = nixpkgs.python3; + }; + + name = "configure"; + version = "0.1.0"; + + mkDerivation = { + src = lib.cleanSourceWith { + src = lib.cleanSource ./.; + filter = + name: _type: + !(builtins.any (x: x) [ + (lib.hasSuffix ".nix" name) + (lib.hasPrefix "." (builtins.baseNameOf name)) + (lib.hasSuffix "flake.lock" name) + ]); + }; + }; + + buildPythonPackage = { + pyproject = true; + pythonImportsCheck = [ + "configure" + ]; + }; + + pip = { + requirementsList = + lib.strings.splitString "\n" (builtins.readFile ./requirements.txt) + ++ lib.strings.splitString "\n" (builtins.readFile ./requirements_extra.txt); + flattenDependencies = true; + + overrides.click = { + buildPythonPackage.pyproject = true; + mkDerivation.nativeBuildInputs = with config.deps.python.pkgs; [ + ninja + zlib + libyaml + python3 + ccache + git + iconv + gcc # for n64crc + (callPackage ../pigment64.nix { }) + (callPackage ../crunch64.nix { }) + ]; + }; + }; +} diff --git a/tools/configure/lock.aarch64-darwin.json b/tools/configure/lock.aarch64-darwin.json new file mode 100644 index 0000000000..1f54f97b6e --- /dev/null +++ b/tools/configure/lock.aarch64-darwin.json @@ -0,0 +1,364 @@ +{ + "fetchPipMetadata": { + "sources": { + "ahocorasick-rs": { + "is_direct": false, + "sha256": "b5d404ceec819d983297816917fec12cca61f6ce825496adec1f701fa14ba0c8", + "type": "url", + "url": "https://files.pythonhosted.org/packages/9c/ac/0ce34ae2b35aaf73153e1f5874dd47c9bacd9121638d07b292e897fbedc1/ahocorasick_rs-0.22.2-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", + "version": "0.22.2" + }, + "ansiwrap": { + "is_direct": false, + "sha256": "7b053567c88e1ad9eed030d3ac41b722125e4c1271c8a99ade797faff1f49fb1", + "type": "url", + "url": "https://files.pythonhosted.org/packages/03/50/43e775a63e0d632d9be3b3fa1c9b2cbaf3b7870d203655710a3426f47c26/ansiwrap-0.8.4-py2.py3-none-any.whl", + "version": "0.8.4" + }, + "certifi": { + "is_direct": false, + "sha256": "f6c12493cfb1b06ba2ff328595af9350c65d6644968e5d3a2ffd78699af217a5", + "type": "url", + "url": "https://files.pythonhosted.org/packages/e5/48/1549795ba7742c948d2ad169c1c8cdbae65bc450d6cd753d124b17c8cd32/certifi-2025.8.3-py3-none-any.whl", + "version": "2025.8.3" + }, + "charset-normalizer": { + "is_direct": false, + "sha256": "e28e334d3ff134e88989d90ba04b47d84382a828c061d0d1027b1b12a62b39b1", + "type": "url", + "url": "https://files.pythonhosted.org/packages/e9/5e/14c94999e418d9b87682734589404a25854d5f5d0408df68bc15b6ff54bb/charset_normalizer-3.4.3-cp312-cp312-macosx_10_13_universal2.whl", + "version": "3.4.3" + }, + "colorama": { + "is_direct": false, + "sha256": "4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", + "type": "url", + "url": "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", + "version": "0.4.6" + }, + "colour": { + "is_direct": false, + "sha256": "33f6db9d564fadc16e59921a56999b79571160ce09916303d35346dddc17978c", + "type": "url", + "url": "https://files.pythonhosted.org/packages/74/46/e81907704ab203206769dee1385dc77e1407576ff8f50a0681d0a6b541be/colour-0.1.5-py2.py3-none-any.whl", + "version": "0.1.5" + }, + "configparser": { + "is_direct": false, + "sha256": "fee5e1f3db4156dcd0ed95bc4edfa3580475537711f67a819c966b389d09ce62", + "type": "url", + "url": "https://files.pythonhosted.org/packages/09/fe/f61e7129e9e689d9e40bbf8a36fb90f04eceb477f4617c02c6a18463e81f/configparser-7.2.0-py3-none-any.whl", + "version": "7.2.0" + }, + "crunch64": { + "is_direct": false, + "sha256": "030e46fbf3a575bee46a5334726cd94a4bd7a701c04310bd9a2d9966c016fe07", + "type": "url", + "url": "https://files.pythonhosted.org/packages/63/cc/408d5cbd71bb4caf3df9038e5721d04f6249b5e91cc64a7e6151ae699d89/crunch64-0.5.3-cp312-cp312-macosx_11_0_arm64.whl", + "version": "0.5.3" + }, + "cxxfilt": { + "is_direct": false, + "sha256": "774e85a8d0157775ed43276d89397d924b104135762d86b3a95f81f203094e07", + "type": "url", + "url": "https://files.pythonhosted.org/packages/1c/29/23572dc59bf4a3984fe3c5fc242f73be916785ee93387dd95c972dbf584e/cxxfilt-0.3.0-py2.py3-none-any.whl", + "version": "0.3.0" + }, + "gitdb": { + "is_direct": false, + "sha256": "67073e15955400952c6565cc3e707c554a4eea2e428946f7a4c162fab9bd9bcf", + "type": "url", + "url": "https://files.pythonhosted.org/packages/a0/61/5c78b91c3143ed5c14207f463aecfc8f9dbb5092fb2869baf37c273b2705/gitdb-4.0.12-py3-none-any.whl", + "version": "4.0.12" + }, + "gitpython": { + "is_direct": false, + "sha256": "8908cb2e02fb3b93b7eb0f2827125cb699869470432cc885f019b8fd0fccff77", + "type": "url", + "url": "https://files.pythonhosted.org/packages/01/61/d4b89fec821f72385526e1b9d9a3a0385dda4a72b206d28049e2c7cd39b8/gitpython-3.1.45-py3-none-any.whl", + "version": "3.1.45" + }, + "idna": { + "is_direct": false, + "sha256": "946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3", + "type": "url", + "url": "https://files.pythonhosted.org/packages/76/c6/c88e154df9c4e1a2a66ccf0005a88dfb2650c1dffb6f5ce603dfbd452ce3/idna-3.10-py3-none-any.whl", + "version": "3.10" + }, + "intervaltree": { + "is_direct": false, + "sha256": "902b1b88936918f9b2a19e0e5eb7ccb430ae45cde4f39ea4b36932920d33952d", + "type": "url", + "url": "https://files.pythonhosted.org/packages/50/fb/396d568039d21344639db96d940d40eb62befe704ef849b27949ded5c3bb/intervaltree-3.1.0.tar.gz", + "version": "3.1.0" + }, + "lark-parser": { + "is_direct": false, + "sha256": "0eaf30cb5ba787fe404d73a7d6e61df97b21d5a63ac26c5008c78a494373c675", + "type": "url", + "url": "https://files.pythonhosted.org/packages/76/00/90f05db333fe1aa6b6ffea83a35425b7d53ea95c8bba0b1597f226cf1d5f/lark_parser-0.12.0-py2.py3-none-any.whl", + "version": "0.12.0" + }, + "levenshtein": { + "is_direct": false, + "sha256": "f09cfab6387e9c908c7b37961c045e8e10eb9b7ec4a700367f8e080ee803a562", + "type": "url", + "url": "https://files.pythonhosted.org/packages/8f/5c/06c01870c0cf336f9f29397bbfbfbbfd3a59918868716e7bb15828e89367/levenshtein-0.27.1-cp312-cp312-macosx_11_0_arm64.whl", + "version": "0.27.1" + }, + "msgpack": { + "is_direct": false, + "sha256": "33be9ab121df9b6b461ff91baac6f2731f83d9b27ed948c5b9d1978ae28bf157", + "type": "url", + "url": "https://files.pythonhosted.org/packages/ab/65/7d1de38c8a22cf8b1551469159d4b6cf49be2126adc2482de50976084d78/msgpack-1.1.1-cp312-cp312-macosx_11_0_arm64.whl", + "version": "1.1.1" + }, + "n64img": { + "is_direct": false, + "sha256": "5db569e3300f3404b875a319822221704ffaf7c1d8f1db874b85702a16947921", + "type": "url", + "url": "https://files.pythonhosted.org/packages/87/6d/9480bcb7a31d6e96a0a8923c9b64812db0e480921bc988fcbfbce3ddf7a4/n64img-0.3.3-py3-none-any.whl", + "version": "0.3.3" + }, + "ninja-syntax": { + "is_direct": false, + "sha256": "342dc97b9e88a6495bae22953ee6063f91d2f03db6f727b62ba5c3092a18ef1f", + "type": "url", + "url": "https://files.pythonhosted.org/packages/4b/c3/303da27e7d72aeae5d1879d592048fcd5e8c0c333505b76dda136ab342c0/ninja_syntax-1.7.2.tar.gz", + "version": "1.7.2" + }, + "pygfxd": { + "is_direct": false, + "sha256": "48519db66955cacda210e6b880f83a6b4ac8d00403b36eb6a455399b94a12e46", + "type": "url", + "url": "https://files.pythonhosted.org/packages/8b/aa/dd2b9ed653cc3c9ff0313da5f21ea8f31cb78abbbb0dc5dbf8113c3a6fa4/pygfxd-1.0.3-cp312-cp312-macosx_11_0_arm64.whl", + "version": "1.0.3" + }, + "pylibyaml": { + "is_direct": false, + "sha256": "3b58dea061903c04689e35fab63ec149f7cf5e82f0808bd3425fb3ab3950623e", + "type": "url", + "url": "https://files.pythonhosted.org/packages/c9/1a/3ae773a0d4cc0b787d1b7307786c666de0729df2c4159ec964e8ba45d06d/pylibyaml-0.1.0.tar.gz", + "version": "0.1.0" + }, + "pypng": { + "is_direct": false, + "sha256": "4a43e969b8f5aaafb2a415536c1a8ec7e341cd6a3f957fd5b5f32a4cfeed902c", + "type": "url", + "url": "https://files.pythonhosted.org/packages/3e/b9/3766cc361d93edb2ce81e2e1f87dd98f314d7d513877a342d31b30741680/pypng-0.20220715.0-py3-none-any.whl", + "version": "0.20220715.0" + }, + "python-githooks": { + "is_direct": false, + "sha256": "4aca1f2e7e3012532b1f8505a07f9879613325b7cc64c115aff0457a8f39dba5", + "type": "url", + "url": "https://files.pythonhosted.org/packages/b7/a0/d6137ce853fc1857688aa5e53247adf26c65a9bb167801cc6f0d79534e8d/python_githooks-1.0.7-py3-none-any.whl", + "version": "1.0.7" + }, + "python-levenshtein": { + "is_direct": false, + "sha256": "e1a4bc2a70284b2ebc4c505646142fecd0f831e49aa04ed972995895aec57396", + "type": "url", + "url": "https://files.pythonhosted.org/packages/2a/95/8c8fd923b0a702388da4f9e0368f490d123cc5224279e6a083984304a15e/python_levenshtein-0.27.1-py3-none-any.whl", + "version": "0.27.1" + }, + "pyyaml": { + "is_direct": false, + "sha256": "ce826d6ef20b1bc864f0a68340c8b3287705cae2f8b4b1d932177dcc76721725", + "type": "url", + "url": "https://files.pythonhosted.org/packages/a8/0c/38374f5bb272c051e2a69281d71cba6fdb983413e6758b84482905e29a5d/PyYAML-6.0.2-cp312-cp312-macosx_11_0_arm64.whl", + "version": "6.0.2" + }, + "rabbitizer": { + "is_direct": false, + "sha256": "eea90421df2704527c268d26c9b0a0fb6e2fddb3915912fd91984b97286abd6c", + "type": "url", + "url": "https://files.pythonhosted.org/packages/78/26/4f48d71530e0204dd7fafbf1e5635aa4b42b6fdcdc77b4779270f6c301a5/rabbitizer-1.13.0-cp312-cp312-macosx_11_0_arm64.whl", + "version": "1.13.0" + }, + "rapidfuzz": { + "is_direct": false, + "sha256": "2fd0975e015b05c79a97f38883a11236f5a24cca83aa992bd2558ceaa5652b26", + "type": "url", + "url": "https://files.pythonhosted.org/packages/b7/53/1f7eb7ee83a06c400089ec7cb841cbd581c2edd7a4b21eb2f31030b88daa/rapidfuzz-3.13.0-cp312-cp312-macosx_11_0_arm64.whl", + "version": "3.13.0" + }, + "requests": { + "is_direct": false, + "sha256": "27babd3cda2a6d50b30443204ee89830707d396671944c998b5975b031ac2b2c", + "type": "url", + "url": "https://files.pythonhosted.org/packages/7c/e4/56027c4a6b4ae70ca9de302488c5ca95ad4a39e190093d6c1a8ace08341b/requests-2.32.4-py3-none-any.whl", + "version": "2.32.4" + }, + "setuptools": { + "is_direct": false, + "sha256": "062d34222ad13e0cc312a4c02d73f059e86a4acbfbdea8f8f76b28c99f306922", + "type": "url", + "url": "https://files.pythonhosted.org/packages/a3/dc/17031897dae0efacfea57dfd3a82fdd2a2aeb58e0ff71b77b87e44edc772/setuptools-80.9.0-py3-none-any.whl", + "version": "80.9.0" + }, + "smmap": { + "is_direct": false, + "sha256": "b30115f0def7d7531d22a0fb6502488d879e75b260a9db4d0819cfb25403af5e", + "type": "url", + "url": "https://files.pythonhosted.org/packages/04/be/d09147ad1ec7934636ad912901c5fd7667e1c858e19d355237db0d0cd5e4/smmap-5.0.2-py3-none-any.whl", + "version": "5.0.2" + }, + "sortedcontainers": { + "is_direct": false, + "sha256": "a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0", + "type": "url", + "url": "https://files.pythonhosted.org/packages/32/46/9cb0e58b2deb7f82b84065f37f3bffeb12413f947f9388e4cac22c4621ce/sortedcontainers-2.4.0-py2.py3-none-any.whl", + "version": "2.4.0" + }, + "spimdisasm": { + "is_direct": false, + "sha256": "0938ef4af6fd2209e9e1f761655fbb80f79587c37701d6222789ec9af8d04cf9", + "type": "url", + "url": "https://files.pythonhosted.org/packages/90/ef/bb8a0ae2dec4f499b50cea0edda8a8428b0541340a22312155fdd084ba12/spimdisasm-1.31.0-py3-none-any.whl", + "version": "1.31.0" + }, + "splat64": { + "is_direct": false, + "sha256": "8f440384f77de8b893980ca5d1303d3bbf1c6aae725af3c3c1f853cfdf0aa1ac", + "type": "url", + "url": "https://files.pythonhosted.org/packages/16/7e/d7069c5c4186c2244987dc1225cd6214644688278785e9875528b5897242/splat64-0.31.0-py3-none-any.whl", + "version": "0.31.0" + }, + "stringcase": { + "is_direct": false, + "sha256": "48a06980661908efe8d9d34eab2b6c13aefa2163b3ced26972902e3bdfd87008", + "type": "url", + "url": "https://files.pythonhosted.org/packages/f3/1f/1241aa3d66e8dc1612427b17885f5fcd9c9ee3079fc0d28e9a3aeeb36fa3/stringcase-1.2.0.tar.gz", + "version": "1.2.0" + }, + "textwrap3": { + "is_direct": false, + "sha256": "bf5f4c40faf2a9ff00a9e0791fed5da7415481054cef45bb4a3cfb1f69044ae0", + "type": "url", + "url": "https://files.pythonhosted.org/packages/77/9c/a53e561d496ee5866bbeea4d3a850b3b545ed854f8a21007c1e0d872e94d/textwrap3-0.9.2-py2.py3-none-any.whl", + "version": "0.9.2" + }, + "tqdm": { + "is_direct": false, + "sha256": "26445eca388f82e72884e0d580d5464cd801a3ea01e63e5601bdff9ba6a48de2", + "type": "url", + "url": "https://files.pythonhosted.org/packages/d0/30/dc54f88dd4a2b5dc8a0279bdd7270e735851848b762aeb1c1184ed1f6b14/tqdm-4.67.1-py3-none-any.whl", + "version": "4.67.1" + }, + "types-colorama": { + "is_direct": false, + "sha256": "b6e89bd3b250fdad13a8b6a465c933f4a5afe485ea2e2f104d739be50b13eea9", + "type": "url", + "url": "https://files.pythonhosted.org/packages/95/3a/44ccbbfef6235aeea84c74041dc6dfee6c17ff3ddba782a0250e41687ec7/types_colorama-0.4.15.20250801-py3-none-any.whl", + "version": "0.4.15.20250801" + }, + "types-requests": { + "is_direct": false, + "sha256": "f73d1832fb519ece02c85b1f09d5f0dd3108938e7d47e7f94bbfa18a6782b163", + "type": "url", + "url": "https://files.pythonhosted.org/packages/2b/6f/ec0012be842b1d888d46884ac5558fd62aeae1f0ec4f7a581433d890d4b5/types_requests-2.32.4.20250809-py3-none-any.whl", + "version": "2.32.4.20250809" + }, + "types-tqdm": { + "is_direct": false, + "sha256": "1a73053b31fcabf3c1f3e2a9d5ecdba0f301bde47a418cd0e0bdf774827c5c57", + "type": "url", + "url": "https://files.pythonhosted.org/packages/3f/13/3ff0781445d7c12730befce0fddbbc7a76e56eb0e7029446f2853238360a/types_tqdm-4.67.0.20250809-py3-none-any.whl", + "version": "4.67.0.20250809" + }, + "urllib3": { + "is_direct": false, + "sha256": "e6b01673c0fa6a13e374b50871808eb3bf7046c4b125b216f6bf1cc604cff0dc", + "type": "url", + "url": "https://files.pythonhosted.org/packages/a7/c2/fe1e52489ae3122415c51f387e221dd0773709bad6c6cdaa599e8a2c5185/urllib3-2.5.0-py3-none-any.whl", + "version": "2.5.0" + }, + "watchdog": { + "is_direct": false, + "sha256": "6f10cb2d5902447c7d0da897e2c6768bca89174d0c6e1e30abec5421af97a5b0", + "type": "url", + "url": "https://files.pythonhosted.org/packages/5b/7e/8f322f5e600812e6f9a31b75d242631068ca8f4ef0582dd3ae6e72daecc8/watchdog-6.0.0-cp312-cp312-macosx_11_0_arm64.whl", + "version": "6.0.0" + } + }, + "targets": { + "default": { + "ahocorasick-rs": [], + "ansiwrap": [ + "textwrap3" + ], + "certifi": [], + "charset-normalizer": [], + "colorama": [], + "colour": [], + "configparser": [], + "crunch64": [], + "cxxfilt": [], + "gitdb": [ + "smmap" + ], + "gitpython": [ + "gitdb" + ], + "idna": [], + "intervaltree": [ + "sortedcontainers" + ], + "lark-parser": [], + "levenshtein": [ + "rapidfuzz" + ], + "msgpack": [], + "n64img": [ + "pypng" + ], + "ninja-syntax": [], + "pygfxd": [], + "pylibyaml": [], + "pypng": [], + "python-githooks": [ + "configparser" + ], + "python-levenshtein": [ + "levenshtein" + ], + "pyyaml": [], + "rabbitizer": [], + "rapidfuzz": [], + "requests": [ + "certifi", + "charset-normalizer", + "idna", + "urllib3" + ], + "setuptools": [], + "smmap": [], + "sortedcontainers": [], + "spimdisasm": [ + "rabbitizer" + ], + "splat64": [ + "colorama", + "intervaltree", + "pylibyaml", + "pyyaml", + "tqdm" + ], + "stringcase": [], + "textwrap3": [], + "tqdm": [], + "types-colorama": [], + "types-requests": [ + "urllib3" + ], + "types-tqdm": [ + "types-requests" + ], + "urllib3": [], + "watchdog": [] + } + } + }, + "invalidationHash": "64b2e949b96ae6f0b1a0245244152c9ed4922c690b2b0e4b6c3fc2279231d855" +} \ No newline at end of file diff --git a/tools/configure/lock.x86_64-linux.json b/tools/configure/lock.x86_64-linux.json new file mode 100644 index 0000000000..b440b99460 --- /dev/null +++ b/tools/configure/lock.x86_64-linux.json @@ -0,0 +1,364 @@ +{ + "fetchPipMetadata": { + "sources": { + "ahocorasick-rs": { + "is_direct": false, + "sha256": "4bfff7aabcbd67dde053dc32c537ff69cd208caf5eabec514bc423693e46d54f", + "type": "url", + "url": "https://files.pythonhosted.org/packages/85/2f/4024ac92a3bf817e5b877d68e01cba1398541de4d9a42b3441598fa93939/ahocorasick_rs-0.22.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "version": "0.22.2" + }, + "ansiwrap": { + "is_direct": false, + "sha256": "7b053567c88e1ad9eed030d3ac41b722125e4c1271c8a99ade797faff1f49fb1", + "type": "url", + "url": "https://files.pythonhosted.org/packages/03/50/43e775a63e0d632d9be3b3fa1c9b2cbaf3b7870d203655710a3426f47c26/ansiwrap-0.8.4-py2.py3-none-any.whl", + "version": "0.8.4" + }, + "certifi": { + "is_direct": false, + "sha256": "6b31f564a415d79ee77df69d757bb49a5bb53bd9f756cbbe24394ffd6fc1f4b2", + "type": "url", + "url": "https://files.pythonhosted.org/packages/4f/52/34c6cf5bb9285074dc3531c437b3919e825d976fde097a7a73f79e726d03/certifi-2025.7.14-py3-none-any.whl", + "version": "2025.7.14" + }, + "charset-normalizer": { + "is_direct": false, + "sha256": "4e594135de17ab3866138f496755f302b72157d115086d100c3f19370839dd3a", + "type": "url", + "url": "https://files.pythonhosted.org/packages/8c/73/6ede2ec59bce19b3edf4209d70004253ec5f4e319f9a2e3f2f15601ed5f7/charset_normalizer-3.4.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "version": "3.4.2" + }, + "colorama": { + "is_direct": false, + "sha256": "4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", + "type": "url", + "url": "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", + "version": "0.4.6" + }, + "colour": { + "is_direct": false, + "sha256": "33f6db9d564fadc16e59921a56999b79571160ce09916303d35346dddc17978c", + "type": "url", + "url": "https://files.pythonhosted.org/packages/74/46/e81907704ab203206769dee1385dc77e1407576ff8f50a0681d0a6b541be/colour-0.1.5-py2.py3-none-any.whl", + "version": "0.1.5" + }, + "configparser": { + "is_direct": false, + "sha256": "fee5e1f3db4156dcd0ed95bc4edfa3580475537711f67a819c966b389d09ce62", + "type": "url", + "url": "https://files.pythonhosted.org/packages/09/fe/f61e7129e9e689d9e40bbf8a36fb90f04eceb477f4617c02c6a18463e81f/configparser-7.2.0-py3-none-any.whl", + "version": "7.2.0" + }, + "crunch64": { + "is_direct": false, + "sha256": "f390208ba9a736d6fb5f9d80e33ab51d623981e53f05f28ffa5045ed30bf460f", + "type": "url", + "url": "https://files.pythonhosted.org/packages/46/4f/f4ea1b605ed4c42ed93a1cf0e08d7b8f49c30ec3beba5c824afb1aad71c7/crunch64-0.5.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "version": "0.5.3" + }, + "cxxfilt": { + "is_direct": false, + "sha256": "774e85a8d0157775ed43276d89397d924b104135762d86b3a95f81f203094e07", + "type": "url", + "url": "https://files.pythonhosted.org/packages/1c/29/23572dc59bf4a3984fe3c5fc242f73be916785ee93387dd95c972dbf584e/cxxfilt-0.3.0-py2.py3-none-any.whl", + "version": "0.3.0" + }, + "gitdb": { + "is_direct": false, + "sha256": "67073e15955400952c6565cc3e707c554a4eea2e428946f7a4c162fab9bd9bcf", + "type": "url", + "url": "https://files.pythonhosted.org/packages/a0/61/5c78b91c3143ed5c14207f463aecfc8f9dbb5092fb2869baf37c273b2705/gitdb-4.0.12-py3-none-any.whl", + "version": "4.0.12" + }, + "gitpython": { + "is_direct": false, + "sha256": "8908cb2e02fb3b93b7eb0f2827125cb699869470432cc885f019b8fd0fccff77", + "type": "url", + "url": "https://files.pythonhosted.org/packages/01/61/d4b89fec821f72385526e1b9d9a3a0385dda4a72b206d28049e2c7cd39b8/gitpython-3.1.45-py3-none-any.whl", + "version": "3.1.45" + }, + "idna": { + "is_direct": false, + "sha256": "946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3", + "type": "url", + "url": "https://files.pythonhosted.org/packages/76/c6/c88e154df9c4e1a2a66ccf0005a88dfb2650c1dffb6f5ce603dfbd452ce3/idna-3.10-py3-none-any.whl", + "version": "3.10" + }, + "intervaltree": { + "is_direct": false, + "sha256": "902b1b88936918f9b2a19e0e5eb7ccb430ae45cde4f39ea4b36932920d33952d", + "type": "url", + "url": "https://files.pythonhosted.org/packages/50/fb/396d568039d21344639db96d940d40eb62befe704ef849b27949ded5c3bb/intervaltree-3.1.0.tar.gz", + "version": "3.1.0" + }, + "lark-parser": { + "is_direct": false, + "sha256": "0eaf30cb5ba787fe404d73a7d6e61df97b21d5a63ac26c5008c78a494373c675", + "type": "url", + "url": "https://files.pythonhosted.org/packages/76/00/90f05db333fe1aa6b6ffea83a35425b7d53ea95c8bba0b1597f226cf1d5f/lark_parser-0.12.0-py2.py3-none-any.whl", + "version": "0.12.0" + }, + "levenshtein": { + "is_direct": false, + "sha256": "712f562c5e64dd0398d3570fe99f8fbb88acec7cc431f101cb66c9d22d74c542", + "type": "url", + "url": "https://files.pythonhosted.org/packages/17/8c/8352e992063952b38fb61d49bad8d193a4a713e7eeceb3ae74b719d7863d/levenshtein-0.27.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "version": "0.27.1" + }, + "msgpack": { + "is_direct": false, + "sha256": "a494554874691720ba5891c9b0b39474ba43ffb1aaf32a5dac874effb1619e1a", + "type": "url", + "url": "https://files.pythonhosted.org/packages/4d/ec/fd869e2567cc9c01278a736cfd1697941ba0d4b81a43e0aa2e8d71dab208/msgpack-1.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "version": "1.1.1" + }, + "n64img": { + "is_direct": false, + "sha256": "5db569e3300f3404b875a319822221704ffaf7c1d8f1db874b85702a16947921", + "type": "url", + "url": "https://files.pythonhosted.org/packages/87/6d/9480bcb7a31d6e96a0a8923c9b64812db0e480921bc988fcbfbce3ddf7a4/n64img-0.3.3-py3-none-any.whl", + "version": "0.3.3" + }, + "ninja-syntax": { + "is_direct": false, + "sha256": "342dc97b9e88a6495bae22953ee6063f91d2f03db6f727b62ba5c3092a18ef1f", + "type": "url", + "url": "https://files.pythonhosted.org/packages/4b/c3/303da27e7d72aeae5d1879d592048fcd5e8c0c333505b76dda136ab342c0/ninja_syntax-1.7.2.tar.gz", + "version": "1.7.2" + }, + "pygfxd": { + "is_direct": false, + "sha256": "16a3c3e1e04c6efd4134862e18f72ef8ff85c17e942b42023794284698e20b36", + "type": "url", + "url": "https://files.pythonhosted.org/packages/fb/4b/eb254ed1dc06dd19438cc6dc1284d6367ebaeefff9cdd838a191dd7d16e2/pygfxd-1.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "version": "1.0.3" + }, + "pylibyaml": { + "is_direct": false, + "sha256": "3b58dea061903c04689e35fab63ec149f7cf5e82f0808bd3425fb3ab3950623e", + "type": "url", + "url": "https://files.pythonhosted.org/packages/c9/1a/3ae773a0d4cc0b787d1b7307786c666de0729df2c4159ec964e8ba45d06d/pylibyaml-0.1.0.tar.gz", + "version": "0.1.0" + }, + "pypng": { + "is_direct": false, + "sha256": "4a43e969b8f5aaafb2a415536c1a8ec7e341cd6a3f957fd5b5f32a4cfeed902c", + "type": "url", + "url": "https://files.pythonhosted.org/packages/3e/b9/3766cc361d93edb2ce81e2e1f87dd98f314d7d513877a342d31b30741680/pypng-0.20220715.0-py3-none-any.whl", + "version": "0.20220715.0" + }, + "python-githooks": { + "is_direct": false, + "sha256": "4aca1f2e7e3012532b1f8505a07f9879613325b7cc64c115aff0457a8f39dba5", + "type": "url", + "url": "https://files.pythonhosted.org/packages/b7/a0/d6137ce853fc1857688aa5e53247adf26c65a9bb167801cc6f0d79534e8d/python_githooks-1.0.7-py3-none-any.whl", + "version": "1.0.7" + }, + "python-levenshtein": { + "is_direct": false, + "sha256": "e1a4bc2a70284b2ebc4c505646142fecd0f831e49aa04ed972995895aec57396", + "type": "url", + "url": "https://files.pythonhosted.org/packages/2a/95/8c8fd923b0a702388da4f9e0368f490d123cc5224279e6a083984304a15e/python_levenshtein-0.27.1-py3-none-any.whl", + "version": "0.27.1" + }, + "pyyaml": { + "is_direct": false, + "sha256": "80bab7bfc629882493af4aa31a4cfa43a4c57c83813253626916b8c7ada83476", + "type": "url", + "url": "https://files.pythonhosted.org/packages/b9/2b/614b4752f2e127db5cc206abc23a8c19678e92b23c3db30fc86ab731d3bd/PyYAML-6.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "version": "6.0.2" + }, + "rabbitizer": { + "is_direct": false, + "sha256": "2bdf0134b03e70d2548d8349ccdcfdb0d1a91ff5fe3a164448ac3fdac5eeefbf", + "type": "url", + "url": "https://files.pythonhosted.org/packages/34/0e/16f00b5431559ef9028762221612d9a7c320bd312a1eea6add55eddcd345/rabbitizer-1.13.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "version": "1.13.0" + }, + "rapidfuzz": { + "is_direct": false, + "sha256": "2d18228a2390375cf45726ce1af9d36ff3dc1f11dce9775eae1f1b13ac6ec50f", + "type": "url", + "url": "https://files.pythonhosted.org/packages/4e/20/e62b4d13ba851b0f36370060025de50a264d625f6b4c32899085ed51f980/rapidfuzz-3.13.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "version": "3.13.0" + }, + "requests": { + "is_direct": false, + "sha256": "27babd3cda2a6d50b30443204ee89830707d396671944c998b5975b031ac2b2c", + "type": "url", + "url": "https://files.pythonhosted.org/packages/7c/e4/56027c4a6b4ae70ca9de302488c5ca95ad4a39e190093d6c1a8ace08341b/requests-2.32.4-py3-none-any.whl", + "version": "2.32.4" + }, + "setuptools": { + "is_direct": false, + "sha256": "062d34222ad13e0cc312a4c02d73f059e86a4acbfbdea8f8f76b28c99f306922", + "type": "url", + "url": "https://files.pythonhosted.org/packages/a3/dc/17031897dae0efacfea57dfd3a82fdd2a2aeb58e0ff71b77b87e44edc772/setuptools-80.9.0-py3-none-any.whl", + "version": "80.9.0" + }, + "smmap": { + "is_direct": false, + "sha256": "b30115f0def7d7531d22a0fb6502488d879e75b260a9db4d0819cfb25403af5e", + "type": "url", + "url": "https://files.pythonhosted.org/packages/04/be/d09147ad1ec7934636ad912901c5fd7667e1c858e19d355237db0d0cd5e4/smmap-5.0.2-py3-none-any.whl", + "version": "5.0.2" + }, + "sortedcontainers": { + "is_direct": false, + "sha256": "a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0", + "type": "url", + "url": "https://files.pythonhosted.org/packages/32/46/9cb0e58b2deb7f82b84065f37f3bffeb12413f947f9388e4cac22c4621ce/sortedcontainers-2.4.0-py2.py3-none-any.whl", + "version": "2.4.0" + }, + "spimdisasm": { + "is_direct": false, + "sha256": "0938ef4af6fd2209e9e1f761655fbb80f79587c37701d6222789ec9af8d04cf9", + "type": "url", + "url": "https://files.pythonhosted.org/packages/90/ef/bb8a0ae2dec4f499b50cea0edda8a8428b0541340a22312155fdd084ba12/spimdisasm-1.31.0-py3-none-any.whl", + "version": "1.31.0" + }, + "splat64": { + "is_direct": false, + "sha256": "8f440384f77de8b893980ca5d1303d3bbf1c6aae725af3c3c1f853cfdf0aa1ac", + "type": "url", + "url": "https://files.pythonhosted.org/packages/16/7e/d7069c5c4186c2244987dc1225cd6214644688278785e9875528b5897242/splat64-0.31.0-py3-none-any.whl", + "version": "0.31.0" + }, + "stringcase": { + "is_direct": false, + "sha256": "48a06980661908efe8d9d34eab2b6c13aefa2163b3ced26972902e3bdfd87008", + "type": "url", + "url": "https://files.pythonhosted.org/packages/f3/1f/1241aa3d66e8dc1612427b17885f5fcd9c9ee3079fc0d28e9a3aeeb36fa3/stringcase-1.2.0.tar.gz", + "version": "1.2.0" + }, + "textwrap3": { + "is_direct": false, + "sha256": "bf5f4c40faf2a9ff00a9e0791fed5da7415481054cef45bb4a3cfb1f69044ae0", + "type": "url", + "url": "https://files.pythonhosted.org/packages/77/9c/a53e561d496ee5866bbeea4d3a850b3b545ed854f8a21007c1e0d872e94d/textwrap3-0.9.2-py2.py3-none-any.whl", + "version": "0.9.2" + }, + "tqdm": { + "is_direct": false, + "sha256": "26445eca388f82e72884e0d580d5464cd801a3ea01e63e5601bdff9ba6a48de2", + "type": "url", + "url": "https://files.pythonhosted.org/packages/d0/30/dc54f88dd4a2b5dc8a0279bdd7270e735851848b762aeb1c1184ed1f6b14/tqdm-4.67.1-py3-none-any.whl", + "version": "4.67.1" + }, + "types-colorama": { + "is_direct": false, + "sha256": "6391de60ddc0db3f147e31ecb230006a6823e81e380862ffca1e4695c13a0b8e", + "type": "url", + "url": "https://files.pythonhosted.org/packages/b7/83/6944b4fa01efb2e63ac62b791a8ddf0fee358f93be9f64b8f152648ad9d3/types_colorama-0.4.15.20240311-py3-none-any.whl", + "version": "0.4.15.20240311" + }, + "types-requests": { + "is_direct": false, + "sha256": "ad2fe5d3b0cb3c2c902c8815a70e7fb2302c4b8c1f77bdcd738192cdb3878072", + "type": "url", + "url": "https://files.pythonhosted.org/packages/3d/ea/0be9258c5a4fa1ba2300111aa5a0767ee6d18eb3fd20e91616c12082284d/types_requests-2.32.4.20250611-py3-none-any.whl", + "version": "2.32.4.20250611" + }, + "types-tqdm": { + "is_direct": false, + "sha256": "1dd9b2c65273f2342f37e5179bc6982df86b6669b3376efc12aef0a29e35d36d", + "type": "url", + "url": "https://files.pythonhosted.org/packages/3b/92/df621429f098fc573a63a8ba348e731c3051b397df0cff278f8887f28d24/types_tqdm-4.67.0.20250516-py3-none-any.whl", + "version": "4.67.0.20250516" + }, + "urllib3": { + "is_direct": false, + "sha256": "e6b01673c0fa6a13e374b50871808eb3bf7046c4b125b216f6bf1cc604cff0dc", + "type": "url", + "url": "https://files.pythonhosted.org/packages/a7/c2/fe1e52489ae3122415c51f387e221dd0773709bad6c6cdaa599e8a2c5185/urllib3-2.5.0-py3-none-any.whl", + "version": "2.5.0" + }, + "watchdog": { + "is_direct": false, + "sha256": "20ffe5b202af80ab4266dcd3e91aae72bf2da48c0d33bdb15c66658e685e94e2", + "type": "url", + "url": "https://files.pythonhosted.org/packages/b5/e8/dbf020b4d98251a9860752a094d09a65e1b436ad181faf929983f697048f/watchdog-6.0.0-py3-none-manylinux2014_x86_64.whl", + "version": "6.0.0" + } + }, + "targets": { + "default": { + "ahocorasick-rs": [], + "ansiwrap": [ + "textwrap3" + ], + "certifi": [], + "charset-normalizer": [], + "colorama": [], + "colour": [], + "configparser": [], + "crunch64": [], + "cxxfilt": [], + "gitdb": [ + "smmap" + ], + "gitpython": [ + "gitdb" + ], + "idna": [], + "intervaltree": [ + "sortedcontainers" + ], + "lark-parser": [], + "levenshtein": [ + "rapidfuzz" + ], + "msgpack": [], + "n64img": [ + "pypng" + ], + "ninja-syntax": [], + "pygfxd": [], + "pylibyaml": [], + "pypng": [], + "python-githooks": [ + "configparser" + ], + "python-levenshtein": [ + "levenshtein" + ], + "pyyaml": [], + "rabbitizer": [], + "rapidfuzz": [], + "requests": [ + "certifi", + "charset-normalizer", + "idna", + "urllib3" + ], + "setuptools": [], + "smmap": [], + "sortedcontainers": [], + "spimdisasm": [ + "rabbitizer" + ], + "splat64": [ + "colorama", + "intervaltree", + "pylibyaml", + "pyyaml", + "tqdm" + ], + "stringcase": [], + "textwrap3": [], + "tqdm": [], + "types-colorama": [], + "types-requests": [ + "urllib3" + ], + "types-tqdm": [ + "types-requests" + ], + "urllib3": [], + "watchdog": [] + } + } + }, + "invalidationHash": "64b2e949b96ae6f0b1a0245244152c9ed4922c690b2b0e4b6c3fc2279231d855" +} \ No newline at end of file diff --git a/tools/configure/pyproject.toml b/tools/configure/pyproject.toml new file mode 100644 index 0000000000..428c292001 --- /dev/null +++ b/tools/configure/pyproject.toml @@ -0,0 +1,10 @@ +[build-system] +requires = [ "setuptools" ] +build-backend = "setuptools.build_meta" + +[project] +name = "configure" +version = "0.1.0" + +[project.scripts] +configure = "configure.main:main" diff --git a/requirements.txt b/tools/configure/requirements.txt similarity index 94% rename from requirements.txt rename to tools/configure/requirements.txt index d6e02b08e9..cfdf338d76 100644 --- a/requirements.txt +++ b/tools/configure/requirements.txt @@ -1,3 +1,4 @@ +setuptools PyYAML lark-parser pypng diff --git a/requirements_extra.txt b/tools/configure/requirements_extra.txt similarity index 100% rename from requirements_extra.txt rename to tools/configure/requirements_extra.txt diff --git a/tools/build/configure.py b/tools/configure/src/configure/main.py similarity index 97% rename from tools/build/configure.py rename to tools/configure/src/configure/main.py index f08886c05d..b652a180c2 100755 --- a/tools/build/configure.py +++ b/tools/configure/src/configure/main.py @@ -15,11 +15,8 @@ VERSIONS = ["us", "jp", "ique", "pal"] DO_SHA1_CHECK = True # Paths: -ROOT = Path(__file__).parent.parent.parent -if ROOT.is_absolute(): - ROOT = ROOT.relative_to(Path.cwd()) - -BUILD_TOOLS = Path("tools/build") +ROOT = Path.cwd() +BUILD_TOOLS = ROOT / "tools/build" CRC_TOOL = f"{BUILD_TOOLS}/rom/n64crc" PIGMENT64 = "pigment64" @@ -88,7 +85,7 @@ def write_ninja_rules( cflags_egcs = f"-c -fno-PIC -mno-abicalls -mcpu=4300 -G 0 -x c -B {cc_egcs_dir} {extra_cflags}" - ninja.variable("python", sys.executable) + ninja.variable("python", "python3") ld_args = f"-T ver/$version/build/undefined_syms.txt -T ver/$version/undefined_syms_auto.txt -T ver/$version/undefined_funcs_auto.txt -Map $mapfile --no-check-sections -T $in -o $out" ld = f"{cross}ld" if not "PAPERMARIO_LD" in os.environ else os.environ["PAPERMARIO_LD"] @@ -368,7 +365,7 @@ def does_iconv_work() -> bool: sub = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, input=stdin, cwd=ROOT) return sub.stdout - expected_stdout = run(["tools/build/iconv.py", "UTF-8", "CP932"], stdin) + expected_stdout = run(["python3", str(BUILD_TOOLS / "iconv.py"), "UTF-8", "CP932"], stdin) actual_stdout = run(["iconv", "--from", "UTF-8", "--to", "CP932"], stdin) return expected_stdout == actual_stdout @@ -534,7 +531,11 @@ class Configure: built_objects.add(str(object_path)) elif object_path.suffix.endswith(".h") or object_path.suffix.endswith(".c"): generated_code.append(str(object_path)) - elif object_path.name.endswith(".png.bin") or object_path.name.endswith(".pal.bin"): + elif ( + object_path.name.endswith(".png.bin") + or object_path.name.endswith(".pal.bin") + or object_path.name.endswith(".dat") + ): inc_img_bins.append(str(object_path)) # don't rebuild objects if we've already seen all of them @@ -570,7 +571,7 @@ class Configure: # Effect data includes effect_yaml = ROOT / "src/effects.yaml" - effect_data_outdir = ROOT / "assets" / version / "effects" + effect_data_outdir = ROOT / "assets" / self.version / "effects" effect_macros_path = effect_data_outdir / "effect_macros.h" effect_defs_path = effect_data_outdir / "effect_defs.h" effect_table_path = effect_data_outdir / "effect_table.c" @@ -614,7 +615,7 @@ class Configure: ) item_table_data = Path("src/item_table.yaml") - if version == "pal": + if self.version == "pal": item_table_data = Path("src/item_table_pal.yaml") build( @@ -669,7 +670,7 @@ class Configure: elif isinstance(seg, splat.segtypes.common.hasm.CommonSegHasm): cppflags = f"-DVERSION_{self.version.upper()}" - if version == "ique" and seg.name.startswith("os/"): + if self.version == "ique" and seg.name.startswith("os/"): cppflags += " -DBBPLAYER" build(entry.object_path, entry.src_paths, "as", variables={"cppflags": cppflags}) @@ -706,9 +707,6 @@ class Configure: if entry.src_paths[0].suffixes[-1] == ".cpp": task = "cxx" - if modern_gcc: - task = "cc_modern" - if seg.name.endswith("osFlash"): task = "cc_ido" elif "gcc_272" in cflags: @@ -724,10 +722,13 @@ class Configure: task = "cc_modern" cflags = cflags.replace("gcc_modern", "") + if modern_gcc: + task = "cc_modern" + if task == "cc_modern": cppflags += " -DMODERN_COMPILER" - if version == "ique": + if self.version == "ique": if "nusys" in entry.src_paths[0].parts: pass elif "os" in entry.src_paths[0].parts: @@ -736,17 +737,17 @@ class Configure: cppflags += " -DBBPLAYER" encoding = "CP932" # similar to SHIFT-JIS, but includes backslash and tilde - if version == "ique": + if self.version == "ique": encoding = "EUC-JP" if use_python_iconv: - iconv = f"tools/build/iconv.py UTF-8 {encoding}" + iconv = f"$python tools/build/iconv.py UTF-8 {encoding}" else: iconv = f"iconv --from UTF-8 --to {encoding}" # use tools/sjis-escape.py for src/battle/area/tik2/area.c - if version != "ique" and seg.dir.parts[-3:] == ("battle", "area", "tik2") and seg.name == "area": - iconv += " | tools/sjis-escape.py" + if self.version != "ique" and seg.dir.parts[-3:] == ("battle", "area", "tik2") and seg.name == "area": + iconv += " | $python tools/sjis-escape.py" # Dead cod if isinstance(seg.parent.yaml, dict) and seg.parent.yaml.get("dead_code", False): @@ -1234,6 +1235,13 @@ class Configure: else: raise Exception(f"don't know how to build {seg.__class__.__name__} '{seg.name}'") + # Phony target for building all objects but not linking + ninja.build( + "lib_" + self.version, + "phony", + [str(obj) for obj in built_objects], + ) + # Run undefined_syms through cpp ninja.build( str(self.undefined_syms_path()), @@ -1292,7 +1300,7 @@ class Configure: ninja.build("ver/current/build/papermario.z64", "phony", str(self.rom_path())) -if __name__ == "__main__": +def main(): from argparse import ArgumentParser parser = ArgumentParser(description="Paper Mario build.ninja generator") @@ -1430,8 +1438,8 @@ if __name__ == "__main__": except OSError: pass - extra_cflags = "" - extra_cppflags = "" + extra_cflags = os.environ.get("CFLAGS", "") + extra_cppflags = os.environ.get("CPPFLAGS", "") if args.non_matching: extra_cppflags += " -DNON_MATCHING" @@ -1450,6 +1458,9 @@ if __name__ == "__main__": # add splat to python import path sys.path.insert(0, str((ROOT / args.splat / "src").resolve())) + # add tools/build to import path + sys.path.insert(0, str(BUILD_TOOLS.resolve())) + ninja = ninja_syntax.Writer(open(str(ROOT / "build.ninja"), "w"), width=9999) non_matching = args.non_matching or args.modern_gcc or args.shift @@ -1499,3 +1510,7 @@ if __name__ == "__main__": else: ninja.build("all", "phony", all_rom_oks) ninja.default("all") + + +if __name__ == "__main__": + main() diff --git a/tools/crunch64.nix b/tools/crunch64.nix new file mode 100644 index 0000000000..fb9082d5f0 --- /dev/null +++ b/tools/crunch64.nix @@ -0,0 +1,23 @@ +{ + lib, + fetchFromGitHub, + rustPlatform, + ... +}: +rustPlatform.buildRustPackage rec { + pname = "crunch64"; + version = "0.5.3"; + src = fetchFromGitHub { + owner = "decompals"; + repo = pname; + rev = version; + hash = "sha256-Kuid2u5HzHfyeDOYlh18P/DKIbNr79zdpZlgQ560N4s="; + }; + buildAndTestSubdir = "cli"; + cargoHash = "sha256-XO9nWhR1hDcx7t9ib6gHI1jSyvNbAUPzTlXQP8Ub7kw="; + meta = with lib; { + description = "Common N64 compression formats"; + homepage = "https://github.com/decompals/crunch64"; + license = licenses.mit; + }; +} diff --git a/tools/pigment64.nix b/tools/pigment64.nix new file mode 100644 index 0000000000..b3655c824b --- /dev/null +++ b/tools/pigment64.nix @@ -0,0 +1,22 @@ +{ + lib, + fetchFromGitHub, + rustPlatform, + ... +}: +rustPlatform.buildRustPackage rec { + pname = "pigment64"; + version = "0.4.5"; + src = fetchFromGitHub { + owner = "decompals"; + repo = pname; + rev = version; + hash = "sha256-AO9Gz3n/MiFyw1Q5/8rqCUKy8NToroSwvu7KBy+nQaY="; + }; + cargoHash = "sha256-mX3yVGFnI1ZQP4E1Vj5IdluWS1KjBOBQYg5RJsczHLs="; + meta = with lib; { + description = "Performant image-generating modestly entertaining new tool...64"; + homepage = "https://github.com/decompals/pigment64"; + license = licenses.mit; + }; +}