Skip to content

Instantly share code, notes, and snippets.

@scribhneoir
Last active September 27, 2024 14:06
Show Gist options
  • Save scribhneoir/f26369519174f223d6e275707b106f27 to your computer and use it in GitHub Desktop.
Save scribhneoir/f26369519174f223d6e275707b106f27 to your computer and use it in GitHub Desktop.
Build aseprite 1.3.1 on Raspberry Pi 4 aarch64 bit

System: Raspberry Pi 4, 4GB RAM, Debian Linux 11 (bullseye) aarch64

Setup

# install required packages:
sudo apt-get install -y g++ clang libc++-dev libc++abi-dev cmake ninja-build libx11-dev libxcursor-dev libxi-dev libgl1-mesa-dev libfontconfig1-dev

Build skia-m102 for aarch64

Aseprite doesn't provide an aarch64 linux build of skia, so we will need to build it ourselves.

mkdir $HOME/deps
cd $HOME/deps
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
git clone -b aseprite-m102 https://github.com/aseprite/skia.git
export PATH="${PWD}/depot_tools:${PATH}"
cd skia
python tools/git-sync-deps

Running python tools/git-sync-deps will fail, but before it fails, we will . This is because emsdk does not have aarch64 builds for all of its releases. skia-m102 requires emsdk 3.1.3. The closest available aarch64 build is 3.1.33. Because I am an idiot, I don't know what to change in skia's source to change the dependency requirement to 3.1.33. So instead, we are going to do this:

Setup emsdk 3.1.33

# clone esmdk
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk

# download and install 3.1.33
./emsdk install 3.1.33
./emsdk activate 3.1.33

skia expects emsdk to be located inside $HOME/deps/skia/third_party/externals

# move emsdk to third_party/externals
cd ../
cp -r emsdk third_party/externals

Finish skia-m102 build

# Generate rules for compiling skia using clang
gn gen out/Release-arm64 --args="is_debug=false is_official_build=true skia_use_system_expat=false skia_use_system_icu=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false skia_use_sfntly=false skia_use_freetype=true skia_use_harfbuzz=true skia_pdf_subset_harfbuzz=true skia_use_system_freetype2=false skia_use_system_harfbuzz=false target_cpu=\"arm64\" cc=\"clang\" cxx=\"clang++\" extra_cflags_cc=[\"-stdlib=libc++\"] extra_ldflags=[\"-stdlib=libc++\"]"

If for some reason this fails (due to gn not being found), try running these commands again.

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH="${PWD}/depot_tools:${PATH}"

It happened to me and running those commands worked.

# compile skia
ninja -C out/Release-arm64 skia modules

Build aseprite for aarch64

# go back home
cd ~
# download aseprite 1.3.1 source and extract it
curl -LJO https://github.com/aseprite/aseprite/archive/refs/tags/v1.3.1.zip
unzip aseprite-1.3.1.zip -d aseprite
cd aseprite-1.3.1

# build!
mkdir build
cd build
export CC=clang
export CXX=clang++
cmake \
  -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  -DCMAKE_CXX_FLAGS:STRING=-stdlib=libc++ \
  -DCMAKE_EXE_LINKER_FLAGS:STRING=-stdlib=libc++ \
  -DLAF_BACKEND=skia \
  -DSKIA_DIR=$HOME/deps/skia \
  -DSKIA_LIBRARY_DIR=$HOME/deps/skia/out/Release-arm64 \
  -DSKIA_LIBRARY=$HOME/deps/skia/out/Release-arm64/libskia.a \
  -G Ninja \
  ..
ninja aseprite

Note: this will put out a lot of warning messages. I don't know what they are or why they be. The build has't blown up yet in my short testing, so they can't be that important.

Once ninja has finished, you will have your executable in build/bin/

# run that puppy
cd bin
./aseprite

If you plan to relocate your executable, make sure you move the entire bin folder. All of the provided files are required.

Rejoice

Hopefully all of that worked for you. If it didn't, or if you have brilliant ideas on how to make this process less janky, feel free to comment below. I'd love to make this easier for future linux nerds who enjoy making pixel art. Have a great life!

@LeadLerner
Copy link

evrything worked up until I followed the build instructions, resulting in this error message:

leadlerner@leadusai:~/aseprite/aseprite-1.3.1/build $ cmake \
  -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  -DCMAKE_CXX_FLAGS:STRING=-stdlib=libc++ \
  -DCMAKE_EXE_LINKER_FLAGS:STRING=-stdlib=libc++ \
  -DLAF_BACKEND=skia \
  -DSKIA_DIR=$HOME/deps/skia \
  -DSKIA_LIBRARY_DIR=$HOME/deps/skia/out/Release-arm64 \
  -DSKIA_LIBRARY=$HOME/deps/skia/out/Release-arm64/libskia.a \
  -G Ninja \
  ..
-- The C compiler identification is Clang 14.0.6
-- The CXX compiler identification is Clang 14.0.6
CMake Error at /usr/share/cmake-3.25/Modules/CMakeCInformation.cmake:84 (include):
  include could not find requested file:

    /home/leadlerner/aseprite/aseprite-1.3.1/laf/cmake/c_flag_overrides.cmake
Call Stack (most recent call first):
  CMakeLists.txt:23 (project)


-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at /usr/share/cmake-3.25/Modules/CMakeCXXInformation.cmake:89 (include):
  include could not find requested file:

    /home/leadlerner/aseprite/aseprite-1.3.1/laf/cmake/cxx_flag_overrides.cmake
Call Stack (most recent call first):
  CMakeLists.txt:23 (project)


-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:27 (message):
  Your Aseprite repository is incomplete, initialize submodules using:

    git submodule update --init --recursive


-- Configuring incomplete, errors occurred!
See also "/home/leadlerner/aseprite/aseprite-1.3.1/build/CMakeFiles/CMakeOutput.log".

@LeadLerner
Copy link

I deleted the aseprite folder and ran git clone --recursive https://github.com/aseprite/aseprite.git from the official build guide, and then followed the rest of your tutorial from right after aseprite 1.3.1 is downloaded. I ran the ninja aseprite command, and it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment