aboutsummaryrefslogtreecommitdiff
path: root/build-packages.sh
blob: 4ecda0a0fe12ad7428bc5e508b47c966dc08f288 (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
163
164
#!/bin/bash
set -e

if [ ! -e "src/api/api.h" ]; then
  echo "Please run this script from the root directory of Lite XL."; exit 1
fi

source scripts/common.sh

show_help() {
  echo
  echo "Usage: $0 <OPTIONS>"
  echo
  echo "Common options:"
  echo
  echo "-h --help                 Show this help and exit."
  echo "-b --builddir DIRNAME     Set the name of the build directory (not path)."
  echo "                          Default: '$(get_default_build_dir)'."
  echo "-p --prefix PREFIX        Install directory prefix."
  echo "                          Default: '/'."
  echo "   --debug                Debug this script."
  echo
  echo "Build options:"
  echo
  echo "-f --forcefallback        Force to build subprojects dependencies statically."
  echo "-B --bundle               Create an App bundle (macOS only)"
  echo "-P --portable             Create a portable package."
  echo "-O --pgo                  Use profile guided optimizations (pgo)."
  echo "                          Requires running the application iteractively."
  echo
  echo "Package options:"
  echo
  echo "-d --destdir DIRNAME      Set the name of the package directory (not path)."
  echo "                          Default: 'lite-xl'."
  echo "-v --version VERSION      Sets the version on the package name."
  echo "-A --appimage             Create an AppImage (Linux only)."
  echo "-D --dmg                  Create a DMG disk image (macOS only)."
  echo "                          Requires NPM and AppDMG."
  echo "-I --innosetup            Create an InnoSetup installer (Windows only)."
  echo "-S --source               Create a source code package,"
  echo "                          including subprojects dependencies."
  echo
}

main() {
  local build_dir
  local build_dir_option=()
  local dest_dir
  local dest_dir_option=()
  local prefix
  local prefix_option=()
  local version
  local version_option=()
  local debug
  local force_fallback
  local appimage
  local bundle
  local innosetup
  local portable
  local pgo

  for i in "$@"; do
    case $i in
      -h|--help)
        show_help
        exit 0
        ;;
      -b|--builddir)
        build_dir="$2"
        shift
        shift
        ;;
      -d|--destdir)
        dest_dir="$2"
        shift
        shift
        ;;
      -f|--forcefallback)
        force_fallback="--forcefallback"
        shift
        ;;
      -p|--prefix)
        prefix="$2"
        shift
        shift
        ;;
      -v|--version)
        version="$2"
        shift
        shift
        ;;
      -A|--appimage)
        appimage="--appimage"
        shift
        ;;
      -B|--bundle)
        bundle="--bundle"
        shift
        ;;
      -D|--dmg)
        dmg="--dmg"
        shift
        ;;
      -I|--innosetup)
        innosetup="--innosetup"
        shift
        ;;
      -P|--portable)
        portable="--portable"
        shift
        ;;
      -S|--source)
        source="--source"
        shift
        ;;
      -O|--pgo)
        pgo="--pgo"
        shift
        ;;
      --debug)
        debug="--debug"
        set -x
        shift
        ;;
      *)
        # unknown option
        ;;
    esac
  done

  if [[ -n $1 ]]; then
    show_help
    exit 1
  fi

  if [[ -n $build_dir ]]; then build_dir_option=("--builddir" "${build_dir}"); fi
  if [[ -n $dest_dir ]]; then dest_dir_option=("--destdir" "${dest_dir}"); fi
  if [[ -n $prefix ]]; then prefix_option=("--prefix" "${prefix}"); fi
  if [[ -n $version ]]; then version_option=("--version" "${version}"); fi

  source scripts/build.sh \
    ${build_dir_option[@]} \
    ${prefix_option[@]} \
    $debug \
    $force_fallback \
    $bundle \
    $portable \
    $pgo

  source scripts/package.sh \
    ${build_dir_option[@]} \
    ${dest_dir_option[@]} \
    ${prefix_option[@]} \
    ${version_option[@]} \
    --binary \
    --addons \
    $debug \
    $appimage \
    $dmg \
    $innosetup \
    $source
}

main "$@"