summaryrefslogtreecommitdiffstats
path: root/tools/buildsteps/windows/make-mingwlibs.sh
blob: e5a3594cd92a623c128ee1ec78aae31128873bfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
[[ -f $(dirname $0)/buildhelpers.sh ]] &&
    source $(dirname $0)/buildhelpers.sh

Win32BuildSetup=/xbmc/project/Win32BuildSetup
ERRORFILE=$Win32BuildSetup/errormingw
TOUCH=/bin/touch
RM=/bin/rm
NOPROMPT=0
MAKECLEAN=""
MAKEFLAGS=""
TRIPLET=""

while true; do
  case $1 in
    --build32=* ) build32="${1#*=}"; shift ;;
    --build64=* ) build64="${1#*=}"; shift ;;
    --buildArm=* ) buildArm="${1#*=}"; shift ;;
    --prompt=* ) PROMPTLEVEL="${1#*=}"; shift ;;
    --mode=* ) BUILDMODE="${1#*=}"; shift ;;
    --win10=* ) win10="${1#*=}"; shift ;;
    -- ) shift; break ;;
    -* ) shift ;;
    * ) break ;;
  esac
done

if [[ $build32 = "yes" ]]; then
  TRIPLET=win32
  ARCH=x86
elif [[ $build64 = "yes" ]]; then
  TRIPLET=x64
  ARCH=x86_64
elif [[ $buildArm = "yes" ]]; then
  TRIPLET=arm
  ARCH=arm
else
  echo "-------------------------------------------------------------------------------"
  echo " none of build types (build32, build64 or buildArm) was specified "
  echo "-------------------------------------------------------------------------------"
  # wait for key press
  if [ "$PROMPTLEVEL" != "noprompt" ]; then
    echo press a key to close the window
    read
  fi
  exit
fi

if [[ $win10 = "no" ]]; then
  export _WIN32_WINNT=0x0600
  export NTDDI_VERSION=0x06000000
elif [[ $win10 = "yes" ]]; then
  TRIPLET=win10-$TRIPLET
fi

export TRIPLET ARCH

throwerror() {
  $TOUCH $ERRORFILE
  echo failed to compile $1
  if [ $NOPROMPT == 0 ]; then
	read
  fi
}

checkfiles() {
  for i in $@; do
    if [ ! -f "$PREFIX/$i" ]; then
      throwerror "$PREFIX/$i"
      exit 1
    fi
  done
}

buildProcess() {
export PREFIX=/xbmc/project/BuildDependencies/mingwlibs/$TRIPLET
if [ "$(pathChanged $PREFIX /xbmc/tools/buildsteps/windows /xbmc/tools/depends/target/ffmpeg/FFMPEG-VERSION)" == "0" ]; then
  return
fi

if [ -d "$PREFIX" ]; then
  rm -rdf $PREFIX/*
fi

cd /xbmc/tools/buildsteps/windows

# compile our mingw dlls
echo "-------------------------------------------------------------------------------"
echo " compiling mingw libs $TRIPLET"
echo
echo " NOPROMPT  = $NOPROMPT"
echo " MAKECLEAN = $MAKECLEAN"
echo " WORKSPACE = $WORKSPACE"
echo
echo "-------------------------------------------------------------------------------"

echo -ne "\033]0;building FFmpeg $TRIPLET\007"
echo "-------------------------------------------------"
echo " building FFmpeg $TRIPLET"
echo "-------------------------------------------------"
./buildffmpeg.sh $MAKECLEAN
checkfiles lib/avcodec.lib lib/avformat.lib lib/avutil.lib lib/postproc.lib lib/swscale.lib lib/avfilter.lib lib/swresample.lib
echo "-------------------------------------------------"
echo " building of FFmpeg $TRIPLET done..."
echo "-------------------------------------------------"
echo "-------------------------------------------------------------------------------"
echo " compile mingw libs $TRIPLET done..."
echo "-------------------------------------------------------------------------------"

tagSuccessFulBuild $PREFIX /xbmc/tools/buildsteps/windows /xbmc/tools/depends/target/ffmpeg/FFMPEG-VERSION
}

run_builds() {
    local profile_path=""
    if [[ $build32 = "yes" ]]; then
      profile_path=/local32/etc/profile.local
    elif [[ $build64 = "yes" ]]; then
      profile_path=/local64/etc/profile.local
    elif [[ $buildArm = "yes" ]]; then
      profile_path=/local32/etc/profile.local
    fi

    if [ ! -z $profile_path ]; then
        if [[ ! -f "$profile_path" ]]; then
          echo "-------------------------------------------------------------------------------"
          echo " $TRIPLET build environment not configured, please run download-msys2.bat"
          echo "-------------------------------------------------------------------------------"
        else
          source $profile_path
          buildProcess
          echo "-------------------------------------------------------------------------------"
          echo " compile all libs $TRIPLET done..."
          echo "-------------------------------------------------------------------------------"
        fi
    fi
}

# cleanup
if [ -f $ERRORFILE ]; then
  $RM $ERRORFILE
fi

# check for noprompt
if [ "$PROMPTLEVEL" == "noprompt" ]; then
  NOPROMPT=1
fi

if [ "$BUILDMODE" == "clean" ]; then
  MAKECLEAN="clean"
else
  MAKECLEAN="noclean"
fi

run_builds

echo -e "\033]0;compiling done...\007"
echo

# wait for key press
if [ $NOPROMPT == 0 ]; then
  echo press a key to close the window
  read
fi