skia-aseprite: init at m102-861e4743af

This commit is contained in:
vigress8 2024-06-13 21:22:06 +04:00
parent 099266ab84
commit e329e660bb
5 changed files with 190 additions and 121 deletions

View File

@ -1,37 +0,0 @@
#!/usr/bin/env bash
FILTER=$1
OUT=skia-deps.nix
REVISION=861e4743af6d9bf6077ae6dda7274e5a136ee4e2
DEPS=$(curl -s https://raw.githubusercontent.com/aseprite/skia/$REVISION/DEPS)
THIRD_PARTY_DEPS=$(echo "$DEPS" | grep third_party | grep "#" -v | sed 's/"//g')
function write_fetch_defs ()
{
while read -r DEP; do
NAME=$(echo "$DEP" | cut -d: -f1 | cut -d/ -f3 | sed 's/ //g')
URL=$(echo "$DEP" | cut -d: -f2- | cut -d@ -f1 | sed 's/ //g')
REV=$(echo "$DEP" | cut -d: -f2- | cut -d@ -f2 | sed 's/[ ,]//g')
echo "Fetching $NAME@$REV"
PREFETCH=$(nix-prefetch-git --rev "$REV" "$URL")
(
cat <<EOF
$NAME = fetchgit {
url = "$URL";
rev = "$REV";
sha256 = $(echo $PREFETCH | jq '.sha256');
};
EOF
) >> "$OUT"
echo "----------"
echo
done <<< "$1"
}
echo "{ fetchgit }:" > "$OUT"
echo "{" >> "$OUT"
write_fetch_defs "$(echo "$THIRD_PARTY_DEPS" | grep -E "$FILTER")"
echo "}" >> "$OUT"

View File

@ -1,80 +0,0 @@
{ stdenv, lib, fetchFromGitHub, fetchgit, python3, gn, ninja
, fontconfig, expat, icu, libglvnd, libjpeg, libpng, libwebp, zlib
, mesa, libX11, harfbuzzFull
}:
let
# skia-deps.nix is generated by: ./skia-make-deps.sh 'angle2|dng_sdk|piex|sfntly'
depSrcs = import ./skia-deps.nix { inherit fetchgit; };
in
stdenv.mkDerivation {
pname = "skia";
version = "aseprite-m102";
src = fetchFromGitHub {
owner = "aseprite";
repo = "skia";
# latest commit from aseprite-m102 branch
rev = "861e4743af6d9bf6077ae6dda7274e5a136ee4e2";
hash = "sha256-IlZbalmHl549uDUfPG8hlzub8TLWhG0EsV6HVAPdsl0=";
};
nativeBuildInputs = [ python3 gn ninja ];
buildInputs = [
fontconfig expat icu libglvnd libjpeg libpng libwebp zlib
mesa libX11 harfbuzzFull
];
preConfigure = with depSrcs; ''
mkdir -p third_party/externals
ln -s ${angle2} third_party/externals/angle2
ln -s ${dng_sdk} third_party/externals/dng_sdk
ln -s ${piex} third_party/externals/piex
ln -s ${sfntly} third_party/externals/sfntly
'';
configurePhase = ''
runHook preConfigure
gn gen out/Release --args="is_debug=false is_official_build=true extra_cflags=[\"-I${harfbuzzFull.dev}/include/harfbuzz\"]"
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
ninja -C out/Release skia modules
runHook postBuild
'';
installPhase = ''
mkdir -p $out
# Glob will match all subdirs.
shopt -s globstar
# All these paths are used in some way when building aseprite.
cp -r --parents -t $out/ \
include/codec \
include/config \
include/core \
include/effects \
include/gpu \
include/private \
include/utils \
include/third_party/skcms/*.h \
out/Release/*.a \
src/gpu/**/*.h \
src/core/*.h \
modules/skshaper/include/*.h \
third_party/externals/angle2/include \
third_party/skcms/**/*.h
'';
meta = with lib; {
description = "Skia is a complete 2D graphic library for drawing Text, Geometries, and Images";
homepage = "https://skia.org/";
license = licenses.bsd3;
maintainers = with maintainers; [ ];
platforms = platforms.all;
};
}

View File

@ -3,21 +3,21 @@
angle2 = fetchgit {
url = "https://chromium.googlesource.com/angle/angle.git";
rev = "8718783526307a3fbb35d4c1ad4e8101262a0d73";
sha256 = "0c90q8f4syvwcayw58743sa332dcpkmblwh3ffkjqn5ygym04xji";
hash = "sha256-UXYCqn++WCyncwNyuuq8rIkxlB7koMK9Ynx7TRzCIDE=";
};
dng_sdk = fetchgit {
url = "https://android.googlesource.com/platform/external/dng_sdk.git";
rev = "c8d0c9b1d16bfda56f15165d39e0ffa360a11123";
sha256 = "1nlq082aij7q197i5646bi4vd2il7fww6sdwhqisv2cs842nyfwm";
hash = "sha256-lTtvBUGaia0jhrxpw7k7NIq2SVyGmBJPCvjIqAQCmNo=";
};
piex = fetchgit {
url = "https://android.googlesource.com/platform/external/piex.git";
rev = "bb217acdca1cc0c16b704669dd6f91a1b509c406";
sha256 = "05ipmag6k55jmidbyvg5mkqm69zfw03gfkqhi9jnjlmlbg31y412";
hash = "sha256-IhAfxlu0UmllihBP9wbg7idT8azlbb9arLKUaZ6qNxY=";
};
sfntly = fetchgit {
url = "https://chromium.googlesource.com/external/github.com/googlei18n/sfntly.git";
rev = "b55ff303ea2f9e26702b514cf6a3196a2e3e2974";
sha256 = "1qi5rfzmwfrji46x95g6dsb03i1v26700kifl2hpgm3pqhr7afpz";
hash = "sha256-/zp1MsR31HehoC5OAI4RO8QBlm7mldQNiTI7Xr/LJeI=";
};
}

View File

@ -0,0 +1,115 @@
{
aseprite,
clangStdenv,
expat,
fetchFromGitHub,
fetchgit,
fontconfig,
gn,
harfbuzzFull,
icu,
lib,
libglvnd,
libjpeg,
libpng,
libwebp,
libX11,
mesa,
ninja,
python3,
zlib,
}:
let
# deps.nix is generated by ./update.sh
depSrcs = import ./deps.nix { inherit fetchgit; };
in
clangStdenv.mkDerivation (finalAttrs: {
pname = "skia-aseprite";
version = "m102-861e4743af";
src = fetchFromGitHub {
owner = "aseprite";
repo = "skia";
rev = finalAttrs.version;
hash = "sha256-IlZbalmHl549uDUfPG8hlzub8TLWhG0EsV6HVAPdsl0=";
};
nativeBuildInputs = [
gn
ninja
python3
];
preConfigure = with depSrcs; ''
mkdir -p third_party/externals
ln -s ${angle2} third_party/externals/angle2
ln -s ${dng_sdk} third_party/externals/dng_sdk
ln -s ${piex} third_party/externals/piex
ln -s ${sfntly} third_party/externals/sfntly
'';
configurePhase = ''
runHook preConfigure
gn gen lib --args="is_debug=false is_official_build=true extra_cflags=[\"-I${harfbuzzFull.dev}/include/harfbuzz\"]"
runHook postConfigure
'';
buildInputs = [
expat
fontconfig
harfbuzzFull
icu
libglvnd
libjpeg
libpng
libwebp
libX11
mesa
zlib
];
buildPhase = ''
runHook preBuild
ninja -C lib skia modules
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out
# Glob will match all subdirs.
shopt -s globstar
# All these paths are used in some way when building Aseprite.
cp -r --parents -t $out/ \
include/codec \
include/config \
include/core \
include/effects \
include/gpu \
include/private \
include/utils \
include/third_party/skcms/*.h \
lib/*.a \
modules/skshaper/include/*.h \
src/core/*.h \
src/gpu/**/*.h \
third_party/externals/angle2/include \
third_party/skcms/**/*.h
runHook postInstall
'';
passthru.updateScript = [ ./update.sh ] ++ builtins.attrNames depSrcs;
meta = {
description = "Complete 2D graphic library for drawing Text, Geometries, and Images (Aseprite's fork)";
homepage = "https://skia.org/";
downloadPage = "https://github.com/aseprite/skia";
license = lib.licenses.bsd3;
inherit (aseprite.meta) maintainers;
platforms = lib.platforms.all;
};
})

View File

@ -0,0 +1,71 @@
#!/usr/bin/env nix-shell
#!nix-shell --pure -i bash
#!nix-shell -p cacert curl git jq nix-prefetch-git
# shellcheck shell=bash
# vim: set tabstop=2 shiftwidth=2 expandtab:
set -euo pipefail
shopt -s inherit_errexit
[ $# -gt 0 ] || {
printf >&2 'usage: %s <deps>' "$0"
exit 1
}
pkgpath=$(git rev-parse --show-toplevel)/pkgs/by-name/sk/skia-aseprite
depfilter=$(tr ' ' '|' <<< "$*")
depfile=$pkgpath/deps.nix
pkgfile=$pkgpath/package.nix
update_deps() {
local deps third_party_deps name url rev hash prefetch
version=$(sed -n 's|.*version = "\(.*\)".*|\1|p' < "$pkgfile")
deps=$(curl -fsS https://raw.githubusercontent.com/aseprite/skia/$version/DEPS)
third_party_deps=$(sed -n 's|[ ",]||g; s|:| |; s|@| |; s|^third_party/externals/||p' <<< "$deps")
filtered=$(grep -E -- "$depfilter" <<< "$third_party_deps")
if [[ -z $filtered ]]; then
printf >&2 '%s: error: filter "%s" matched nothing' "$0" "$depfilter"
return 1
fi
printf '{ fetchgit }:\n{\n'
while read -r name url rev; do
printf >&2 'Fetching %s@%s\n' "$name" "$rev"
prefetch=$(nix-prefetch-git --quiet --rev "$rev" "$url")
hash=$(jq -r '.hash' <<< "$prefetch")
cat << EOF
$name = fetchgit {
url = "$url";
rev = "$rev";
hash = "$hash";
};
EOF
# `read` could exit with a non-zero code without a newline at the end
done < <(printf '%s\n' "$filtered")
printf '}\n'
}
update_version() {
local newver newrev
newver=$(
curl --fail \
--header 'Accept: application/vnd.github+json' \
--location --show-error --silent \
${GITHUB_TOKEN:+ --user \":$GITHUB_TOKEN\"} \
https://api.github.com/repos/aseprite/skia/releases/latest \
| jq -r .tag_name
)
newhash=$(nix-prefetch-git --quiet --rev "$newver" https://github.com/aseprite/skia.git | jq -r '.hash')
sed \
-e 's|version = ".*"|version = "'$newver'"|' \
-e 's|hash = ".*"|hash = "'$newhash'"|' \
-- "$pkgfile"
}
temp=$(mktemp)
trap 'ret=$?; rm -rf -- "$temp"; exit $ret' EXIT
update_version > "$temp"
cp "$temp" "$pkgfile"
update_deps > "$temp"
cp "$temp" "$depfile"