|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
3 | | -# sets up LDC for cross-compilation. Source this script, s.t. the new LDC is in PATH |
| 3 | +# Sets up LDC for cross-compilation. Source this script, s.t. the new LDC is in PATH |
4 | 4 |
|
5 | | -LDC_VERSION="1.13.0" |
| 5 | +# Make sure this version matches the version of LDC2 used in .travis.yml, |
| 6 | +# otherwise the compiler and the lib used might mismatch. |
| 7 | +LDC_VERSION="1.23.0" |
6 | 8 | ARCH=${ARCH:-32} |
7 | 9 | VERSION=$(git describe --abbrev=0 --tags) |
8 | 10 | OS=windows |
9 | 11 |
|
10 | | -# Step 0: install ldc |
11 | | -if [ ! -f install.sh ] ; then |
12 | | - wget https://dlang.org/install.sh |
| 12 | +# LDC should already be installed (see .travis.yml) |
| 13 | +# However, we need the libraries, so download them |
| 14 | +# We can't use the downloaded ldc2 itself, because obviously it's for Windows |
| 15 | + |
| 16 | +if [ "${ARCH}" == 64 ]; then |
| 17 | + ARCH_SUFFIX='x86_64' |
| 18 | + ZIP_ARCH_SUFFIX='x64' |
| 19 | +else |
| 20 | + ARCH_SUFFIX='i686' |
| 21 | + ZIP_ARCH_SUFFIX='x86' |
13 | 22 | fi |
14 | | -. $(bash ./install.sh -a "ldc-${LDC_VERSION}") |
15 | 23 |
|
16 | | -# for the install.sh script only |
17 | | -LDC_PATH="$(dirname $(dirname $(which ldc2)))" |
| 24 | +LDC_DIR_PATH="$(pwd)/ldc2-${LDC_VERSION}-windows-${ZIP_ARCH_SUFFIX}" |
| 25 | +LDC_XDFLAGS="-conf=${LDC_DIR_PATH}/etc/ldc2.conf -mtriple=${ARCH_SUFFIX}-pc-windows-msvc" |
18 | 26 |
|
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 |
| 27 | +# Step 1: download the LDC Windows release |
| 28 | +# Check if the user already have it (e.g. building locally) |
| 29 | +if [ ! -d ${LDC_DIR_PATH} ]; then |
| 30 | + if [ ! -d "ldc2-${LDC_VERSION}-windows-${ZIP_ARCH_SUFFIX}.7z" ]; then |
| 31 | + wget "https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION}/ldc2-${LDC_VERSION}-windows-${ZIP_ARCH_SUFFIX}.7z" |
| 32 | + fi |
| 33 | + 7z x "ldc2-${LDC_VERSION}-windows-${ZIP_ARCH_SUFFIX}.7z" > /dev/null |
39 | 34 | 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": |
| 35 | + |
| 36 | +# Step 2: Generate a config file with the proper path |
| 37 | +cat > ${LDC_DIR_PATH}/etc/ldc2.conf <<EOF |
| 38 | +default: |
49 | 39 | { |
50 | 40 | switches = [ |
51 | 41 | "-defaultlib=phobos2-ldc,druntime-ldc", |
52 | 42 | "-link-defaultlib-shared=false", |
53 | 43 | ]; |
| 44 | + post-switches = [ |
| 45 | + "-I${LDC_DIR_PATH}/import", |
| 46 | + ]; |
54 | 47 | lib-dirs = [ |
55 | | - "%%ldcbinarypath%%/../lib-win32", |
| 48 | + "${LDC_DIR_PATH}/lib/", |
| 49 | + "${LDC_DIR_PATH}/lib/mingw/", |
56 | 50 | ]; |
57 | 51 | }; |
58 | 52 | 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 | | - |
0 commit comments