1
0

fix(manifest): Attmept at handling library

This commit is contained in:
Jose Daniel G. Percy 2025-05-07 01:55:48 +08:00
parent a0506f94a3
commit 5a4239dd9e
2 changed files with 122 additions and 88 deletions

View File

@ -8,6 +8,8 @@ BUILD_DIR := ${PWD}/build
SRC_DIR := ${PWD}/src SRC_DIR := ${PWD}/src
FLATPAK_STATE_DIR := ${PWD}/flatpak-state FLATPAK_STATE_DIR := ${PWD}/flatpak-state
FLATPAK_CACHE_DIR := ${PWD}/flatpak-cache 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 --- # --- Main Targets ---
# Default target # Default target
@ -44,7 +46,7 @@ run-flatpak-builder:
-v ${PWD}/com.aseprite.Aseprite.yaml:/build/com.aseprite.Aseprite.yaml:ro \ -v ${PWD}/com.aseprite.Aseprite.yaml:/build/com.aseprite.Aseprite.yaml:ro \
-w /build \ -w /build \
${IMAGE_NAME} \ ${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 # Create the Flatpak bundle from the repo built in the previous step
.PHONY: create-bundle .PHONY: create-bundle
@ -93,3 +95,8 @@ deep-clean: clean
@rm -rf ${FLATPAK_STATE_DIR} @rm -rf ${FLATPAK_STATE_DIR}
@rm -rf ${FLATPAK_CACHE_DIR} @rm -rf ${FLATPAK_CACHE_DIR}
@echo "Deep cleanup complete." @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

View File

@ -33,6 +33,8 @@ cleanup:
- /share/pkgconfig - /share/pkgconfig
- '*-debuginfo*' - '*-debuginfo*'
- '*.la' - '*.la'
# Remove files that cause cleanup errors
- /third_party/externals/emsdk
modules: modules:
# 1. Depot Tools (Needed for Skia build) # 1. Depot Tools (Needed for Skia build)
@ -60,8 +62,9 @@ modules:
PKG_CONFIG_PATH: /app/lib/pkgconfig:/usr/lib/pkgconfig PKG_CONFIG_PATH: /app/lib/pkgconfig:/usr/lib/pkgconfig
build-commands: build-commands:
# Prepare GN arguments # 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 \ GN_ARGS="is_debug=false \
is_official_build=true \ is_official_build=true \
skia_use_system_expat=true \ skia_use_system_expat=true \
@ -76,95 +79,122 @@ modules:
skia_pdf_subset_harfbuzz=true \ skia_pdf_subset_harfbuzz=true \
skia_use_system_freetype2=false \ skia_use_system_freetype2=false \
skia_use_system_harfbuzz=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_cflags=[\"-mavx\",\"-O3\"] \
extra_cxxflags=[\"-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..." echo "Extracting and installing bundled libraries..."
# Look for Freetype # Find and install freetype
if [ -f out/Release-x64/libfreetype.a ]; then for lib_file in $(find out/Release-x64 -name "libfreetype.a" 2>/dev/null || echo ""); do
echo "Installing libfreetype.a from Skia build" echo "Installing libfreetype.a from $lib_file"
cp -f out/Release-x64/libfreetype.a /app/lib/ install -m644 "$lib_file" /app/lib/libfreetype.a
else break
echo "libfreetype.a not found in Skia build output, checking third_party..." done
find . -name "libfreetype.a" -exec cp -f {} /app/lib/ \; -print || echo "Failed to find libfreetype.a"
fi
# Look for Harfbuzz # Find and install harfbuzz
if [ -f out/Release-x64/libharfbuzz.a ]; then for lib_file in $(find out/Release-x64 -name "libharfbuzz.a" 2>/dev/null || echo ""); do
echo "Installing libharfbuzz.a from Skia build" echo "Installing libharfbuzz.a from $lib_file"
cp -f out/Release-x64/libharfbuzz.a /app/lib/ install -m644 "$lib_file" /app/lib/libharfbuzz.a
else break
echo "libharfbuzz.a not found in Skia build output, checking third_party..." done
find . -name "libharfbuzz.a" -exec cp -f {} /app/lib/ \; -print || echo "Failed to find libharfbuzz.a"
fi
# Look for WebP # Find and install webp
if [ -f out/Release-x64/libwebp.a ]; then for lib_file in $(find out/Release-x64 -name "libwebp.a" 2>/dev/null || echo ""); do
echo "Installing libwebp.a from Skia build" echo "Installing libwebp.a from $lib_file"
cp -f out/Release-x64/libwebp.a /app/lib/ install -m644 "$lib_file" /app/lib/libwebp.a
else break
echo "libwebp.a not found in Skia build output, checking third_party..." done
find . -name "libwebp.a" -exec cp -f {} /app/lib/ \; -print || echo "Failed to find libwebp.a"
fi
# Look for JPEG # Find and install jpeg
if [ -f out/Release-x64/libjpeg.a ]; then for lib_file in $(find out/Release-x64 -name "libjpeg.a" 2>/dev/null || echo ""); do
echo "Installing libjpeg.a from Skia build" echo "Installing libjpeg.a from $lib_file"
cp -f out/Release-x64/libjpeg.a /app/lib/ install -m644 "$lib_file" /app/lib/libjpeg.a
else break
echo "libjpeg.a not found in Skia build output, checking third_party..." done
find . -name "libjpeg.a" -exec cp -f {} /app/lib/ \; -print || echo "Failed to find libjpeg.a"
fi
# Create symlinks for libraries that might have different names # 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) (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 # Copy necessary include directories from third_party
- mkdir -p /app/third_party/externals/icu/flutter
- | - |
echo "Looking for and copying icudtl.dat to the expected location..." echo "Copying third_party includes needed by Aseprite..."
# Check various possible locations # Instead of copying the whole externals directory (which is large and causes cleanup issues)
if [ -f out/Release-x64/icudtl.dat ]; then # Copy only the specific libraries that Aseprite needs
cp out/Release-x64/icudtl.dat /app/third_party/externals/icu/flutter/ mkdir -p /app/third_party/externals/freetype/include
echo "Found icudtl.dat in out/Release-x64/" mkdir -p /app/third_party/externals/harfbuzz/src
elif [ -f third_party/externals/icu/common/icudtl.dat ]; then mkdir -p /app/third_party/externals/libwebp/src
cp third_party/externals/icu/common/icudtl.dat /app/third_party/externals/icu/flutter/ mkdir -p /app/third_party/externals/libjpeg-turbo
echo "Found icudtl.dat in third_party/externals/icu/common/" mkdir -p /app/third_party/externals/icu/flutter
elif [ -f third_party/externals/icu/flutter/icudtl.dat ]; then
cp third_party/externals/icu/flutter/icudtl.dat /app/third_party/externals/icu/flutter/ # Copy only the necessary include files
echo "Found icudtl.dat in third_party/externals/icu/flutter/" if [ -d third_party/externals/freetype/include ]; then
else cp -r third_party/externals/freetype/include/* /app/third_party/externals/freetype/include/
echo "Attempting to find icudtl.dat with find command..."
find . -name "icudtl.dat" -exec cp {} /app/third_party/externals/icu/flutter/ \; -print
fi 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 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 touch /app/third_party/externals/icu/flutter/icudtl.dat
fi fi
# List what we've installed for debugging
echo "Contents of /app/lib:"
ls -la /app/lib
echo "Skia installation complete."
sources: sources:
# Use the directory copied into the Docker image # Use the directory copied into the Docker image
- type: dir - type: dir
@ -196,7 +226,7 @@ modules:
- -DUSE_SHARED_WEBP=OFF - -DUSE_SHARED_WEBP=OFF
- -DUSE_SHARED_FREETYPE=OFF - -DUSE_SHARED_FREETYPE=OFF
- -DUSE_SHARED_HARFBUZZ=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_INCLUDE_DIR=/app/third_party/externals/libwebp/src
- -DWEBP_LIBRARIES=/app/lib/libwebp.a - -DWEBP_LIBRARIES=/app/lib/libwebp.a
- -DLIBJPEG_TURBO_INCLUDE_DIR=/app/third_party/externals/libjpeg-turbo - -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_INCLUDE_DIR=/app/third_party/externals/harfbuzz/src
- -DHARFBUZZ_LIBRARY=/app/lib/libharfbuzz.a - -DHARFBUZZ_LIBRARY=/app/lib/libharfbuzz.a
build-commands: build-commands:
# Run the standard build from cmake-ninja # Standard ninja build
- ninja - 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..." echo "Verifying required libraries..."
if [ ! -f /app/lib/libfreetype.a ]; then if [ ! -f /app/lib/libskia.a ]; then echo "ERROR: libskia.a missing"; exit 1; fi
echo "ERROR: libfreetype.a is missing" if [ ! -f /app/lib/libfreetype.a ]; then echo "ERROR: libfreetype.a missing"; exit 1; fi
exit 1 if [ ! -f /app/lib/libharfbuzz.a ]; then echo "ERROR: libharfbuzz.a missing"; exit 1; fi
fi echo "All required libraries present."
if [ ! -f /app/lib/libharfbuzz.a ]; then
echo "ERROR: libharfbuzz.a is missing" # Install with ninja
exit 1
fi
# Install the build artifacts using standard ninja install
- DESTDIR=/app ninja install - DESTDIR=/app ninja install
sources: sources:
# Use the directory copied into the Docker image # Use the directory copied into the Docker image
- type: dir - type: dir
path: /sources/aseprite path: /sources/aseprite
# Note: Submodules are expected to be present due to prepare_sources.sh
# Install desktop file and icon after build/install # Install desktop file and icon after build/install
post-install: post-install:
# Install files from the source directory (/sources/aseprite) # Install files from the source directory (/sources/aseprite)