From 0de4f1502b0d122ca0c835b948462ce2e1b453ff Mon Sep 17 00:00:00 2001 From: Karim Vergnes Date: Mon, 9 Oct 2023 17:28:24 +0200 Subject: [PATCH 01/61] Use global nixpkgs to allow immutable builds --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index e444e32b01..92c36262ff 100644 --- a/default.nix +++ b/default.nix @@ -4,7 +4,7 @@ in { system ? builtins.currentSystem, nixpkgs ? sources.nixpkgs, ... }: let retroPlatforms = import nix/platforms.nix; - lib = ((import ) { }).lib; + lib = ((import nixpkgs) { }).lib; multiversal_src = if builtins.pathExists ./multiversal/make-multiverse.rb then ./multiversal From 7d2ebc7ba66e2b5be960dd8d4b24231abd265120 Mon Sep 17 00:00:00 2001 From: Karim Vergnes Date: Mon, 9 Oct 2023 17:31:35 +0200 Subject: [PATCH 02/61] Hotfix: inherit system provided in argument --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index 92c36262ff..388b79d9fa 100644 --- a/default.nix +++ b/default.nix @@ -4,7 +4,7 @@ in { system ? builtins.currentSystem, nixpkgs ? sources.nixpkgs, ... }: let retroPlatforms = import nix/platforms.nix; - lib = ((import nixpkgs) { }).lib; + lib = ((import nixpkgs) { inherit system; }).lib; multiversal_src = if builtins.pathExists ./multiversal/make-multiverse.rb then ./multiversal From 591f2620d2edee4b1c2ab587c10f76cb7a1f388b Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Sat, 16 Dec 2023 03:53:07 +0100 Subject: [PATCH 03/61] export variables from PEF (thanks to @elliotnunn) --- PEFTools/MakePEF.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/PEFTools/MakePEF.cc b/PEFTools/MakePEF.cc index 9f5d03bb53..f2ee393154 100755 --- a/PEFTools/MakePEF.cc +++ b/PEFTools/MakePEF.cc @@ -227,9 +227,9 @@ class ExportTable public: void addExport(StringTable& stringTable, const std::string& name, - uint32_t value, int16_t section) /* TODO: symbol class */ + uint32_t value, int16_t section, uint8_t clas) { - uint32_t classAndName = (kPEFTVectorSymbol << 24) | stringTable.insert(name); + uint32_t classAndName = ((uint32_t)clas << 24) | stringTable.insert(name); symbols.push_back({hash(name), {classAndName, value, section}}); } @@ -376,7 +376,9 @@ void mkpef(const std::string& inFn, const std::string& outFn) { if(verboseFlag) std::cerr << "... exported from section " << get(sym.l_scnum) << " addr " << get(sym.l_value) << ".\n"; - exports.addExport(stringTable, name, get(sym.l_value), 0 /* ### */); + exports.addExport(stringTable, name, get(sym.l_value), 1 /*all exports from section 1*/, + (get(sym.l_smclas) == 10) ? kPEFTVectorSymbol : kPEFDataSymbol); + } } importedSymbolIndices.resize(get(xcoffLoaderHeader.l_nsyms)); From a230a79ca35ea24c9553434943c09c8cd8503fe6 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Sun, 16 Oct 2022 18:31:59 +0100 Subject: [PATCH 04/61] azure-pipelines.yml: temporary disable all non-Linux builds --- azure-pipelines.yml | 110 -------------------------------------------- 1 file changed, 110 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 172434818b..3959607112 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -36,113 +36,3 @@ jobs: testResultsFiles: build/Testing/**/*.xml buildPlatform: 'x86_64-linux' -- job: macOS - pool: - vmImage: 'macOS-11' - timeoutInMinutes: 90 - steps: - - checkout: self - submodules: true - - script: | - brew install boost cmake gmp mpfr libmpc bison - displayName: 'Brew prerequisites' - - script: | - mkdir build - cd build - ../build-toolchain.bash - displayName: Build - - script: | - cd build - curl -L -O https://github.com/autc04/executor/releases/download/v0.1.0/Executor2000-0.1.0-Darwin.tar.bz2 - tar xfvj Executor2000-0.1.0-Darwin.tar.bz2 Executor2000-0.1.0-Darwin/bin/executor-headless - echo "executor-path=`pwd`/Executor2000-0.1.0-Darwin/bin/executor-headless" > ~/.LaunchAPPL.cfg - echo "emulator=executor" >> ~/.LaunchAPPL.cfg - ctest --no-compress-output -T test -E Carbon || true - displayName: Run Tests using Executor 2000 - - task: PublishTestResults@2 - inputs: - testResultsFormat: 'CTest' - testResultsFiles: build/Testing/**/*.xml - buildPlatform: 'x86_64-macos' - -- job: NixLinux - strategy: - matrix: - M68K: - TARGET: m68k - PowerPC: - TARGET: powerpc - Carbon: - TARGET: carbon - maxParallel: 2 - pool: - vmImage: 'ubuntu-20.04' - steps: - - checkout: self - submodules: true - - script: | - docker run -i --name nix -v`pwd`:/src nixos/nix:2.18.1 < Date: Mon, 17 Oct 2022 14:29:05 +0100 Subject: [PATCH 05/61] Dockerfile: bring build up to date with that in azure-pipelines.yml Update Dockerfile to use Ubuntu 20.04 and the updated package list from azure-pipelines.yml. Also explicitly include the g++ package into the container without which configure will error out with a 'configure: error: C++ preprocessor "/lib/cpp" fails sanity check' error. --- Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index f69d67c15b..2acc1e6e0b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,12 @@ # vim:ft=dockerfile -FROM ubuntu:18.04 +FROM ubuntu:20.04 -RUN apt-get update && apt-get -y install \ - g++ \ - cmake libgmp-dev libmpfr-dev libmpc-dev libboost-all-dev bison \ - zlib1g-dev \ - perl texinfo +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + cmake libgmp-dev libmpfr-dev libmpc-dev \ + libboost-all-dev bison texinfo \ + ruby flex curl g++ ADD . /Retro68 From bde1485a9edaafed72d70b21c6ab997561f39bae Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Mon, 17 Oct 2022 21:08:12 +0100 Subject: [PATCH 06/61] Dockerfile: only copy the build directory artifacts into the final release image Use the docker multi-stage build functionality to perform the Retro68 build in a temporary build image, and then copy the final build directory into a fresh release image. This reduces the final release image size from 9.2GB to 2.6GB. --- Dockerfile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2acc1e6e0b..ffe7550605 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ # vim:ft=dockerfile -FROM ubuntu:20.04 +# Base image +FROM ubuntu:20.04 AS base RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y \ @@ -8,8 +9,15 @@ RUN apt-get update && \ libboost-all-dev bison texinfo \ ruby flex curl g++ +# Build image +FROM base AS build + ADD . /Retro68 -RUN mkdir /Retro68-build +RUN mkdir /Retro68-build && \ + bash -c "cd /Retro68-build && bash /Retro68/build-toolchain.bash" -RUN bash -c "cd /Retro68-build && bash /Retro68/build-toolchain.bash --clean-after-build" +# Release image +FROM base AS release + +COPY --from=build /Retro68-build/toolchain /Retro68-build/toolchain From 86a16a78cf269c1d3e99bae8dcaa2875385372fc Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Mon, 17 Oct 2022 22:24:08 +0100 Subject: [PATCH 07/61] Dockerfile: add git package to the image This enables code to be checked out from within the running container as is typically used by CI runners. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ffe7550605..21dc725f77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y \ cmake libgmp-dev libmpfr-dev libmpc-dev \ libboost-all-dev bison texinfo \ - ruby flex curl g++ + ruby flex curl g++ git # Build image FROM base AS build From d8e2780f8d8cd0ddcf5f89043f93c238c4be5e76 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Mon, 17 Oct 2022 22:26:58 +0100 Subject: [PATCH 08/61] Dockerfile: add toolchain bin directory to the default PATH This allows the Retro68 compilers to be executed regardless of the current working directory which is set to /root by default. --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index 21dc725f77..9f885bb5ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,10 @@ RUN apt-get update && \ libboost-all-dev bison texinfo \ ruby flex curl g++ git +# Add toolchain to default PATH +ENV PATH=/Retro68-build/toolchain/bin:$PATH +WORKDIR /root + # Build image FROM base AS build From 3a4468b27023b69f4f15be4f97baad65fa4d1b07 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 21 Oct 2022 15:00:55 +0100 Subject: [PATCH 09/61] azure-pipelines.yml: switch from host build to container build This has two main advantages: firstly it means that the Dockerfile is being tested as part of the pipeline when changes are merged into master, and secondly it allows testing of Linux builds without requiring a separate job for Docker that can consume even more CI minutes. In order to test the container image it is necessary to manually start the build image using docker run, execute the tests, and then copy the results back to the host ready for publishing. Note that since the base OS image is now handled by docker we can switch the host to use the 'ubuntu-latest' image rather than the older 'ubuntu-20.04' image. --- azure-pipelines.yml | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3959607112..47bd19e2d0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -5,34 +5,33 @@ jobs: - job: Linux pool: - vmImage: 'ubuntu-20.04' + vmImage: 'ubuntu-latest' timeoutInMinutes: 90 steps: - checkout: self submodules: true - - script: | - sudo apt-get update - DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \ - cmake libgmp-dev libmpfr-dev libmpc-dev \ - libboost-all-dev bison texinfo \ - ruby flex curl - displayName: 'Install prerequisites' - - script: | - mkdir build - cd build - ../build-toolchain.bash + - task: Docker@2 + inputs: + command: build + repository: ghcr.io/mcayland/retro68-build + tags: latest + arguments: --target build displayName: 'Build' - script: | - cd build - curl -L -O https://github.com/autc04/executor/releases/download/v0.1.0/Executor2000-0.1.0-Linux.tar.bz2 - tar xfvj Executor2000-0.1.0-Linux.tar.bz2 Executor2000-0.1.0-Linux/bin/executor-headless - echo "executor-path=`pwd`/Executor2000-0.1.0-Linux/bin/executor-headless" > ~/.LaunchAPPL.cfg - echo "emulator=executor" >> ~/.LaunchAPPL.cfg - ctest --no-compress-output -T test -E Carbon || true + docker run --name retro68-build --rm -i -d ghcr.io/mcayland/retro68-build:latest + docker exec -i retro68-build /bin/bash <<"EOF" + cd /Retro68-build + curl -L -O https://github.com/autc04/executor/releases/download/v0.1.0/Executor2000-0.1.0-Linux.tar.bz2 + tar xfvj Executor2000-0.1.0-Linux.tar.bz2 Executor2000-0.1.0-Linux/bin/executor-headless + echo "executor-path=`pwd`/Executor2000-0.1.0-Linux/bin/executor-headless" > ~/.LaunchAPPL.cfg + echo "emulator=executor" >> ~/.LaunchAPPL.cfg + ctest --no-compress-output -T test -E Carbon || true + EOF + mkdir build && docker cp retro68-build:/Retro68-build/Testing build + docker stop retro68-build displayName: Run Tests using Executor 2000 - task: PublishTestResults@2 inputs: testResultsFormat: 'CTest' testResultsFiles: build/Testing/**/*.xml buildPlatform: 'x86_64-linux' - From de06b24fd78b851b32d1aa9a76b06b75e1201df9 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 21 Oct 2022 22:14:14 +0100 Subject: [PATCH 10/61] azure-pipelines.yml: push retro68 release image to GHCR This release image contains the basic toolchain that can be used for building projects without having to build Retro68 locally, including integration into a CI pipeline. --- azure-pipelines.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 47bd19e2d0..cce41dacda 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -17,6 +17,13 @@ jobs: tags: latest arguments: --target build displayName: 'Build' + - task: Docker@2 + inputs: + command: build + repository: ghcr.io/mcayland/retro68 + tags: latest + arguments: --target release + displayName: 'Build release' - script: | docker run --name retro68-build --rm -i -d ghcr.io/mcayland/retro68-build:latest docker exec -i retro68-build /bin/bash <<"EOF" @@ -35,3 +42,15 @@ jobs: testResultsFormat: 'CTest' testResultsFiles: build/Testing/**/*.xml buildPlatform: 'x86_64-linux' + - task: Docker@2 + inputs: + command: login + containerRegistry: mcayland-github-docker + displayName: Login to GHCR + - task: Docker@2 + inputs: + containerRegistry: mcayland-github-docker + repository: mcayland/retro68 + command: push + tags: latest + displayName: 'Push release to GHCR' From 147b839de6dfb8c1b6bfc30bb7e81f8a715d20e8 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Thu, 29 Dec 2022 22:00:04 +0100 Subject: [PATCH 11/61] update docker connection --- azure-pipelines.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index cce41dacda..648cf0069c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -13,19 +13,19 @@ jobs: - task: Docker@2 inputs: command: build - repository: ghcr.io/mcayland/retro68-build + repository: ghcr.io/autc04/retro68-build tags: latest arguments: --target build displayName: 'Build' - task: Docker@2 inputs: command: build - repository: ghcr.io/mcayland/retro68 + repository: ghcr.io/autc04/retro68 tags: latest arguments: --target release displayName: 'Build release' - script: | - docker run --name retro68-build --rm -i -d ghcr.io/mcayland/retro68-build:latest + docker run --name retro68-build --rm -i -d ghcr.io/autc04/retro68-build:latest docker exec -i retro68-build /bin/bash <<"EOF" cd /Retro68-build curl -L -O https://github.com/autc04/executor/releases/download/v0.1.0/Executor2000-0.1.0-Linux.tar.bz2 @@ -45,12 +45,12 @@ jobs: - task: Docker@2 inputs: command: login - containerRegistry: mcayland-github-docker + containerRegistry: autc04-github-docker displayName: Login to GHCR - task: Docker@2 inputs: - containerRegistry: mcayland-github-docker - repository: mcayland/retro68 + containerRegistry: autc04-github-docker + repository: autc04/retro68 command: push tags: latest displayName: 'Push release to GHCR' From 8b57ceac129ae5df521183a19730a9c4e2c0ad55 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Sat, 16 Dec 2023 15:14:53 +0100 Subject: [PATCH 12/61] add /build to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 34858dba26..1bc7ea3bb1 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ InterfacesAndLibraries .vscode /result /result-* +/build From 1d8f4f6774dbe02b47968022c060d25e5841b63a Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Sat, 16 Dec 2023 16:19:01 +0100 Subject: [PATCH 13/61] test setup for docker --- Dockerfile | 6 +++ azure-pipelines.yml | 90 ++++++++++++++++++++++++++------------------- 2 files changed, 58 insertions(+), 38 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9f885bb5ba..737f64f0f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,3 +25,9 @@ RUN mkdir /Retro68-build && \ FROM base AS release COPY --from=build /Retro68-build/toolchain /Retro68-build/toolchain + + + +FROM ubuntu:20.04 AS testimage + +RUN apt-get update diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 648cf0069c..9200d248ce 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -13,44 +13,58 @@ jobs: - task: Docker@2 inputs: command: build - repository: ghcr.io/autc04/retro68-build + repository: ghcr.io/autc04/testimage tags: latest - arguments: --target build + arguments: --target testimage displayName: 'Build' - - task: Docker@2 - inputs: - command: build - repository: ghcr.io/autc04/retro68 - tags: latest - arguments: --target release - displayName: 'Build release' + + +# - task: Docker@2 +# inputs: +# command: build +# repository: ghcr.io/autc04/retro68-build +# tags: latest +# arguments: --target build +# displayName: 'Build' +# - task: Docker@2 +# inputs: +# command: build +# repository: ghcr.io/autc04/retro68 +# tags: latest +# arguments: --target release +# displayName: 'Build release' +# - script: | +# docker run --name retro68-build --rm -i -d ghcr.io/autc04/retro68-build:latest +# docker exec -i retro68-build /bin/bash <<"EOF" +# cd /Retro68-build +# curl -L -O https://github.com/autc04/executor/releases/download/v0.1.0/Executor2000-0.1.0-Linux.tar.bz2 +# tar xfvj Executor2000-0.1.0-Linux.tar.bz2 Executor2000-0.1.0-Linux/bin/executor-headless +# echo "executor-path=`pwd`/Executor2000-0.1.0-Linux/bin/executor-headless" > ~/.LaunchAPPL.cfg +# echo "emulator=executor" >> ~/.LaunchAPPL.cfg +# ctest --no-compress-output -T test -E Carbon || true +# EOF +# mkdir build && docker cp retro68-build:/Retro68-build/Testing build +# docker stop retro68-build +# displayName: Run Tests using Executor 2000 +# - task: PublishTestResults@2 +# inputs: +# testResultsFormat: 'CTest' +# testResultsFiles: build/Testing/**/*.xml +# buildPlatform: 'x86_64-linux' +# - task: Docker@2 +# inputs: +# command: login +# containerRegistry: autc04-github-docker +# displayName: Login to GHCR +# - task: Docker@2 +# inputs: +# containerRegistry: autc04-github-docker +# repository: autc04/testimage +# command: push +# tags: latest +# displayName: 'Push release to GHCR' - script: | - docker run --name retro68-build --rm -i -d ghcr.io/autc04/retro68-build:latest - docker exec -i retro68-build /bin/bash <<"EOF" - cd /Retro68-build - curl -L -O https://github.com/autc04/executor/releases/download/v0.1.0/Executor2000-0.1.0-Linux.tar.bz2 - tar xfvj Executor2000-0.1.0-Linux.tar.bz2 Executor2000-0.1.0-Linux/bin/executor-headless - echo "executor-path=`pwd`/Executor2000-0.1.0-Linux/bin/executor-headless" > ~/.LaunchAPPL.cfg - echo "emulator=executor" >> ~/.LaunchAPPL.cfg - ctest --no-compress-output -T test -E Carbon || true - EOF - mkdir build && docker cp retro68-build:/Retro68-build/Testing build - docker stop retro68-build - displayName: Run Tests using Executor 2000 - - task: PublishTestResults@2 - inputs: - testResultsFormat: 'CTest' - testResultsFiles: build/Testing/**/*.xml - buildPlatform: 'x86_64-linux' - - task: Docker@2 - inputs: - command: login - containerRegistry: autc04-github-docker - displayName: Login to GHCR - - task: Docker@2 - inputs: - containerRegistry: autc04-github-docker - repository: autc04/retro68 - command: push - tags: latest - displayName: 'Push release to GHCR' + docker login ghcr.io/autc04 -u autc04 -p $GHC_TOKEN + docker push ghcr.io/autc04/testimage + env: + GHCR_TOKEN: $(GHCR_TOKEN) From 34eeb4dbb72c2150fbc45dc6b83e44054c7f49ed Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Sat, 16 Dec 2023 16:33:00 +0100 Subject: [PATCH 14/61] use token variable and explicit commands for docker --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9200d248ce..4461fd37dc 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -64,7 +64,7 @@ jobs: # tags: latest # displayName: 'Push release to GHCR' - script: | - docker login ghcr.io/autc04 -u autc04 -p $GHC_TOKEN + docker login ghcr.io/autc04 -u autc04 -p $(GHC_TOKEN) docker push ghcr.io/autc04/testimage - env: - GHCR_TOKEN: $(GHCR_TOKEN) + displayName: 'Push release to GHCR' + condition: and(succeeded(), ne(variables['GHCR_TOKEN'], '')) From e2143c9c202855be062dd8acca2443793eb2f3d5 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Sat, 16 Dec 2023 17:02:16 +0100 Subject: [PATCH 15/61] try with service connection again --- azure-pipelines.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4461fd37dc..95faadd943 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -51,20 +51,20 @@ jobs: # testResultsFormat: 'CTest' # testResultsFiles: build/Testing/**/*.xml # buildPlatform: 'x86_64-linux' -# - task: Docker@2 -# inputs: -# command: login -# containerRegistry: autc04-github-docker -# displayName: Login to GHCR -# - task: Docker@2 -# inputs: -# containerRegistry: autc04-github-docker -# repository: autc04/testimage -# command: push -# tags: latest -# displayName: 'Push release to GHCR' - - script: | - docker login ghcr.io/autc04 -u autc04 -p $(GHC_TOKEN) - docker push ghcr.io/autc04/testimage + - task: Docker@2 + inputs: + command: login + containerRegistry: autc04-github-docker + displayName: Login to GHCR + - task: Docker@2 + inputs: + containerRegistry: autc04-github-docker + repository: autc04/testimage + command: push + tags: latest displayName: 'Push release to GHCR' - condition: and(succeeded(), ne(variables['GHCR_TOKEN'], '')) +# - script: | +# docker login ghcr.io/autc04 -u autc04 -p $(GHC_TOKEN) +# docker push ghcr.io/autc04/testimage +# displayName: 'Push release to GHCR' +# condition: and(succeeded(), ne(variables['GHCR_TOKEN'], '')) From 192081cd01c0e949245b5a64c42a90cb0abfd8f3 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Sat, 16 Dec 2023 19:05:30 +0100 Subject: [PATCH 16/61] use variable group --- azure-pipelines.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 95faadd943..75f585e6db 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,6 +7,8 @@ jobs: pool: vmImage: 'ubuntu-latest' timeoutInMinutes: 90 + variables: + - group: Tokens steps: - checkout: self submodules: true @@ -63,8 +65,10 @@ jobs: command: push tags: latest displayName: 'Push release to GHCR' -# - script: | -# docker login ghcr.io/autc04 -u autc04 -p $(GHC_TOKEN) -# docker push ghcr.io/autc04/testimage -# displayName: 'Push release to GHCR' -# condition: and(succeeded(), ne(variables['GHCR_TOKEN'], '')) + - script: | + docker login ghcr.io/autc04 -u autc04 -p $GHCR_TOKEN + docker push ghcr.io/autc04/testimage + env: + GHCR_TOKEN: $(GHCR_TOKEN) + displayName: 'Push release to GHCR' + condition: and(succeeded(), ne(variables['GHCR_TOKEN'], '')) From 3737404c4b3ef13a90f3750f0049c4604996d980 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Sat, 16 Dec 2023 19:10:22 +0100 Subject: [PATCH 17/61] without comdition --- azure-pipelines.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 75f585e6db..78b1de2ee4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -53,22 +53,22 @@ jobs: # testResultsFormat: 'CTest' # testResultsFiles: build/Testing/**/*.xml # buildPlatform: 'x86_64-linux' - - task: Docker@2 - inputs: - command: login - containerRegistry: autc04-github-docker - displayName: Login to GHCR - - task: Docker@2 - inputs: - containerRegistry: autc04-github-docker - repository: autc04/testimage - command: push - tags: latest - displayName: 'Push release to GHCR' +# - task: Docker@2 +# inputs: +# command: login +# containerRegistry: autc04-github-docker +# displayName: Login to GHCR +# - task: Docker@2 +# inputs: +# containerRegistry: autc04-github-docker +# repository: autc04/testimage +# command: push +# tags: latest +# displayName: 'Push release to GHCR' - script: | docker login ghcr.io/autc04 -u autc04 -p $GHCR_TOKEN docker push ghcr.io/autc04/testimage env: GHCR_TOKEN: $(GHCR_TOKEN) displayName: 'Push release to GHCR' - condition: and(succeeded(), ne(variables['GHCR_TOKEN'], '')) +# condition: and(succeeded(), ne(variables['GHCR_TOKEN'], '')) From 9ff29c557eae9600b6e645b115873663275251f6 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Sat, 16 Dec 2023 20:39:52 +0100 Subject: [PATCH 18/61] reactivate actual build --- azure-pipelines.yml | 80 +++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 50 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 78b1de2ee4..af36a8ef39 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,63 +12,43 @@ jobs: steps: - checkout: self submodules: true + - task: Docker@2 inputs: command: build - repository: ghcr.io/autc04/testimage + repository: ghcr.io/autc04/retro68-build tags: latest - arguments: --target testimage + arguments: --target build displayName: 'Build' - - -# - task: Docker@2 -# inputs: -# command: build -# repository: ghcr.io/autc04/retro68-build -# tags: latest -# arguments: --target build -# displayName: 'Build' -# - task: Docker@2 -# inputs: -# command: build -# repository: ghcr.io/autc04/retro68 -# tags: latest -# arguments: --target release -# displayName: 'Build release' -# - script: | -# docker run --name retro68-build --rm -i -d ghcr.io/autc04/retro68-build:latest -# docker exec -i retro68-build /bin/bash <<"EOF" -# cd /Retro68-build -# curl -L -O https://github.com/autc04/executor/releases/download/v0.1.0/Executor2000-0.1.0-Linux.tar.bz2 -# tar xfvj Executor2000-0.1.0-Linux.tar.bz2 Executor2000-0.1.0-Linux/bin/executor-headless -# echo "executor-path=`pwd`/Executor2000-0.1.0-Linux/bin/executor-headless" > ~/.LaunchAPPL.cfg -# echo "emulator=executor" >> ~/.LaunchAPPL.cfg -# ctest --no-compress-output -T test -E Carbon || true -# EOF -# mkdir build && docker cp retro68-build:/Retro68-build/Testing build -# docker stop retro68-build -# displayName: Run Tests using Executor 2000 -# - task: PublishTestResults@2 -# inputs: -# testResultsFormat: 'CTest' -# testResultsFiles: build/Testing/**/*.xml -# buildPlatform: 'x86_64-linux' -# - task: Docker@2 -# inputs: -# command: login -# containerRegistry: autc04-github-docker -# displayName: Login to GHCR -# - task: Docker@2 -# inputs: -# containerRegistry: autc04-github-docker -# repository: autc04/testimage -# command: push -# tags: latest -# displayName: 'Push release to GHCR' + - task: Docker@2 + inputs: + command: build + repository: ghcr.io/autc04/retro68 + tags: latest + arguments: --target release + displayName: 'Build release' + - script: | + docker run --name retro68-build --rm -i -d ghcr.io/autc04/retro68-build:latest + docker exec -i retro68-build /bin/bash <<"EOF" + cd /Retro68-build + curl -L -O https://github.com/autc04/executor/releases/download/v0.1.0/Executor2000-0.1.0-Linux.tar.bz2 + tar xfvj Executor2000-0.1.0-Linux.tar.bz2 Executor2000-0.1.0-Linux/bin/executor-headless + echo "executor-path=`pwd`/Executor2000-0.1.0-Linux/bin/executor-headless" > ~/.LaunchAPPL.cfg + echo "emulator=executor" >> ~/.LaunchAPPL.cfg + ctest --no-compress-output -T test -E Carbon || true + EOF + mkdir build && docker cp retro68-build:/Retro68-build/Testing build + docker stop retro68-build + displayName: Run Tests using Executor 2000 + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'CTest' + testResultsFiles: build/Testing/**/*.xml + buildPlatform: 'x86_64-linux' - script: | docker login ghcr.io/autc04 -u autc04 -p $GHCR_TOKEN - docker push ghcr.io/autc04/testimage + docker push ghcr.io/autc04/retro68 env: GHCR_TOKEN: $(GHCR_TOKEN) displayName: 'Push release to GHCR' -# condition: and(succeeded(), ne(variables['GHCR_TOKEN'], '')) + # condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) From 323d3e3a341f20c68c6581de834ec4be5295adb8 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Sat, 16 Dec 2023 22:27:36 +0100 Subject: [PATCH 19/61] Revert "azure-pipelines.yml: temporary disable all non-Linux builds" This reverts commit a230a79ca35ea24c9553434943c09c8cd8503fe6. --- azure-pipelines.yml | 111 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index af36a8ef39..10af4e2ca2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -52,3 +52,114 @@ jobs: GHCR_TOKEN: $(GHCR_TOKEN) displayName: 'Push release to GHCR' # condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) + +- job: macOS + pool: + vmImage: 'macOS-11' + timeoutInMinutes: 90 + steps: + - checkout: self + submodules: true + - script: | + brew install boost cmake gmp mpfr libmpc bison + displayName: 'Brew prerequisites' + - script: | + mkdir build + cd build + ../build-toolchain.bash + displayName: Build + - script: | + cd build + curl -L -O https://github.com/autc04/executor/releases/download/v0.1.0/Executor2000-0.1.0-Darwin.tar.bz2 + tar xfvj Executor2000-0.1.0-Darwin.tar.bz2 Executor2000-0.1.0-Darwin/bin/executor-headless + echo "executor-path=`pwd`/Executor2000-0.1.0-Darwin/bin/executor-headless" > ~/.LaunchAPPL.cfg + echo "emulator=executor" >> ~/.LaunchAPPL.cfg + ctest --no-compress-output -T test -E Carbon || true + displayName: Run Tests using Executor 2000 + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'CTest' + testResultsFiles: build/Testing/**/*.xml + buildPlatform: 'x86_64-macos' + +- job: NixLinux + strategy: + matrix: + M68K: + TARGET: m68k + PowerPC: + TARGET: powerpc + Carbon: + TARGET: carbon + maxParallel: 2 + pool: + vmImage: 'ubuntu-20.04' + steps: + - checkout: self + submodules: true + - script: | + docker run -i --name nix -v`pwd`:/src nixos/nix:2.18.1 < Date: Sat, 16 Dec 2023 22:29:26 +0100 Subject: [PATCH 20/61] only push docker image when on main branch --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 10af4e2ca2..834a658ba4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -51,7 +51,7 @@ jobs: env: GHCR_TOKEN: $(GHCR_TOKEN) displayName: 'Push release to GHCR' - # condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) - job: macOS pool: From 01bccd3d356c6efb3ed613276f1ad430c9d2a88a Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Sat, 16 Dec 2023 22:49:02 +0100 Subject: [PATCH 21/61] remove test image from Dockerfile, link to repo --- Dockerfile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 737f64f0f0..54588672dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,8 +26,4 @@ FROM base AS release COPY --from=build /Retro68-build/toolchain /Retro68-build/toolchain - - -FROM ubuntu:20.04 AS testimage - -RUN apt-get update +LABEL org.opencontainers.image.source https://github.com/autc04/Retro68 From 9dd5dca1fa5fa84035235f449a06bc769ab23582 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Sun, 17 Dec 2023 19:04:47 +0100 Subject: [PATCH 22/61] fix libelf build --- libelf/src/config.h | 5 +++-- libelf/src/system.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libelf/src/config.h b/libelf/src/config.h index 5a6219d9ee..2d3f00f630 100644 --- a/libelf/src/config.h +++ b/libelf/src/config.h @@ -53,8 +53,9 @@ #endif /* USE_LOCKS */ /* Compiler-specific definitions. */ -//#define strong_alias(name, aliasname) \ - // extern __typeof (name) aliasname __attribute__ ((alias (#name))); +/*#define strong_alias(name, aliasname) \ + extern __typeof (name) aliasname __attribute__ ((alias (#name))); +*/ #define strong_alias(name, aliasname) diff --git a/libelf/src/system.h b/libelf/src/system.h index c23ad05db4..ebf34799a1 100644 --- a/libelf/src/system.h +++ b/libelf/src/system.h @@ -35,6 +35,7 @@ #include #include "portable_endian.h" #include +#include # define LE32(n) le32toh (n) # define LE64(n) le64toh (n) From c57f0d98db25930cf9b87571037eb38fd187d644 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Sat, 16 Dec 2023 23:48:42 +0100 Subject: [PATCH 23/61] init flake --- flake.lock | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 33 ++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000000..e346e4aee5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,63 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1701473968, + "narHash": "sha256-YcVE5emp1qQ8ieHUnxt1wCZCC3ZfAS+SRRWZ2TMda7E=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "34fed993f1674c8d06d58b37ce1e0fe5eebcb9f5", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1702312524, + "narHash": "sha256-gkZJRDBUCpTPBvQk25G0B7vfbpEYM5s5OZqghkjZsnE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a9bf124c46ef298113270b1f84a164865987a91c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1701253981, + "narHash": "sha256-ztaDIyZ7HrTAfEEUt9AtTDNoCYxUdSd6NrRHaYOIxtk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e92039b55bcd58469325ded85d4f58dd5a4eaf58", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000000..929e34f4ff --- /dev/null +++ b/flake.nix @@ -0,0 +1,33 @@ +{ + description = "Description for the project"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + # To import a flake module + # 1. Add foo to inputs + # 2. Add foo as a parameter to the outputs function + # 3. Add here: foo.flakeModule + + ]; + systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ]; + perSystem = { config, self', inputs', pkgs, system, ... }: { + # Per-system attributes can be defined here. The self' and inputs' + # module parameters provide easy access to attributes of the same + # system. + + # Equivalent to inputs'.nixpkgs.legacyPackages.hello; + packages.default = pkgs.hello; + }; + flake = { + # The usual flake attributes can be defined here, including system- + # agnostic ones like nixosModule and system-enumerating ones, although + # those are more easily expressed in perSystem. + + }; + }; +} From 40424639917b2a4a5e530ec300f366cc95ff1151 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Thu, 9 Nov 2023 21:07:21 +0000 Subject: [PATCH 24/61] Dockerfile: add macutils and interfaces-and-libraries.sh to image These files will be required in order to download and install the Universal Interfaces within the created image. --- Dockerfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 54588672dd..58b1f5280b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y \ cmake libgmp-dev libmpfr-dev libmpc-dev \ libboost-all-dev bison texinfo \ - ruby flex curl g++ git + ruby flex curl g++ git macutils # Add toolchain to default PATH ENV PATH=/Retro68-build/toolchain/bin:$PATH @@ -19,11 +19,18 @@ FROM base AS build ADD . /Retro68 RUN mkdir /Retro68-build && \ + mkdir /Retro68-build/bin && \ bash -c "cd /Retro68-build && bash /Retro68/build-toolchain.bash" # Release image FROM base AS release +COPY --from=build \ + /Retro68/interfaces-and-libraries.sh \ + /Retro68/prepare-headers.sh \ + /Retro68/prepare-rincludes.sh \ + /Retro68-build/bin/ + COPY --from=build /Retro68-build/toolchain /Retro68-build/toolchain LABEL org.opencontainers.image.source https://github.com/autc04/Retro68 From 6931631adc930bc1303e5d870c5c51e3727ee07a Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Sat, 11 Nov 2023 11:45:08 +0000 Subject: [PATCH 25/61] Dockerfile: add logic for optional install Universal interfaces on startup Define a docker-entrypoint.sh that checks for the environment variables INTERFACES. If INTERFACES is set to "universal" then we do the following: - If the universal/RIncludes directory is not empty, assume that the Universal interfaces are already installed. Call interfaces-and-libraries.sh to link the Universal interfaces instead of the default multiversal interfaces. - Otherwise check the INTERFACESFILE environment variable to locate a suitable Macbinary DiskCopy image of MPW-GM.img.bin containing the "Interfaces&Libraries" directory, which can be a path within the container image itself or an external URL. If the file is a URL then download it first, then decompress the file using ConvertDiskImage and then use the in-built hfsutils to extract the relevant files under /tmp/InterfacesAndLibraries. Finally call interfaces-and-libraries.sh to link the Universal interfaces instead of the default multiversal interfaces. Otherwise use the multiversal interfaces which are included by default. --- Dockerfile | 7 +++ docker-entrypoint.sh | 65 ++++++++++++++++++++ install-universal-interfaces.sh | 101 ++++++++++++++++++++++++++++++++ 3 files changed, 173 insertions(+) create mode 100755 docker-entrypoint.sh create mode 100755 install-universal-interfaces.sh diff --git a/Dockerfile b/Dockerfile index 58b1f5280b..653d4975b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,12 +25,19 @@ RUN mkdir /Retro68-build && \ # Release image FROM base AS release +ENV INTERFACES=multiversal + COPY --from=build \ /Retro68/interfaces-and-libraries.sh \ /Retro68/prepare-headers.sh \ /Retro68/prepare-rincludes.sh \ + /Retro68/install-universal-interfaces.sh \ + /Retro68/docker-entrypoint.sh \ /Retro68-build/bin/ COPY --from=build /Retro68-build/toolchain /Retro68-build/toolchain LABEL org.opencontainers.image.source https://github.com/autc04/Retro68 + +CMD [ "/bin/bash" ] +ENTRYPOINT [ "/Retro68-build/bin/docker-entrypoint.sh" ] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000000..792a753266 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +set -e + +TMPDIR=/tmp +BUILDDIR=/Retro68-build + +if [[ $INTERFACES == "universal" ]]; +then + # If the universal RIncludes directory is empty, download and install the universal headers + if [ ! "$(ls -A $BUILDDIR/toolchain/universal/RIncludes 2> /dev/null)" ]; then + # If INTERFACESFILE is empty, exit + if [[ -z $INTERFACESFILE ]]; + then + echo -n "Universal interfaces not present, please specify the location of a suitable " + echo "MacBinary DiskCopy image using the INTERFACESFILE environment variable." + exit 1 + fi + + BASEINTERFACESFILE=`basename $INTERFACESFILE` + + # If INTERFACESFILE is a URL, download it first to TMPDIR. Otherwise assume the file is + # already present and copy it to TMPDIR for installation + if [[ $INTERFACESFILE == http* ]]; + then + echo "Downloading Universal interfaces from MacBinary DiskCopy image $BASEINTERFACESFILE..." + curl -s $INTERFACESFILE -o $TMPDIR/$BASEINTERFACESFILE + echo "done" + else + if [[ -z $INTERFACESFILE ]]; + then + echo "Unable to locate universal interfaces file $INTERFACESFILE" + exit 1 + else + echo "Using Universal intefaces from MacBinary Diskcopy image $BASEINTERFACESFILE" + cp $INTERFACESFILE $TMPDIR/$BASEINTERFACESFILE + fi + fi + + # Extract the file + $BUILDDIR/bin/install-universal-interfaces.sh $TMPDIR $BASEINTERFACESFILE + + # Switch to universal + echo "Linking Universal interfaces..." + $BUILDDIR/bin/interfaces-and-libraries.sh $BUILDDIR/toolchain $TMPDIR/InterfacesAndLibraries + echo "done" + else + echo "Linking Universal interfaces..." + + # Link to existing universal interfaces + PREFIX=$BUILDDIR/toolchain + . "$BUILDDIR/bin/interfaces-and-libraries.sh" + BUILD_68K=true + BUILD_PPC=true + + unlinkInterfacesAndLibraries + linkInterfacesAndLibraries "universal" + echo "done" + fi +else + echo "Using multiversal interfaces" +fi + +# Execute command +exec "$@" diff --git a/install-universal-interfaces.sh b/install-universal-interfaces.sh new file mode 100755 index 0000000000..013aeaf644 --- /dev/null +++ b/install-universal-interfaces.sh @@ -0,0 +1,101 @@ +#!/bin/bash + +# +# install-universal-interfaces.sh +# +# Optionally download and attempt to install the universal interfaces from +# a Macbinary disk image containing the Interfaces&Libraries directory +# +# Usage: +# install-universal-interfaces.sh +# +# Decompress the Macbinary image at / into +# /InterfacesAndLibraries in the correct format for +# interfaces-and-libraries.sh. +# + +set -e + +TMPDIR=$1 +FILENAME=$2 + +if [[ ! -f $TMPDIR/$FILENAME ]]; +then + echo "$TMPDIR/$FILENAME not found" + exit 1 +fi + +echo "Decompressing $FILENAME..." +ConvertDiskImage $TMPDIR/$FILENAME $TMPDIR/$FILENAME.img +echo "Decompression complete" + +# Copy over Interfaces&Libraries files +echo "Copying Interfaces&Libraries files..." +hmount $TMPDIR/$FILENAME.img + +# Find Interfaces&Libraries directory, get recursive directory listing +HFSINTERFACESANDLIBSDIR=`hls -R | grep 'Interfaces&Libraries:$'` +IFS="$(printf '\n')" +echo "Found Interfaces&Libraries at $HFSINTERFACESANDLIBSDIR" +FILES=`hls -FR1 $HFSINTERFACESANDLIBSDIR` + +UNIXINTERFACESANDLIBSDIR=$TMPDIR/InterfacesAndLibraries +mkdir -p $UNIXINTERFACESANDLIBSDIR + +# Parse results: first line is the HFS path, following lines contain one file +# per line terminated by an empty line +while IFS= read -r LINE; do + if [[ $LINE == :* ]]; + then + # If it starts with : then it is a HFS path + HFSPATH=$LINE + UNIXRELPATH=$(echo "$HFSPATH" | sed "s#$HFSINTERFACESANDLIBSDIR##g" | sed "s#:#/"#g) + UNIXPATH="$UNIXINTERFACESANDLIBSDIR/$UNIXRELPATH" + + # Make UNIX directory + mkdir -p $UNIXPATH + else + # If it ends with : it is a directory so ignore (we will find it during the descent) + if [[ ! $LINE == *: ]]; + then + # If it isn't empty, it must be a filename + if [[ ! -z $LINE ]]; + then + HFSFULLPATH="$HFSPATH$LINE" + UNIXFULLPATH="$UNIXPATH$LINE" + + echo "Copying $HFSFULLPATH to $UNIXFULLPATH" + + # PPC libraries need a resource fork, but the code in + # interfaces-and-libraries.sh doesn't correctly detect InterfaceLib in + # Macbinary format. Work around this for now by using Basilisk II format + # which can be parsed by ResourceFile and still allows the filename + # detection logic to work. + if [[ $HFSPATH == *SharedLibraries: ]]; + then + if [[ ! -d $UNIXPATH.rsrc ]]; + then + mkdir $UNIXPATH.rsrc + fi + + # First copy as Macbinary + hcopy -m $HFSFULLPATH $UNIXFULLPATH.bin + + # Extract data fork using normal name + bash -c "cd $UNIXPATH && macunpack -d $UNIXFULLPATH.bin && mv $UNIXFULLPATH.data $UNIXFULLPATH" + + # Extract resource fork into .rsrc directory + bash -c "cd $UNIXPATH && macunpack -r $UNIXFULLPATH.bin && mv $UNIXFULLPATH.rsrc $UNIXPATH.rsrc/$LINE" + + # Delete original Macbinary + rm -rf $UNIXFULLPATH.bin + else + hcopy -r $HFSFULLPATH $UNIXFULLPATH + fi + fi + fi + fi +done <<< "$FILES" + +# Unmount image +humount From 14503f06118edf000a627e9c8d41e25c7c2829de Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Sun, 12 Nov 2023 13:38:53 +0000 Subject: [PATCH 26/61] README.md: add section on using the Retro68 docker image --- README.md | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/README.md b/README.md index 9652577e2c..88d7e628aa 100644 --- a/README.md +++ b/README.md @@ -192,6 +192,89 @@ package contains a very portable library, the command will of course fail. Pleas report bugs, please report successes instead! +Using Retro68 with Docker +------------------------- + +Whenever commits are merged into the Retro68 git repository, a build pipeline is triggered to +create a container image which is then pushed to the Retro68 package repository as +`ghcr.io/autc04/retro68`. This image contains the complete 68K and PPC toolchains ready for +use for either local development or as part of CI pipeline. The command line below shows an +example invocation of Retro68 to build the `Samples/Raytracer` app: + +``` +$ git clone --depth 1 https://github.com/autc04/Retro68.git +$ cd Retro68 +$ docker run --rm -v $(pwd):/root -i ghcr.io/autc04/retro68 /bin/bash <<"EOF" + cd Samples/Raytracer + rm -rf build && mkdir build && cd build + cmake .. -DCMAKE_TOOLCHAIN_FILE=/Retro68-build/toolchain/m68k-apple-macos/cmake/retro68.toolchain.cmake + make +EOF +``` + +The container image is configured by default to use the multiversal interfaces, but it is +possible to use the universal interfaces by passing a path to either a local file or a URL +that points to a Macbinary DiskCopy image containing the "Interfaces&Libraries" directory +from MPW. + +Using the universal interfaces from a local file: + +``` +$ docker run --rm -v $(pwd):/root -v $(pwd)/MPW-GM.img.bin:/tmp/MPW-GM.img.bin \ + -e INTERFACES=universal -e INTERFACESFILE=/tmp/MPW-GM.img.bin \ + -i ghcr.io/autc04/retro68 /bin/bash <<"EOF" + cd Samples/Raytracer + rm -rf build && mkdir build && cd build + cmake .. -DCMAKE_TOOLCHAIN_FILE=/Retro68-build/toolchain/m68k-apple-macos/cmake/retro68.toolchain.cmake + make +EOF +``` + +Using the universal interfaces from a URL: + +``` +$ docker run --rm -v $(pwd):/root \ + -e INTERFACES=universal -e INTERFACESFILE=https://mysite.com/MPW-GM.img.bin \ + -i ghcr.io/autc04/retro68 /bin/bash <<"EOF" + cd Samples/Raytracer + rm -rf build && mkdir build && cd build + cmake .. -DCMAKE_TOOLCHAIN_FILE=/Retro68-build/toolchain/m68k-apple-macos/cmake/retro68.toolchain.cmake + make +EOF +``` + +Note that `entrypoint.sh` checks to see if the universal interfaces are installed into +`/Retro68/toolchain/universal` first before attempting to access the file or URL specified +by INTERFACESFILE. This means that it is possible to use caching or another volume so that +the universal interfaces are only processed once to speed up builds e.g. + +``` +$ docker run --rm -v $(pwd):/root \ + -v $(pwd)/universal:/Retro68-build/toolchain/universal \ + -e INTERFACES=universal -e INTERFACESFILE=https://mysite.com/MPW-GM.img.bin \ + -i ghcr.io/autc04/retro68 /bin/bash <<"EOF" + cd Samples/Raytracer + rm -rf build && mkdir build && cd build + cmake .. -DCMAKE_TOOLCHAIN_FILE=/Retro68-build/toolchain/m68k-apple-macos/cmake/retro68.toolchain.cmake + make +EOF +``` + +and then on subsequent runs: + +``` +$ docker run --rm -v $(pwd):/root \ + -v $(pwd)/universal:/Retro68-build/toolchain/universal \ + -e INTERFACES=universal \ + -i ghcr.io/autc04/retro68 /bin/bash <<"EOF" + cd Samples/Raytracer + rm -rf build && mkdir build && cd build + cmake .. -DCMAKE_TOOLCHAIN_FILE=/Retro68-build/toolchain/m68k-apple-macos/cmake/retro68.toolchain.cmake + make +EOF +``` + + Sample programs --------------- From 551c7588ca1c56c90c0cdcf3e99108f39f807c1e Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Sun, 17 Dec 2023 19:04:35 +0100 Subject: [PATCH 27/61] Set up flake using the old overlay.nix --- default.nix | 15 +++--- flake.lock | 17 +++++++ flake.nix | 67 +++++++++++++++++++-------- nix/sources.json | 18 ++++---- nix/sources.nix | 118 ++++++++++++++++++++++++++++------------------- 5 files changed, 153 insertions(+), 82 deletions(-) diff --git a/default.nix b/default.nix index 388b79d9fa..8285c81524 100644 --- a/default.nix +++ b/default.nix @@ -1,16 +1,16 @@ let sources = import ./nix/sources.nix; -in { system ? builtins.currentSystem, nixpkgs ? sources.nixpkgs, ... }: +in { system ? builtins.currentSystem, nixpkgs ? sources.nixpkgs, + multiversal_src ? if builtins.pathExists ./multiversal/make-multiverse.rb then + ./multiversal + else + sources.multiversal, + ... }: let retroPlatforms = import nix/platforms.nix; lib = ((import nixpkgs) { inherit system; }).lib; - multiversal_src = if builtins.pathExists ./multiversal/make-multiverse.rb then - ./multiversal - else - sources.multiversal; - # A Nixpkgs overlay. overlay = lib.composeManyExtensions [ ((import nix/overlay.nix) { inherit multiversal_src; }) @@ -30,6 +30,8 @@ let crossSystem = plat; config = { allowUnsupportedSystem = true; }; }) retroPlatforms; + targetPkgs = lib.mapAttrs (name: cross: + cross.buildPackages) crossPkgs; shell = lib.mapAttrs (name: cross: cross.mkShell { @@ -45,4 +47,5 @@ let in shell.m68k // shell // { inherit overlay; inherit (overlaidPkgs) retro68; + targetPkg = targetPkgs; } diff --git a/flake.lock b/flake.lock index e346e4aee5..9b37985172 100644 --- a/flake.lock +++ b/flake.lock @@ -17,6 +17,22 @@ "type": "indirect" } }, + "multiversal": { + "flake": false, + "locked": { + "lastModified": 1682955462, + "narHash": "sha256-fOLYuSJOWh/iE7JelpeuT4NgZ/5bZivqV+o9LtiJGxA=", + "owner": "autc04", + "repo": "multiversal", + "rev": "1170bce4c98f1956ad73ca335479d510cd6e8620", + "type": "github" + }, + "original": { + "owner": "autc04", + "repo": "multiversal", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1702312524, @@ -54,6 +70,7 @@ "root": { "inputs": { "flake-parts": "flake-parts", + "multiversal": "multiversal", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 929e34f4ff..5d64f032ef 100644 --- a/flake.nix +++ b/flake.nix @@ -3,31 +3,58 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + multiversal.url = "github:autc04/multiversal"; + multiversal.flake = false; }; - outputs = inputs@{ flake-parts, ... }: - flake-parts.lib.mkFlake { inherit inputs; } { - imports = [ - # To import a flake module - # 1. Add foo to inputs - # 2. Add foo as a parameter to the outputs function - # 3. Add here: foo.flakeModule + outputs = inputs@{ flake-parts, nixpkgs, multiversal, ... }: + flake-parts.lib.mkFlake { inherit inputs; } ({ self, lib, retroPlatforms, ... }: { + _module.args.lib = import (nixpkgs + "/lib"); + _module.args.retroPlatforms = import ./nix/platforms.nix; - ]; systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ]; - perSystem = { config, self', inputs', pkgs, system, ... }: { - # Per-system attributes can be defined here. The self' and inputs' - # module parameters provide easy access to attributes of the same - # system. + perSystem = { config, self', inputs', pkgs, system, ... }: + { + _module.args.pkgs = import nixpkgs { inherit system; overlays = [ self.overlays.default ]; }; - # Equivalent to inputs'.nixpkgs.legacyPackages.hello; - packages.default = pkgs.hello; - }; + legacyPackages.crossPkgs = lib.mapAttrs + (name: plat: + import nixpkgs { + inherit system; + overlays = [ self.overlays.default ]; + crossSystem = plat; + config = { allowUnsupportedSystem = true; }; + }) + retroPlatforms; + + devShells = { + default = pkgs.mkShell { + inputsFrom = [ pkgs.retro68.monolithic ]; + nativeBuildInputs = [ pkgs.nixpkgs-fmt ]; + }; + } // lib.mapAttrs + (name: cross: + cross.mkShell + { + nativeBuildInputs = with pkgs; [ + retro68.hfsutils + retro68.tools + cmake + gnumake + ]; + buildInputs = [ cross.retro68.console ]; + } // cross) + self'.legacyPackages.crossPkgs; + + + }; flake = { - # The usual flake attributes can be defined here, including system- - # agnostic ones like nixosModule and system-enumerating ones, although - # those are more easily expressed in perSystem. - + overlays.default = + lib.composeManyExtensions [ + ((import nix/overlay.nix) { multiversal_src = multiversal; }) + (import nix/universal.nix) + (import nix/samples.nix) + ]; }; - }; + }); } diff --git a/nix/sources.json b/nix/sources.json index f017eed65e..15b7018841 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -5,10 +5,10 @@ "homepage": null, "owner": "autc04", "repo": "multiversal", - "rev": "ce33b1bada9b0acb14021c21ac916927c757d525", - "sha256": "1fsyjad4kwsqgr2mlx9dfl7z8z42cf2sgw1arqmci47zhaj8is1f", + "rev": "1170bce4c98f1956ad73ca335479d510cd6e8620", + "sha256": "040vi7c2wggaazm2nrjvzrkn10sgmsbrcpmj2gi1ynjf4awxiqkw", "type": "tarball", - "url": "https://github.com/autc04/multiversal/archive/ce33b1bada9b0acb14021c21ac916927c757d525.tar.gz", + "url": "https://github.com/autc04/multiversal/archive/1170bce4c98f1956ad73ca335479d510cd6e8620.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "niv": { @@ -17,10 +17,10 @@ "homepage": "https://github.com/nmattia/niv", "owner": "nmattia", "repo": "niv", - "rev": "5830a4dd348d77e39a0f3c4c762ff2663b602d4c", - "sha256": "1d3lsrqvci4qz2hwjrcnd8h5vfkg8aypq3sjd4g3izbc8frwz5sm", + "rev": "6bd7cd686220bf3db0e212481faf9578e8c8ff0f", + "sha256": "15claxlj6y15db67qc7kb4vzyn6sv7r13z4q502vq7a4z2488z94", "type": "tarball", - "url": "https://github.com/nmattia/niv/archive/5830a4dd348d77e39a0f3c4c762ff2663b602d4c.tar.gz", + "url": "https://github.com/nmattia/niv/archive/6bd7cd686220bf3db0e212481faf9578e8c8ff0f.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "nixpkgs": { @@ -29,10 +29,10 @@ "homepage": "", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d1e59cfc49961e121583abe32e2f3db1550fbcff", - "sha256": "03ldf1dlxqf3g8qh9x5vp6vd9zvvr481fyjds111imll69y60wpm", + "rev": "2766f77c32e171a04d59b636a91083bae862274e", + "sha256": "1xk1f62n00z7q5i3pf4c8c4rlv5k4jwpgh0pqgzw1l40vhdkixk9", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/d1e59cfc49961e121583abe32e2f3db1550fbcff.tar.gz", + "url": "https://github.com/NixOS/nixpkgs/archive/2766f77c32e171a04d59b636a91083bae862274e.tar.gz", "url_template": "https://github.com///archive/.tar.gz" } } diff --git a/nix/sources.nix b/nix/sources.nix index 1938409ddd..fe3dadf7eb 100644 --- a/nix/sources.nix +++ b/nix/sources.nix @@ -10,29 +10,50 @@ let let name' = sanitizeName name + "-src"; in - if spec.builtin or true then - builtins_fetchurl { inherit (spec) url sha256; name = name'; } - else - pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; + if spec.builtin or true then + builtins_fetchurl { inherit (spec) url sha256; name = name'; } + else + pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; fetch_tarball = pkgs: name: spec: let name' = sanitizeName name + "-src"; in - if spec.builtin or true then - builtins_fetchTarball { name = name'; inherit (spec) url sha256; } - else - pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; + if spec.builtin or true then + builtins_fetchTarball { name = name'; inherit (spec) url sha256; } + else + pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; fetch_git = name: spec: let ref = - if spec ? ref then spec.ref else + spec.ref or ( if spec ? branch then "refs/heads/${spec.branch}" else - if spec ? tag then "refs/tags/${spec.tag}" else - abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; + if spec ? tag then "refs/tags/${spec.tag}" else + abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!" + ); + submodules = spec.submodules or false; + submoduleArg = + let + nixSupportsSubmodules = builtins.compareVersions builtins.nixVersion "2.4" >= 0; + emptyArgWithWarning = + if submodules + then + builtins.trace + ( + "The niv input \"${name}\" uses submodules " + + "but your nix's (${builtins.nixVersion}) builtins.fetchGit " + + "does not support them" + ) + { } + else { }; + in + if nixSupportsSubmodules + then { inherit submodules; } + else emptyArgWithWarning; in - builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }; + builtins.fetchGit + ({ url = spec.repo; inherit (spec) rev; inherit ref; } // submoduleArg); fetch_local = spec: spec.path; @@ -66,16 +87,16 @@ let hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; hasThisAsNixpkgsPath = == ./.; in - if builtins.hasAttr "nixpkgs" sources - then sourcesNixpkgs - else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then - import {} - else - abort - '' - Please specify either (through -I or NIX_PATH=nixpkgs=...) or - add a package called "nixpkgs" to your sources.json. - ''; + if builtins.hasAttr "nixpkgs" sources + then sourcesNixpkgs + else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then + import { } + else + abort + '' + Please specify either (through -I or NIX_PATH=nixpkgs=...) or + add a package called "nixpkgs" to your sources.json. + ''; # The actual fetching function. fetch = pkgs: name: spec: @@ -95,13 +116,13 @@ let # the path directly as opposed to the fetched source. replace = name: drv: let - saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; + saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name; ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; in - if ersatz == "" then drv else - # this turns the string into an actual Nix path (for both absolute and - # relative paths) - if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; + if ersatz == "" then drv else + # this turns the string into an actual Nix path (for both absolute and + # relative paths) + if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; # Ports of functions for older nix versions @@ -112,7 +133,7 @@ let ); # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 - range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1); + range = first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1); # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); @@ -123,43 +144,46 @@ let concatStrings = builtins.concatStringsSep ""; # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 - optionalAttrs = cond: as: if cond then as else {}; + optionalAttrs = cond: as: if cond then as else { }; # fetchTarball version that is compatible between all the versions of Nix builtins_fetchTarball = { url, name ? null, sha256 }@attrs: let inherit (builtins) lessThan nixVersion fetchTarball; in - if lessThan nixVersion "1.12" then - fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) - else - fetchTarball attrs; + if lessThan nixVersion "1.12" then + fetchTarball ({ inherit url; } // (optionalAttrs (name != null) { inherit name; })) + else + fetchTarball attrs; # fetchurl version that is compatible between all the versions of Nix builtins_fetchurl = { url, name ? null, sha256 }@attrs: let inherit (builtins) lessThan nixVersion fetchurl; in - if lessThan nixVersion "1.12" then - fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) - else - fetchurl attrs; + if lessThan nixVersion "1.12" then + fetchurl ({ inherit url; } // (optionalAttrs (name != null) { inherit name; })) + else + fetchurl attrs; # Create the final "sources" from the config mkSources = config: - mapAttrs ( - name: spec: - if builtins.hasAttr "outPath" spec - then abort - "The values in sources.json should not have an 'outPath' attribute" - else - spec // { outPath = replace name (fetch config.pkgs name spec); } - ) config.sources; + mapAttrs + ( + name: spec: + if builtins.hasAttr "outPath" spec + then + abort + "The values in sources.json should not have an 'outPath' attribute" + else + spec // { outPath = replace name (fetch config.pkgs name spec); } + ) + config.sources; # The "config" used by the fetchers mkConfig = { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null - , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile) + , sources ? if sourcesFile == null then { } else builtins.fromJSON (builtins.readFile sourcesFile) , system ? builtins.currentSystem , pkgs ? mkPkgs sources system }: rec { @@ -171,4 +195,4 @@ let }; in -mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); } +mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); } From f21a12a7ebd9aea00bd71b6838dc21035ff9bdba Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 18:09:28 +0100 Subject: [PATCH 28/61] platfoms.nix cleanup: add vendor and abi --- nix/platforms.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nix/platforms.nix b/nix/platforms.nix index 3f36c5956b..db0ebcf1b6 100644 --- a/nix/platforms.nix +++ b/nix/platforms.nix @@ -14,6 +14,8 @@ name = "macos"; execFormat = { name = "unknown"; }; }; + vendor = { name = "apple"; }; + abi = { name = "macos"; }; }; bfdEmulation = "m68k"; isStatic = true; @@ -37,6 +39,8 @@ name = "macos"; execFormat = { name = "unknown"; }; }; + vendor = { name = "apple"; }; + abi = { name = "macos"; }; }; isStatic = true; @@ -60,6 +64,8 @@ name = "carbon"; execFormat = { name = "unknown"; }; }; + vendor = { name = "apple"; }; + abi = { name = "macos"; }; }; isStatic = true; retro68BinutilsConfig = [ "--disable-plugins" ]; @@ -67,9 +73,4 @@ retro68 = true; cmakeSystemName = "RetroCarbon"; }; - - isStatic = true; - retro68BinutilsConfig = [ "--disable-plugins" ]; - retro68GccConfig = [ "--disable-lto" ]; - retro68 = true; } From 21e79c8adf757b50ee0076effee43a612fba830b Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 18:09:34 +0100 Subject: [PATCH 29/61] overlay.nix cleanup --- nix/overlay.nix | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/nix/overlay.nix b/nix/overlay.nix index 65737471a5..fbc4c65485 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -1,6 +1,5 @@ { multiversal_src }: -pkgs: prevPkgs: -{ +pkgs: prevPkgs: { retro68 = pkgs.lib.makeScope pkgs.newScope (self: { platforms = import ./platforms.nix; @@ -89,7 +88,7 @@ pkgs: prevPkgs: rm $out/${stdenv.targetPlatform.config}/bin/ld ln -s ${ld} $out/${stdenv.targetPlatform.config}/bin/ld - ''; + ''; }; # gcc -- gcc, without any wrappers @@ -168,7 +167,7 @@ pkgs: prevPkgs: export RETRO68_REAL_LD="${pkgs.buildPackages.retro68.binutils_unwrapped}/bin/m68k-apple-macos-ld.real" ''); }; - in pkgs.makeSetupHook { } hook; + in pkgs.makeSetupHook { name = "retro68.setup_hook"; } hook; # ----------- Retro68 core libraries ------------- @@ -193,7 +192,6 @@ pkgs: prevPkgs: ""); }; - import_libraries = with pkgs; if stdenvNoCC.targetPlatform.system != "m68k-macos" then stdenvNoCC.mkDerivation { @@ -248,30 +246,36 @@ pkgs: prevPkgs: }; }); -} // prevPkgs.lib.optionalAttrs (prevPkgs.targetPlatform ? retro68) { # ----------- Binutils & GCC wrapped for nixpkgs ------------- # binutils -- binutils with the wrappers provided by nixpkgs - binutils = - pkgs.wrapBintoolsWith { bintools = pkgs.retro68.binutils_unwrapped; }; + binutils = if (prevPkgs.targetPlatform ? retro68) then + pkgs.wrapBintoolsWith { bintools = pkgs.retro68.binutils_unwrapped; } + else + prevPkgs.binutils; # gcc -- gcc with the wrappers provided by nixpkgs - gcc = pkgs.wrapCCWith { - cc = pkgs.retro68.gcc_unwrapped; + gcc = if (prevPkgs.targetPlatform ? retro68) then + pkgs.wrapCCWith { + cc = pkgs.retro68.gcc_unwrapped; + bintools = pkgs.binutils; + libc = null; - # don't allow nix to add options for hardening - extraBuildCommands = '' - echo "" > $out/nix-support/add-hardening.sh - ''; + # don't allow nix to add options for hardening + extraBuildCommands = '' + echo "" > $out/nix-support/add-hardening.sh + ''; - extraPackages = with pkgs.targetPackages.retro68; [ - multiversal - import_libraries - libretro - setup_hook - ]; - }; + extraPackages = with pkgs.targetPackages.retro68; [ + multiversal + import_libraries + libretro + setup_hook + ]; + } + else + prevPkgs.gcc; # no separate libc package for now libcCrossChooser = name: From c11fd5f3030b9b853595b7240a8dbbc1814e94db Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 10:18:05 +0100 Subject: [PATCH 30/61] prevent inifinite recursion for stdenvUniversal --- nix/universal.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/nix/universal.nix b/nix/universal.nix index 1f7df2856b..96d9bf38a1 100644 --- a/nix/universal.nix +++ b/nix/universal.nix @@ -53,7 +53,6 @@ pkgs: prevPkgs: ''); }; }); -} // prevPkgs.lib.optionalAttrs (prevPkgs.targetPlatform ? retro68) { stdenvUniversal = pkgs.stdenv.override { cc = pkgs.stdenv.cc.override { From 7e0e20edbd417315ff401f76d07db7bff5b5a807 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 17:22:09 +0100 Subject: [PATCH 31/61] add ninja to shells --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index 5d64f032ef..9e98edcbaf 100644 --- a/flake.nix +++ b/flake.nix @@ -41,6 +41,7 @@ retro68.tools cmake gnumake + ninja ]; buildInputs = [ cross.retro68.console ]; } // cross) From f98b4910dce4dd24dd3fb60e26b538506b38450c Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 17:22:27 +0100 Subject: [PATCH 32/61] add packages for tools & hfsutils --- flake.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flake.nix b/flake.nix index 9e98edcbaf..ba7102416c 100644 --- a/flake.nix +++ b/flake.nix @@ -47,6 +47,8 @@ } // cross) self'.legacyPackages.crossPkgs; + packages.tools = pkgs.retro68.tools; + packages.hfsutils = pkgs.retro68.hfsutils; }; flake = { From 963594d8d807302b82904c449731149c0aa8e7f8 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 17:22:37 +0100 Subject: [PATCH 33/61] add .envrc --- .envrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 0000000000..3550a30f2d --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake From e51da67371108b0c33d172693d142936a53d5ed9 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 17:55:09 +0100 Subject: [PATCH 34/61] add a default package --- flake.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/flake.nix b/flake.nix index ba7102416c..1cc3c40445 100644 --- a/flake.nix +++ b/flake.nix @@ -50,6 +50,23 @@ packages.tools = pkgs.retro68.tools; packages.hfsutils = pkgs.retro68.hfsutils; + packages.default = pkgs.runCommand "Retro68" {} '' + mkdir $out + mkdir $out/m68k-apple-macos + mkdir $out/powerpc-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.m68k.retro68.libretro}/. $out/m68k-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.m68k.retro68.multiversal}/. $out/m68k-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.powerpc.retro68.libretro}/. $out/powerpc-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.powerpc.retro68.multiversal}/. $out/powerpc-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.retro68.tools}/. $out + ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.retro68.hfsutils}/. $out + ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.cmake}/. $out + ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.gnumake}/. $out + ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.ninja}/. $out + + ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.crossPkgs.m68k.buildPackages.retro68.gcc_unwrapped}/. $out + ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.crossPkgs.powerpc.buildPackages.retro68.gcc_unwrapped}/. $out + ''; }; flake = { overlays.default = From faf6b7fbbfa36757b8e857e889d16f3677ee3f6d Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 18:19:08 +0100 Subject: [PATCH 35/61] we don't actually need libcCrossChooser --- nix/overlay.nix | 5 ----- nix/platforms.nix | 6 +++--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/nix/overlay.nix b/nix/overlay.nix index fbc4c65485..c72172df31 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -276,9 +276,4 @@ pkgs: prevPkgs: { } else prevPkgs.gcc; - - # no separate libc package for now - libcCrossChooser = name: - if name == "retro68" then null else prevPkgs.libcCrossChooser name; - } diff --git a/nix/platforms.nix b/nix/platforms.nix index db0ebcf1b6..d3683cadef 100644 --- a/nix/platforms.nix +++ b/nix/platforms.nix @@ -2,7 +2,7 @@ m68k = { system = "m68k-macos"; config = "m68k-apple-macos"; - libc = "retro68"; + libc = null; parsed = { cpu = { name = "m68k"; @@ -27,7 +27,7 @@ powerpc = { system = "powerpc-macos"; config = "powerpc-apple-macos"; - libc = "retro68"; + libc = null; parsed = { cpu = { name = "powerpc"; @@ -52,7 +52,7 @@ carbon = { system = "powerpc-carbon"; config = "powerpc-apple-macos"; - libc = "retro68"; + libc = null; parsed = { cpu = { name = "powerpc"; From 914ce6e144770d70b81e133b5d01bceb13c06428 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 19:04:49 +0100 Subject: [PATCH 36/61] add an url for flake-parts --- flake.lock | 5 +++-- flake.nix | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/flake.lock b/flake.lock index 9b37985172..47eea3ad1a 100644 --- a/flake.lock +++ b/flake.lock @@ -13,8 +13,9 @@ "type": "github" }, "original": { - "id": "flake-parts", - "type": "indirect" + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" } }, "multiversal": { diff --git a/flake.nix b/flake.nix index 1cc3c40445..02d88e2825 100644 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,7 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; multiversal.url = "github:autc04/multiversal"; multiversal.flake = false; + flake-parts.url = "github:hercules-ci/flake-parts"; }; outputs = inputs@{ flake-parts, nixpkgs, multiversal, ... }: From 2dd9d79398d06d85329490f7b12c12e9c59584c1 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 19:53:34 +0100 Subject: [PATCH 37/61] add a check so that the flake can be used with submodules as well --- flake.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 02d88e2825..0653aaea87 100644 --- a/flake.nix +++ b/flake.nix @@ -72,7 +72,11 @@ flake = { overlays.default = lib.composeManyExtensions [ - ((import nix/overlay.nix) { multiversal_src = multiversal; }) + ((import nix/overlay.nix) { + multiversal_src = if builtins.pathExists ./multiversal/make-multiverse.rb + then ./multiversal + else multiversal; + }) (import nix/universal.nix) (import nix/samples.nix) ]; From 047e39041936b65ba400b085e9accac41b04b8a8 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 19:53:51 +0100 Subject: [PATCH 38/61] add a 'samples' package --- flake.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flake.nix b/flake.nix index 0653aaea87..a401e1c7cf 100644 --- a/flake.nix +++ b/flake.nix @@ -68,6 +68,12 @@ ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.crossPkgs.m68k.buildPackages.retro68.gcc_unwrapped}/. $out ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.crossPkgs.powerpc.buildPackages.retro68.gcc_unwrapped}/. $out ''; + + packages.samples = pkgs.linkFarm "Retro68-Samples" [ + { name = "m68k"; path = self'.legacyPackages.crossPkgs.m68k.retro68.samples; } + { name = "powerpc"; path = self'.legacyPackages.crossPkgs.powerpc.retro68.samples; } + { name = "carbon"; path = self'.legacyPackages.crossPkgs.carbon.retro68.samples; } + ]; }; flake = { overlays.default = From af8c831bfa7130b4f619548457edf7aec64484ae Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 19:54:40 +0100 Subject: [PATCH 39/61] add carbon to default package --- flake.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/flake.nix b/flake.nix index a401e1c7cf..ac22add28b 100644 --- a/flake.nix +++ b/flake.nix @@ -59,6 +59,8 @@ ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.m68k.retro68.multiversal}/. $out/m68k-apple-macos ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.powerpc.retro68.libretro}/. $out/powerpc-apple-macos ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.powerpc.retro68.multiversal}/. $out/powerpc-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.carbon.retro68.libretro}/. $out/powerpc-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.carbon.retro68.multiversal}/. $out/powerpc-apple-macos ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.retro68.tools}/. $out ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.retro68.hfsutils}/. $out ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.cmake}/. $out @@ -67,6 +69,7 @@ ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.crossPkgs.m68k.buildPackages.retro68.gcc_unwrapped}/. $out ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.crossPkgs.powerpc.buildPackages.retro68.gcc_unwrapped}/. $out + ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.crossPkgs.carbon.buildPackages.retro68.gcc_unwrapped}/. $out ''; packages.samples = pkgs.linkFarm "Retro68-Samples" [ From 867b3eca743f0e9c6e343fe2148a3877d7e0a209 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 20:15:15 +0100 Subject: [PATCH 40/61] update multiversal --- flake.lock | 6 +++--- multiversal | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index 47eea3ad1a..0e7a6645aa 100644 --- a/flake.lock +++ b/flake.lock @@ -21,11 +21,11 @@ "multiversal": { "flake": false, "locked": { - "lastModified": 1682955462, - "narHash": "sha256-fOLYuSJOWh/iE7JelpeuT4NgZ/5bZivqV+o9LtiJGxA=", + "lastModified": 1703617805, + "narHash": "sha256-GngLWR9i+hC7hJ+ZkKlRK4K63lIJ4D/CMXZwefcVAqw=", "owner": "autc04", "repo": "multiversal", - "rev": "1170bce4c98f1956ad73ca335479d510cd6e8620", + "rev": "27c08c654bbd48d23f025741e3a584b59374904a", "type": "github" }, "original": { diff --git a/multiversal b/multiversal index d7aac1e58d..27c08c654b 160000 --- a/multiversal +++ b/multiversal @@ -1 +1 @@ -Subproject commit d7aac1e58d165c30fd3a0796e7b4745e78d34643 +Subproject commit 27c08c654bbd48d23f025741e3a584b59374904a From 7bebb04690c31da00e6ab7ea7b4bc52b55335e91 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 20:26:57 +0100 Subject: [PATCH 41/61] use nixos-23.11, update niv to match flake --- flake.lock | 8 ++++---- flake.nix | 2 +- nix/sources.json | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/flake.lock b/flake.lock index 0e7a6645aa..4d943e6cc9 100644 --- a/flake.lock +++ b/flake.lock @@ -36,16 +36,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1702312524, - "narHash": "sha256-gkZJRDBUCpTPBvQk25G0B7vfbpEYM5s5OZqghkjZsnE=", + "lastModified": 1703200384, + "narHash": "sha256-q5j06XOsy0qHOarsYPfZYJPWbTbc8sryRxianlEPJN0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a9bf124c46ef298113270b1f84a164865987a91c", + "rev": "0b3d618173114c64ab666f557504d6982665d328", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "nixos-23.11", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index ac22add28b..46480d0354 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "Description for the project"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; multiversal.url = "github:autc04/multiversal"; multiversal.flake = false; flake-parts.url = "github:hercules-ci/flake-parts"; diff --git a/nix/sources.json b/nix/sources.json index 15b7018841..13b4dfc2d2 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -5,10 +5,10 @@ "homepage": null, "owner": "autc04", "repo": "multiversal", - "rev": "1170bce4c98f1956ad73ca335479d510cd6e8620", - "sha256": "040vi7c2wggaazm2nrjvzrkn10sgmsbrcpmj2gi1ynjf4awxiqkw", + "rev": "27c08c654bbd48d23f025741e3a584b59374904a", + "sha256": "1b022pvpjw3n6713zq09abgbm0iba6lr16czhjxi1yk23xchny0s", "type": "tarball", - "url": "https://github.com/autc04/multiversal/archive/1170bce4c98f1956ad73ca335479d510cd6e8620.tar.gz", + "url": "https://github.com/autc04/multiversal/archive/27c08c654bbd48d23f025741e3a584b59374904a.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "niv": { @@ -24,15 +24,15 @@ "url_template": "https://github.com///archive/.tar.gz" }, "nixpkgs": { - "branch": "release-21.11", + "branch": "nixos-23.11", "description": "Nix Packages collection", "homepage": "", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2766f77c32e171a04d59b636a91083bae862274e", - "sha256": "1xk1f62n00z7q5i3pf4c8c4rlv5k4jwpgh0pqgzw1l40vhdkixk9", + "rev": "0b3d618173114c64ab666f557504d6982665d328", + "sha256": "1p941x8rx6hq8zrcmwnw6rnxd4v0v7vn1v5a763lmjxcfglz965b", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/2766f77c32e171a04d59b636a91083bae862274e.tar.gz", + "url": "https://github.com/NixOS/nixpkgs/archive/0b3d618173114c64ab666f557504d6982665d328.tar.gz", "url_template": "https://github.com///archive/.tar.gz" } } From 97a082224446556ac6337294e0770cdbcf5e4afe Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 23:14:38 +0100 Subject: [PATCH 42/61] add platform-specific samples packages --- flake.nix | 56 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/flake.nix b/flake.nix index 46480d0354..5a8c8d6b06 100644 --- a/flake.nix +++ b/flake.nix @@ -48,35 +48,39 @@ } // cross) self'.legacyPackages.crossPkgs; - packages.tools = pkgs.retro68.tools; - packages.hfsutils = pkgs.retro68.hfsutils; + packages = { + tools = pkgs.retro68.tools; + hfsutils = pkgs.retro68.hfsutils; - packages.default = pkgs.runCommand "Retro68" {} '' - mkdir $out - mkdir $out/m68k-apple-macos - mkdir $out/powerpc-apple-macos - ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.m68k.retro68.libretro}/. $out/m68k-apple-macos - ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.m68k.retro68.multiversal}/. $out/m68k-apple-macos - ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.powerpc.retro68.libretro}/. $out/powerpc-apple-macos - ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.powerpc.retro68.multiversal}/. $out/powerpc-apple-macos - ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.carbon.retro68.libretro}/. $out/powerpc-apple-macos - ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.carbon.retro68.multiversal}/. $out/powerpc-apple-macos - ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.retro68.tools}/. $out - ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.retro68.hfsutils}/. $out - ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.cmake}/. $out - ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.gnumake}/. $out - ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.ninja}/. $out + default = pkgs.runCommand "Retro68" {} '' + mkdir $out + mkdir $out/m68k-apple-macos + mkdir $out/powerpc-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.m68k.retro68.libretro}/. $out/m68k-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.m68k.retro68.multiversal}/. $out/m68k-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.powerpc.retro68.libretro}/. $out/powerpc-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.powerpc.retro68.multiversal}/. $out/powerpc-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.carbon.retro68.libretro}/. $out/powerpc-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.carbon.retro68.multiversal}/. $out/powerpc-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.retro68.tools}/. $out + ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.retro68.hfsutils}/. $out + ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.cmake}/. $out + ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.gnumake}/. $out + ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.ninja}/. $out - ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.crossPkgs.m68k.buildPackages.retro68.gcc_unwrapped}/. $out - ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.crossPkgs.powerpc.buildPackages.retro68.gcc_unwrapped}/. $out - ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.crossPkgs.carbon.buildPackages.retro68.gcc_unwrapped}/. $out - ''; + ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.crossPkgs.m68k.buildPackages.retro68.gcc_unwrapped}/. $out + ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.crossPkgs.powerpc.buildPackages.retro68.gcc_unwrapped}/. $out + ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.crossPkgs.carbon.buildPackages.retro68.gcc_unwrapped}/. $out + ''; - packages.samples = pkgs.linkFarm "Retro68-Samples" [ - { name = "m68k"; path = self'.legacyPackages.crossPkgs.m68k.retro68.samples; } - { name = "powerpc"; path = self'.legacyPackages.crossPkgs.powerpc.retro68.samples; } - { name = "carbon"; path = self'.legacyPackages.crossPkgs.carbon.retro68.samples; } - ]; + samples = pkgs.linkFarm "Retro68-Samples" [ + { name = "m68k"; path = self'.legacyPackages.crossPkgs.m68k.retro68.samples; } + { name = "powerpc"; path = self'.legacyPackages.crossPkgs.powerpc.retro68.samples; } + { name = "carbon"; path = self'.legacyPackages.crossPkgs.carbon.retro68.samples; } + ]; + } // lib.mapAttrs' + (name: cross: lib.nameValuePair "samples-${name}" cross.retro68.samples) + self'.legacyPackages.crossPkgs; }; flake = { overlays.default = From d37d7e0612fa83b4aef3cd375c8389ed9e465586 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 23:22:55 +0100 Subject: [PATCH 43/61] use determinate nix installer & flake build on ADO --- azure-pipelines.yml | 70 +++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 38 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 834a658ba4..317a95b19f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -93,34 +93,28 @@ jobs: TARGET: carbon maxParallel: 2 pool: - vmImage: 'ubuntu-20.04' + vmImage: 'ubuntu-22.04' steps: - checkout: self - submodules: true + submodules: false - script: | - docker run -i --name nix -v`pwd`:/src nixos/nix:2.18.1 < Date: Tue, 26 Dec 2023 23:25:43 +0100 Subject: [PATCH 44/61] use no-confirm option for nix installer --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 317a95b19f..1c41dc3a4b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -98,7 +98,7 @@ jobs: - checkout: self submodules: false - script: | - curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install + curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm displayName: Install Nix - script: | nix-env -iA cachix -f https://cachix.org/api/v1/install @@ -135,7 +135,7 @@ jobs: - checkout: self submodules: false - script: | - curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install + curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm displayName: Install Nix - script: | nix-env -iA cachix -f https://cachix.org/api/v1/install From d22b0d31843f165153ce8ae0a73819d57a4630d8 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 23:26:45 +0100 Subject: [PATCH 45/61] setup nx before checkout --- azure-pipelines.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1c41dc3a4b..678501b41f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -95,8 +95,6 @@ jobs: pool: vmImage: 'ubuntu-22.04' steps: - - checkout: self - submodules: false - script: | curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm displayName: Install Nix @@ -104,6 +102,8 @@ jobs: nix-env -iA cachix -f https://cachix.org/api/v1/install cachix use autc04 displayName: Setup Cachix + - checkout: self + submodules: false - script: | nix develop .#${TARGET} --profile dev-profile -c true nix build .#samples-${TARGET} --out-link=CompiledSamples @@ -132,8 +132,6 @@ jobs: pool: vmImage: 'macOS-11' steps: - - checkout: self - submodules: false - script: | curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm displayName: Install Nix @@ -141,6 +139,8 @@ jobs: nix-env -iA cachix -f https://cachix.org/api/v1/install cachix use autc04 displayName: Setup Cachix + - checkout: self + submodules: false - script: | nix develop .#${TARGET} --profile dev-profile -c true nix build .#samples-${TARGET} --out-link=CompiledSamples From ddfda03281c75e8684ee75a4e840a60260143d17 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 23:28:47 +0100 Subject: [PATCH 46/61] install cachix via nixpkgs#cachix --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 678501b41f..34d06aa689 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -99,7 +99,7 @@ jobs: curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm displayName: Install Nix - script: | - nix-env -iA cachix -f https://cachix.org/api/v1/install + nix profile install --accept-flake-config nixpkgs#cachix cachix use autc04 displayName: Setup Cachix - checkout: self @@ -136,7 +136,7 @@ jobs: curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm displayName: Install Nix - script: | - nix-env -iA cachix -f https://cachix.org/api/v1/install + nix profile install --accept-flake-config nixpkgs#cachix cachix use autc04 displayName: Setup Cachix - checkout: self From 193610a2e19a26d8ad9764216453dc8a856b307a Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 23:33:00 +0100 Subject: [PATCH 47/61] we want nix in path --- azure-pipelines.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 34d06aa689..2f2d65fb90 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -99,19 +99,21 @@ jobs: curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm displayName: Install Nix - script: | + . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh nix profile install --accept-flake-config nixpkgs#cachix cachix use autc04 displayName: Setup Cachix - checkout: self submodules: false - script: | + . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh nix develop .#${TARGET} --profile dev-profile -c true nix build .#samples-${TARGET} --out-link=CompiledSamples displayName: Build - publish: CompiledSamples artifact: Samples ($(TARGET)) - script: | - set -e + . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh export CACHIX_AUTH_TOKEN=$(CACHIX_AUTH_TOKEN) cachix push autc04 dev-profile cachix push autc04 CompiledSamples @@ -136,19 +138,21 @@ jobs: curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm displayName: Install Nix - script: | + . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh nix profile install --accept-flake-config nixpkgs#cachix cachix use autc04 displayName: Setup Cachix - checkout: self submodules: false - script: | + . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh nix develop .#${TARGET} --profile dev-profile -c true nix build .#samples-${TARGET} --out-link=CompiledSamples displayName: Build - publish: CompiledSamples artifact: Samples ($(TARGET)) - script: | - set -e + . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh export CACHIX_AUTH_TOKEN=$(CACHIX_AUTH_TOKEN) cachix push autc04 dev-profile cachix push autc04 CompiledSamples From d88e9aba553bfaeb678e6a70de257d385b246323 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 23:33:22 +0100 Subject: [PATCH 48/61] disable non-nix builds --- azure-pipelines.yml | 156 ++++++++++++++++++++++---------------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2f2d65fb90..fc731da84e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,84 +3,84 @@ trigger: jobs: -- job: Linux - pool: - vmImage: 'ubuntu-latest' - timeoutInMinutes: 90 - variables: - - group: Tokens - steps: - - checkout: self - submodules: true - - - task: Docker@2 - inputs: - command: build - repository: ghcr.io/autc04/retro68-build - tags: latest - arguments: --target build - displayName: 'Build' - - task: Docker@2 - inputs: - command: build - repository: ghcr.io/autc04/retro68 - tags: latest - arguments: --target release - displayName: 'Build release' - - script: | - docker run --name retro68-build --rm -i -d ghcr.io/autc04/retro68-build:latest - docker exec -i retro68-build /bin/bash <<"EOF" - cd /Retro68-build - curl -L -O https://github.com/autc04/executor/releases/download/v0.1.0/Executor2000-0.1.0-Linux.tar.bz2 - tar xfvj Executor2000-0.1.0-Linux.tar.bz2 Executor2000-0.1.0-Linux/bin/executor-headless - echo "executor-path=`pwd`/Executor2000-0.1.0-Linux/bin/executor-headless" > ~/.LaunchAPPL.cfg - echo "emulator=executor" >> ~/.LaunchAPPL.cfg - ctest --no-compress-output -T test -E Carbon || true - EOF - mkdir build && docker cp retro68-build:/Retro68-build/Testing build - docker stop retro68-build - displayName: Run Tests using Executor 2000 - - task: PublishTestResults@2 - inputs: - testResultsFormat: 'CTest' - testResultsFiles: build/Testing/**/*.xml - buildPlatform: 'x86_64-linux' - - script: | - docker login ghcr.io/autc04 -u autc04 -p $GHCR_TOKEN - docker push ghcr.io/autc04/retro68 - env: - GHCR_TOKEN: $(GHCR_TOKEN) - displayName: 'Push release to GHCR' - condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) - -- job: macOS - pool: - vmImage: 'macOS-11' - timeoutInMinutes: 90 - steps: - - checkout: self - submodules: true - - script: | - brew install boost cmake gmp mpfr libmpc bison - displayName: 'Brew prerequisites' - - script: | - mkdir build - cd build - ../build-toolchain.bash - displayName: Build - - script: | - cd build - curl -L -O https://github.com/autc04/executor/releases/download/v0.1.0/Executor2000-0.1.0-Darwin.tar.bz2 - tar xfvj Executor2000-0.1.0-Darwin.tar.bz2 Executor2000-0.1.0-Darwin/bin/executor-headless - echo "executor-path=`pwd`/Executor2000-0.1.0-Darwin/bin/executor-headless" > ~/.LaunchAPPL.cfg - echo "emulator=executor" >> ~/.LaunchAPPL.cfg - ctest --no-compress-output -T test -E Carbon || true - displayName: Run Tests using Executor 2000 - - task: PublishTestResults@2 - inputs: - testResultsFormat: 'CTest' - testResultsFiles: build/Testing/**/*.xml - buildPlatform: 'x86_64-macos' +#- job: Linux +# pool: +# vmImage: 'ubuntu-latest' +# timeoutInMinutes: 90 +# variables: +# - group: Tokens +# steps: +# - checkout: self +# submodules: true +# +# - task: Docker@2 +# inputs: +# command: build +# repository: ghcr.io/autc04/retro68-build +# tags: latest +# arguments: --target build +# displayName: 'Build' +# - task: Docker@2 +# inputs: +# command: build +# repository: ghcr.io/autc04/retro68 +# tags: latest +# arguments: --target release +# displayName: 'Build release' +# - script: | +# docker run --name retro68-build --rm -i -d ghcr.io/autc04/retro68-build:latest +# docker exec -i retro68-build /bin/bash <<"EOF" +# cd /Retro68-build +# curl -L -O https://github.com/autc04/executor/releases/download/v0.1.0/Executor2000-0.1.0-Linux.tar.bz2 +# tar xfvj Executor2000-0.1.0-Linux.tar.bz2 Executor2000-0.1.0-Linux/bin/executor-headless +# echo "executor-path=`pwd`/Executor2000-0.1.0-Linux/bin/executor-headless" > ~/.LaunchAPPL.cfg +# echo "emulator=executor" >> ~/.LaunchAPPL.cfg +# ctest --no-compress-output -T test -E Carbon || true +# EOF +# mkdir build && docker cp retro68-build:/Retro68-build/Testing build +# docker stop retro68-build +# displayName: Run Tests using Executor 2000 +# - task: PublishTestResults@2 +# inputs: +# testResultsFormat: 'CTest' +# testResultsFiles: build/Testing/**/*.xml +# buildPlatform: 'x86_64-linux' +# - script: | +# docker login ghcr.io/autc04 -u autc04 -p $GHCR_TOKEN +# docker push ghcr.io/autc04/retro68 +# env: +# GHCR_TOKEN: $(GHCR_TOKEN) +# displayName: 'Push release to GHCR' +# condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) +# +#- job: macOS +# pool: +# vmImage: 'macOS-11' +# timeoutInMinutes: 90 +# steps: +# - checkout: self +# submodules: true +# - script: | +# brew install boost cmake gmp mpfr libmpc bison +# displayName: 'Brew prerequisites' +# - script: | +# mkdir build +# cd build +# ../build-toolchain.bash +# displayName: Build +# - script: | +# cd build +# curl -L -O https://github.com/autc04/executor/releases/download/v0.1.0/Executor2000-0.1.0-Darwin.tar.bz2 +# tar xfvj Executor2000-0.1.0-Darwin.tar.bz2 Executor2000-0.1.0-Darwin/bin/executor-headless +# echo "executor-path=`pwd`/Executor2000-0.1.0-Darwin/bin/executor-headless" > ~/.LaunchAPPL.cfg +# echo "emulator=executor" >> ~/.LaunchAPPL.cfg +# ctest --no-compress-output -T test -E Carbon || true +# displayName: Run Tests using Executor 2000 +# - task: PublishTestResults@2 +# inputs: +# testResultsFormat: 'CTest' +# testResultsFiles: build/Testing/**/*.xml +# buildPlatform: 'x86_64-macos' - job: NixLinux strategy: From 3193ad031cf877e844e2673be88207b3dac9cca4 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 23:37:56 +0100 Subject: [PATCH 49/61] trust the right user for cache setup --- azure-pipelines.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fc731da84e..205682e5b0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -96,7 +96,8 @@ jobs: vmImage: 'ubuntu-22.04' steps: - script: | - curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm + curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix \ + | sh -s -- install --no-confirm --extra-conf "trusted-users = root vsts" displayName: Install Nix - script: | . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh @@ -135,7 +136,8 @@ jobs: vmImage: 'macOS-11' steps: - script: | - curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm + curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix \ + | sh -s -- install --no-confirm --extra-conf "trusted-users = root runner" displayName: Install Nix - script: | . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh From de58f40581d573931d42a3963de1a6c35d138753 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 23:50:25 +0100 Subject: [PATCH 50/61] try to fix a nixpkgs assert --- nix/overlay.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nix/overlay.nix b/nix/overlay.nix index c72172df31..4febc74aa1 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -251,7 +251,10 @@ pkgs: prevPkgs: { # binutils -- binutils with the wrappers provided by nixpkgs binutils = if (prevPkgs.targetPlatform ? retro68) then - pkgs.wrapBintoolsWith { bintools = pkgs.retro68.binutils_unwrapped; } + pkgs.wrapBintoolsWith { + bintools = pkgs.retro68.binutils_unwrapped; + libc = null; + } else prevPkgs.binutils; From 3c453c897fdcf7b2275c919628611d1c3993ca75 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 26 Dec 2023 23:52:27 +0100 Subject: [PATCH 51/61] fix --out-link option syntax --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 205682e5b0..682c4b7e31 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -109,7 +109,7 @@ jobs: - script: | . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh nix develop .#${TARGET} --profile dev-profile -c true - nix build .#samples-${TARGET} --out-link=CompiledSamples + nix build .#samples-${TARGET} --out-link CompiledSamples displayName: Build - publish: CompiledSamples artifact: Samples ($(TARGET)) @@ -149,7 +149,7 @@ jobs: - script: | . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh nix develop .#${TARGET} --profile dev-profile -c true - nix build .#samples-${TARGET} --out-link=CompiledSamples + nix build .#samples-${TARGET} --out-link CompiledSamples displayName: Build - publish: CompiledSamples artifact: Samples ($(TARGET)) From 1ee050839f97f9956345f511ad278b70a5372c66 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Wed, 27 Dec 2023 23:51:51 +0100 Subject: [PATCH 52/61] various fixes & workarounds for nix/mac --- nix/overlay.nix | 58 +++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/nix/overlay.nix b/nix/overlay.nix index 4febc74aa1..c15fb6f80d 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -32,6 +32,7 @@ pkgs: prevPkgs: { mkdir -p $out/share/man/man1 ''; configureFlags = [ "--mandir=$(out)/share/man" "--enable-devlibs" ]; + env.CFLAGS = "--std=c89"; # the configure script fails with modern C }; # tools -- native tools that are part of Retro68 @@ -116,8 +117,34 @@ pkgs: prevPkgs: { make -j$NIX_BUILD_CORES make install ''; + env.CXXFLAGS="--std=c++14"; # gcc 9 doesn't seem to like C++17 }; + # binutils -- binutils with the wrappers provided by nixpkgs + binutils = pkgs.wrapBintoolsWith { + bintools = pkgs.retro68.binutils_unwrapped; + libc = null; + }; + + # gcc -- gcc with the wrappers provided by nixpkgs + gcc = pkgs.wrapCCWith { + cc = pkgs.retro68.gcc_unwrapped; + bintools = pkgs.retro68.binutils; + libc = null; + + # don't allow nix to add options for hardening + extraBuildCommands = '' + echo "" > $out/nix-support/add-hardening.sh + ''; + + extraPackages = with pkgs.targetPackages.retro68; [ + multiversal + import_libraries + libretro + setup_hook + ]; + }; + } // prevPkgs.lib.optionalAttrs (prevPkgs.hostPlatform ? retro68) { setup_hook = let @@ -178,7 +205,7 @@ pkgs: prevPkgs: { }).mkDerivation { name = "retro68.multiversal"; src = multiversal_src; - nativeBuildInputs = [ buildPackages.ruby ]; + nativeBuildInputs = [ pkgsBuildBuild.ruby ]; buildCommand = '' echo $src build=`pwd` @@ -249,34 +276,17 @@ pkgs: prevPkgs: { # ----------- Binutils & GCC wrapped for nixpkgs ------------- - # binutils -- binutils with the wrappers provided by nixpkgs + # binutils -- binutils with the wrappers provided by nixpkgs + # note: on nix/darwin (as of nixpkgs 23.11), nixpkgs seems to + # ignore (or re-override) this override. binutils = if (prevPkgs.targetPlatform ? retro68) then - pkgs.wrapBintoolsWith { - bintools = pkgs.retro68.binutils_unwrapped; - libc = null; - } + pkgs.retro68.binutils else prevPkgs.binutils; - + # gcc -- gcc with the wrappers provided by nixpkgs gcc = if (prevPkgs.targetPlatform ? retro68) then - pkgs.wrapCCWith { - cc = pkgs.retro68.gcc_unwrapped; - bintools = pkgs.binutils; - libc = null; - - # don't allow nix to add options for hardening - extraBuildCommands = '' - echo "" > $out/nix-support/add-hardening.sh - ''; - - extraPackages = with pkgs.targetPackages.retro68; [ - multiversal - import_libraries - libretro - setup_hook - ]; - } + pkgs.retro68.gcc else prevPkgs.gcc; } From ede7d46d0e6704eda0e46d7ec29c7ce981e274bb Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Thu, 28 Dec 2023 00:59:39 +0100 Subject: [PATCH 53/61] hfsutils: add missing includes --- hfsutils/libhfs/data.h | 2 ++ hfsutils/librsrc/data.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/hfsutils/libhfs/data.h b/hfsutils/libhfs/data.h index fd38e75c46..8bebfb78ea 100644 --- a/hfsutils/libhfs/data.h +++ b/hfsutils/libhfs/data.h @@ -19,6 +19,8 @@ * $Id: data.h,v 1.7 1998/11/02 22:08:58 rob Exp $ */ +#include + extern const unsigned char hfs_charorder[]; signed char d_getsb(register const unsigned char *); diff --git a/hfsutils/librsrc/data.h b/hfsutils/librsrc/data.h index 6e5d644ee0..9fdb75cbc1 100644 --- a/hfsutils/librsrc/data.h +++ b/hfsutils/librsrc/data.h @@ -19,6 +19,8 @@ * $Id: data.h,v 1.5 1998/04/11 08:27:18 rob Exp $ */ +# include + extern const unsigned char hfs_charorder[]; signed char d_getsb(const unsigned char *); From 08baa1ab702b473d088a1fa341a6983a7227828e Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Thu, 28 Dec 2023 20:40:19 +0100 Subject: [PATCH 54/61] use macos-latest and ubuntu-latest for nix builds --- azure-pipelines.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 682c4b7e31..897058e1f0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -93,7 +93,7 @@ jobs: TARGET: carbon maxParallel: 2 pool: - vmImage: 'ubuntu-22.04' + vmImage: 'ubuntu-latest' steps: - script: | curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix \ @@ -133,7 +133,7 @@ jobs: TARGET: carbon maxParallel: 2 pool: - vmImage: 'macOS-11' + vmImage: 'macOS-latest' steps: - script: | curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix \ @@ -151,8 +151,6 @@ jobs: nix develop .#${TARGET} --profile dev-profile -c true nix build .#samples-${TARGET} --out-link CompiledSamples displayName: Build - - publish: CompiledSamples - artifact: Samples ($(TARGET)) - script: | . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh export CACHIX_AUTH_TOKEN=$(CACHIX_AUTH_TOKEN) @@ -160,6 +158,3 @@ jobs: cachix push autc04 CompiledSamples displayName: Push to Cachix condition: and(succeeded(), ne(variables['CACHIX_AUTH_TOKEN'], '')) - - #export NIX_EXTRA_CONF="trusted-users = root runner" - #. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh From db9c28db76f6b9147f93d274cbf8cfe2a1326f2a Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Thu, 28 Dec 2023 20:40:32 +0100 Subject: [PATCH 55/61] crossPkgs -> pkgsCross --- flake.nix | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/flake.nix b/flake.nix index 5a8c8d6b06..d410e397f0 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,7 @@ { _module.args.pkgs = import nixpkgs { inherit system; overlays = [ self.overlays.default ]; }; - legacyPackages.crossPkgs = lib.mapAttrs + legacyPackages.pkgsCross = lib.mapAttrs (name: plat: import nixpkgs { inherit system; @@ -46,7 +46,7 @@ ]; buildInputs = [ cross.retro68.console ]; } // cross) - self'.legacyPackages.crossPkgs; + self'.legacyPackages.pkgsCross; packages = { tools = pkgs.retro68.tools; @@ -56,31 +56,31 @@ mkdir $out mkdir $out/m68k-apple-macos mkdir $out/powerpc-apple-macos - ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.m68k.retro68.libretro}/. $out/m68k-apple-macos - ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.m68k.retro68.multiversal}/. $out/m68k-apple-macos - ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.powerpc.retro68.libretro}/. $out/powerpc-apple-macos - ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.powerpc.retro68.multiversal}/. $out/powerpc-apple-macos - ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.carbon.retro68.libretro}/. $out/powerpc-apple-macos - ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.crossPkgs.carbon.retro68.multiversal}/. $out/powerpc-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.pkgsCross.m68k.retro68.libretro}/. $out/m68k-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.pkgsCross.m68k.retro68.multiversal}/. $out/m68k-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.pkgsCross.powerpc.retro68.libretro}/. $out/powerpc-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.pkgsCross.powerpc.retro68.multiversal}/. $out/powerpc-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.pkgsCross.carbon.retro68.libretro}/. $out/powerpc-apple-macos + ${pkgs.xorg.lndir}/bin/lndir -silent ${self'.legacyPackages.pkgsCross.carbon.retro68.multiversal}/. $out/powerpc-apple-macos ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.retro68.tools}/. $out ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.retro68.hfsutils}/. $out ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.cmake}/. $out ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.gnumake}/. $out ${pkgs.xorg.lndir}/bin/lndir -silent ${pkgs.ninja}/. $out - ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.crossPkgs.m68k.buildPackages.retro68.gcc_unwrapped}/. $out - ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.crossPkgs.powerpc.buildPackages.retro68.gcc_unwrapped}/. $out - ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.crossPkgs.carbon.buildPackages.retro68.gcc_unwrapped}/. $out + ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.pkgsCross.m68k.buildPackages.retro68.gcc_unwrapped}/. $out + ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.pkgsCross.powerpc.buildPackages.retro68.gcc_unwrapped}/. $out + ${pkgs.rsync}/bin/rsync -a ${self'.legacyPackages.pkgsCross.carbon.buildPackages.retro68.gcc_unwrapped}/. $out ''; samples = pkgs.linkFarm "Retro68-Samples" [ - { name = "m68k"; path = self'.legacyPackages.crossPkgs.m68k.retro68.samples; } - { name = "powerpc"; path = self'.legacyPackages.crossPkgs.powerpc.retro68.samples; } - { name = "carbon"; path = self'.legacyPackages.crossPkgs.carbon.retro68.samples; } + { name = "m68k"; path = self'.legacyPackages.pkgsCross.m68k.retro68.samples; } + { name = "powerpc"; path = self'.legacyPackages.pkgsCross.powerpc.retro68.samples; } + { name = "carbon"; path = self'.legacyPackages.pkgsCross.carbon.retro68.samples; } ]; } // lib.mapAttrs' (name: cross: lib.nameValuePair "samples-${name}" cross.retro68.samples) - self'.legacyPackages.crossPkgs; + self'.legacyPackages.pkgsCross; }; flake = { overlays.default = From 504108a43ae2cec2232cdde57d5510a896007d3d Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Thu, 28 Dec 2023 20:57:54 +0100 Subject: [PATCH 56/61] deprecate default.nix --- default.nix | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/default.nix b/default.nix index 8285c81524..988cf902f0 100644 --- a/default.nix +++ b/default.nix @@ -1,10 +1,9 @@ let sources = import ./nix/sources.nix; -in { system ? builtins.currentSystem, nixpkgs ? sources.nixpkgs, - multiversal_src ? if builtins.pathExists ./multiversal/make-multiverse.rb then - ./multiversal - else - sources.multiversal, - ... }: +in { system ? builtins.currentSystem, nixpkgs ? sources.nixpkgs +, multiversal_src ? if builtins.pathExists ./multiversal/make-multiverse.rb then + ./multiversal +else + sources.multiversal, ... }: let retroPlatforms = import nix/platforms.nix; @@ -30,8 +29,7 @@ let crossSystem = plat; config = { allowUnsupportedSystem = true; }; }) retroPlatforms; - targetPkgs = lib.mapAttrs (name: cross: - cross.buildPackages) crossPkgs; + targetPkgs = lib.mapAttrs (name: cross: cross.buildPackages) crossPkgs; shell = lib.mapAttrs (name: cross: cross.mkShell { @@ -44,8 +42,10 @@ let buildInputs = [ cross.retro68.console ]; } // cross) crossPkgs; -in shell.m68k // shell // { +in builtins.trace +"Warning: Retro68's default.nix is deprecated and will disappear soon. Please use the flake instead." +(shell.m68k // shell // { inherit overlay; inherit (overlaidPkgs) retro68; targetPkg = targetPkgs; -} +}) From e0d73d5329d2304a5633d7814e5e48b7e420425a Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Thu, 28 Dec 2023 21:34:56 +0100 Subject: [PATCH 57/61] update README for nix flakes --- README.md | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 9652577e2c..ce0ddf1285 100644 --- a/README.md +++ b/README.md @@ -155,37 +155,39 @@ Using Retro68 with Nix If you are not using the [Nix Package Manager](https://www.nixos.org), please skip this section. But maybe you should be using it ;-). Nix is a package manager that runs on Linux and macOS, and NixOS is a Linux distribution based on it. +Try the [Determinate Nix Installer](https://install.determinate.systems/) for the best installation experience. -If you've got `nix` installed, after downloading Retro68, you can run +[TODO: docs on using the binary cache to avoid builds] - nix-shell +Once you've got `nix` installed, and without checking out the Retro68 repository, you can run + + nix develop github:autc04/Retro68#m68k from the Retro68 directory to get a shell with the compiler tools targeting 68K Macs available in the path, and `CC` and other environment variables already set up for you. You can then `cd` to one of the example directories or to your own project and use `cmake` to build it. -You can use the `nix-shell` command to invoke various useful shell environments: +Likewise, use -| Command | What | -|-------------------------------------|----------------------------------------------| -| `nix-shell` | 68K development environment | -| `nix-shell -A m68k` | 68K development environment | -| `nix-shell -A powerpc` | PowerPC development environment | -| `nix-shell -A retro68.monolithic` | Shell for running `build-toolchain.bash` | + nix develop github:autc04/Retro68#powerpc -You can also use the `nix-build` command to build packages. As always with `nix`, +... to get an environment targeting PowerPC Macs. + +If you have a local checkout of Retro68, you can replace `github:autc04/Retro68` by the path +to that local checkout, e.g., run `nix develop .#m68k` from inside the Retro68 directory. + +You can also use the `nix build` command to build packages. As always with `nix`, the result will be somewhere in a subdirectory of `/nix/store`, with a symlink -named `result` placed in your Retro68 directory. +named `result` placed in the directory where you invoked the command. -| Command | What | -|----------------------------------------|----------------------------------------------| -| `nix-build -A m68k.retro68.samples` | Sample programs for 68K | -| `nix-build -A powerpc.retro68.samples` | Sample programs for PowerPC | -| `nix-build -A retro68.monolithic` | Result of `build-toolchain.bash --no-carbon` | -| `nix-build -A m68k.zlib` | zlib library, cross-compiled for 68K Macs | -| `nix-build -A m68k.`*packagename* | cross-compile *packagename* to 68K | -| `nix-build -A powerpc.`*packagename* | cross-compile *packagename* to PowerPC | +| Command | What | +|--------------------------------------------------------------------|-------------------------------------------| +| `nix build github:autc04/Retro68#samples-m68k` | Sample programs for 68K | +| `nix build github:autc04/Retro68#samples-powerpc` | Sample programs for PowerPC | +| `nix build github:autc04/Retro68#pkgsCross.m68k.zlib` | zlib library, cross-compiled for 68K Macs | +| `nix build github:autc04/Retro68#pkgsCross.m68k.`*packagename* | cross-compile *packagename* to 68K | +| `nnix build github:autc04/Retro68#pkgsCross.powerpc.`*packagename* | cross-compile *packagename* to PowerPC | You can attempt to cross-compile *any* package from the `nixpkgs` collection. Unless the package contains a very portable library, the command will of course fail. Please don't From 3516d8ca44546b33d5641f535d6411f1a4fbdff8 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Thu, 28 Dec 2023 22:25:29 +0100 Subject: [PATCH 58/61] no reason to limit parallelism for the nix builds (yet, until the carbon & powerpc builds actually share a package) --- azure-pipelines.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 897058e1f0..57d5b080b1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -91,7 +91,6 @@ jobs: TARGET: powerpc Carbon: TARGET: carbon - maxParallel: 2 pool: vmImage: 'ubuntu-latest' steps: @@ -131,7 +130,6 @@ jobs: TARGET: powerpc Carbon: TARGET: carbon - maxParallel: 2 pool: vmImage: 'macOS-latest' steps: From 8063e142d74ea27eb97141b854cfcfd6a4a57015 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Thu, 28 Dec 2023 22:26:23 +0100 Subject: [PATCH 59/61] re-enable regular build --- azure-pipelines.yml | 156 ++++++++++++++++++++++---------------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 57d5b080b1..d13df78d82 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,84 +3,84 @@ trigger: jobs: -#- job: Linux -# pool: -# vmImage: 'ubuntu-latest' -# timeoutInMinutes: 90 -# variables: -# - group: Tokens -# steps: -# - checkout: self -# submodules: true -# -# - task: Docker@2 -# inputs: -# command: build -# repository: ghcr.io/autc04/retro68-build -# tags: latest -# arguments: --target build -# displayName: 'Build' -# - task: Docker@2 -# inputs: -# command: build -# repository: ghcr.io/autc04/retro68 -# tags: latest -# arguments: --target release -# displayName: 'Build release' -# - script: | -# docker run --name retro68-build --rm -i -d ghcr.io/autc04/retro68-build:latest -# docker exec -i retro68-build /bin/bash <<"EOF" -# cd /Retro68-build -# curl -L -O https://github.com/autc04/executor/releases/download/v0.1.0/Executor2000-0.1.0-Linux.tar.bz2 -# tar xfvj Executor2000-0.1.0-Linux.tar.bz2 Executor2000-0.1.0-Linux/bin/executor-headless -# echo "executor-path=`pwd`/Executor2000-0.1.0-Linux/bin/executor-headless" > ~/.LaunchAPPL.cfg -# echo "emulator=executor" >> ~/.LaunchAPPL.cfg -# ctest --no-compress-output -T test -E Carbon || true -# EOF -# mkdir build && docker cp retro68-build:/Retro68-build/Testing build -# docker stop retro68-build -# displayName: Run Tests using Executor 2000 -# - task: PublishTestResults@2 -# inputs: -# testResultsFormat: 'CTest' -# testResultsFiles: build/Testing/**/*.xml -# buildPlatform: 'x86_64-linux' -# - script: | -# docker login ghcr.io/autc04 -u autc04 -p $GHCR_TOKEN -# docker push ghcr.io/autc04/retro68 -# env: -# GHCR_TOKEN: $(GHCR_TOKEN) -# displayName: 'Push release to GHCR' -# condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) -# -#- job: macOS -# pool: -# vmImage: 'macOS-11' -# timeoutInMinutes: 90 -# steps: -# - checkout: self -# submodules: true -# - script: | -# brew install boost cmake gmp mpfr libmpc bison -# displayName: 'Brew prerequisites' -# - script: | -# mkdir build -# cd build -# ../build-toolchain.bash -# displayName: Build -# - script: | -# cd build -# curl -L -O https://github.com/autc04/executor/releases/download/v0.1.0/Executor2000-0.1.0-Darwin.tar.bz2 -# tar xfvj Executor2000-0.1.0-Darwin.tar.bz2 Executor2000-0.1.0-Darwin/bin/executor-headless -# echo "executor-path=`pwd`/Executor2000-0.1.0-Darwin/bin/executor-headless" > ~/.LaunchAPPL.cfg -# echo "emulator=executor" >> ~/.LaunchAPPL.cfg -# ctest --no-compress-output -T test -E Carbon || true -# displayName: Run Tests using Executor 2000 -# - task: PublishTestResults@2 -# inputs: -# testResultsFormat: 'CTest' -# testResultsFiles: build/Testing/**/*.xml -# buildPlatform: 'x86_64-macos' +- job: Linux + pool: + vmImage: 'ubuntu-latest' + timeoutInMinutes: 90 + variables: + - group: Tokens + steps: + - checkout: self + submodules: true + + - task: Docker@2 + inputs: + command: build + repository: ghcr.io/autc04/retro68-build + tags: latest + arguments: --target build + displayName: 'Build' + - task: Docker@2 + inputs: + command: build + repository: ghcr.io/autc04/retro68 + tags: latest + arguments: --target release + displayName: 'Build release' + - script: | + docker run --name retro68-build --rm -i -d ghcr.io/autc04/retro68-build:latest + docker exec -i retro68-build /bin/bash <<"EOF" + cd /Retro68-build + curl -L -O https://github.com/autc04/executor/releases/download/v0.1.0/Executor2000-0.1.0-Linux.tar.bz2 + tar xfvj Executor2000-0.1.0-Linux.tar.bz2 Executor2000-0.1.0-Linux/bin/executor-headless + echo "executor-path=`pwd`/Executor2000-0.1.0-Linux/bin/executor-headless" > ~/.LaunchAPPL.cfg + echo "emulator=executor" >> ~/.LaunchAPPL.cfg + ctest --no-compress-output -T test -E Carbon || true + EOF + mkdir build && docker cp retro68-build:/Retro68-build/Testing build + docker stop retro68-build + displayName: Run Tests using Executor 2000 + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'CTest' + testResultsFiles: build/Testing/**/*.xml + buildPlatform: 'x86_64-linux' + - script: | + docker login ghcr.io/autc04 -u autc04 -p $GHCR_TOKEN + docker push ghcr.io/autc04/retro68 + env: + GHCR_TOKEN: $(GHCR_TOKEN) + displayName: 'Push release to GHCR' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) + +- job: macOS + pool: + vmImage: 'macOS-11' + timeoutInMinutes: 90 + steps: + - checkout: self + submodules: true + - script: | + brew install boost cmake gmp mpfr libmpc bison + displayName: 'Brew prerequisites' + - script: | + mkdir build + cd build + ../build-toolchain.bash + displayName: Build + - script: | + cd build + curl -L -O https://github.com/autc04/executor/releases/download/v0.1.0/Executor2000-0.1.0-Darwin.tar.bz2 + tar xfvj Executor2000-0.1.0-Darwin.tar.bz2 Executor2000-0.1.0-Darwin/bin/executor-headless + echo "executor-path=`pwd`/Executor2000-0.1.0-Darwin/bin/executor-headless" > ~/.LaunchAPPL.cfg + echo "emulator=executor" >> ~/.LaunchAPPL.cfg + ctest --no-compress-output -T test -E Carbon || true + displayName: Run Tests using Executor 2000 + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'CTest' + testResultsFiles: build/Testing/**/*.xml + buildPlatform: 'x86_64-macos' - job: NixLinux strategy: From 09e4e34c41f4aaec13bac5ecc065e89dfe2e58c4 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Thu, 28 Dec 2023 22:29:24 +0100 Subject: [PATCH 60/61] disable garnix for now --- garnix.yaml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 garnix.yaml diff --git a/garnix.yaml b/garnix.yaml new file mode 100644 index 0000000000..e391f4b267 --- /dev/null +++ b/garnix.yaml @@ -0,0 +1,4 @@ +# turn off garnix for now +builds: + include: [] + exclude: [] From b6b30d2c10587f8cc0dc96cd848695267270a619 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Thu, 28 Dec 2023 23:50:29 +0100 Subject: [PATCH 61/61] setup nix source formatter --- default.nix | 67 ++++++++++++--------- flake.nix | 9 ++- nix/overlay.nix | 150 ++++++++++++++++++++++++---------------------- nix/samples.nix | 31 +++++----- nix/universal.nix | 97 +++++++++++++++--------------- 5 files changed, 189 insertions(+), 165 deletions(-) diff --git a/default.nix b/default.nix index 988cf902f0..134286e3c9 100644 --- a/default.nix +++ b/default.nix @@ -1,9 +1,12 @@ let sources = import ./nix/sources.nix; -in { system ? builtins.currentSystem, nixpkgs ? sources.nixpkgs -, multiversal_src ? if builtins.pathExists ./multiversal/make-multiverse.rb then - ./multiversal -else - sources.multiversal, ... }: +in { system ? builtins.currentSystem + , nixpkgs ? sources.nixpkgs + , multiversal_src ? if builtins.pathExists ./multiversal/make-multiverse.rb then + ./multiversal + else + sources.multiversal + , ... + }: let retroPlatforms = import nix/platforms.nix; @@ -22,30 +25,36 @@ let overlays = [ overlay ]; }; - crossPkgs = lib.mapAttrs (name: plat: - import nixpkgs { - inherit system; - overlays = [ overlay ]; - crossSystem = plat; - config = { allowUnsupportedSystem = true; }; - }) retroPlatforms; + crossPkgs = lib.mapAttrs + (name: plat: + import nixpkgs { + inherit system; + overlays = [ overlay ]; + crossSystem = plat; + config = { allowUnsupportedSystem = true; }; + }) + retroPlatforms; targetPkgs = lib.mapAttrs (name: cross: cross.buildPackages) crossPkgs; - shell = lib.mapAttrs (name: cross: - cross.mkShell { - nativeBuildInputs = with overlaidPkgs; [ - retro68.hfsutils - retro68.tools - cmake - gnumake - ]; - buildInputs = [ cross.retro68.console ]; - } // cross) crossPkgs; + shell = lib.mapAttrs + (name: cross: + cross.mkShell + { + nativeBuildInputs = with overlaidPkgs; [ + retro68.hfsutils + retro68.tools + cmake + gnumake + ]; + buildInputs = [ cross.retro68.console ]; + } // cross) + crossPkgs; -in builtins.trace -"Warning: Retro68's default.nix is deprecated and will disappear soon. Please use the flake instead." -(shell.m68k // shell // { - inherit overlay; - inherit (overlaidPkgs) retro68; - targetPkg = targetPkgs; -}) +in +builtins.trace + "Warning: Retro68's default.nix is deprecated and will disappear soon. Please use the flake instead." + (shell.m68k // shell // { + inherit overlay; + inherit (overlaidPkgs) retro68; + targetPkg = targetPkgs; + }) diff --git a/flake.nix b/flake.nix index d410e397f0..846a412da6 100644 --- a/flake.nix +++ b/flake.nix @@ -18,6 +18,8 @@ { _module.args.pkgs = import nixpkgs { inherit system; overlays = [ self.overlays.default ]; }; + formatter = pkgs.nixpkgs-fmt; + legacyPackages.pkgsCross = lib.mapAttrs (name: plat: import nixpkgs { @@ -52,7 +54,7 @@ tools = pkgs.retro68.tools; hfsutils = pkgs.retro68.hfsutils; - default = pkgs.runCommand "Retro68" {} '' + default = pkgs.runCommand "Retro68" { } '' mkdir $out mkdir $out/m68k-apple-macos mkdir $out/powerpc-apple-macos @@ -85,8 +87,9 @@ flake = { overlays.default = lib.composeManyExtensions [ - ((import nix/overlay.nix) { - multiversal_src = if builtins.pathExists ./multiversal/make-multiverse.rb + ((import nix/overlay.nix) { + multiversal_src = + if builtins.pathExists ./multiversal/make-multiverse.rb then ./multiversal else multiversal; }) diff --git a/nix/overlay.nix b/nix/overlay.nix index c15fb6f80d..694f272813 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -10,7 +10,7 @@ pkgs: prevPkgs: { src = ../.; nativeBuildInputs = [ cmake bison flex ruby ninja bash ]; buildInputs = [ boost gmp mpfr libmpc zlib ] - ++ lib.optional hostPlatform.isDarwin + ++ lib.optional hostPlatform.isDarwin darwin.apple_sdk.frameworks.ApplicationServices; buildCommand = '' bash $src/build-toolchain.bash --ninja --prefix=$out --no-carbon @@ -56,7 +56,7 @@ pkgs: prevPkgs: { nativeBuildInputs = [ cmake bison flex ]; buildInputs = [ boost zlib retro68.hfsutils ] - ++ lib.optional hostPlatform.isDarwin + ++ lib.optional hostPlatform.isDarwin darwin.apple_sdk.frameworks.ApplicationServices; }; @@ -75,15 +75,17 @@ pkgs: prevPkgs: { ++ stdenv.targetPlatform.retro68BinutilsConfig or [ ]; enableParallelBuilding = true; - postInstall = let - ld = "$out/bin/${stdenv.targetPlatform.config}-ld"; - ld_real = "$out/bin/${stdenv.targetPlatform.config}-ld.real"; + postInstall = + let + ld = "$out/bin/${stdenv.targetPlatform.config}-ld"; + ld_real = "$out/bin/${stdenv.targetPlatform.config}-ld.real"; - in '' - mv ${ld} ${ld_real} + in + '' + mv ${ld} ${ld_real} - echo "#!${stdenv.shell}" > ${ld} - echo "exec \$'' + '' + echo "#!${stdenv.shell}" > ${ld} + echo "exec \$'' + '' {RETRO68_LD_WRAPPER_${stdenv.targetPlatform.cmakeSystemName}-${ld_real}} \"\$@\"" >> ${ld} chmod +x ${ld} @@ -117,12 +119,12 @@ pkgs: prevPkgs: { make -j$NIX_BUILD_CORES make install ''; - env.CXXFLAGS="--std=c++14"; # gcc 9 doesn't seem to like C++17 + env.CXXFLAGS = "--std=c++14"; # gcc 9 doesn't seem to like C++17 }; # binutils -- binutils with the wrappers provided by nixpkgs - binutils = pkgs.wrapBintoolsWith { - bintools = pkgs.retro68.binutils_unwrapped; + binutils = pkgs.wrapBintoolsWith { + bintools = pkgs.retro68.binutils_unwrapped; libc = null; }; @@ -147,54 +149,56 @@ pkgs: prevPkgs: { } // prevPkgs.lib.optionalAttrs (prevPkgs.hostPlatform ? retro68) { - setup_hook = let - systemName = pkgs.targetPlatform.cmakeSystemName; - toolchain = pkgs.writeTextFile { - name = "retro68.cmake-toolchain"; - text = '' - set(CMAKE_SYSTEM_NAME ${systemName}) - set(CMAKE_SYSTEM_VERSION 1) - set(CMAKE_CROSSCOMPILING TRUE) + setup_hook = + let + systemName = pkgs.targetPlatform.cmakeSystemName; + toolchain = pkgs.writeTextFile { + name = "retro68.cmake-toolchain"; + text = '' + set(CMAKE_SYSTEM_NAME ${systemName}) + set(CMAKE_SYSTEM_VERSION 1) + set(CMAKE_CROSSCOMPILING TRUE) - set(REZ "${pkgs.buildPackages.retro68.tools}/bin/Rez" ) - set(REZ_TEMPLATES_PATH ${pkgs.retro68.libretro}/RIncludes) + set(REZ "${pkgs.buildPackages.retro68.tools}/bin/Rez" ) + set(REZ_TEMPLATES_PATH ${pkgs.retro68.libretro}/RIncludes) - set(MAKE_PEF "${pkgs.buildPackages.retro68.tools}/bin/MakePEF" ) + set(MAKE_PEF "${pkgs.buildPackages.retro68.tools}/bin/MakePEF" ) - include(${../cmake/add_application.cmake}) - '' + (pkgs.lib.optionalString (systemName == "RetroCarbon") '' - set(CMAKE_EXE_LINKER_FLAGS_INIT "-carbon") - set(CMAKE_SHARED_LINKER_FLAGS_INIT "-carbon") - add_definitions( -DTARGET_API_MAC_CARBON=1 ) - ''); - }; - hook = pkgs.writeTextFile { - name = "retro68.setup_hook"; - text = '' - export CMAKE_TOOLCHAIN_FILE=${toolchain} + include(${../cmake/add_application.cmake}) + '' + (pkgs.lib.optionalString (systemName == "RetroCarbon") '' + set(CMAKE_EXE_LINKER_FLAGS_INIT "-carbon") + set(CMAKE_SHARED_LINKER_FLAGS_INIT "-carbon") + add_definitions( -DTARGET_API_MAC_CARBON=1 ) + ''); + }; + hook = pkgs.writeTextFile { + name = "retro68.setup_hook"; + text = '' + export CMAKE_TOOLCHAIN_FILE=${toolchain} - retro68_addRIncludes() { - case $depHostOffset in - -1) local role='BUILD_' ;; - 0) local role="" ;; - 1) local role='TARGET_' ;; - *) echo "retro68_addRIncludes: Error: Cannot be used with $depHostOffset-offset deps" >2; - return 1 ;; - esac + retro68_addRIncludes() { + case $depHostOffset in + -1) local role='BUILD_' ;; + 0) local role="" ;; + 1) local role='TARGET_' ;; + *) echo "retro68_addRIncludes: Error: Cannot be used with $depHostOffset-offset deps" >2; + return 1 ;; + esac - if [[ -d "$1/RIncludes" ]]; then - export REZ_INCLUDE_PATH+=":$1/RIncludes" - fi - } + if [[ -d "$1/RIncludes" ]]; then + export REZ_INCLUDE_PATH+=":$1/RIncludes" + fi + } - addEnvHooks "$targetOffset" retro68_addRIncludes + addEnvHooks "$targetOffset" retro68_addRIncludes - '' + (pkgs.lib.optionalString (systemName == "Retro68") '' - export RETRO68_LD_WRAPPER_Retro68="${pkgs.buildPackages.retro68.tools}/bin/Elf2Mac" - export RETRO68_REAL_LD="${pkgs.buildPackages.retro68.binutils_unwrapped}/bin/m68k-apple-macos-ld.real" - ''); - }; - in pkgs.makeSetupHook { name = "retro68.setup_hook"; } hook; + '' + (pkgs.lib.optionalString (systemName == "Retro68") '' + export RETRO68_LD_WRAPPER_Retro68="${pkgs.buildPackages.retro68.tools}/bin/Elf2Mac" + export RETRO68_REAL_LD="${pkgs.buildPackages.retro68.binutils_unwrapped}/bin/m68k-apple-macos-ld.real" + ''); + }; + in + pkgs.makeSetupHook { name = "retro68.setup_hook"; } hook; # ----------- Retro68 core libraries ------------- @@ -221,14 +225,15 @@ pkgs: prevPkgs: { import_libraries = with pkgs; if stdenvNoCC.targetPlatform.system != "m68k-macos" then - stdenvNoCC.mkDerivation { - name = "retro68.import_libraries"; - src = ../ImportLibraries; - buildCommand = '' - mkdir -p $out/lib - cp $src/*.a $out/lib/ - ''; - } + stdenvNoCC.mkDerivation + { + name = "retro68.import_libraries"; + src = ../ImportLibraries; + buildCommand = '' + mkdir -p $out/lib + cp $src/*.a $out/lib/ + ''; + } else null; @@ -243,7 +248,8 @@ pkgs: prevPkgs: { set(CMAKE_CROSSCOMPILING TRUE) ''; }; - in (pkgs.stdenv.override { + in + (pkgs.stdenv.override { cc = stdenv.cc.override { extraPackages = [ ]; }; }).mkDerivation { name = "libretro"; @@ -279,14 +285,16 @@ pkgs: prevPkgs: { # binutils -- binutils with the wrappers provided by nixpkgs # note: on nix/darwin (as of nixpkgs 23.11), nixpkgs seems to # ignore (or re-override) this override. - binutils = if (prevPkgs.targetPlatform ? retro68) then - pkgs.retro68.binutils - else - prevPkgs.binutils; - + binutils = + if (prevPkgs.targetPlatform ? retro68) then + pkgs.retro68.binutils + else + prevPkgs.binutils; + # gcc -- gcc with the wrappers provided by nixpkgs - gcc = if (prevPkgs.targetPlatform ? retro68) then - pkgs.retro68.gcc - else - prevPkgs.gcc; + gcc = + if (prevPkgs.targetPlatform ? retro68) then + pkgs.retro68.gcc + else + prevPkgs.gcc; } diff --git a/nix/samples.nix b/nix/samples.nix index 24f9ac71d7..3c4d9e4d19 100644 --- a/nix/samples.nix +++ b/nix/samples.nix @@ -2,18 +2,20 @@ pkgs: prevPkgs: { retro68 = prevPkgs.retro68.overrideScope' (self: prevRetro: { samples = with pkgs; let - individualSamples = lib.mapAttrs (key: path: - stdenv.mkDerivation { - name = "retro68.samples." + key; - src = path; - nativeBuildInputs = [ buildPackages.ninja buildPackages.cmake ]; - buildInputs = [ retro68.console ]; - installPhase = '' - mkdir $out - cp *.bin $out/ - rm -f $out/*.code.bin $out/*.rsrc.bin - ''; - }) ({ + individualSamples = lib.mapAttrs + (key: path: + stdenv.mkDerivation { + name = "retro68.samples." + key; + src = path; + nativeBuildInputs = [ buildPackages.ninja buildPackages.cmake ]; + buildInputs = [ retro68.console ]; + installPhase = '' + mkdir $out + cp *.bin $out/ + rm -f $out/*.code.bin $out/*.rsrc.bin + ''; + }) + ({ dialog = ../Samples/Dialog; helloworld = ../Samples/HelloWorld; raytracer = ../Samples/Raytracer; @@ -25,8 +27,9 @@ pkgs: prevPkgs: { } // lib.optionalAttrs (targetPlatform.cmakeSystemName == "Retro68") { systemextension = ../Samples/SystemExtension; launcher = ../Samples/Launcher; - }) // { launchapplserver = self.launchapplserver; }; - in runCommand "retro68.samples" { } '' + }) // { launchapplserver = self.launchapplserver; }; + in + runCommand "retro68.samples" { } '' mkdir -p $out/ ${lib.concatMapStrings (x: '' diff --git a/nix/universal.nix b/nix/universal.nix index 96d9bf38a1..4648ef0db5 100644 --- a/nix/universal.nix +++ b/nix/universal.nix @@ -1,58 +1,59 @@ pkgs: prevPkgs: { - retro68 = if !(prevPkgs.hostPlatform ? retro68) then - prevPkgs.retro68 - else - prevPkgs.retro68.overrideScope' (self: prevRetro: { + retro68 = + if !(prevPkgs.hostPlatform ? retro68) then + prevPkgs.retro68 + else + prevPkgs.retro68.overrideScope' (self: prevRetro: { - mpw_35_gm = with pkgs; - fetchurl { - url = - "https://web.archive.org/web/20210309154524/https://staticky.com/mirrors/ftp.apple.com/developer/Tool_Chest/Core_Mac_OS_Tools/MPW_etc./MPW-GM_Images/MPW-GM.img.bin"; - sha256 = "0wm8dwmm0cpp8px27in564ih27sn5vbydz3jqpzwh04qpfazmfwr"; - }; + mpw_35_gm = with pkgs; + fetchurl { + url = + "https://web.archive.org/web/20210309154524/https://staticky.com/mirrors/ftp.apple.com/developer/Tool_Chest/Core_Mac_OS_Tools/MPW_etc./MPW-GM_Images/MPW-GM.img.bin"; + sha256 = "0wm8dwmm0cpp8px27in564ih27sn5vbydz3jqpzwh04qpfazmfwr"; + }; - universal = with pkgs; - stdenvNoCC.mkDerivation { - name = "retro68.universal"; - src = retro68.mpw_35_gm; - nativeBuildInputs = with buildPackages.retro68; [ - tools - hfsutils - binutils_unwrapped - ]; + universal = with pkgs; + stdenvNoCC.mkDerivation { + name = "retro68.universal"; + src = retro68.mpw_35_gm; + nativeBuildInputs = with buildPackages.retro68; [ + tools + hfsutils + binutils_unwrapped + ]; - buildCommand = '' - ConvertDiskImage $src decoded.dsk - export HOME=. - hmount decoded.dsk - mkdir -p CIncludes RIncludes - hcopy -t 'MPW-GM:MPW-GM:Interfaces&Libraries:Interfaces:CIncludes:*.h' CIncludes/ - hcopy -t 'MPW-GM:MPW-GM:Interfaces&Libraries:Interfaces:RIncludes:*.r' RIncludes/ - mkdir -p $out/include $out/RIncludes - bash ${../prepare-headers.sh} CIncludes $out/include - bash ${../prepare-rincludes.sh} RIncludes $out/RIncludes + buildCommand = '' + ConvertDiskImage $src decoded.dsk + export HOME=. + hmount decoded.dsk + mkdir -p CIncludes RIncludes + hcopy -t 'MPW-GM:MPW-GM:Interfaces&Libraries:Interfaces:CIncludes:*.h' CIncludes/ + hcopy -t 'MPW-GM:MPW-GM:Interfaces&Libraries:Interfaces:RIncludes:*.r' RIncludes/ + mkdir -p $out/include $out/RIncludes + bash ${../prepare-headers.sh} CIncludes $out/include + bash ${../prepare-rincludes.sh} RIncludes $out/RIncludes - . ${../interfaces-and-libraries.sh} - '' + (pkgs.lib.optionalString (pkgs.targetPlatform.cmakeSystemName == "Retro68") '' - mkdir -p lib68 - hcopy -r 'MPW-GM:MPW-GM:Interfaces&Libraries:Libraries:Libraries:*.o' lib68 - M68KLIBRARIES=lib68 - setup68KLibraries $out/ - mv $out/lib68k $out/lib - '') + (pkgs.lib.optionalString (pkgs.targetPlatform.cmakeSystemName != "Retro68") '' - mkdir -p libppc peflibs - hcopy -r 'MPW-GM:MPW-GM:Interfaces&Libraries:Libraries:PPCLibraries:*.o' libppc - hcopy -m 'MPW-GM:MPW-GM:Interfaces&Libraries:Libraries:SharedLibraries:*' peflibs - PPCLIBRARIES=libppc - SHAREDLIBRARIES=peflibs - INTERFACELIB=peflibs/InterfaceLib.bin + . ${../interfaces-and-libraries.sh} + '' + (pkgs.lib.optionalString (pkgs.targetPlatform.cmakeSystemName == "Retro68") '' + mkdir -p lib68 + hcopy -r 'MPW-GM:MPW-GM:Interfaces&Libraries:Libraries:Libraries:*.o' lib68 + M68KLIBRARIES=lib68 + setup68KLibraries $out/ + mv $out/lib68k $out/lib + '') + (pkgs.lib.optionalString (pkgs.targetPlatform.cmakeSystemName != "Retro68") '' + mkdir -p libppc peflibs + hcopy -r 'MPW-GM:MPW-GM:Interfaces&Libraries:Libraries:PPCLibraries:*.o' libppc + hcopy -m 'MPW-GM:MPW-GM:Interfaces&Libraries:Libraries:SharedLibraries:*' peflibs + PPCLIBRARIES=libppc + SHAREDLIBRARIES=peflibs + INTERFACELIB=peflibs/InterfaceLib.bin - setupPPCLibraries $out/ - mv $out/libppc $out/lib - ''); - }; - }); + setupPPCLibraries $out/ + mv $out/libppc $out/lib + ''); + }; + }); stdenvUniversal = pkgs.stdenv.override { cc = pkgs.stdenv.cc.override {