diff --git a/Makefile b/Makefile index b439ad4..c8585e3 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,8 @@ BUILD_DIR := ${PWD}/build SRC_DIR := ${PWD}/src FLATPAK_STATE_DIR := ${PWD}/flatpak-state FLATPAK_CACHE_DIR := ${PWD}/flatpak-cache +# Whether to use a clean build each time (set to empty to disable) +# CLEAN_BUILD := --force-clean # --- Main Targets --- # Default target @@ -44,7 +46,7 @@ run-flatpak-builder: -v ${PWD}/com.aseprite.Aseprite.yaml:/build/com.aseprite.Aseprite.yaml:ro \ -w /build \ ${IMAGE_NAME} \ - sh -c "flatpak-builder --disable-rofiles-fuse --state-dir=/root/.local/share/flatpak-builder --ccache --force-clean build-dir com.aseprite.Aseprite.yaml --repo=repo" + sh -c "flatpak-builder --disable-rofiles-fuse --state-dir=/root/.local/share/flatpak-builder --ccache ${CLEAN_BUILD} build-dir com.aseprite.Aseprite.yaml --repo=repo && if [ -d 'build-dir/files/third_party/externals/emsdk' ]; then rm -rf build-dir/files/third_party/externals/emsdk; fi" # Create the Flatpak bundle from the repo built in the previous step .PHONY: create-bundle @@ -93,3 +95,8 @@ deep-clean: clean @rm -rf ${FLATPAK_STATE_DIR} @rm -rf ${FLATPAK_CACHE_DIR} @echo "Deep cleanup complete." + +# Force clean build by setting CLEAN_BUILD variable +.PHONY: force-clean-build +force-clean-build: + @$(MAKE) CLEAN_BUILD="--force-clean" build diff --git a/com.aseprite.Aseprite.yaml b/com.aseprite.Aseprite.yaml index 851b236..8e2f441 100644 --- a/com.aseprite.Aseprite.yaml +++ b/com.aseprite.Aseprite.yaml @@ -33,6 +33,8 @@ cleanup: - /share/pkgconfig - '*-debuginfo*' - '*.la' + # Remove files that cause cleanup errors + - /third_party/externals/emsdk modules: # 1. Depot Tools (Needed for Skia build) @@ -60,8 +62,9 @@ modules: PKG_CONFIG_PATH: /app/lib/pkgconfig:/usr/lib/pkgconfig build-commands: # Prepare GN arguments - # Using system libs provided by the Freedesktop SDK and our additional modules + # Using Skia's bundled libs for better compatibility - | + echo "Generating Skia build configuration..." GN_ARGS="is_debug=false \ is_official_build=true \ skia_use_system_expat=true \ @@ -76,95 +79,122 @@ modules: skia_pdf_subset_harfbuzz=true \ skia_use_system_freetype2=false \ skia_use_system_harfbuzz=false \ + skia_enable_fontmgr_empty=false \ + skia_enable_fontmgr_android=false \ + skia_enable_fontmgr_win=false \ + skia_enable_fontmgr_win_gdi=false \ + skia_enable_fontmgr_custom_directory=false \ + skia_enable_fontmgr_custom_embedded=false \ + skia_enable_fontmgr_fontconfig=true \ + skia_enable_pdf=false \ + skia_enable_tools=false \ extra_cflags=[\"-mavx\",\"-O3\"] \ extra_cxxflags=[\"-mavx\",\"-O3\"]" - # Generate build files using gn from depot_tools - - /app/depot_tools/gn gen out/Release-x64 --args="${GN_ARGS}" - # Compile Skia - - ninja -C out/Release-x64 skia modules - # Install Skia library and headers into the /app prefix for the next module - - install -Dm644 out/Release-x64/libskia.a /app/lib/libskia.a - - install -d /app/include/skia - # Copy headers from the source directory '.' which is /sources/skia - - cp -r include/* /app/include/skia/ - # Also copy Skia third_party includes needed by Aseprite - - mkdir -p /app/third_party - - cp -r third_party/externals /app/third_party/ - # Extract and install the bundled static libraries that Aseprite needs + # Generate build files using gn from depot_tools + - echo "Running GN to generate Ninja build files..." + - /app/depot_tools/gn gen out/Release-x64 --args="${GN_ARGS}" + + # Compile Skia (only the necessary targets) + - echo "Building Skia with Ninja (this may take a while)..." + - ninja -C out/Release-x64 skia modules + + # Create directory structure for Aseprite + - echo "Installing Skia libraries and headers..." + - install -d /app/lib + - install -d /app/include/skia + - install -d /app/third_party/externals + + # Install Skia library + - install -m644 out/Release-x64/libskia.a /app/lib/libskia.a + + # Copy headers + - cp -r include/* /app/include/skia/ + + # Extract and install libraries that Aseprite needs - | - echo "Extracting and installing static libraries from Skia build..." - # Look for Freetype - if [ -f out/Release-x64/libfreetype.a ]; then - echo "Installing libfreetype.a from Skia build" - cp -f out/Release-x64/libfreetype.a /app/lib/ - else - echo "libfreetype.a not found in Skia build output, checking third_party..." - find . -name "libfreetype.a" -exec cp -f {} /app/lib/ \; -print || echo "Failed to find libfreetype.a" - fi + echo "Extracting and installing bundled libraries..." + # Find and install freetype + for lib_file in $(find out/Release-x64 -name "libfreetype.a" 2>/dev/null || echo ""); do + echo "Installing libfreetype.a from $lib_file" + install -m644 "$lib_file" /app/lib/libfreetype.a + break + done - # Look for Harfbuzz - if [ -f out/Release-x64/libharfbuzz.a ]; then - echo "Installing libharfbuzz.a from Skia build" - cp -f out/Release-x64/libharfbuzz.a /app/lib/ - else - echo "libharfbuzz.a not found in Skia build output, checking third_party..." - find . -name "libharfbuzz.a" -exec cp -f {} /app/lib/ \; -print || echo "Failed to find libharfbuzz.a" - fi + # Find and install harfbuzz + for lib_file in $(find out/Release-x64 -name "libharfbuzz.a" 2>/dev/null || echo ""); do + echo "Installing libharfbuzz.a from $lib_file" + install -m644 "$lib_file" /app/lib/libharfbuzz.a + break + done - # Look for WebP - if [ -f out/Release-x64/libwebp.a ]; then - echo "Installing libwebp.a from Skia build" - cp -f out/Release-x64/libwebp.a /app/lib/ - else - echo "libwebp.a not found in Skia build output, checking third_party..." - find . -name "libwebp.a" -exec cp -f {} /app/lib/ \; -print || echo "Failed to find libwebp.a" - fi + # Find and install webp + for lib_file in $(find out/Release-x64 -name "libwebp.a" 2>/dev/null || echo ""); do + echo "Installing libwebp.a from $lib_file" + install -m644 "$lib_file" /app/lib/libwebp.a + break + done - # Look for JPEG - if [ -f out/Release-x64/libjpeg.a ]; then - echo "Installing libjpeg.a from Skia build" - cp -f out/Release-x64/libjpeg.a /app/lib/ - else - echo "libjpeg.a not found in Skia build output, checking third_party..." - find . -name "libjpeg.a" -exec cp -f {} /app/lib/ \; -print || echo "Failed to find libjpeg.a" - fi + # Find and install jpeg + for lib_file in $(find out/Release-x64 -name "libjpeg.a" 2>/dev/null || echo ""); do + echo "Installing libjpeg.a from $lib_file" + install -m644 "$lib_file" /app/lib/libjpeg.a + break + done # Create symlinks for libraries that might have different names - echo "Creating symlinks for libraries with different names..." (cd /app/lib && [ -f libjpeg.a ] && ln -sf libjpeg.a libjpeg-turbo.a || true) - - # Create a pkgconfig directory to help CMake find our libraries - mkdir -p /app/lib/pkgconfig - - # List installed libraries for debugging - echo "Installed static libraries in /app/lib:" - ls -la /app/lib/*.a || true - # Make sure ICU data file exists and is in the right place - - mkdir -p /app/third_party/externals/icu/flutter + # Copy necessary include directories from third_party - | - echo "Looking for and copying icudtl.dat to the expected location..." - # Check various possible locations - if [ -f out/Release-x64/icudtl.dat ]; then - cp out/Release-x64/icudtl.dat /app/third_party/externals/icu/flutter/ - echo "Found icudtl.dat in out/Release-x64/" - elif [ -f third_party/externals/icu/common/icudtl.dat ]; then - cp third_party/externals/icu/common/icudtl.dat /app/third_party/externals/icu/flutter/ - echo "Found icudtl.dat in third_party/externals/icu/common/" - elif [ -f third_party/externals/icu/flutter/icudtl.dat ]; then - cp third_party/externals/icu/flutter/icudtl.dat /app/third_party/externals/icu/flutter/ - echo "Found icudtl.dat in third_party/externals/icu/flutter/" - else - echo "Attempting to find icudtl.dat with find command..." - find . -name "icudtl.dat" -exec cp {} /app/third_party/externals/icu/flutter/ \; -print + echo "Copying third_party includes needed by Aseprite..." + # Instead of copying the whole externals directory (which is large and causes cleanup issues) + # Copy only the specific libraries that Aseprite needs + mkdir -p /app/third_party/externals/freetype/include + mkdir -p /app/third_party/externals/harfbuzz/src + mkdir -p /app/third_party/externals/libwebp/src + mkdir -p /app/third_party/externals/libjpeg-turbo + mkdir -p /app/third_party/externals/icu/flutter + + # Copy only the necessary include files + if [ -d third_party/externals/freetype/include ]; then + cp -r third_party/externals/freetype/include/* /app/third_party/externals/freetype/include/ fi - # Create an empty file as a fallback if nothing is found + if [ -d third_party/externals/harfbuzz/src ]; then + cp -r third_party/externals/harfbuzz/src/*.h /app/third_party/externals/harfbuzz/src/ + fi + + if [ -d third_party/externals/libwebp/src ]; then + cp -r third_party/externals/libwebp/src/webp /app/third_party/externals/libwebp/src/ + fi + + if [ -d third_party/externals/libjpeg-turbo ]; then + cp -r third_party/externals/libjpeg-turbo/*.h /app/third_party/externals/libjpeg-turbo/ + fi + + # Find and copy the ICU data file + - | + echo "Looking for ICU data file..." + # Check for icudtl.dat in various places + for icu_file in $(find . -name "icudtl.dat" 2>/dev/null || echo ""); do + echo "Found ICU data file at $icu_file" + mkdir -p /app/third_party/externals/icu/flutter + cp "$icu_file" /app/third_party/externals/icu/flutter/icudtl.dat + break + done + + # Create an empty placeholder if not found if [ ! -f /app/third_party/externals/icu/flutter/icudtl.dat ]; then - echo "WARNING: icudtl.dat not found. Creating empty placeholder..." + echo "ICU data file not found, creating placeholder..." touch /app/third_party/externals/icu/flutter/icudtl.dat fi + + # List what we've installed for debugging + echo "Contents of /app/lib:" + ls -la /app/lib + + echo "Skia installation complete." sources: # Use the directory copied into the Docker image - type: dir @@ -196,7 +226,7 @@ modules: - -DUSE_SHARED_WEBP=OFF - -DUSE_SHARED_FREETYPE=OFF - -DUSE_SHARED_HARFBUZZ=OFF - # Set library locations explicitly to avoid CMake warnings/errors + # Set library locations explicitly - -DWEBP_INCLUDE_DIR=/app/third_party/externals/libwebp/src - -DWEBP_LIBRARIES=/app/lib/libwebp.a - -DLIBJPEG_TURBO_INCLUDE_DIR=/app/third_party/externals/libjpeg-turbo @@ -206,26 +236,23 @@ modules: - -DHARFBUZZ_INCLUDE_DIR=/app/third_party/externals/harfbuzz/src - -DHARFBUZZ_LIBRARY=/app/lib/libharfbuzz.a build-commands: - # Run the standard build from cmake-ninja + # Standard ninja build - ninja - # Add additional step to copy all Skia's static libraries that might be needed + + # Verify libraries exist before install - | - echo "Verifying libraries are available before install..." - if [ ! -f /app/lib/libfreetype.a ]; then - echo "ERROR: libfreetype.a is missing" - exit 1 - fi - if [ ! -f /app/lib/libharfbuzz.a ]; then - echo "ERROR: libharfbuzz.a is missing" - exit 1 - fi - # Install the build artifacts using standard ninja install + echo "Verifying required libraries..." + if [ ! -f /app/lib/libskia.a ]; then echo "ERROR: libskia.a missing"; exit 1; fi + if [ ! -f /app/lib/libfreetype.a ]; then echo "ERROR: libfreetype.a missing"; exit 1; fi + if [ ! -f /app/lib/libharfbuzz.a ]; then echo "ERROR: libharfbuzz.a missing"; exit 1; fi + echo "All required libraries present." + + # Install with ninja - DESTDIR=/app ninja install sources: # Use the directory copied into the Docker image - type: dir path: /sources/aseprite - # Note: Submodules are expected to be present due to prepare_sources.sh # Install desktop file and icon after build/install post-install: # Install files from the source directory (/sources/aseprite)