Last active
October 26, 2021 08:25
-
-
Save andrew-ma/3e94995fea369cd6664f51eebc684ea9 to your computer and use it in GitHub Desktop.
Aseprite Compile Instructions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
🔥🔥🔥 NEW STEPS for 2021: 🔥🔥🔥 | |
########################### WINDOWS 64-bit Aseprite Compile Instructions ########################### | |
1. Open Powershell as Administrator | |
* Type "powershell" (without the quotes) into the Start Menu Search Bar | |
* There should be an app with exactly "Windows Powershell" (not ISE), and click the "Run as Administrator" button | |
2. Copy and Paste these commands into Powershell | |
###################################################################################################### | |
# Allows running powershell scripts | |
Set-ExecutionPolicy Bypass -Scope Process -Force | |
# Install Chocolatey | |
if (-not (Get-Command "choco" -errorAction SilentlyContinue)) { | |
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) | |
} | |
# Install git, ninja, and llvm (clang) using Chcolatey | |
choco install -y git ninja llvm | |
# Download Visual Studio 2019 Build Tools using Chocolatey | |
## Installs it to 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools' | |
choco install -y visualstudio2019buildtools --package-parameters "--norestart --nocache --wait --passive --locale en-US --includeRecommended --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Component.VC.CLI.Support" | |
# Reload Chocolatey | |
$env:ChocolateyInstall = Convert-Path "$((Get-Command choco).Path)\..\.." | |
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" | |
refreshenv | |
# Activate 'Developer Powershell for VS 2019 (x64)' to be able to access Build Tools | |
## Make sure we are using x64 compilers and not x86 | |
# & "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\Launch-VsDevShell.ps1" | |
# Call vcvars64.bat and retain environment variable changes | |
$tempFile = [IO.Path]::GetTempFileName() | |
## Store the output of cmd.exe. We also ask cmd.exe to output | |
## the environment table after the batch file completes | |
$Path = "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat" | |
cmd /c " `"$Path`" $argumentList && set > `"$tempFile`" " | |
## Go through the environment variables in the temp file. | |
## For each of them, set the variable in our local environment. | |
Get-Content $tempFile | Foreach-Object { | |
if($_ -match "^(.*?)=(.*)$") | |
{ | |
Set-Content "env:\$($matches[1])" $matches[2] | |
} | |
} | |
Remove-Item $tempFile | |
###################################################################################################### | |
# Change directory to where Aseprite dependency files will be downloaded | |
$ROOT_FOLDER = "$($env:temp)\Aseprite_Dependencies" | |
if (-not (Test-Path "$ROOT_FOLDER")) { | |
New-Item "$ROOT_FOLDER" -ItemType "directory" -force | |
} | |
Set-Location "$ROOT_FOLDER" | |
# # Skia (dependency for Aseprite) Steps | |
# ## Instructions: https://skia.org/docs/user/download/ | |
# ## Clone depot_tools github repo, which contains 'gn' command | |
# $DEPOT_TOOLS_FOLDER = "$ROOT_FOLDER\depot_tools" | |
# if ((Test-Path "$DEPOT_TOOLS_FOLDER") -eq $false) { | |
# Start-Process -NoNewWindow -Wait -FilePath "git" -ArgumentList "clone", "https://chromium.googlesource.com/chromium/tools/depot_tools.git", "$DEPOT_TOOLS_FOLDER" | |
# Set-Location "$DEPOT_TOOLS_FOLDER" | |
# } else { | |
# Set-Location "$DEPOT_TOOLS_FOLDER" | |
# Start-Process -NoNewWindow -Wait -FilePath "git" -ArgumentList "pull", "origin", "main" | |
# } | |
# ## Add depot_tools to Path | |
# $env:Path = "$DEPOT_TOOLS_FOLDER;$env:Path" | |
# ## Run "gclient sync" | |
# Start-Process -NoNewWindow -Wait -FilePath "gclient" -ArgumentList "sync" -RedirectStandardError "NUL" | |
# ## Clone Skia github repo | |
# $SKIA_FOLDER = "$ROOT_FOLDER\skia" | |
# if ((Test-Path "$SKIA_FOLDER") -eq $false) { | |
# Start-Process -NoNewWindow -Wait -FilePath "git" -ArgumentList "clone", "https://skia.googlesource.com/skia.git", "$SKIA_FOLDER" | |
# Set-Location "$SKIA_FOLDER" | |
# } else { | |
# Set-Location "$SKIA_FOLDER" | |
# Start-Process -NoNewWindow -Wait -FilePath "git" -ArgumentList "pull", "origin", "main" | |
# } | |
# ## Use the DEPS file inside the skia repo | |
# Start-Process -NoNewWindow -Wait -FilePath "python" -ArgumentList "tools/git-sync-deps" | |
# ## 'gn gen' to generate the build files | |
# $win_vc = "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC" | |
# $win_sdk = "C:\Program Files (x86)\Windows Kits\10" | |
# $clang_win = "C:\Program Files\LLVM" | |
# ### or (resolve-path "$($(get-command clang).Source)\..\..").Path | |
# ## Remove Last generated Skia build files | |
# #Remove-item $SKIA_FOLDER\out -force -recurse 2>$null | |
# ## Generate Skia build files with "gn gen" (and clang compiler) | |
# ### will later compile to a static library (.lib) in 'out/Release-x64' directory | |
# ### NOTE: for cmd.exe command, use (gn gen out/Release-x64 --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=""x64"" cc=""clang"" cxx=""clang++"" clang_win=""C:\Program Files\LLVM"" win_sdk=""C:\Program Files (x86)\Windows Kits\10"" win_vc=""C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC"" extra_cflags=[""-MT""]") | |
# Start-Process -NoNewWindow -Wait -FilePath "C:\Windows\System32\cmd.exe" -ArgumentList '/c', 'gn', 'gen', 'out/Release-x64', " --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=\`"x64\`" cc=\`"clang\`" cxx=\`"clang++\`" win_vc=\`"$win_vc\`" win_sdk=\`"$win_sdk\`" clang_win=\`"$clang_win\`" extra_cflags=[\`"-MT\`"] `" " | |
# ## Compile Skia with Ninja | |
# Start-Process -NoNewWindow -Wait -FilePath "ninja" -ArgumentList "-C", "out/Release-x64", "skia", "modules" | |
############################################################### | |
## Downloaded Precompiled Skia from ZIP, and Expand-Archive | |
$SKIA_RELEASE_NAME = "Skia-Windows-Release-x64" | |
$SKIA_FOLDER = "$ROOT_FOLDER\$SKIA_RELEASE_NAME" | |
if ((Test-Path $SKIA_FOLDER) -eq $false) { | |
Write-Output "Downloading Precompiled Skia ZIP file" | |
$skia = Invoke-WebRequest 'https://api.github.com/repos/aseprite/skia/releases/latest' -UseBasicParsing | Convertfrom-json | |
$assetUrl = $null | |
$assetName = $null | |
foreach ($asset in $skia.assets) { | |
if ($asset.name -like '*Windows-Release-x64*') { | |
$assetUrl = $asset.browser_download_url | |
$assetName = $asset.name | |
} | |
} | |
if ($null -eq $assetUrl) { | |
throw "Could not find a windows x64 release!" | |
} | |
# download skia | |
$SKIA_ZIP_FILE = "$ROOT_FOLDER\$assetName" | |
(New-Object System.Net.WebClient).DownloadFile($assetUrl, $SKIA_ZIP_FILE) | |
New-Item -Path $SKIA_FOLDER -ItemType "directory" | Out-Null | |
# extract skia into the deps folder | |
Expand-Archive -LiteralPath $SKIA_ZIP_FILE -DestinationPath $SKIA_FOLDER | |
} | |
else { | |
Write-Output "Already downloaded..." | |
} | |
############################################################### | |
## Download Aseprite github repo | |
$aseprite_git_url = "https://github.com/aseprite/aseprite.git" | |
$aseprite_git_tag_or_branch = "v1.2.29" | |
$aseprite_git_folder_prefix = "$ROOT_FOLDER\aseprite" | |
$latestTag = $null | |
if ($aseprite_git_tag_or_branch -eq $null) { | |
# Use latest tag version if null | |
Write-Output "Using the latest tag version on github" | |
$latestTag = (git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' $aseprite_git_url '*.*' | Select-Object -Last 1).split('')[1].replace("refs/tags/","") | |
Write-Output " $latestTag" | |
} | |
elseif ($aseprite_git_tag_or_branch -eq "master") { | |
Write-Output "Using the master branch on github" | |
$latestTag = "master" | |
} | |
else { | |
# Use custom specified Tag or Branch | |
Write-Output "Using custom tag/branch '$aseprite_git_tag_or_branch' on github" | |
$latestTag = "$aseprite_git_tag_or_branch" | |
} | |
$aseprite_git_folder = "$aseprite_git_folder_prefix" + '_' + "$latestTag" | |
if ((Test-Path $aseprite_git_folder) -eq $false) { | |
& git clone --recursive -b $latestTag --single-branch "$aseprite_git_url" "$aseprite_git_folder" | |
Set-Location "$aseprite_git_folder" | |
} | |
else { | |
Set-Location "$aseprite_git_folder" | |
& git pull origin $latestTag | |
& git submodule update --init --recursive | |
} | |
###################################################################################################### | |
## Makes a clean "build" folder, and renames last run's "build" folder to "build_last" | |
$BUILD_FOLDER = "$aseprite_git_folder\build" | |
$BUILD_FOLDER_PREVIOUS = "$aseprite_git_folder\build_previous" | |
if (-not (Test-Path "$BUILD_FOLDER")) { | |
mkdir "$BUILD_FOLDER" | |
} | |
else { | |
if (Test-Path "$BUILD_FOLDER_PREVIOUS") { | |
Remove-item -path "$BUILD_FOLDER_PREVIOUS" -force -recurse | |
} | |
Rename-item -path "$BUILD_FOLDER" -newname "$BUILD_FOLDER_PREVIOUS" | |
mkdir "$BUILD_FOLDER" | |
} | |
Set-Location "$BUILD_FOLDER" | |
## Generate Aseprite build with cmake (and MSVC cl.exe compiler) | |
## NOTE: this process might get stuck on the message 'Build files have been written to' | |
## And if so, press CTRL+C, and paste the rest | |
Start-Process -NoNewWindow -Wait -FilePath "cmake" -ArgumentList "-DCMAKE_BUILD_TYPE=Release", "-DCMAKE_C_COMPILER=cl", "-DCMAKE_CXX_COMPILER=cl", "-DLAF_BACKEND=skia", "-DSKIA_DIR=$SKIA_FOLDER", "-DSKIA_LIBRARY_DIR=$SKIA_FOLDER\out\Release-x64", "-DSKIA_LIBRARY=$SKIA_FOLDER\out\Release-x64\skia.lib", "-G", "Ninja", ".." | |
###################################################################################################### | |
## NOTE: if stuck on previous command, CTRL+C, and paste the rest | |
## Compile Aseprite with Ninja | |
Start-Process -NoNewWindow -Wait -FilePath "ninja" -ArgumentList "aseprite" | |
# Change directory to Aseprite built bin folder | |
Set-Location "$BUILD_FOLDER\bin" | |
# List folder | |
Get-ChildItem . | |
## Print path of the new executable | |
Write-Output "############################################################" | |
Write-Output " You successfully compiled Aseprite! " | |
Write-Output " Files are in: $BUILD_FOLDER\bin " | |
Write-Output " only 'aseprite.exe' and the 'data' folder are essential " | |
Write-Output "############################################################" | |
###################################################################################################### | |
3. To update aseprite if there is ever a new version, just re-run steps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment