From 7e50d7de1c07fe00bc0895b489d85495571b63fd Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 15 Jun 2020 20:11:19 +0800 Subject: [PATCH] conda-windows: build binutils via WFVM --- artiq-fast/conda-windows/binutils.nix | 69 +++++++++++++++++++++++++++ artiq-fast/default.nix | 11 +++++ 2 files changed, 80 insertions(+) create mode 100644 artiq-fast/conda-windows/binutils.nix diff --git a/artiq-fast/conda-windows/binutils.nix b/artiq-fast/conda-windows/binutils.nix new file mode 100644 index 0000000..0958bd0 --- /dev/null +++ b/artiq-fast/conda-windows/binutils.nix @@ -0,0 +1,69 @@ +{ pkgs, version, src, target }: + +let + wfvm = import ../wfvm { inherit pkgs; }; + libiconv-filename = "libiconv-1.15-h0c8e037_1006.tar.bz2"; + libiconv = pkgs.fetchurl { + url = "https://anaconda.org/conda-forge/libiconv/1.15/download/win-64/${libiconv-filename}"; + sha256 = "1jaxnpg5y5pkhvpp9kaq0kpvz7jlj5hynp567q35l7hpfk6xxghh"; + }; + build = wfvm.utils.wfvm-run { + name = "build-binutils"; + image = wfvm.makeWindowsImage { installCommands = with wfvm.layers; [ anaconda3 msys2 msys2-packages ]; }; + script = '' + ${wfvm.utils.win-put}/bin/win-put ${libiconv} ${libiconv-filename} + ${wfvm.utils.win-exec}/bin/win-exec ".\Anaconda3\scripts\activate && conda create -n build ${libiconv-filename}" + + cat > meta.yaml << EOF + package: + name: binutils-${target} + version: ${version} + + source: + url: src.tar.bz2 + + EOF + + cat > bld.bat << EOF + set MSYS=C:\\MSYS64 + set ARCH=32 + set TOOLPREF=mingw-w64-i686- + set TRIPLE=x86_64-pc-mingw32 + set PATH=%MSYS%\usr\bin;%MSYS%\mingw%ARCH%\bin;%PATH% + + mkdir build + cd build + set CFLAGS=-I%PREFIX:\=/%/Library/include/ + set LDFLAGS=-L%PREFIX:\=/%/Library/lib/ + sh ../configure --build=%TRIPLE% ^ + --prefix="%PREFIX:\=/%/Library" ^ + --target=or1k-linux + if errorlevel 1 exit 1 + + make -j4 + if errorlevel 1 exit 1 + + make install + if errorlevel 1 exit 1 + + rem this is a copy of prefixed executables + rmdir /S /Q %PREFIX%\Library\or1k-linux + EOF + + ${wfvm.utils.win-exec}/bin/win-exec "mkdir binutils" + ${wfvm.utils.win-put}/bin/win-put meta.yaml ".\binutils" + ${wfvm.utils.win-put}/bin/win-put bld.bat ".\binutils" + ${wfvm.utils.win-put}/bin/win-put ${src} ".\binutils\src.tar.bz2" + + ${wfvm.utils.win-exec}/bin/win-exec ".\Anaconda3\scripts\activate build && conda build --no-anaconda-upload --no-test binutils" + + ${wfvm.utils.win-get}/bin/win-get ".\Anaconda3\conda-bld\win-64\binutils-${target}-${version}-0.tar.bz2" + ''; + }; +in + pkgs.runCommand "conda-windows-binutils-${target}" { buildInputs = [ build ]; } '' + wfvm-run-build-binutils + mkdir -p $out/win-64 $out/nix-support + cp *.tar.bz2 $out/win-64 + echo file conda $out/win-64/*.tar.bz2 >> $out/nix-support/hydra-build-products + '' diff --git a/artiq-fast/default.nix b/artiq-fast/default.nix index 5449ce5..903b87b 100644 --- a/artiq-fast/default.nix +++ b/artiq-fast/default.nix @@ -90,6 +90,17 @@ let dependencies = ["pyserial"]; }; }; + + conda-windows-binutils-or1k = import ./conda-windows/binutils.nix { + inherit pkgs; + inherit (binutils-or1k) version src; + target = "or1k-linux"; + }; + conda-windows-binutils-arm = import ./conda-windows/binutils.nix { + inherit pkgs; + inherit (binutils-arm) version src; + target = "armv7-unknown-linux-gnueabihf"; + }; }; in mainPackages // boardPackages