Install plugins with lpm inside meson (#1951)

* meson: install plugins with lpm

* meson: add cachedir as output

* build.sh: fix bash syntax error

* build.sh: only copy datadir when PGO is enabled

* build.sh: properly install files with meson install

* build.sh: install macOS bundle files with .app suffix

* ci: copy bundle and portable files correctly

* package-dmg: remove extraneous steps

* ci: fix wrong bundle path

* build.sh: force reconfigure bundle=false if bundle is not explicitly given

* build.sh: move wrong bundle=true assignment to the right place

* ci: remove -a flag from cp command

* ci: use xargs and find -print0 to omit spaces in find output

* ci: specify correct path to Info.plist

* ci: correctly run dmgbuild

* dmgbuild: get application path from command line

* ci: organize dmgbuild arguments

* ci: properly escape arguments

* ci: finally correctly specify yaml string

* ci: don't copy Info.plist again

* build.sh: don't install any plugins if -A is not specified

* build.sh: use the latest release from github
This commit is contained in:
Takase 2024-11-25 20:39:48 +08:00 committed by GitHub
parent 7c5b631ff0
commit 3fe64609e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 77 additions and 46 deletions

View File

@ -85,7 +85,7 @@ jobs:
- name: Build & Package Mac (Bundle) - name: Build & Package Mac (Bundle)
run: | run: |
scripts/build.sh --addons --debug --forcefallback --reconfigure --bundle -b build scripts/build.sh --addons --debug --forcefallback --reconfigure --bundle -b build
tar -C build -czvf lite-xl-${{ needs.version.outputs.ref }}-${{ matrix.config.arch }}-bundle.tar.gz lite-xl Info.plist tar -C build -czvf lite-xl-${{ needs.version.outputs.ref }}-${{ matrix.config.arch }}-bundle.tar.gz "Lite XL.app"
- name: Build & Package Mac (Portable) - name: Build & Package Mac (Portable)
run: | run: |
@ -124,20 +124,24 @@ jobs:
- name: Create Universal Binaries - name: Create Universal Binaries
run: | run: |
REF="lite-xl-${{ needs.version.outputs.ref }}"
for TYPE in bundle portable; do for TYPE in bundle portable; do
mkdir -p lite-xl-${{ needs.version.outputs.ref }}-{x86_64,aarch64,universal}-darwin-$TYPE/lite-xl mkdir -p $REF-universal-darwin-$TYPE package-$TYPE/{x86_64,aarch64}
tar -C lite-xl-${{ needs.version.outputs.ref }}-x86_64-darwin-$TYPE -zxvf lite-xl-${{ needs.version.outputs.ref }}-x86_64-darwin-$TYPE.tar.gz tar -C package-$TYPE/x86_64 -zxvf $REF-x86_64-darwin-$TYPE.tar.gz
tar -C lite-xl-${{ needs.version.outputs.ref }}-aarch64-darwin-$TYPE -zxvf lite-xl-${{ needs.version.outputs.ref }}-aarch64-darwin-$TYPE.tar.gz tar -C package-$TYPE/aarch64 -zxvf $REF-aarch64-darwin-$TYPE.tar.gz
cp -r lite-xl-${{ needs.version.outputs.ref }}-*-$TYPE/lite-xl/data lite-xl-${{ needs.version.outputs.ref }}-universal-darwin-$TYPE/lite-xl cp -a package-$TYPE/*/* $REF-universal-darwin-$TYPE
lipo -create -output lite-xl-${{ needs.version.outputs.ref }}-universal-darwin-$TYPE/lite-xl/lite-xl lite-xl-${{ needs.version.outputs.ref }}-*-darwin-$TYPE/lite-xl/lite-xl find package-$TYPE -type f -name lite-xl -perm +111 -print0 | \
xargs -0 lipo -create -output "$(find $REF-universal-darwin-$TYPE -type f -name lite-xl -perm +111)"
done done
cp lite-xl-${{ needs.version.outputs.ref }}-x86_64-darwin-bundle/Info.plist lite-xl-${{ needs.version.outputs.ref }}-universal-darwin-bundle/Info.plist
- name: Package Darwin (Universal DMG Image) - name: Package Darwin (Universal DMG Image)
run: scripts/package-dmg.sh lite-xl-${{ needs.version.outputs.ref }}-universal-darwin-bundle lite-xl-${{ needs.version.outputs.ref }}-universal-darwin run: |
dmgbuild -s resources/macos/lite-xl-dmg.py \
-D "app_path=lite-xl-${{ needs.version.outputs.ref }}-universal-darwin-bundle/Lite XL.app" \
"Lite XL" "lite-xl-${{ needs.version.outputs.ref }}-universal-darwin.dmg"
- name: Package Darwin (Universal Portable) - name: Package Darwin (Universal Portable)
run: cd lite-xl-${{ needs.version.outputs.ref }}-universal-darwin-portable && tar -zcvf ../lite-xl-${{ needs.version.outputs.ref }}-universal-darwin-portable.tar.gz * run: tar -C lite-xl-${{ needs.version.outputs.ref }}-universal-darwin-portable -zcvf lite-xl-${{ needs.version.outputs.ref }}-universal-darwin-portable.tar.gz .
- name: Upload (Release) - name: Upload (Release)
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4

20
data/meson.build Normal file
View File

@ -0,0 +1,20 @@
if get_option('bundle_plugins').length() > 0
lpm_exe = find_program('lpm')
plugin_bundle = custom_target(
'lpm_plugins',
input: 'meson.build',
output: [lpm_userdir, 'lpm_cache'],
command: [
lpm_exe,
'--datadir', meson.project_source_root() / 'data',
'--userdir', '@OUTPUT0@',
'--cachedir', '@OUTPUT1@',
'--assume-yes',
'install',
get_option('bundle_plugins'),
],
install: true,
install_dir: [lpm_install_dir, false],
build_by_default: true,
)
endif

View File

@ -183,6 +183,8 @@ if get_option('portable') or host_machine.system() == 'windows'
lite_bindir = '/' lite_bindir = '/'
lite_docdir = '/doc' lite_docdir = '/doc'
lite_datadir = '/data' lite_datadir = '/data'
lpm_userdir = 'data'
lpm_install_dir = '/'
configure_file( configure_file(
input: 'resources' / 'windows' / 'lite-xl.exe.manifest.in', input: 'resources' / 'windows' / 'lite-xl.exe.manifest.in',
output: 'lite-xl.exe.manifest', output: 'lite-xl.exe.manifest',
@ -193,6 +195,8 @@ elif get_option('bundle') and host_machine.system() == 'darwin'
lite_bindir = 'Contents' / 'MacOS' lite_bindir = 'Contents' / 'MacOS'
lite_docdir = 'Contents' / 'Resources' lite_docdir = 'Contents' / 'Resources'
lite_datadir = 'Contents' / 'Resources' lite_datadir = 'Contents' / 'Resources'
lpm_userdir = 'Resources'
lpm_install_dir = 'Contents'
conf_data.set( conf_data.set(
'CURRENT_YEAR', 'CURRENT_YEAR',
run_command('date', '+%Y', capture: true).stdout().strip() run_command('date', '+%Y', capture: true).stdout().strip()
@ -210,6 +214,8 @@ else
lite_bindir = 'bin' lite_bindir = 'bin'
lite_docdir = get_option('datadir') / 'doc' / 'lite-xl' lite_docdir = get_option('datadir') / 'doc' / 'lite-xl'
lite_datadir = get_option('datadir') / 'lite-xl' lite_datadir = get_option('datadir') / 'lite-xl'
lpm_userdir = 'lite-xl'
lpm_install_dir = get_option('datadir')
if host_machine.system() == 'linux' if host_machine.system() == 'linux'
install_data('resources' / 'icons' / 'lite-xl.svg', install_data('resources' / 'icons' / 'lite-xl.svg',
install_dir : get_option('datadir') / 'icons' / 'hicolor' / 'scalable' / 'apps' install_dir : get_option('datadir') / 'icons' / 'hicolor' / 'scalable' / 'apps'
@ -241,4 +247,5 @@ configure_file(
if not get_option('source-only') if not get_option('source-only')
subdir('src') subdir('src')
subdir('scripts') subdir('scripts')
subdir('data')
endif endif

View File

@ -5,3 +5,4 @@ option('renderer', type : 'boolean', value : false, description: 'Use SDL render
option('dirmonitor_backend', type : 'combo', value : '', choices : ['', 'inotify', 'fsevents', 'kqueue', 'win32', 'dummy'], description: 'define what dirmonitor backend to use') option('dirmonitor_backend', type : 'combo', value : '', choices : ['', 'inotify', 'fsevents', 'kqueue', 'win32', 'dummy'], description: 'define what dirmonitor backend to use')
option('arch_tuple', type : 'string', value : '', description: 'Specify a custom architecture tuple') option('arch_tuple', type : 'string', value : '', description: 'Specify a custom architecture tuple')
option('use_system_lua', type : 'boolean', value : false, description: 'Prefer System Lua over a the meson wrap') option('use_system_lua', type : 'boolean', value : false, description: 'Prefer System Lua over a the meson wrap')
option('bundle_plugins', type : 'array', value : [], description: 'Plugins to bundle when building Lite XL')

View File

@ -2,7 +2,7 @@
import os.path import os.path
app_path = "Lite XL.app" app_path = defines.get("app_path", "Lite XL.app")
app_name = os.path.basename(app_path) app_name = os.path.basename(app_path)
# Image options # Image options

View File

@ -21,7 +21,11 @@ show_help() {
echo "-d --debug-build Builds a debug build." echo "-d --debug-build Builds a debug build."
echo "-p --prefix PREFIX Install directory prefix. Default: '/'." echo "-p --prefix PREFIX Install directory prefix. Default: '/'."
echo "-B --bundle Create an App bundle (macOS only)" echo "-B --bundle Create an App bundle (macOS only)"
echo "-A --addons Add in addons" echo "-A --addons Install extra plugins."
echo " Default: If specified, install the welcome plugin."
echo " An comma-separated list can be specified after this flag"
echo " to specify a list of plugins to install."
echo " If this option is not specified, no extra plugins will be installed."
echo "-P --portable Create a portable binary package." echo "-P --portable Create a portable binary package."
echo "-r --reconfigure Tries to reuse the meson build directory, if possible." echo "-r --reconfigure Tries to reuse the meson build directory, if possible."
echo " Default: Deletes the build directory and recreates it." echo " Default: Deletes the build directory and recreates it."
@ -42,20 +46,21 @@ main() {
local platform="$(get_platform_name)" local platform="$(get_platform_name)"
local arch="$(get_platform_arch)" local arch="$(get_platform_arch)"
local build_dir local build_dir
local plugins="welcome" local plugins="-Dbundle_plugins="
local prefix=/ local prefix=/
local addons
local build_type="release" local build_type="release"
local force_fallback local force_fallback
local bundle local bundle="-Dbundle=false"
local portable local portable="-Dportable=false"
local pgo local pgo
local cross local cross
local cross_platform local cross_platform
local cross_arch local cross_arch
local cross_file local cross_file
local reconfigure local reconfigure
local lpm_path
local should_reconfigure local should_reconfigure
local destdir="lite-xl"
for i in "$@"; do for i in "$@"; do
case $i in case $i in
@ -90,7 +95,12 @@ main() {
shift shift
;; ;;
-A|--addons) -A|--addons)
addons="1" if [[ -n $2 ]] && [[ $2 != -* ]]; then
plugins="-Dbundle_plugins=$2"
shift
else
plugins="-Dbundle_plugins=welcome"
fi
shift shift
;; ;;
-B|--bundle) -B|--bundle)
@ -98,6 +108,7 @@ main() {
echo "Warning: ignoring --bundle option, works only under macOS." echo "Warning: ignoring --bundle option, works only under macOS."
else else
bundle="-Dbundle=true" bundle="-Dbundle=true"
destdir="Lite XL.app"
fi fi
shift shift
;; ;;
@ -138,7 +149,7 @@ main() {
exit 1 exit 1
fi fi
if [[ $platform == "macos" && -n $bundle && -n $portable ]]; then if [[ $platform == "macos" && $bundle == "-Dbundle=true" && $portable == "-Dportable=true" ]]; then
echo "Warning: \"bundle\" and \"portable\" specified; excluding portable package." echo "Warning: \"bundle\" and \"portable\" specified; excluding portable package."
portable="" portable=""
fi fi
@ -192,6 +203,17 @@ main() {
rm -rf "${build_dir}" rm -rf "${build_dir}"
fi fi
if [[ -n "$plugins" ]] && [[ -z `command -v lpm` ]]; then
mkdir -p "${build_dir}"
lpm_path="$(pwd)/${build_dir}/lpm$(get_executable_extension)"
if [[ ! -e "$lpm_path" ]]; then
curl --insecure -L -o "$lpm_path" \
"https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/${LPM_VERSION:-latest}/lpm.$(get_platform_tuple)$(get_executable_extension)"
chmod u+x "$lpm_path"
fi
export PATH="$(dirname "$lpm_path"):$PATH"
fi
CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS meson setup \ CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS meson setup \
"${build_dir}" \ "${build_dir}" \
--buildtype "$build_type" \ --buildtype "$build_type" \
@ -201,27 +223,22 @@ main() {
$bundle \ $bundle \
$portable \ $portable \
$pgo \ $pgo \
$plugins \
$reconfigure $reconfigure
meson compile -C "${build_dir}" meson compile -C "${build_dir}"
cp -r data "${build_dir}/src"
if [[ $pgo != "" ]]; then if [[ $pgo != "" ]]; then
cp -r data "${build_dir}/src"
"${build_dir}/src/lite-xl" "${build_dir}/src/lite-xl"
meson configure -Db_pgo=use "${build_dir}" meson configure -Db_pgo=use "${build_dir}"
meson compile -C "${build_dir}" meson compile -C "${build_dir}"
rm -fr "${build_dir}/data" rm -fr "${build_dir}/src/data"
fi fi
rm -fr $build_dir/src/lite-xl.*p $build_dir/src/*.o meson install -C "${build_dir}" --destdir "$destdir" \
--skip-subprojects=freetype2,lua,pcre2,sdl2 --no-rebuild
if [[ $addons != "" ]]; then
[[ ! -e "$build_dir/lpm" ]] && curl --insecure -L "https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/v1.2.9/lpm.$(get_platform_tuple)$(get_executable_extension)" -o "$build_dir/lpm$(get_executable_extension)" && chmod +x "$build_dir/lpm$(get_executable_extension)"
"$build_dir/lpm$(get_executable_extension)" install --datadir ${build_dir}/src/data --userdir ${build_dir}/src/data --arch $(get_platform_tuple) $plugins --assume-yes; "$build_dir/lpm$(get_executable_extension)" purge --datadir ${build_dir}/src/data --userdir ${build_dir}/src/data && chmod -R a+r ${build_dir}
fi
mv "${build_dir}/src" "${build_dir}/lite-xl"
} }
main "$@" main "$@"

View File

@ -1,18 +0,0 @@
#!/usr/bin/env 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
mkdir -p "Lite XL.app/Contents/MacOS" "Lite XL.app/Contents/Resources"
cp -r $1/lite-xl/lite-xl "Lite XL.app/Contents/MacOS"
cp -r $1/lite-xl/data/* "Lite XL.app/Contents/Resources"
cp resources/icons/icon.icns "Lite XL.app/Contents/Resources"
cp -r $1/Info.plist "Lite XL.app/Contents/Resources"
dmgbuild -s resources/macos/lite-xl-dmg.py "Lite XL" "$2.dmg"
rm -rf "Lite XL.app"