Skip to content

Instantly share code, notes, and snippets.

@idbrii
Last active January 14, 2024 17:54
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idbrii/9e1e56818ba99fc4403724f33acb4305 to your computer and use it in GitHub Desktop.
Save idbrii/9e1e56818ba99fc4403724f33acb4305 to your computer and use it in GitHub Desktop.
A simple build script for building Aseprite on Windows 10
@echo off
SETLOCAL EnableDelayedExpansion
:: Derived from the steps in INSTALL.md (https://github.com/aseprite/aseprite/blob/fd2077ce7d80e6af3202958c52291e5d6fb7f556/INSTALL.md)
:: to figure out how to builds this. Worked to build aseprite 1.2.16 release
:: with skia m71 and the most recent (sorry) verison of depot tools.
:: https://github.com/aseprite/aseprite/releases/download/v1.2.16.2/Aseprite-v1.2.16.2-Source.zip
:: https://github.com/aseprite/skia/archive/aseprite-m71.zip
:: https://storage.googleapis.com/chrome-infra/depot_tools.zip
::
:: Prerequisites: ninja, cmake, python, llvm, Visual Studio, Windows SDK (see
:: INSTALL.md in aseprite).
:: I recommend using scoop (https://scoop.sh/) to install some of them:
:: scoop install ninja cmake python llvm
::
:: Update that paths below to match your locations and give it a shot. I make
:: no guarantees that it won't bork your system. Use at yoru own risk.
::
:: If it doesn't work, compare with INSTALL.md and see if any steps have
:: changed. Good luck figuring it out!
set ASEPRITE=e:\clones\aseprite
set GDEPOT=e:\clones\google_depot_tools
set LLVM=%USERPROFILE%\scoop\apps\llvm\9.0.0
set SKIA=e:\clones\skia\skia-aseprite-m71
set VISUALSTUDIO="C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional"
set VISUALSTUDIO=C:\PROGRA~2\MIB055~1\2017\PROFES~1
:: git-sync-deps is python2
set PYTHON2_EXE=C:\apps\Python\Python27\python.exe
echo Checking ninja...
where /q ninja
if ERRORLEVEL 1 (
echo Ninja is not installed.
echo Setup scoop and invoke:
echo scoop install ninja
exit /b 1
)
echo Checking cmake...
where /q cmake
if ERRORLEVEL 1 (
echo cmake is not installed.
echo Setup scoop and invoke:
echo scoop install cmake
exit /b 1
)
echo Checking python...
if not exist %PYTHON2_EXE% (
echo Please install python
echo Setup scoop and invoke:
echo scoop install python
exit /b 1
)
echo Checking aseprite checkout...
if not exist %ASEPRITE%\NUL (
echo Did you download https://github.com/aseprite/aseprite/releases/tag/v1.2.16.2
echo and unzip to %ASEPRITE%
exit /b 1
)
echo Checking chrome-infra/depot_tools...
if not exist %GDEPOT%\NUL (
echo Did you download https://storage.googleapis.com/chrome-infra/depot_tools.zip
echo and unzip to %GDEPOT%
exit /b 1
)
echo Checking llvm...
if not exist %LLVM%\NUL (
echo Did you install llvm?
echo It's recommended to compile Skia with Clang to get better performance.
echo https://github.com/google/skia/blob/master/site/user/build.md#a-note-on-software-backend-performance
echo.
echo Setup scoop and invoke:
echo scoop install llvm
exit /b 1
)
echo Checking skia checkout...
if not exist %SKIA%\NUL (
echo Did you download the right branch of skia? Get it from https://github.com/aseprite/skia.git :
echo cd %SKIA%\..\..
echo git clone --depth 1 -b aseprite-m71 https://github.com/aseprite/skia.git
:: Use depth because we probably don't care about history.
exit /b 1
)
echo All checks okay!
echo.
set PATH=%LLVM%\bin;%GDEPOT%;%PATH%
:: Skia on Windows
echo Building Skia on Windows
echo.
pushd %GDEPOT%
REM gclient sync
set ERRORLEVEL=0
REM Ignore errors here.
if ERRORLEVEL 1 (
echo Error. Aborting...
popd
exit /b %ERRORLEVEL%
)
echo The `gclient` command might print an error like
echo Error: client not configured; see gclient config'.'
echo Just ignore it.
pushd %SKIA%
set GIT_EXECUTABLE=git.bat
:: If you get "\Common was unexpected at this time.", then comment this section
:: out, open a new Command Prompt, and run again.
REM echo The `tools/git-sync-deps` will take some minutes because it downloads
REM echo a lot of packages, please wait and re-run the same command in case it
REM echo fails.
REM %PYTHON2_EXE% tools/git-sync-deps
if ERRORLEVEL 1 (
echo Error. Aborting...
popd
exit /b %ERRORLEVEL%
)
REM call %VISUALSTUDIO%\VC\Auxiliary\Build\vcvars64.bat
call %VISUALSTUDIO%\Common7\Tools\VsDevCmd.bat -arch=x64
REM echo msvc is not recommended because the performance penalty is too big.
REM gn gen out/Release --args="is_official_build=true skia_use_system_expat=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false target_cpu=""x64"" win_vc=""%VISUALSTUDIO%\VC"""
call gn gen out/Release --args="is_official_build=true skia_use_system_expat=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false target_cpu=""x64"" cc=""clang"" cxx=""clang++"" clang_win=""%LLVM%"" win_vc=""%VISUALSTUDIO%\VC"""
if ERRORLEVEL 1 (
echo Error. Aborting...
popd
exit /b %ERRORLEVEL%
)
call ninja -C out/Release skia
if ERRORLEVEL 1 (
echo Error. Aborting...
popd
exit /b %ERRORLEVEL%
)
:: Windows details
echo Building Aseprite on Windows
echo.
pushd %ASEPRITE%
:: In this way, if you want to start with a fresh copy of Aseprite
:: source code, you can remove the `build` directory and start again.
mkdir build
cd build
call cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLAF_OS_BACKEND=skia -DSKIA_DIR=%SKIA% -DSKIA_OUT_DIR=%SKIA%\out\Release -G Ninja ..
call ninja aseprite
if ERRORLEVEL 1 (
echo Error. Aborting...
popd
exit /b %ERRORLEVEL%
)
echo Build complete.
dir %ASEPRITE%\build\bin\aseprite.exe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment