Update README.md
[VK9.git] / package-release.sh
blob7b5ae6e223921217afbc8c87943f6bac2a55b6ac
1 #!/bin/bash
2 # Based on DXVK build script - https://github.com/doitsujin/dxvk/blob/master/package-release.sh
4 function print_usage {
5 echo "Usage: package-release.sh version destdir [options]
6 Options are:
7 --no-package: Do not build tar package
8 --keep-builddir: Do not delete builddir, use this to keep logfiles for debugging
9 --no-32bit: Do not build 32 bit binaries
10 --no-64bit: Do not build 64 bit binaries
11 --debug: Build debug version of the library
12 --no-pch: Do not use precompiled headers"
15 if [ -z "$1" ] || [ -z "$2" ]; then
16 print_usage
17 exit -1
20 if [ -z "$(export -p | grep WINEPREFIX\=)" ]; then
21 export WINEPREFIX=~/.wine/VK9-build
24 # Get positional arguments and remove them from argument list
25 VK9_VERSION="$1"
26 VK9_SRC_DIR=`dirname $(readlink -f $0)`
27 VK9_BUILD_DIR=$(realpath "$2")"/vk9-$VK9_VERSION"
28 VK9_ARCHIVE_PATH=$(realpath "$2")"/vk9-$VK9_VERSION.tar.gz"
29 shift
30 shift
32 BUILD_PACKAGE=true
33 BUILD_32BIT=true
34 BUILD_64BIT=true
35 BUILD_TYPE="release"
36 KEEP_BUILDDIR=false
37 USE_PCH=true
39 # Parse options
40 while [[ $# -gt 0 ]]
42 key="$1"
44 case $key in
45 --no-package)
46 BUILD_PACKAGE=false
47 shift
49 --keep-builddir)
50 KEEP_BUILDDIR=true
51 shift
53 --no-32bit)
54 BUILD_32BIT=false
55 shift
57 --no-64bit)
58 BUILD_64BIT=false
59 shift
61 --debug)
62 $BUILD_TYPE="debug"
63 shift
65 --no-pch)
66 USE_PCH=false
67 shift
69 *) # unknown option
70 echo "Found unknown argument \"$key\". Abort!"
71 print_usage
72 exit -1
74 esac
75 done
77 echo "Building VK9 with the following options:"
78 echo " tar package: $BUILD_PACKAGE"
79 echo " 32 bit: $BUILD_32BIT"
80 echo " 64 bit: $BUILD_64BIT"
81 echo " build type: $BUILD_TYPE"
82 echo " keep builddir: $KEEP_BUILDDIR"
83 echo " precompiled header: $USE_PCH"
85 function build_arch {
86 cd "$VK9_SRC_DIR"
88 PKG_CONFIG_PATH_SET=true
89 PKG_CONFIG_PATH_CUSTOM_SET=true
91 if [ -z "$(export -p | grep PKG_CONFIG_PATH\=)" ]; then
92 export PKG_CONFIG_PATH=./dep$1
93 PKG_CONFIG_PATH_SET=false
95 if [ -z "$(export -p | grep PKG_CONFIG_PATH_CUSTOM\=)" ]; then
96 # Some distributions use PKG_CONFIG_PATH_CUSTOM instead.
97 export PKG_CONFIG_PATH_CUSTOM=./dep$1
98 PKG_CONFIG_PATH_CUSTOM_SET=false
101 BOOST_INCLUDEDIR_SET=true
102 BOOST_LIBRARYDIR_SET=true
103 source ./dep$1/boost.sh
105 meson --cross-file "$VK9_SRC_DIR/build-win$1.txt" \
106 --buildtype $BUILD_TYPE \
107 --prefix "$VK9_BUILD_DIR/install.$1" \
108 --unity off \
109 --strip \
110 -Db_pch=$USE_PCH \
111 -Denable_tests=false \
112 "$VK9_BUILD_DIR/build.$1"
114 cd "$VK9_BUILD_DIR/build.$1"
115 ninja install
117 mkdir -p "$VK9_BUILD_DIR/x$1"
119 cp "$VK9_BUILD_DIR/install.$1/bin/d3d9.dll" "$VK9_BUILD_DIR/x$1/d3d9.dll"
120 cp "$VK9_SRC_DIR/VK9-Library/VK9.conf" "$VK9_BUILD_DIR/x$1/VK9.conf"
121 cp "$VK9_BUILD_DIR/install.$1/bin/setup_vk9.sh" "$VK9_BUILD_DIR/x$1/setup_vk9.sh"
122 cp "$VK9_SRC_DIR/wine_utils/setup_vk9.verb" "$VK9_BUILD_DIR/setup_vk9.verb"
124 if [ $KEEP_BUILDDIR == false ]; then
125 rm -R "$VK9_BUILD_DIR/build.$1"
126 rm -R "$VK9_BUILD_DIR/install.$1"
129 # Clean up environment variables.
130 if [ $BOOST_INCLUDEDIR_SET == false ]; then
131 unset BOOST_INCLUDEDIR
133 if [ $BOOST_LIBRARYDIR_SET == false ]; then
134 unset BOOST_LIBRARYDIR
136 if [ $PKG_CONFIG_PATH_SET == false ]; then
137 unset PKG_CONFIG_PATH
139 if [ $PKG_CONFIG_PATH_CUSTOM_SET == false ]; then
140 unset PKG_CONFIG_PATH_CUSTOM
144 function package {
145 echo "Building package..."
146 cd "$VK9_BUILD_DIR/.."
147 TAR_DIRS=""
148 if [ -d "vk9-$VK9_VERSION/x64" ]; then
149 TAR_DIRS="vk9-$VK9_VERSION/x64"
151 if [ -d "vk9-$VK9_VERSION/x32" ]; then
152 TAR_DIRS="$TAR_DIRS vk9-$VK9_VERSION/x32"
154 TAR_DIRS="$TAR_DIRS vk9-$VK9_VERSION/setup_vk9.verb"
156 tar -czvf "$VK9_ARCHIVE_PATH" $TAR_DIRS
157 if [ $KEEP_BUILDDIR == false ]; then
158 rm -R "vk9-$VK9_VERSION"
163 if [ $BUILD_32BIT == true ]; then
164 build_arch 32
167 if [ $BUILD_64BIT == true ]; then
168 build_arch 64
171 if [ $BUILD_PACKAGE == true ]; then
172 package
175 exit 0