Newer
Older
dub_jkp / setup-ldc-windows.sh
@Sebastian Wilzbach Sebastian Wilzbach on 4 Jan 2019 1 KB Build win{32,64} binaries with LDC
  1. #!/usr/bin/env bash
  2.  
  3. # sets up LDC for cross-compilation. Source this script, s.t. the new LDC is in PATH
  4.  
  5. LDC_VERSION="1.13.0"
  6. ARCH=${ARCH:-32}
  7. VERSION=$(git describe --abbrev=0 --tags)
  8. OS=windows
  9.  
  10. # Step 0: install ldc
  11. if [ ! -f install.sh ] ; then
  12. wget https://dlang.org/install.sh
  13. fi
  14. . $(bash ./install.sh -a "ldc-${LDC_VERSION}")
  15.  
  16. # for the install.sh script only
  17. LDC_PATH="$(dirname $(dirname $(which ldc2)))"
  18.  
  19. # Step 1a: download the LDC x64 windows binaries
  20. if [ "${ARCH}" == 64 ] && [ ! -d "ldc2-${LDC_VERSION}-windows-x64" ] ; then
  21. wget "https://github.com/ldc-developers/ldc/releases/download/v1.13.0/ldc2-${LDC_VERSION}-windows-x64.7z"
  22. 7z x "ldc2-${LDC_VERSION}-windows-x64.7z" > /dev/null
  23. # Step 2a: Add LDC windows binaries to LDC Linux
  24. if [ ! -d "${LDC_PATH}/lib-win64" ] ; then
  25. cp -r ldc2-1.13.0-windows-x64/lib "${LDC_PATH}/lib-win64"
  26. cat >> "$LDC_PATH"/etc/ldc2.conf <<EOF
  27. "x86_64-.*-windows-msvc":
  28. {
  29. switches = [
  30. "-defaultlib=phobos2-ldc,druntime-ldc",
  31. "-link-defaultlib-shared=false",
  32. ];
  33. lib-dirs = [
  34. "%%ldcbinarypath%%/../lib-win64",
  35. ];
  36. };
  37. EOF
  38. fi
  39. fi
  40. # Step 1b: download the LDC x86 windows binaries
  41. if [ "${ARCH}" == 32 ] && [ ! -d "ldc2-${LDC_VERSION}-windows-x86" ] ; then
  42. wget "https://github.com/ldc-developers/ldc/releases/download/v1.13.0/ldc2-${LDC_VERSION}-windows-x86.7z"
  43. 7z x "ldc2-${LDC_VERSION}-windows-x86.7z" > /dev/null
  44. # Step 2b: Add LDC windows binaries to LDC Linux
  45. if [ ! -d "${LDC_PATH}/lib-win32" ] ; then
  46. cp -r ldc2-1.13.0-windows-x86/lib "${LDC_PATH}/lib-win32"
  47. cat >> "$LDC_PATH"/etc/ldc2.conf <<EOF
  48. "i686-.*-windows-msvc":
  49. {
  50. switches = [
  51. "-defaultlib=phobos2-ldc,druntime-ldc",
  52. "-link-defaultlib-shared=false",
  53. ];
  54. lib-dirs = [
  55. "%%ldcbinarypath%%/../lib-win32",
  56. ];
  57. };
  58. EOF
  59. fi
  60. fi
  61.  
  62. # set suffices and compilation flags
  63. if [ "$ARCH" == "64" ] ; then
  64. ARCH_SUFFIX="x86_64"
  65. export DFLAGS="-mtriple=x86_64-windows-msvc"
  66. else
  67. ARCH_SUFFIX="x86"
  68. export DFLAGS="-mtriple=i686-windows-msvc"
  69. fi
  70.