diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 976270ff..5c85811a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -85,7 +85,7 @@ jobs: - name: Build & Package Mac (Bundle) run: | 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) run: | @@ -124,20 +124,24 @@ jobs: - name: Create Universal Binaries run: | + REF="lite-xl-${{ needs.version.outputs.ref }}" for TYPE in bundle portable; do - mkdir -p lite-xl-${{ needs.version.outputs.ref }}-{x86_64,aarch64,universal}-darwin-$TYPE/lite-xl - 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 lite-xl-${{ needs.version.outputs.ref }}-aarch64-darwin-$TYPE -zxvf lite-xl-${{ needs.version.outputs.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 - 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 + mkdir -p $REF-universal-darwin-$TYPE package-$TYPE/{x86_64,aarch64} + tar -C package-$TYPE/x86_64 -zxvf $REF-x86_64-darwin-$TYPE.tar.gz + tar -C package-$TYPE/aarch64 -zxvf $REF-aarch64-darwin-$TYPE.tar.gz + cp -a package-$TYPE/*/* $REF-universal-darwin-$TYPE + 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 - 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) - 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) - 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) uses: actions/upload-artifact@v4 diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 00000000..f862862a --- /dev/null +++ b/data/meson.build @@ -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 diff --git a/meson.build b/meson.build index deb5353f..7f2dfb9f 100644 --- a/meson.build +++ b/meson.build @@ -183,6 +183,8 @@ if get_option('portable') or host_machine.system() == 'windows' lite_bindir = '/' lite_docdir = '/doc' lite_datadir = '/data' + lpm_userdir = 'data' + lpm_install_dir = '/' configure_file( input: 'resources' / 'windows' / 'lite-xl.exe.manifest.in', output: 'lite-xl.exe.manifest', @@ -193,6 +195,8 @@ elif get_option('bundle') and host_machine.system() == 'darwin' lite_bindir = 'Contents' / 'MacOS' lite_docdir = 'Contents' / 'Resources' lite_datadir = 'Contents' / 'Resources' + lpm_userdir = 'Resources' + lpm_install_dir = 'Contents' conf_data.set( 'CURRENT_YEAR', run_command('date', '+%Y', capture: true).stdout().strip() @@ -210,6 +214,8 @@ else lite_bindir = 'bin' lite_docdir = get_option('datadir') / 'doc' / 'lite-xl' lite_datadir = get_option('datadir') / 'lite-xl' + lpm_userdir = 'lite-xl' + lpm_install_dir = get_option('datadir') if host_machine.system() == 'linux' install_data('resources' / 'icons' / 'lite-xl.svg', install_dir : get_option('datadir') / 'icons' / 'hicolor' / 'scalable' / 'apps' @@ -241,4 +247,5 @@ configure_file( if not get_option('source-only') subdir('src') subdir('scripts') + subdir('data') endif diff --git a/meson_options.txt b/meson_options.txt index ae9d8c6b..70c941d6 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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('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('bundle_plugins', type : 'array', value : [], description: 'Plugins to bundle when building Lite XL') diff --git a/resources/macos/lite-xl-dmg.py b/resources/macos/lite-xl-dmg.py index 8088faec..0f7c93dd 100644 --- a/resources/macos/lite-xl-dmg.py +++ b/resources/macos/lite-xl-dmg.py @@ -2,7 +2,7 @@ import os.path -app_path = "Lite XL.app" +app_path = defines.get("app_path", "Lite XL.app") app_name = os.path.basename(app_path) # Image options diff --git a/scripts/build.sh b/scripts/build.sh index 851342bf..c3dc00c3 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -21,7 +21,11 @@ show_help() { echo "-d --debug-build Builds a debug build." echo "-p --prefix PREFIX Install directory prefix. Default: '/'." 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 "-r --reconfigure Tries to reuse the meson build directory, if possible." echo " Default: Deletes the build directory and recreates it." @@ -42,20 +46,21 @@ main() { local platform="$(get_platform_name)" local arch="$(get_platform_arch)" local build_dir - local plugins="welcome" + local plugins="-Dbundle_plugins=" local prefix=/ - local addons local build_type="release" local force_fallback - local bundle - local portable + local bundle="-Dbundle=false" + local portable="-Dportable=false" local pgo local cross local cross_platform local cross_arch local cross_file local reconfigure + local lpm_path local should_reconfigure + local destdir="lite-xl" for i in "$@"; do case $i in @@ -90,7 +95,12 @@ main() { shift ;; -A|--addons) - addons="1" + if [[ -n $2 ]] && [[ $2 != -* ]]; then + plugins="-Dbundle_plugins=$2" + shift + else + plugins="-Dbundle_plugins=welcome" + fi shift ;; -B|--bundle) @@ -98,6 +108,7 @@ main() { echo "Warning: ignoring --bundle option, works only under macOS." else bundle="-Dbundle=true" + destdir="Lite XL.app" fi shift ;; @@ -138,7 +149,7 @@ main() { exit 1 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." portable="" fi @@ -192,6 +203,17 @@ main() { rm -rf "${build_dir}" 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 \ "${build_dir}" \ --buildtype "$build_type" \ @@ -201,27 +223,22 @@ main() { $bundle \ $portable \ $pgo \ + $plugins \ $reconfigure meson compile -C "${build_dir}" - cp -r data "${build_dir}/src" if [[ $pgo != "" ]]; then + cp -r data "${build_dir}/src" "${build_dir}/src/lite-xl" meson configure -Db_pgo=use "${build_dir}" meson compile -C "${build_dir}" - rm -fr "${build_dir}/data" + rm -fr "${build_dir}/src/data" fi - rm -fr $build_dir/src/lite-xl.*p $build_dir/src/*.o - - 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" + meson install -C "${build_dir}" --destdir "$destdir" \ + --skip-subprojects=freetype2,lua,pcre2,sdl2 --no-rebuild } main "$@" diff --git a/scripts/package-dmg.sh b/scripts/package-dmg.sh deleted file mode 100755 index 0f47bddf..00000000 --- a/scripts/package-dmg.sh +++ /dev/null @@ -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" -