package-release.sh 1.92 KB
Newer Older
1 2
#!/bin/bash

3 4
set -e

5 6
shopt -s extglob

7
if [ -z "$1" ] || [ -z "$2" ]; then
8
  echo "Usage: $0 version destdir [--no-package] [--dev-build] [--winelib]"
9 10 11 12 13
  exit 1
fi

DXVK_VERSION="$1"
DXVK_SRC_DIR=`dirname $(readlink -f $0)`
14
DXVK_BUILD_DIR=$(realpath "$2")"/dxvk-$DXVK_VERSION"
15
DXVK_ARCHIVE_PATH=$(realpath "$2")"/dxvk-$DXVK_VERSION.tar.gz"
16

17 18 19 20 21
if [ -e "$DXVK_BUILD_DIR" ]; then
  echo "Build directory $DXVK_BUILD_DIR already exists"
  exit 1
fi

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
shift 2

opt_nopackage=0
opt_devbuild=0
opt_winelib=0

crossfile="build-win"

while [ $# -gt 0 ]; do
  case "$1" in
  "--no-package")
    opt_nopackage=1
    ;;
  "--dev-build")
    opt_nopackage=1
    opt_devbuild=1
    ;;
  "--winelib")
    opt_winelib=1
    crossfile="build-wine"
    ;;
  *)
    echo "Unrecognized option: $1" >&2
    exit 1
  esac
  shift
done

50
function build_arch {
51 52 53
  export WINEARCH="win$1"
  export WINEPREFIX="$DXVK_BUILD_DIR/wine.$1"
  
54 55
  cd "$DXVK_SRC_DIR"

56
  meson --cross-file "$DXVK_SRC_DIR/$crossfile$1.txt" \
57
        --buildtype "release"                         \
58
        --prefix "$DXVK_BUILD_DIR"                    \
59
        --strip                                       \
60 61
        --bindir "x$1"                                \
        --libdir "x$1"                                \
62
        -Denable_tests=false                          \
63
        "$DXVK_BUILD_DIR/build.$1"
64

65
  cd "$DXVK_BUILD_DIR/build.$1"
66 67
  ninja install

68 69 70 71 72 73 74
  if [ $opt_devbuild -eq 0 ]; then
    if [ $opt_winelib -eq 0 ]; then
      # get rid of some useless .a files
      rm "$DXVK_BUILD_DIR/x$1/"*.!(dll)
    fi
    rm -R "$DXVK_BUILD_DIR/build.$1"
  fi
75 76
}

77 78 79
function build_script {
  cp "$DXVK_SRC_DIR/setup_dxvk.sh" "$DXVK_BUILD_DIR/setup_dxvk.sh"
  chmod +x "$DXVK_BUILD_DIR/setup_dxvk.sh"
80 81 82
}

function package {
83
  cd "$DXVK_BUILD_DIR/.."
84 85 86 87 88 89
  tar -czf "$DXVK_ARCHIVE_PATH" "dxvk-$DXVK_VERSION"
  rm -R "dxvk-$DXVK_VERSION"
}

build_arch 64
build_arch 32
90
build_script
91

92
if [ $opt_nopackage -eq 0 ]; then
93
  package
94
fi