#!/bin/sh # This file is a part of Julia. License is MIT: https://julialang.org/license # download mingw-w64 compilers from opensuse build service, usage: # ./get_toolchain.sh 64 # (or ./get_toolchain.sh 32) # depends on curl, xmllint, gunzip, sort -V, sha256sum, and p7zip # Run in top-level Julia directory cd $[dirname $0]/../.. # Stop on error set -e global bits := $1 matchstr $bits { 32 { global host := 'i686-w64-mingw32' global exc := 'sjlj' } 64 { global host := 'x86_64-w64-mingw32' global exc := 'seh' } * { echo 'error: run script either as `./get_toolchain.sh 32` or `./get_toolchain.sh 64`' > !2 exit 1 } } echo "Downloading $host toolchain, check $PWD/get_toolchain.log for full output" contrib/windows/winrpm.sh http://download.opensuse.org/repositories/windows:/mingw:/win$bits/openSUSE_Leap_42.2 \ "mingw$bits-gcc mingw$bits-gcc-c++ mingw$bits-gcc-fortran \ mingw$bits-libssp0 mingw$bits-libstdc++6 mingw$bits-libgfortran3" > get_toolchain.log global mingwdir := "usr/$host/sys-root/mingw" chmod +x $mingwdir/bin/* $mingwdir/$host/bin/* $mingwdir/libexec/gcc/$host/*/* mkdir -p usr/bin for i in [gcc_s_$exc-1 ssp-0 stdc++-6 gfortran-3 quadmath-0] { cp $mingwdir/bin/lib$i.dll usr/bin } $mingwdir/bin/g++ --version # copy around binutils and make a junction for includes cp $mingwdir/$host/bin/* $mingwdir/bin matchstr $[uname] { CYGWIN* { global mklink := '"cmd /C mklink /J'" # treat these like cross-compilers if we're running from cygwin for i in [gcc g++ gfortran] { mv $mingwdir/bin/$i.exe $mingwdir/bin/$host-$i.exe } } * { global mklink := '"cmd //C mklink //J'" } } if ! test -e $mingwdir/$host/include { $mklink $[cygpath -w $mingwdir/$host/include] $[cygpath -w $mingwdir/include] } echo "Toolchain successfully downloaded to $PWD/$mingwdir" echo "Add toolchain to your path by running \`export PATH=$PWD/$mingwdir/bin:\$PATH\`" (CommandList children: [ (C {(cd)} { (CommandSubPart command_list: (CommandList children:[(C {(dirname)} {(DQ ($ VSub_Number "$0"))})]) left_token: spids: [25 31] ) (/../..) } ) (C {(set)} {(-e)}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:bits) op:Equal rhs:{($ VSub_Number "$1")} spids:[41])] spids: [41] ) (Case to_match: {($ VSub_Name "$bits")} arms: [ (case_arm pat_list: [{(32)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:host) op: Equal rhs: {(i686-w64-mingw32)} spids: [56] ) ] spids: [56] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:exc) op:Equal rhs:{(sjlj)} spids:[60])] spids: [60] ) ] spids: [52 53 64 -1] ) (case_arm pat_list: [{(64)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:host) op: Equal rhs: {(x86_64-w64-mingw32)} spids: [71] ) ] spids: [71] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:exc) op:Equal rhs:{(seh)} spids:[75])] spids: [75] ) ] spids: [67 68 79 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (SimpleCommand words: [ {(echo)} { (SQ < "error: run script either as `./get_toolchain.sh 32` or `./get_toolchain.sh 64`" > ) } ] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[92])] ) (C {(exit)} {(1)}) ] spids: [82 83 101 -1] ) ] spids: [45 49 103] ) (C {(echo)} { (DQ ("Downloading ") ($ VSub_Name "$host") (" toolchain, check ") ($ VSub_Name "$PWD") ("/get_toolchain.log for full output") ) } ) (SimpleCommand words: [ {(contrib/windows/winrpm.sh)} {(http) (Lit_Other ":") (//download.opensuse.org/repositories/windows) (Lit_Other ":") (/mingw) (Lit_Other ":") (/win) ($ VSub_Name "$bits") (/openSUSE_Leap_42.2) } { (DQ (mingw) ($ VSub_Name "$bits") ("-gcc mingw") ($ VSub_Name "$bits") ("-gcc-c++ mingw") ($ VSub_Name "$bits") ("-gcc-fortran ") (" mingw") ($ VSub_Name "$bits") ("-libssp0 mingw") ($ VSub_Name "$bits") ("-libstdc++6 mingw") ($ VSub_Name "$bits") (-libgfortran3) ) } ] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(get_toolchain.log)} spids:[147])] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:mingwdir) op: Equal rhs: {(usr/) ($ VSub_Name "$host") (/sys-root/mingw)} spids: [152] ) ] spids: [152] ) (C {(chmod)} {(Lit_Other "+") (x)} {($ VSub_Name "$mingwdir") (/bin/) (Lit_Other "*")} {($ VSub_Name "$mingwdir") (/) ($ VSub_Name "$host") (/bin/) (Lit_Other "*")} {($ VSub_Name "$mingwdir") (/libexec/gcc/) ($ VSub_Name "$host") (/) (Lit_Other "*") (/) (Lit_Other "*") } ) (C {(mkdir)} {(-p)} {(usr/bin)}) (ForEach iter_name: i iter_words: [ {(gcc_s_) ($ VSub_Name "$exc") (-1)} {(ssp-0)} {(stdc) (Lit_Other "+") (Lit_Other "+") (-6)} {(gfortran-3)} {(quadmath-0)} ] do_arg_iter: False body: (DoGroup children: [ (C {(cp)} {($ VSub_Name "$mingwdir") (/bin/lib) ($ VSub_Name "$i") (.dll)} {(usr/bin)}) ] spids: [208 220] ) spids: [191 206] ) (C {($ VSub_Name "$mingwdir") (/bin/g) (Lit_Other "+") (Lit_Other "+")} {(--version)}) (C {(cp)} {($ VSub_Name "$mingwdir") (/) ($ VSub_Name "$host") (/bin/) (Lit_Other "*")} {($ VSub_Name "$mingwdir") (/bin)} ) (Case to_match: { (CommandSubPart command_list: (CommandList children:[(C {(uname)})]) left_token: spids: [245 247] ) } arms: [ (case_arm pat_list: [{(CYGWIN) (Lit_Other "*")}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:mklink) op: Equal rhs: {(DQ ("cmd /C mklink /J"))} spids: [257] ) ] spids: [257] ) (ForEach iter_name: i iter_words: [{(gcc)} {(g) (Lit_Other "+") (Lit_Other "+")} {(gfortran)}] do_arg_iter: False body: (DoGroup children: [ (C {(mv)} {($ VSub_Name "$mingwdir") (/bin/) ($ VSub_Name "$i") (.exe)} {($ VSub_Name "$mingwdir") (/bin/) ($ VSub_Name "$host") (-) ($ VSub_Name "$i") (.exe) } ) ] spids: [282 300] ) spids: [272 280] ) ] spids: [252 254 303 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:mklink) op: Equal rhs: {(DQ ("cmd //C mklink //J"))} spids: [310] ) ] spids: [310] ) ] spids: [306 307 316 -1] ) ] spids: [243 249 318] ) (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (C {(Lit_Other "[")} {(-e)} {($ VSub_Name "$mingwdir") (/) ($ VSub_Name "$host") (/include)} {(Lit_Other "]")} ) ] negated: True ) terminator: ) ] action: [ (C {($ VSub_Name "$mklink")} { (CommandSubPart command_list: (CommandList children: [ (C {(cygpath)} {(-w)} {($ VSub_Name "$mingwdir") (/) ($ VSub_Name "$host") (/include)} ) ] ) left_token: spids: [341 350] ) } { (CommandSubPart command_list: (CommandList children: [(C {(cygpath)} {(-w)} {($ VSub_Name "$mingwdir") (/include)})] ) left_token: spids: [352 359] ) } ) ] spids: [-1 336] ) ] spids: [-1 361] ) (C {(echo)} { (DQ ("Toolchain successfully downloaded to ") ($ VSub_Name "$PWD") (/) ($ VSub_Name "$mingwdir")) } ) (C {(echo)} { (DQ ("Add toolchain to your path by running ") (EscapedLiteralPart token:) ("export PATH=") ($ VSub_Name "$PWD") (/) ($ VSub_Name "$mingwdir") ("/bin:") (EscapedLiteralPart token:) (PATH) (EscapedLiteralPart token:) ) } ) ] )