Adapt all scripts to work together with build-packages.sh

This commit is contained in:
redtide 2021-08-29 10:15:55 +02:00 committed by Francesco
parent 9e5d404b29
commit 38d85f2483
17 changed files with 829 additions and 601 deletions

View File

@ -1,26 +1,25 @@
name: CI name: CI
# All builds use lhelper only for releases,
# otherwise for normal builds dependencies are dynamically linked.
on: on:
push: push:
branches: branches:
- '*' - '*'
# Temporarily disabled # tags:
#tags: # - 'v[0-9]*'
#- 'v[0-9]*'
pull_request: pull_request:
branches: branches:
- '*' - '*'
jobs: jobs:
# Note: not using git-archive(-all) because it can't include subprojects ignored by git
archive_source_code: archive_source_code:
name: Source Code Tarball name: Source Code Tarball
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
# Only on tags/releases # Only on tags/releases
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
steps: steps:
- name: Set Environment Variables
run: echo "INSTALL_NAME=lite-xl-${GITHUB_REF##*/}-src" >> "$GITHUB_ENV"
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Python Setup - name: Python Setup
uses: actions/setup-python@v2 uses: actions/setup-python@v2
@ -30,16 +29,14 @@ jobs:
run: | run: |
sudo apt-get install -qq ninja-build sudo apt-get install -qq ninja-build
pip3 install meson pip3 install meson
- name: Archive source code - name: Package
shell: bash shell: bash
run: bash scripts/source-package.sh --destdir "${INSTALL_NAME}" run: bash scripts/package.sh --version ${GITHUB_REF##*/} --debug --source
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
name: Source Code Tarball name: Source Code Tarball
path: ${{ env.INSTALL_NAME }}.tar.gz path: "lite-xl-*-src.tar.gz"
# All builds use lhelper only for releases, using --static build argument,
# otherwise for normal builds dependencies are dynamically linked.
build_linux: build_linux:
name: Linux name: Linux
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
@ -52,11 +49,12 @@ jobs:
CC: ${{ matrix.config.cc }} CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cxx }} CXX: ${{ matrix.config.cxx }}
steps: steps:
- name: Set Archive Name - name: Set Environment Variables
if: ${{ matrix.config.cc == 'gcc' }} if: ${{ matrix.config.cc == 'gcc' }}
run: | run: |
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
echo "INSTALL_REF=${GITHUB_REF##*/}" >> "$GITHUB_ENV" echo "INSTALL_REF=${GITHUB_REF##*/}" >> "$GITHUB_ENV"
echo "INSTALL_NAME=lite-xl-${GITHUB_REF##*/}-linux" >> "$GITHUB_ENV" echo "INSTALL_NAME=lite-xl-${GITHUB_REF##*/}-linux-$(uname -m)" >> "$GITHUB_ENV"
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Python Setup - name: Python Setup
uses: actions/setup-python@v2 uses: actions/setup-python@v2
@ -64,27 +62,24 @@ jobs:
python-version: 3.6 python-version: 3.6
- name: Update Packages - name: Update Packages
run: sudo apt-get update run: sudo apt-get update
- name: Install Meson
run: |
sudo apt-get install -qq ninja-build
pip3 install meson
- name: Install Dependencies - name: Install Dependencies
if: ${{ !startsWith(github.ref, 'refs/tags/') }} if: ${{ !startsWith(github.ref, 'refs/tags/') }}
run: sudo apt-get install -qq libsdl2-dev libfreetype6 run: bash scripts/install-dependencies.sh --debug
- name: Install Release Dependencies
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
bash scripts/install-dependencies.sh --debug --lhelper
bash scripts/lhelper.sh --debug
- name: Build - name: Build
if: ${{ matrix.config.cc == 'gcc' && !startsWith(github.ref, 'refs/tags/') }} run: |
run: bash scripts/build.sh --prefix / bash --version
- name: Release Build bash scripts/build.sh --debug --forcefallback
if: ${{ matrix.config.cc == 'gcc' && startsWith(github.ref, 'refs/tags/') }}
run: bash scripts/build.sh --prefix / --static
- name: Package - name: Package
if: ${{ matrix.config.cc == 'gcc' }} if: ${{ matrix.config.cc == 'gcc' }}
run: | run: bash scripts/package.sh --version ${INSTALL_REF} --debug --addons --binary
DESTDIR="$(pwd)/$INSTALL_NAME" meson install --skip-subprojects -C build
tar czvf "${INSTALL_NAME}".tar.gz "${INSTALL_NAME}"
- name: AppImage - name: AppImage
if: ${{ matrix.config.cc == 'gcc' && startsWith(github.ref, 'refs/tags/') }} if: ${{ matrix.config.cc == 'gcc' && startsWith(github.ref, 'refs/tags/') }}
run: bash scripts/appimage.sh --nobuild --static --version ${{ env.INSTALL_REF }} run: bash scripts/appimage.sh --nobuild --version ${INSTALL_REF}
- name: Upload Artifacts - name: Upload Artifacts
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
if: ${{ matrix.config.cc == 'gcc' }} if: ${{ matrix.config.cc == 'gcc' }}
@ -104,47 +99,42 @@ jobs:
- name: System Information - name: System Information
run: | run: |
system_profiler SPSoftwareDataType system_profiler SPSoftwareDataType
bash --version
gcc -v gcc -v
xcodebuild -version xcodebuild -version
- name: Set Archive Name - name: Set Environment Variables
run: | run: |
echo "INSTALL_NAME=lite-xl-${GITHUB_REF##*/}-macos" >> "$GITHUB_ENV" echo "$HOME/.local/bin" >> "$GITHUB_PATH"
bash --version echo "INSTALL_REF=${GITHUB_REF##*/}" >> "$GITHUB_ENV"
echo "INSTALL_NAME=lite-xl-${GITHUB_REF##*/}-macos-$(uname -m)" >> "$GITHUB_ENV"
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Python Setup - name: Python Setup
uses: actions/setup-python@v2 uses: actions/setup-python@v2
with: with:
python-version: 3.9 python-version: 3.9
- name: Install Build Tools
run: |
brew install ninja
pip3 install meson
cd ~; npm install appdmg; cd -
~/node_modules/appdmg/bin/appdmg.js --version
- name: Install Dependencies - name: Install Dependencies
if: ${{ !startsWith(github.ref, 'refs/tags/') }} if: ${{ !startsWith(github.ref, 'refs/tags/') }}
run: brew install sdl2 run: bash scripts/install-dependencies.sh --debug
- name: Install LHelper Dependencies - name: Install Release Dependencies
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: brew install bash md5sha1sum
- name: Build
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
run: bash scripts/build.sh --prefix "${GITHUB_WORKSPACE}/Lite XL.app"
- name: Release Build
if: ${{ startsWith(github.ref, 'refs/tags/') }} if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
bash scripts/install-dependencies.sh --debug --lhelper
bash scripts/lhelper.sh --debug
- name: Build
run: | run: |
bash --version bash --version
bash scripts/build.sh --prefix "${GITHUB_WORKSPACE}/Lite XL.app" --static bash scripts/build.sh --bundle --debug --forcefallback
- name: Error Logs - name: Error Logs
if: failure() if: failure()
run: | run: |
mkdir ${INSTALL_NAME} mkdir ${INSTALL_NAME}
cp /usr/var/lhenv/lite-xl/logs/* ${INSTALL_NAME} cp /usr/var/lhenv/lite-xl/logs/* ${INSTALL_NAME}
tar czvf ${INSTALL_NAME}.tar.gz ${INSTALL_NAME} tar czvf ${INSTALL_NAME}.tar.gz ${INSTALL_NAME}
- name: Install # - name: Package
run: meson install --skip-subprojects -C build # if: ${{ !startsWith(github.ref, 'refs/tags/') }}
# run: bash scripts/package.sh --version ${INSTALL_REF} --debug --addons
- name: Create DMG Image - name: Create DMG Image
run: bash scripts/appdmg.sh ${{ env.INSTALL_NAME }} run: bash scripts/package.sh --version ${INSTALL_REF} --debug --addons --dmg
- name: Upload DMG Image - name: Upload DMG Image
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
@ -178,34 +168,20 @@ jobs:
git git
zip zip
- name: Set Environment Variables - name: Set Environment Variables
run: echo "INSTALL_NAME=lite-xl-${GITHUB_REF##*/}-$(echo $MSYSTEM | awk '{print tolower($0)}')" >> "$GITHUB_ENV" run: |
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
echo "INSTALL_NAME=lite-xl-${GITHUB_REF##*/}-windows-$(uname -m)" >> "$GITHUB_ENV"
echo "INSTALL_REF=${GITHUB_REF##*/}" >> "$GITHUB_ENV"
- name: Install Dependencies - name: Install Dependencies
if: ${{ !startsWith(github.ref, 'refs/tags/') }} if: ${{ !startsWith(github.ref, 'refs/tags/') }}
run: | run: bash scripts/install-dependencies.sh --debug
pacman --noconfirm -S \
${MINGW_PACKAGE_PREFIX}-gcc \
${MINGW_PACKAGE_PREFIX}-meson \
${MINGW_PACKAGE_PREFIX}-ninja \
${MINGW_PACKAGE_PREFIX}-pkg-config \
${MINGW_PACKAGE_PREFIX}-freetype \
${MINGW_PACKAGE_PREFIX}-pcre2 \
${MINGW_PACKAGE_PREFIX}-SDL2
- name: Install Release Dependencies - name: Install Release Dependencies
if: ${{ startsWith(github.ref, 'refs/tags/') }} if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: | run: bash scripts/install-dependencies.sh --debug --lhelper
pacman --noconfirm -S \
${MINGW_PACKAGE_PREFIX}-gcc \
${MINGW_PACKAGE_PREFIX}-meson \
${MINGW_PACKAGE_PREFIX}-ninja \
${MINGW_PACKAGE_PREFIX}-pkg-config
- name: Build - name: Build
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
run: bash scripts/build.sh --prefix /
- name: Release Build
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: | run: |
bash --version bash --version
bash scripts/build.sh --prefix / --static bash scripts/build.sh --debug --forcefallback
- name: Error Logs - name: Error Logs
if: failure() if: failure()
run: | run: |
@ -213,10 +189,10 @@ jobs:
cp /usr/var/lhenv/lite-xl/logs/* ${INSTALL_NAME} cp /usr/var/lhenv/lite-xl/logs/* ${INSTALL_NAME}
tar czvf ${INSTALL_NAME}.tar.gz ${INSTALL_NAME} tar czvf ${INSTALL_NAME}.tar.gz ${INSTALL_NAME}
- name: Package - name: Package
run: bash scripts/msys2-package.sh --destdir ${INSTALL_NAME} run: bash scripts/package.sh --version ${INSTALL_REF} --debug --addons --binary
- name: Build Installer - name: Build Installer
if: ${{ startsWith(github.ref, 'refs/tags/') }} if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: bash scripts/innosetup/innosetup.sh run: bash scripts/innosetup/innosetup.sh --debug
- name: Upload Artifacts - name: Upload Artifacts
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
@ -234,9 +210,8 @@ jobs:
deploy: deploy:
name: Deployment name: Deployment
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
# Temporarily disabled # if: startsWith(github.ref, 'refs/tags/')
if: false if: false
#if: startsWith(github.ref, 'refs/tags/')
needs: needs:
- archive_source_code - archive_source_code
- build_linux - build_linux

2
.gitignore vendored
View File

@ -10,6 +10,7 @@ subprojects/reproc/
.lite-debug.log .lite-debug.log
.run* .run*
*.diff *.diff
*.exe
*.tar.gz *.tar.gz
*.zip *.zip
*.DS_Store *.DS_Store
@ -17,3 +18,4 @@ subprojects/reproc/
compile_commands.json compile_commands.json
error.txt error.txt
lite-xl* lite-xl*
LiteXL*

View File

@ -49,11 +49,11 @@ If you compile Lite XL yourself, it is recommended to use the script
`build-packages.sh`: `build-packages.sh`:
```sh ```sh
bash build-packages.sh <arch> bash build-packages.sh -h
``` ```
The script will run Meson and create a zip file with the application or, The script will run Meson and create a tar compressed archive with the application or,
for Linux, a tar compressed archive. Lite XL can be easily installed for Windows, a zip file. Lite XL can be easily installed
by unpacking the archive in any directory of your choice. by unpacking the archive in any directory of your choice.
Otherwise the following is an example of basic commands if you want to customize Otherwise the following is an example of basic commands if you want to customize
@ -65,7 +65,15 @@ meson compile -C build
DESTDIR="$(pwd)/lite-xl" meson install --skip-subprojects -C build DESTDIR="$(pwd)/lite-xl" meson install --skip-subprojects -C build
``` ```
where `<prefix>` might be one of `/`, `/usr` or `/opt`, the default is `/usr/local`. where `<prefix>` might be one of `/`, `/usr` or `/opt`, the default is `/`.
To build a bundle application on macOS:
```sh
meson setup --buildtype=release --Dbundle=true --prefix / build
meson compile -C build
DESTDIR="$(pwd)/Lite XL.app" meson install --skip-subprojects -C build
```
Please note that the package is relocatable to any prefix and the option prefix Please note that the package is relocatable to any prefix and the option prefix
affects only the place where the application is actually installed. affects only the place where the application is actually installed.

View File

@ -1,259 +1,156 @@
#!/bin/bash #!/bin/bash
set -e
# strip-components is normally set to 1 to strip the initial "data" from the if [ ! -e "src/api/api.h" ]; then
# directory path. echo "Please run this script from the root directory of Lite XL."; exit 1
copy_directory_from_repo () { fi
local tar_options=()
if [[ $1 == --strip-components=* ]]; then source scripts/common.sh
tar_options+=($1)
shift show_help() {
fi echo
local dirname="$1" echo "Usage: $0 <OPTIONS>"
local destdir="$2" echo
_archive "$use_branch" "$dirname" "$destdir" "${tar_options[@]}" 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
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
} }
_archive () { main() {
if [[ $git_available -eq 1 ]]; then local build_dir
git archive "$1" "$2" --format=tar | tar xf - -C "$3" "$4" local build_dir_option=()
else local dest_dir
cp -r "$2" "$3" local dest_dir_option=()
fi local prefix
} local prefix_option=()
local version
local version_option=()
local debug
local force_fallback
local appimage
local bundle
local innosetup
local portable
# Check if build directory is ok to be used to build. for i in "$@"; do
build_dir_is_usable () { case $i in
local build="$1" -h|--help)
if [[ $build == */* || -z "$build" ]]; then show_help
echo "invalid build directory, no path allowed: \"$build\"" exit 0
return 1 ;;
fi -b|--builddir)
if [[ $git_available -eq 1 ]]; then build_dir="$2"
git ls-files --error-unmatch "$build" &> /dev/null shift
if [ $? == 0 ]; then shift
echo "invalid path, \"$build\" is under revision control" ;;
return 1 -d|--destdir)
fi dest_dir="$2"
fi shift
} shift
;;
# Ordinary release build -f|--forcefallback)
lite_build () { force_fallback="--forcefallback"
local build="$1" shift
build_dir_is_usable "$build" || exit 1 ;;
rm -fr "$build" -p|--prefix)
setup_options=("${@:2}") prefix="$2"
if [[ "$OSTYPE" == "darwin"* ]]; then shift
setup_options+=(-Dbundle=true) shift
fi ;;
meson setup --buildtype=release "${setup_options[@]}" "$build" || exit 1 -v|--version)
ninja -C "$build" || exit 1 version="$2"
} shift
shift
# Build using Profile Guided Optimizations (PGO) ;;
lite_build_pgo () { -A|--appimage)
local build="$1" appimage="--appimage"
build_dir_is_usable "$build" || exit 1 shift
rm -fr "$build" ;;
echo meson setup --buildtype=release "${@:2}" -Db_pgo=generate "$build" -B|--bundle)
meson setup --buildtype=release "${@:2}" -Db_pgo=generate "$build" || exit 1 bundle="--bundle"
ninja -C "$build" || exit 1 shift
copy_directory_from_repo data "$build/src" ;;
"$build/src/lite-xl" -D|--dmg)
meson configure -Db_pgo=use "$build" dmg="--dmg"
ninja -C "$build" || exit 1 shift
} ;;
-I|--innosetup)
lite_build_package_windows () { innosetup="--innosetup"
local portable="-msys" shift
if [ "$1" == "-portable" ]; then ;;
portable="" -P|--portable)
shift portable="--portable"
fi shift
local build="$1" ;;
local arch="$2" -S|--source)
local os="win" source="--source"
local pdir=".package-build/lite-xl" shift
if [ -z "$portable" ]; then ;;
local bindir="$pdir" --debug)
local datadir="$pdir/data" debug="--debug"
else set -x
local bindir="$pdir/bin" shift
local datadir="$pdir/share/lite-xl" ;;
fi *)
mkdir -p "$bindir" # unknown option
mkdir -p "$datadir" ;;
for module_name in core plugins colors fonts; do esac
copy_directory_from_repo --strip-components=1 "data/$module_name" "$datadir"
done done
# copy the meson generated start.lua file
cp "$build/start.lua" "$datadir/core"
for module_name in plugins colors; do
cp -r "$build/third/data/$module_name" "$datadir"
done
cp "$build/src/lite-xl.exe" "$bindir"
strip --strip-all "$bindir/lite-xl.exe"
pushd ".package-build"
local package_name="lite-xl-$os-$arch$portable.zip"
zip "$package_name" -r "lite-xl"
mv "$package_name" ..
popd
rm -fr ".package-build"
echo "created package $package_name"
}
lite_build_package_macos () { if [[ -n $1 ]]; then
local build="$1" show_help
local arch="$2"
local os="macos"
local appdir=".package-build/lite-xl.app"
local bindir="$appdir/Contents/MacOS"
local datadir="$appdir/Contents/Resources"
mkdir -p "$bindir" "$datadir"
for module_name in core plugins colors fonts; do
copy_directory_from_repo --strip-components=1 "data/$module_name" "$datadir"
done
# copy the meson generated start.lua file
cp "$build/start.lua" "$datadir/core"
for module_name in plugins colors; do
cp -r "$build/third/data/$module_name" "$datadir"
done
cp resources/icons/icon.icns "$appdir/Contents/Resources/icon.icns"
cp "$build/Info.plist" "$appdir/Contents/Info.plist"
cp "$build/src/lite-xl" "$bindir/lite-xl"
strip "$bindir/lite-xl"
pushd ".package-build"
local package_name="lite-xl-$os-$arch.zip"
zip "$package_name" -r "lite-xl.app"
mv "$package_name" ..
popd
rm -fr ".package-build"
echo "created package $package_name"
}
lite_build_package_linux () {
local portable=""
if [ "$1" == "-portable" ]; then
portable="-portable"
shift
fi
local build="$1"
local arch="$2"
local os="linux"
local pdir=".package-build/lite-xl"
if [ "$portable" == "-portable" ]; then
local bindir="$pdir"
local datadir="$pdir/data"
local docdir="$pdir/doc"
else
local bindir="$pdir/bin"
local datadir="$pdir/share/lite-xl"
local docdir="$pdir/share/doc/lite-xl"
fi
mkdir -p "$bindir"
mkdir -p "$datadir"
mkdir -p "$docdir"
for module_name in core plugins colors fonts; do
copy_directory_from_repo --strip-components=1 "data/$module_name" "$datadir"
done
# copy the meson generated start.lua file
cp "$build/start.lua" "$datadir/core"
for module_name in plugins colors; do
cp -r "$build/third/data/$module_name" "$datadir"
done
cp "$build/src/lite-xl" "$bindir"
cp "licenses/licenses.md" "$docdir"
strip "$bindir/lite-xl"
if [ -z "$portable" ]; then
mkdir -p "$pdir/share/applications" "$pdir/share/icons/hicolor/scalable/apps" "$pdir/share/metainfo"
cp "resources/linux/org.lite_xl.lite_xl.desktop" "$pdir/share/applications"
cp "resources/linux/org.lite_xl.lite_xl.appdata.xml" "$pdir/share/metainfo"
cp "resources/icons/lite-xl.svg" "$pdir/share/icons/hicolor/scalable/apps/lite-xl.svg"
fi
pushd ".package-build"
local package_name="lite-xl-$os-$arch$portable.tar.gz"
tar czf "$package_name" "lite-xl"
mv "$package_name" ..
popd
rm -fr ".package-build"
echo "created package $package_name"
}
lite_build_package () {
if [[ "$OSTYPE" == msys || "$OSTYPE" == win32 ]]; then
lite_build_package_windows "$@"
elif [[ "$OSTYPE" == "darwin"* ]]; then
lite_build_package_macos "$@"
elif [[ "$OSTYPE" == "linux"* || "$OSTYPE" == "freebsd"* ]]; then
lite_build_package_linux "$@"
else
echo "Unknown OS type \"$OSTYPE\""
exit 1 exit 1
fi 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
source scripts/package.sh \
${build_dir_option[@]} \
${dest_dir_option[@]} \
${prefix_option[@]} \
${version_option[@]} \
--binary \
--addons \
$debug \
$appimage \
$dmg \
$innosetup \
$source
} }
lite_copy_third_party_modules () { main "$@"
local build="$1"
curl --insecure -L "https://github.com/rxi/lite-colors/archive/master.zip" -o "$build/rxi-lite-colors.zip"
mkdir -p "$build/third/data/colors" "$build/third/data/plugins"
unzip "$build/rxi-lite-colors.zip" -d "$build"
mv "$build/lite-colors-master/colors" "$build/third/data"
rm -fr "$build/lite-colors-master"
}
build_opts=()
unset arch
while [ ! -z {$1+x} ]; do
case $1 in
-renderer)
build_opts+=("-Drenderer=true")
shift
;;
-pgo)
pgo=true
shift
;;
-branch=*)
use_branch="${1#-branch=}"
shift
;;
*)
arch="$1"
break
esac
done
if [ -z ${arch+set} ]; then
echo "usage: $0 [options] <arch>"
exit 1
fi
if [[ -d ".git" || $BUILD_PROHIBIT_GIT -ne 0 ]]; then
git_available=1;
else
echo "Use of git prohibited. Either '.git' wasn't found or BUILD_PROHIBIT_GIT was set."
git_available=0;
fi
if [ -z ${use_branch+set} ]; then
if [[ $git_available -eq 1 ]]; then
use_branch="$(git rev-parse --abbrev-ref HEAD)"
else
# it really doesn't matter if git isn't present
use_branch="master"
fi
fi
build_dir=".build-$arch"
if [ -z ${pgo+set} ]; then
lite_build "$build_dir" "${build_opts[@]}"
else
lite_build_pgo "$build_dir" "${build_opts[@]}"
fi
lite_copy_third_party_modules "$build_dir"
lite_build_package "$build_dir" "$arch"
if [[ ! ( "$OSTYPE" == "linux"* || "$OSTYPE" == "freebsd"* || "$OSTYPE" == "darwin"* ) ]]; then
lite_build_package -portable "$build_dir" "$arch"
fi

View File

@ -42,26 +42,28 @@ endif
#=============================================================================== #===============================================================================
# Dependencies # Dependencies
#=============================================================================== #===============================================================================
libm = cc.find_library('m', required : false) if not get_option('source-only')
libdl = cc.find_library('dl', required : false) libm = cc.find_library('m', required : false)
lua_dep = dependency('lua5.2', fallback: ['lua', 'lua_dep'], libdl = cc.find_library('dl', required : false)
default_options: ['shared=false', 'use_readline=false', 'app=false'] lua_dep = dependency('lua5.2', fallback: ['lua', 'lua_dep'],
) default_options: ['shared=false', 'use_readline=false', 'app=false']
pcre2_dep = dependency('libpcre2-8') )
sdl_dep = dependency('sdl2', method: 'config-tool') pcre2_dep = dependency('libpcre2-8')
reproc_dep = dependency('reproc', fallback: ['reproc', 'reproc_dep'], sdl_dep = dependency('sdl2', method: 'config-tool')
default_options: [ reproc_dep = dependency('reproc', fallback: ['reproc', 'reproc_dep'],
'default_library=static', 'multithreaded=false', default_options: [
'reproc-cpp=false', 'examples=false' 'default_library=static', 'multithreaded=false',
] 'reproc-cpp=false', 'examples=false'
) ]
)
lite_deps = [lua_dep, sdl_dep, reproc_dep, pcre2_dep, libm, libdl] lite_deps = [lua_dep, sdl_dep, reproc_dep, pcre2_dep, libm, libdl]
if host_machine.system() == 'windows' if host_machine.system() == 'windows'
# Note that we need to explicitly add the windows socket DLL because # Note that we need to explicitly add the windows socket DLL because
# the pkg-config file from reproc does not include it. # the pkg-config file from reproc does not include it.
lite_deps += meson.get_compiler('cpp').find_library('ws2_32', required: true) lite_deps += meson.get_compiler('cpp').find_library('ws2_32', required: true)
endif
endif endif
#=============================================================================== #===============================================================================
# Install Configuration # Install Configuration
@ -118,6 +120,8 @@ configure_file(
#=============================================================================== #===============================================================================
# Targets # Targets
#=============================================================================== #===============================================================================
subdir('lib/font_renderer') if not get_option('source-only')
subdir('src') subdir('lib/font_renderer')
subdir('scripts') subdir('src')
subdir('scripts')
endif

View File

@ -1,3 +1,4 @@
option('bundle', type : 'boolean', value : false, description: 'Build a macOS bundle') option('bundle', type : 'boolean', value : false, description: 'Build a macOS bundle')
option('source-only', type : 'boolean', value : false, description: 'Configure source files only, doesn\'t checks for dependencies')
option('portable', type : 'boolean', value : false, description: 'Portable install') option('portable', type : 'boolean', value : false, description: 'Portable install')
option('renderer', type : 'boolean', value : false, description: 'Use SDL renderer') option('renderer', type : 'boolean', value : false, description: 'Use SDL renderer')

28
scripts/README.md Normal file
View File

@ -0,0 +1,28 @@
# Scripts
Various scripts and configurations used to configure, build, and package Lite XL.
### Build
- **build.sh**
- **build-packages.sh**: In root directory, as all in one script; relies to the
ones in this directory.
### Package
- **appdmg.sh**: Create a macOS DMG image using [AppDMG][1].
- **appimage.sh**: [AppImage][2] builder.
- **innosetup.sh**: Creates a 32/64 bit [InnoSetup][3] installer package.
- **package.sh**: Creates all binary / DMG image / installer / source packages.
### Utility
- **common.sh**: Common functions used by other scripts.
- **install-dependencies.sh**: Installs required applications to build, package
and run Lite XL, mainly useful for CI and documentation purpose.
Preferably not to be used in user systems.
- **fontello-config.json**: Used by the icons generator.
[1]: https://github.com/LinusU/node-appdmg
[2]: https://docs.appimage.org/
[3]: https://jrsoftware.org/isinfo.php

View File

@ -6,9 +6,11 @@ if [ ! -e "src/api/api.h" ]; then
exit 1 exit 1
fi fi
source scripts/common.sh
show_help(){ show_help(){
echo echo
echo $0 echo "Usage: $0 <OPTIONS>"
echo echo
echo "Available options:" echo "Available options:"
echo echo
@ -23,7 +25,7 @@ show_help(){
} }
ARCH="$(uname -m)" ARCH="$(uname -m)"
BUILD_DIR=build BUILD_DIR="$(get_default_build_dir)"
RUN_BUILD=true RUN_BUILD=true
STATIC_BUILD=false STATIC_BUILD=false
@ -67,7 +69,7 @@ if [[ -n $1 ]]; then
exit 1 exit 1
fi fi
setup_appimagetool(){ setup_appimagetool() {
if ! which appimagetool > /dev/null ; then if ! which appimagetool > /dev/null ; then
if [ ! -e appimagetool ]; then if [ ! -e appimagetool ]; then
if ! wget -O appimagetool "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-${ARCH}.AppImage" ; then if ! wget -O appimagetool "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-${ARCH}.AppImage" ; then
@ -80,7 +82,7 @@ setup_appimagetool(){
fi fi
} }
download_appimage_apprun(){ download_appimage_apprun() {
if [ ! -e AppRun ]; then if [ ! -e AppRun ]; then
if ! wget -O AppRun "https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-${ARCH}" ; then if ! wget -O AppRun "https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-${ARCH}" ; then
echo "Could not download AppRun for the arch '${ARCH}'." echo "Could not download AppRun for the arch '${ARCH}'."
@ -91,7 +93,7 @@ download_appimage_apprun(){
fi fi
} }
build_litexl(){ build_litexl() {
if [ -e build ]; then if [ -e build ]; then
rm -rf build rm -rf build
fi fi
@ -106,7 +108,7 @@ build_litexl(){
meson compile -C ${BUILD_DIR} meson compile -C ${BUILD_DIR}
} }
generate_appimage(){ generate_appimage() {
if [ -e LiteXL.AppDir ]; then if [ -e LiteXL.AppDir ]; then
rm -rf LiteXL.AppDir rm -rf LiteXL.AppDir
fi fi

View File

@ -1,103 +1,102 @@
#!/bin/bash #!/bin/bash
set -ex set -e
if [ ! -e "src/api/api.h" ]; then if [ ! -e "src/api/api.h" ]; then
echo "Please run this script from the root directory of Lite XL." echo "Please run this script from the root directory of Lite XL."; exit 1
exit 1
fi fi
show_help(){ source scripts/common.sh
show_help() {
echo echo
echo "Usage: $0 <OPTIONS>" echo "Usage: $0 <OPTIONS>"
echo echo
echo "Available options:" echo "Available options:"
echo echo
echo "-b --builddir DIRNAME Sets the name of the build directory (not path)." echo "-b --builddir DIRNAME Sets the name of the build directory (not path)."
echo " Default: 'build'." echo " Default: '$(get_default_build_dir)'."
echo "-p --prefix Install directory prefix. Mandatory." echo " --debug Debug this script."
echo "-s --static Specify if building using static libraries" echo "-f --forcefallback Force to build dependencies statically."
echo " by using lhelper tool." echo "-h --help Show this help and exit."
echo "-p --prefix PREFIX Install directory prefix. Default: '/'."
echo "-B --bundle Create an App bundle (macOS only)"
echo "-P --portable Create a portable binary package."
echo " macOS: disabled when used with --bundle,"
echo " Windows: Implicit being the only option."
echo echo
} }
install_lhelper() { main() {
if [[ ! -d lhelper ]]; then local platform="$(get_platform_name)"
git clone https://github.com/franko/lhelper.git local build_dir="$(get_default_build_dir)"
pushd lhelper; bash install-github; popd local prefix=/
local force_fallback
local bundle
local portable
if [[ "$OSTYPE" == "darwin"* ]]; then for i in "$@"; do
CC=clang CXX=clang++ lhelper create lite-xl -n case $i in
else -h|--help)
lhelper create lite-xl -n show_help
fi exit 0
;;
-b|--builddir)
build_dir="$2"
shift
shift
;;
--debug)
set -x
shift
;;
-f|--forcefallback)
force_fallback="--wrap-mode=forcefallback"
shift
;;
-p|--prefix)
prefix="$2"
shift
shift
;;
-B|--bundle)
if [[ "$platform" != "macos" ]]; then
echo "Warning: ignoring --bundle option, works only under macOS."
else
bundle="-Dbundle=true"
fi
shift
;;
-P|--portable)
portable="-Dportable=true"
shift
;;
*)
# unknown option
;;
esac
done
if [[ -n $1 ]]; then
show_help
exit 1
fi fi
# Not using `lhelper activate lite-xl` if [[ $platform == "macos" && -n $bundle && -n $portable ]]; then
source "$(lhelper env-source lite-xl)" echo "Warning: \"bundle\" and \"portable\" specified; excluding portable package."
portable=""
lhelper install freetype2
lhelper install sdl2 2.0.14-wait-event-timeout-1
lhelper install pcre2
# Help MSYS2 to find the SDL2 include and lib directories to avoid errors
# during build and linking when using lhelper.
if [[ "$OSTYPE" == "msys" ]]; then
CFLAGS=-I${LHELPER_ENV_PREFIX}/include/SDL2
LDFLAGS=-L${LHELPER_ENV_PREFIX}/lib
fi fi
}
build() { rm -rf "${build_dir}"
CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS meson setup \ CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS meson setup \
--buildtype=release \ --buildtype=release \
--prefix "$PREFIX" \ --prefix "$prefix" \
--wrap-mode=forcefallback \ $force_fallback \
"${BUILD_DIR}" $bundle \
$portable \
"${build_dir}"
meson compile -C build meson compile -C "${build_dir}"
} }
BUILD_DIR=build main "$@"
STATIC_BUILD=false
for i in "$@"; do
case $i in
-h|--belp)
show_help
exit 0
;;
-b|--builddir)
BUILD_DIR="$2"
shift
shift
;;
-p|--prefix)
PREFIX="$2"
shift
shift
;;
-s|--static)
STATIC_BUILD=true
shift
;;
*)
# unknown option
;;
esac
done
if [[ -n $1 ]]; then
show_help
exit 1
fi
if [[ -z $PREFIX ]]; then
echo "ERROR: prefix argument is missing."
exit 1
fi
if [[ $STATIC_BUILD == true ]]; then
install_lhelper
fi
build

25
scripts/common.sh Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash
set -e
get_platform_name() {
if [[ "$OSTYPE" == "msys" ]]; then
echo "windows"
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "macos"
elif [[ "$OSTYPE" == "linux"* || "$OSTYPE" == "freebsd"* ]]; then
echo "linux"
else
echo "UNSUPPORTED-OS"
fi
}
get_default_build_dir() {
platform=$(get_platform_name)
echo "build-$platform-$(uname -m)"
}
if [[ $(get_platform_name) == "UNSUPPORTED-OS" ]]; then
echo "Error: unknown OS type: \"$OSTYPE\""
exit 1
fi

View File

@ -9,7 +9,7 @@
; Use /dArch option to create a setup for a different architecture, e.g.: ; Use /dArch option to create a setup for a different architecture, e.g.:
; iscc /dArch=x86 innosetup.iss ; iscc /dArch=x86 innosetup.iss
#ifndef Arch #ifndef Arch
#define Arch "x64" #define Arch "x64"
#endif #endif
[Setup] [Setup]
@ -27,8 +27,11 @@ AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL} AppUpdatesURL={#MyAppURL}
#if Arch=="x64" #if Arch=="x64"
ArchitecturesAllowed=x64 ArchitecturesAllowed=x64
ArchitecturesInstallIn64BitMode={#Arch} ArchitecturesInstallIn64BitMode=x64
#define ArchInternal "x86_64"
#else
#define ArchInternal "i686"
#endif #endif
AllowNoIcons=yes AllowNoIcons=yes
@ -48,7 +51,7 @@ PrivilegesRequiredOverridesAllowed=dialog
UsedUserAreasWarning=no UsedUserAreasWarning=no
OutputDir=. OutputDir=.
OutputBaseFilename=LiteXL-{#MyAppVersion}-{#Arch}-setup OutputBaseFilename=LiteXL-{#MyAppVersion}-{#ArchInternal}-setup
;DisableDirPage=yes ;DisableDirPage=yes
;DisableProgramGroupPage=yes ;DisableProgramGroupPage=yes
@ -67,18 +70,16 @@ Name: "portablemode"; Description: "Portable Mode"; Flags: unchecked
[Files] [Files]
Source: "{#BuildDir}/src/lite-xl.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "{#BuildDir}/src/lite-xl.exe"; DestDir: "{app}"; Flags: ignoreversion
; MSYS2 produces no external dlls on 32 bit builds when using lhelper Source: "{#BuildDir}/mingwLibs{#Arch}/*"; DestDir: "{app}"; Flags: ignoreversion ; Check: DirExists(ExpandConstant('{#BuildDir}/mingwLibs{#Arch}'))
#if Arch=="x64"
Source: "{#BuildDir}/mingwLibs{#Arch}/*"; DestDir: "{app}"; Flags: ignoreversion
#endif
Source: "{#SourceDir}/data/*"; DestDir: "{app}/data"; Flags: ignoreversion recursesubdirs Source: "{#SourceDir}/data/*"; DestDir: "{app}/data"; Flags: ignoreversion recursesubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons] [Icons]
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Check: not WizardIsTaskSelected('portablemode') Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Check: not WizardIsTaskSelected('portablemode')
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"; Check: not WizardIsTaskSelected('portablemode') Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"; Check: not WizardIsTaskSelected('portablemode')
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon; Check: not WizardIsTaskSelected('portablemode') Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon; Check: not WizardIsTaskSelected('portablemode')
; Name: "{usersendto}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
[Run] [Run]
Filename: "{app}/{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent Filename: "{app}/{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

View File

@ -1,55 +1,65 @@
#!/bin/bash #!/bin/bash
set -ex set -e
if [ ! -e "src/api/api.h" ]; then if [ ! -e "src/api/api.h" ]; then
echo "Please run this script from the root directory of Lite XL." echo "Please run this script from the root directory of Lite XL."; exit 1
exit 1
fi fi
show_help(){ source scripts/common.sh
show_help() {
echo echo
echo "Usage: $0 <OPTIONS>" echo "Usage: $0 <OPTIONS>"
echo echo
echo "Available options:" echo "Available options:"
echo echo
echo "-b --builddir DIRNAME Sets the name of the build directory (not path)." echo "-b --builddir DIRNAME Sets the name of the build directory (not path)."
echo " Default: 'build'." echo " Default: '$(get_default_build_dir)'."
echo " --debug Debug this script."
echo echo
} }
BUILD_DIR=build main() {
local build_dir=$(get_default_build_dir)
local arch
for i in "$@"; do if [[ $MSYSTEM == "MINGW64" ]]; then arch=x64; else arch=Win32; fi
case $i in
-h|--belp)
show_help
exit 0
;;
-b|--BUILD_DIR)
BUILD_DIR="$2"
shift
shift
;;
*)
# unknown option
;;
esac
done
if [[ -n $1 ]]; then for i in "$@"; do
show_help case $i in
exit 1 -h|--help)
fi show_help
exit 0
;;
-b|--builddir)
build_dir="$2"
shift
shift
;;
--debug)
set -x
shift
;;
*)
# unknown option
;;
esac
done
# TODO: Required MinGW dlls are built only (?) when using lhelper on 64 bit if [[ -n $1 ]]; then
if [[ $MSYSTEM == "MINGW64" ]]; then show_help
ARCH=x64; exit 1
mingwLibsDir=$BUILD_DIR/mingwLibs$ARCH fi
# Copy MinGW libraries dependencies.
# MSYS2 ldd command seems to be only 64bit, so use ntldd
# see https://github.com/msys2/MINGW-packages/issues/4164
local mingwLibsDir="${build_dir}/mingwLibs$arch"
mkdir -p "$mingwLibsDir" mkdir -p "$mingwLibsDir"
ldd "$BUILD_DIR/src/lite-xl.exe" | grep mingw | awk '{print $3}' | xargs -I '{}' cp -v '{}' $mingwLibsDir ntldd -R "${build_dir}/src/lite-xl.exe" | grep mingw | awk '{print $3}' | sed 's#\\#/#g' | xargs -I '{}' cp -v '{}' $mingwLibsDir
else
ARCH=Win32
fi
/c/Program\ Files\ \(x86\)/Inno\ Setup\ 6/ISCC.exe -dARCH=$ARCH $BUILD_DIR/scripts/innosetup.iss "/c/Program Files (x86)/Inno Setup 6/ISCC.exe" -dARCH=$arch "${build_dir}/scripts/innosetup.iss"
mv $BUILD_DIR/LiteXL*.exe $(pwd) pushd "${build_dir}/scripts"; mv LiteXL*.exe "./../../"; popd
}
main "$@"

View File

@ -0,0 +1,74 @@
#!/bin/bash
set -ex
if [ ! -e "src/api/api.h" ]; then
echo "Please run this script from the root directory of Lite XL."; exit 1
fi
show_help() {
echo
echo "Lite XL dependecies installer. Mainly used for CI but can also work on users systems."
echo "USE IT AT YOUR OWN RISK!"
echo
echo "Usage: $0 <OPTIONS>"
echo
echo "Available options:"
echo
echo "-l --lhelper Install tools required by LHelper and doesn't"
echo " install external libraries."
echo " --debug Debug this script."
echo
}
main() {
local lhelper=false
for i in "$@"; do
case $i in
-s|--lhelper)
lhelper=true
shift
;;
--debug)
set -x
shift
;;
*)
# unknown option
;;
esac
done
if [[ -n $1 ]]; then
show_help
exit 1
fi
if [[ "$OSTYPE" == "linux"* ]]; then
if [[ $lhelper == true ]]; then
sudo apt-get install -qq ninja-build
else
sudo apt-get install -qq ninja-build libsdl2-dev libfreetype6
fi
pip3 install meson
elif [[ "$OSTYPE" == "darwin"* ]]; then
if [[ $lhelper == true ]]; then
brew install bash md5sha1sum ninja
else
brew install ninja sdl2
fi
pip3 install meson
cd ~; npm install appdmg; cd -
~/node_modules/appdmg/bin/appdmg.js --version
elif [[ "$OSTYPE" == "msys" ]]; then
if [[ $lhelper == true ]]; then
pacman --noconfirm -S \
${MINGW_PACKAGE_PREFIX}-{gcc,meson,ninja,ntldd,pkg-config} unzip
else
pacman --noconfirm -S \
${MINGW_PACKAGE_PREFIX}-{gcc,meson,ninja,ntldd,pkg-config,freetype,pcre2,SDL2} unzip
fi
fi
}
main "$@"

75
scripts/lhelper.sh Normal file
View File

@ -0,0 +1,75 @@
#!/bin/bash
set -e
show_help() {
echo
echo "Usage: $0 <OPTIONS>"
echo
echo "Available options:"
echo
echo " --debug Debug this script."
echo "-h --help Show this help and exit."
echo "-p --prefix PREFIX Install directory prefix."
echo " Default: '$HOME/.local'."
echo
}
main() {
local lhelper_prefix="$HOME/.local"
for i in "$@"; do
case $i in
-h|--help)
show_help
exit 0
;;
-p|--prefix)
lhelper_prefix="$2"
echo "LHelper prefix set to: \"${lhelper_prefix}\""
shift
shift
;;
--debug)
set -x
shift
;;
*)
# unknown option
;;
esac
done
if [[ -n $1 ]]; then show_help; exit 1; fi
if [[ ! -f ${lhelper_prefix}/bin/lhelper ]]; then
git clone https://github.com/franko/lhelper.git
# FIXME: This should be set in ~/.bash_profile if not using CI
# export PATH="${HOME}/.local/bin:${PATH}"
mkdir -p "${lhelper_prefix}/bin"
pushd lhelper; bash install "${lhelper_prefix}"; popd
if [[ "$OSTYPE" == "darwin"* ]]; then
CC=clang CXX=clang++ lhelper create lite-xl -n
else
lhelper create lite-xl -n
fi
fi
# Not using $(lhelper activate lite-xl) to support CI
source "$(lhelper env-source lite-xl)"
lhelper install freetype2
lhelper install sdl2 2.0.14-wait-event-timeout-1
lhelper install pcre2
# Help MSYS2 to find the SDL2 include and lib directories to avoid errors
# during build and linking when using lhelper.
if [[ "$OSTYPE" == "msys" ]]; then
CFLAGS=-I${LHELPER_ENV_PREFIX}/include/SDL2
LDFLAGS=-L${LHELPER_ENV_PREFIX}/lib
fi
}
main

View File

@ -1,56 +0,0 @@
#!/bin/bash
set -ex
if [ ! -e "src/api/api.h" ]; then
echo "Please run this script from the root directory of Lite XL."
exit 1
fi
# FIXME: For some strange reason sometimes an error occurs randomly on the
# MINGW32 build of GitHub Actions; the environment variable $INSTALL_NAME
# is correct, but it expands with a drive letter at the end (all builds).
show_help(){
echo
echo "Usage: $0 <OPTIONS>"
echo
echo "Available options:"
echo
echo "-b --builddir DIRNAME Sets the name of the build directory (not path)."
echo " Default: 'build'."
echo "-d --destdir DIRNAME Sets the name of the install directory (not path)."
echo
}
BUILD_DIR=build
for i in "$@"; do
case $i in
-h|--belp)
show_help
exit 0
;;
-b|--builddir)
BUILD_DIR="$2"
shift
shift
;;
-d|--destdir)
DEST_DIR="$2"
shift
shift
;;
*)
# unknown option
;;
esac
done
if [[ -n $1 ]]; then
show_help
exit 1
fi
DESTDIR="$(pwd)/${DEST_DIR}" meson install --skip-subprojects -C ${BUILD_DIR}
zip -9rv ${DEST_DIR}.zip ${DEST_DIR}/*

252
scripts/package.sh Normal file
View File

@ -0,0 +1,252 @@
#!/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 "Available options:"
echo
echo "-b --builddir DIRNAME Sets the name of the build directory (not path)."
echo " Default: '$(get_default_build_dir)'."
echo "-d --destdir DIRNAME Set the name of the package directory (not path)."
echo " Default: 'lite-xl'."
echo "-h --help Show this help and exit."
echo "-p --prefix PREFIX Install directory prefix. Default: '/'."
echo "-v --version VERSION Sets the version on the package name."
echo " --addons Install 3rd party addons (currently RXI colors)."
echo " --debug Debug this script."
echo "-A --appimage Create an AppImage (Linux only)."
echo "-B --binary Create a normal / portable package or macOS bundle,"
echo " depending on how the build was configured. (Default.)"
echo "-D --dmg Create a DMG disk image with AppDMG (macOS only)."
echo "-I --innosetup Create a InnoSetup package (Windows only)."
echo "-S --source Create a source code package,"
echo " including subprojects dependencies."
echo
}
# Addons installation: some distributions forbid external downloads
# so make it as optional module.
install_addons() {
local build_dir="$1"
local data_dir="$2"
if [[ -d "${build_dir}/third/data/colors" ]]; then
echo "Warning: found previous colors addons installation, skipping."
return 0
fi
# Copy third party color themes
curl --insecure \
-L "https://github.com/rxi/lite-colors/archive/master.zip" \
-o "${build_dir}/rxi-lite-colors.zip"
mkdir -p "${build_dir}/third/data/colors"
unzip "${build_dir}/rxi-lite-colors.zip" -d "${build_dir}"
mv "${build_dir}/lite-colors-master/colors" "${build_dir}/third/data"
rm -rf "${build_dir}/lite-colors-master"
for module_name in colors; do
cp -r "${build_dir}/third/data/$module_name" "${data_dir}"
done
}
source_package() {
local build_dir=build-src
local package_name=$1
rm -rf ${build_dir}
rm -rf ${package_name}
rm -f ${package_name}.tar.gz
meson subprojects download
meson setup ${build_dir} -Dsource-only=true
# Note: not using git-archive(-all) because it can't include subprojects ignored by git
rsync -arv \
--exclude /*build*/ \
--exclude *.git* \
--exclude lhelper \
--exclude lite-xl* \
--exclude submodules \
. ${package_name}
cp "${build_dir}/start.lua" "${package_name}/data/core"
tar rf ${package_name}.tar ${package_name}
gzip -9 ${package_name}.tar
}
main() {
local arch="$(uname -m)"
local platform="$(get_platform_name)"
local build_dir="$(get_default_build_dir)"
local dest_dir=lite-xl
local prefix=/
local version
local addons=false
local appimage=false
local binary=false
local dmg=false
local innosetup=false
local source=false
for i in "$@"; do
case $i in
-b|--builddir)
build_dir="$2"
shift
shift
;;
-d|--destdir)
dest_dir="$2"
shift
shift
;;
-h|--help)
show_help
exit 0
;;
-p|--prefix)
prefix="$2"
shift
shift
;;
-v|--version)
if [[ -n $2 ]]; then version="-$2"; fi
shift
shift
;;
-A|--appimage)
if [[ "$platform" != "linux" ]]; then
echo "Warning: ignoring --appimage option, works only under Linux."
else
appimage=true
fi
shift
;;
-B|--binary)
binary=true
shift
;;
-D|--dmg)
if [[ "$platform" != "macos" ]]; then
echo "Warning: ignoring --dmg option, works only under macOS."
else
dmg=true
fi
shift
;;
-I|--innosetup)
if [[ "$platform" != "windows" ]]; then
echo "Warning: ignoring --innosetup option, works only under Windows."
else
innosetup=true
fi
shift
;;
-S|--source)
source=true
shift
;;
--addons)
addons=true
shift
;;
--debug)
set -x
shift
;;
*)
# unknown option
;;
esac
done
if [[ -n $1 ]]; then show_help; exit 1; fi
# The source package doesn't require a previous build,
# nor the following install step, so run it now.
if [[ $source == true ]]; then source_package "lite-xl$version-src"; fi
# No packages request
if [[ $appimage == false && $binary == false && $dmg == false && $innosetup == false ]]; then
# Source only, return.
if [[ $source == true ]]; then return 0; fi
# Build the binary package as default instead doing nothing.
binary=true
fi
rm -rf "${dest_dir}"
DESTDIR="$(pwd)/${dest_dir}" meson install -C "${build_dir}"
local data_dir="$(pwd)/${dest_dir}/data"
local exe_file="$(pwd)/${dest_dir}/lite-xl"
local package_name=lite-xl$version-$platform-$arch
local bundle=false
local stripcmd="strip"
if [[ -d "${data_dir}" ]]; then
# Portable archive
exe_file="$(pwd)/${dest_dir}/lite-xl"
if [[ $platform == "windows" ]]; then
exe_file="${exe_file}.exe"
stripcmd="strip --strip-all"
else
# Windows archive is always portable
package_name+="-portable"
fi
elif [[ $platform == "macos" && ! -d "${data_dir}" ]]; then
# macOS bundle app
bundle=true
# Specify "bundle" on compressed archive only, implicit on images
if [[ $dmg == false ]]; then package_name+="-bundle"; fi
rm -rf "Lite XL.app"; mv "${dest_dir}" "Lite XL.app"
dest_dir="Lite XL.app"
data_dir="$(pwd)/${dest_dir}/Contents/Resources"
exe_file="$(pwd)/${dest_dir}/Contents/MacOS/lite-xl"
else
data_dir="$(pwd)/${dest_dir}/$prefix/share/lite-xl"
exe_file="$(pwd)/${dest_dir}/$prefix/bin/lite-xl"
fi
mkdir -p "${data_dir}"
if [[ $addons == true ]]; then install_addons "${build_dir}" "${data_dir}"; fi
# TODO: use --skip-subprojects when 0.58.0 will be available on supported
# distributions to avoid subprojects' include and lib directories to be copied.
# Install Meson with PIP to get the latest version is not always possible.
pushd "${dest_dir}"
find . -type d -name 'include' -prune -exec rm -rf {} \;
find . -type d -name 'lib' -prune -exec rm -rf {} \;
find . -type d -empty -delete
popd
$stripcmd "${exe_file}"
if [[ $binary == true ]]; then
rm -f "${package_name}".tar.gz
rm -f "${package_name}".zip
if [[ $platform == "windows" ]]; then
zip -9rv ${package_name}.zip ${dest_dir}/*
else
tar czvf "${package_name}".tar.gz "${dest_dir}"
fi
fi
if [[ $appimage == true ]]; then source scripts/appimage.sh; fi
if [[ $bundle == true && $dmg == true ]]; then source scripts/appdmg.sh "${package_name}"; fi
if [[ $innosetup == true ]]; then source scripts/innosetup/innosetup.sh -b "${build_dir}"; fi
}
main "$@"

View File

@ -1,69 +0,0 @@
#!/bin/bash
set -ex
if [ ! -e "src/api/api.h" ]; then
echo "Please run this script from the root directory of Lite XL."
exit 1
fi
show_help(){
echo
echo "Usage: $0 <OPTIONS>"
echo
echo "Available options:"
echo
echo "-b --builddir DIRNAME Sets the name of the build directory (no path)."
echo " Default: 'build'."
echo "-d --destdir DIRNAME Sets the name of the install directory (no path)."
echo
}
BUILD_DIR=build
DEST_DIR=lite-xl-src
for i in "$@"; do
case $i in
-h|--belp)
show_help
exit 0
;;
-b|--builddir)
BUILD_DIR="$2"
shift
shift
;;
-d|--destdir)
DEST_DIR="$2"
shift
shift
;;
*)
# unknown option
;;
esac
done
if [[ -n $1 ]]; then
show_help
exit 1
fi
if test -d ${BUILD_DIR}; then rm -rf ${BUILD_DIR}; fi
if test -d ${DEST_DIR}; then rm -rf ${DEST_DIR}; fi
if test -f ${DEST_DIR}.tar.gz; then rm ${DEST_DIR}.tar.gz; fi
meson subprojects download
meson setup ${BUILD_DIR}
rsync -arv \
--exclude /*build*/ \
--exclude *.git* \
--exclude lhelper \
--exclude lite-xl* \
--exclude submodules \
. ${DEST_DIR}
cp "${BUILD_DIR}/start.lua" "${DEST_DIR}/data/core"
tar rf ${DEST_DIR}.tar ${DEST_DIR}
gzip -9 ${DEST_DIR}.tar