Revert "conda-windows-binutils-or1k: build with msys2, not conda"

This reverts commit 3409eb3c11.
This commit is contained in:
Astro 2020-07-24 09:35:29 +08:00
parent 7f32f8e438
commit bc447638a9
6 changed files with 23 additions and 97 deletions

View File

@ -1,7 +1,21 @@
set MSYS=C:\MSYS64 set MSYS=C:\MSYS64
set TRIPLE=x86_64-pc-mingw64
set PATH=%MSYS%\usr\bin;%MSYS%\mingw64\bin;%PATH% set PATH=%MSYS%\usr\bin;%MSYS%\mingw64\bin;%PATH%
cd %PREFIX% mkdir build
tar xjf /c/Users/wfvm/src.tar.bz2 cd build
dir C:\Users\wfvm set CFLAGS=-I%PREFIX:\=/%/Library/include/
python C:\Users\wfvm\patch_prefix.py "##PREFIX##" %PREFIX% set LDFLAGS=-L%PREFIX:\=/%/Library/lib/
sh ../configure --build=%TRIPLE% ^
--prefix="%PREFIX:\=/%/Library" ^
--target=##TARGET##
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\##TARGET##

View File

@ -1,4 +1,4 @@
{ pkgs, version, target, windows-binutils }: { pkgs, version, src, target }:
let let
wfvm = import ../wfvm.nix { inherit pkgs; }; wfvm = import ../wfvm.nix { inherit pkgs; };
@ -34,13 +34,11 @@ let
cp --no-preserve=mode,ownership -R ${./binutils-recipe} binutils cp --no-preserve=mode,ownership -R ${./binutils-recipe} binutils
sed -i s/##TARGET##/${target}/g binutils/* sed -i s/##TARGET##/${target}/g binutils/*
sed -i s/##VERSION##/${version}/g binutils/* sed -i s/##VERSION##/${version}/g binutils/*
sed -i 's!##PREFIX##!${windows-binutils.prefix}!g' binutils/*
${wfvm.utils.win-put}/bin/win-put binutils . ${wfvm.utils.win-put}/bin/win-put binutils .
cp ${windows-binutils} src.tar.bz2 tar xjf ${src}
patch -d binutils-${version} -p1 < ${./binutils-hack-libiconv.patch}
tar cjf src.tar.bz2 binutils-${version}
${wfvm.utils.win-put}/bin/win-put src.tar.bz2 . ${wfvm.utils.win-put}/bin/win-put src.tar.bz2 .
cp ${./patch_prefix.py} patch_prefix.py
ls -l patch_prefix.py
${wfvm.utils.win-put}/bin/win-put patch_prefix.py .
${wfvm.utils.win-exec}/bin/win-exec ".\Anaconda3\scripts\activate && conda build --no-anaconda-upload --no-test -c file:///C:/users/wfvm/fake-channel --override-channels binutils" ${wfvm.utils.win-exec}/bin/win-exec ".\Anaconda3\scripts\activate && conda build --no-anaconda-upload --no-test -c file:///C:/users/wfvm/fake-channel --override-channels binutils"

View File

@ -1,35 +0,0 @@
import os, sys, re
OLD = sys.argv[1].encode('utf-8')
NEW = sys.argv[2].encode('utf-8')
if len(NEW) > len(OLD):
raise ValueError("Cannot new shorter than the replacement")
new = NEW + b"\0" * (len(OLD) - len(NEW))
def patch_file(path):
with open(path, "r+b") as f:
s = f.read()
occurrences = s.count(OLD)
s = s.replace(OLD, new)
if occurrences > 0:
print("{}: replaced {}, left {}".format(path, occurrences, s.count(OLD)))
with open(path, "w+b") as f:
f.write(s)
for root, dirs, files in os.walk("."):
for filename in files:
path = "{}/{}".format(root, filename)
patch_file(path)
def mangle_path(path):
path = re.sub(r"^/c/", "C:/", path)
return str(path)
OLD = mangle_path(sys.argv[1]).encode('utf-8')
NEW = mangle_path(sys.argv[2]).encode('utf-8')
for root, dirs, files in os.walk("."):
for filename in files:
path = "{}/{}".format(root, filename)
patch_file(path)

View File

@ -124,17 +124,11 @@ let
}; };
condaWindowsExperimental = rec { condaWindowsExperimental = rec {
windows-binutils-or1k = import ./windows/binutils.nix { conda-windows-binutils-or1k = import ./conda-windows/binutils.nix {
inherit pkgs; inherit pkgs;
inherit (mainPackages.binutils-or1k) version src; inherit (mainPackages.binutils-or1k) version src;
target = "or1k-linux"; target = "or1k-linux";
}; };
conda-windows-binutils-or1k = import ./conda-windows/binutils.nix {
inherit pkgs;
inherit (mainPackages.binutils-or1k) version;
target = "or1k-linux";
windows-binutils = windows-binutils-or1k;
};
conda-windows-binutils-arm = import ./conda-windows/binutils.nix { conda-windows-binutils-arm = import ./conda-windows/binutils.nix {
inherit pkgs; inherit pkgs;
inherit (mainPackages.binutils-or1k) version src; inherit (mainPackages.binutils-or1k) version src;

View File

@ -1,45 +0,0 @@
{ pkgs, version, src, target }:
let
wfvm = import ../wfvm.nix { inherit pkgs; };
repeat = s:
let go = n:
if n > 0
then s + go (n - 1)
else "";
in go;
outName = "windows-binutils-${target}-${version}.tar.bz2";
# add padding for later PREFIX replacement in `conda build`
prefix = "/c/Users/wfvm/binutils_" + repeat "0" 80;
build = wfvm.utils.wfvm-run {
name = "build-binutils";
image = wfvm.makeWindowsImage { installCommands = with wfvm.layers; [ msys2 (msys2-packages (import ../conda-windows/msys_packages.nix { inherit pkgs; } )) ]; };
script = ''
tar xjf ${src}
patch -d binutils-${version} -p1 < ${./binutils-hack-libiconv.patch}
tar cjf src.tar.bz2 binutils-${version}
${wfvm.utils.win-put}/bin/win-put src.tar.bz2 .
cat > build-binutils.bat << EOF
set MSYS=c:\msys64
set PATH=%MSYS%\usr\bin;%MSYS%\mingw64\bin;%PATH%
tar xjf src.tar.bz2
bash -c "cd binutils-${version} && ./configure --build=x86_64-w64-mingw32 --prefix=${prefix}/Library --target=${target} && make -j$NIX_BUILD_CORES && make install"
rm -r ${prefix}/Library/or1k-linux
cp %MSYS%/mingw64/bin/libiconv-2.dll ${prefix}/Library/bin/
tar cjf ${outName} -C ${prefix} .
EOF
${wfvm.utils.win-put}/bin/win-put build-binutils.bat .
${wfvm.utils.win-exec}/bin/win-exec build-binutils
${wfvm.utils.win-get}/bin/win-get ${outName}
'';
};
in
pkgs.runCommand outName {
buildInputs = [ build ];
passthru = { inherit prefix; };
} ''
wfvm-run-build-binutils
cp ${outName} $out
''