[SKIABUILD] Initial build-recipe and Docker containers for skiabuild

This commit is contained in:
James Walmsley 2022-02-22 21:05:03 +00:00
Коммит 72ebba8c3e
22 изменённых файлов: 634 добавлений и 0 удалений

29
.github/workflows/build_containers.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,29 @@
name: Build Docker Containers
on:
push:
paths:
- 'docker/**'
- '.github/workflows/build_containers.yml'
jobs:
build_skiabuild-64:
runs-on: [self-hosted, linux, x64]
container: jameswalmsley/container-builder:latest
steps:
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.JAMES_DOCKER_HUB_USERNAME }}
password: ${{ secrets.JAMES_DOCKER_HUB_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: docker/skiabuild
file: docker/skiabuild/Dockerfile
push: true
tags: jameswalmsley/skiabuild:latest

79
.github/workflows/skiabuild.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,79 @@
name: Build Skia x-plat
on: [push]
jobs:
build_skia_64:
runs-on: [self-hosted, linux, x64]
container: jameswalmsley/skiabuild:latest
steps:
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Build Skia
run: |
make skia_defconfig
make source-checkout -j$(nproc)
make
- run: echo "🍏 This job's status is ${{ job.status }}."
- uses: actions/upload-artifact@v3
with:
name: libskia-x86_64-linux-gnu
path: out/skia/sysroot.tar.gz
# - uses: actions/upload-artifact@v3
# with:
# name: libskia-x86-linux-gnu
# path: out/skia/sysroot.tar.gz
test_skia_archlinux:
runs-on: ubuntu-latest
needs: build_skia_64
container: archlinux:latest
steps:
- run: echo "Testing skia shim on archlinux"
test_skia_fedora:
runs-on: ubuntu-latest
needs: build_skia_64
container: fedora:latest
steps:
- run: echo "Testing skia shim on archlinux"
test_skia_debian:
runs-on: ubuntu-latest
needs: build_skia_64
container: debian:latest
steps:
- run: echo "Testing skia shim on archlinux"
test_skia_alpine:
runs-on: ubuntu-latest
needs: build_skia_64
container: alpine:latest
steps:
- run: echo "Testing skia shim on archlinux"
release_libskia:
needs: [build_skia_64]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
if: startsWith(github.ref, 'refs/tags/v')
- run: ls -R
if: startsWith(github.ref, 'refs/tags/v')
- run: tar cvzf avalonia.skialibs.tar.gz *
if: startsWith(github.ref, 'refs/tags/v')
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
files: |
avalonia.skia.sysroots.tar.gz

3
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,3 @@
.config
out
sources

3
.gitmodules поставляемый Normal file
Просмотреть файл

@ -0,0 +1,3 @@
[submodule "ve-root"]
path = ve-root
url = https://github.com/jameswalmsley/ve-root

27
Makefile Normal file
Просмотреть файл

@ -0,0 +1,27 @@
BASE:=$(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
include $(BASE)/ve-root/Makefile
DOCKER_IMAGE:=skiabuild
DOCKER:=skiabuild
CONTAINER?=skiabuild
# all:
# cd skia && python ./tools/git-sync-deps
# cd skia && ./bin/gn gen out/Shared --args='is_official_build=true skia_use_system_harfbuzz=false is_component_build=true'
# cd skia/out/Shared && ninja -j16
# docker.build:
# cd docker/$(DOCKER) && BASE=$(shell pwd) docker-compose build $(CONTAINER)
# docker.pull:
# cd docker/$(DOCKER) && BASE=$(shell pwd) docker-compose pull $(CONTAINER)
# .PHONY: docker
# docker:
# cd docker/$(DOCKER) && BASE=$(shell pwd) CURRENT_DIR=$(shell pwd) CURRENT_UID=$(shell id -u) \
# CURRENT_GID=$(shell id -g) CURRENT_USER=$(shell whoami) docker-compose run --rm $(CONTAINER) /bin/bash

4
README.md Normal file
Просмотреть файл

@ -0,0 +1,4 @@
# SkiaBuild
[![Build Skia x-plat](https://github.com/AvaloniaUI/Avalonia.Skia/actions/workflows/skiabuild.yml/badge.svg?branch=main)](https://github.com/AvaloniaUI/Avalonia.Skia/actions/workflows/skiabuild.yml)
Cross-platform meta build of skia for Avalonia

1
configs/skia_defconfig Normal file
Просмотреть файл

@ -0,0 +1 @@
CONFIG_RECIPE:=skia

146
docker/skiabuild/Dockerfile Normal file
Просмотреть файл

@ -0,0 +1,146 @@
FROM centos:7 AS buildbase
RUN yum --enablerepo=base clean metadata
RUN yum install -y deltarpm
RUN yum update -y
RUN yum install -y tar \
curl \
curl-devel \
m4 \
autoconf \
automake \
libtool \
pkgconfig \
openssl-devel \
file \
patch \
bzip2 \
zlib-devel \
gettext \
python-setuptools \
python-devel \
epel-release \
centos-release-scl \
git \
gcc \
gcc-c++ \
python3 \
expat-devel \
dh-autoreconf \
curl-devel \
gettext-devel \
openssl-devel \
perl-devel \
zlib-devel \
mesa-libGL-devel \
gperf \
gettext-devel \
expat-devel \
binutils-devel \
python3-devel \
flex \
bison \
texinfo \
which
RUN pip3 install cmake ninja meson
FROM buildbase AS toolchains
RUN yum install -y devtoolset-10
RUN git clone -v --depth=1 https://github.com/distcc/distcc.git && cd distcc && ./autogen.sh && source /opt/rh/devtoolset-10/enable && ./configure && make -j$(nproc) && make install && rm -rf /distcc
RUN ln -s /usr/bin/gcc /usr/bin/gcc-4.8.5
RUN ln -s /usr/bin/g++ /usr/bin/g++-4.8.5
RUN yum -y install glibc-devel.i686
# #
# # Modern GCC
# #
RUN git clone --depth=1 -b releases/gcc-10.3.0 https://github.com/gcc-mirror/gcc
RUN git clone --depth=1 -b binutils-2_38 https://github.com/bminor/binutils-gdb
RUN mkdir -p binutils-gdb/build
RUN cd binutils-gdb/build && ../configure CC='distcc gcc-4.8.5' CXX='distcc g++-4.8.5' --disable-shared --disable-gdb --disable-sim --disable-nls --enable-multilib --enable-multiarch
ENV DISTCC_HOSTS="10.1.0.16/1 10.1.0.24/32 10.1.0.32/8 10.1.0.40/20 10.1.0.48/16"
RUN cd binutils-gdb/build && make -j$(distcc -j)
RUN cd binutils-gdb/build && make install
RUN mkdir -p gcc/build
RUN cd gcc && ./contrib/download_prerequisites
RUN cd gcc/build && ../configure CC='distcc gcc-4.8.5' CXX='distcc g++-4.8.5' \
--prefix=/usr \
--target=x86_64-linux-gnu \
--enable-languages="c,c++" --enable-multilib --enable-multiarch --enable-threads='posix' --program-suffix=-10
RUN cd gcc/build && make -j$(distcc -j)
RUN cd gcc/build && make DESTDIR=$(pwd)/out install
RUN cd gcc/build && make install
RUN git clone -v --depth=1 -b llvmorg-13.0.1 https://github.com/llvm/llvm-project.git
WORKDIR /llvm-project
RUN mkdir build
RUN cd build && CC="distcc gcc-10" CXX="distcc g++-10" cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS=clang \
-G "Ninja" ../llvm
ENV DISTCC_HOSTS="10.1.0.16/8 10.1.0.24/14 10.1.0.40/20 10.1.0.48/16"
RUN cd build && ninja -j$(distcc -j)
RUN cd build && DESTDIR=$(pwd)/out ninja install
RUN cd build && ninja install
RUN cd build/out/usr/local/bin && ln -s clang++ clang++-13
RUN cd /usr/local/bin && ln -s clang++ clang++-13
WORKDIR /
RUN git clone -v --depth=1 -b v2.35.1 https://github.com/git/git.git
RUN cd git && make configure && ./configure CC='distcc clang-13' CXX='distcc clang++-13'
RUN cd git && make -j$(distcc -j)
RUN cd git && make DESTDIR=out install
RUN cd git && make install
RUN git clone -v https://gn.googlesource.com/gn
RUN cd gn && CC='distcc clang-13' CXX='distcc clang++-13' ./build/gen.py
RUN cd gn/out && ninja -j$(distcc -j)
RUN git clone --depth=1 https://gitlab.freedesktop.org/freetype/freetype.git
WORKDIR /freetype
RUN CC="distcc clang-13" CXX="distcc clang++-13" CFLAGS="-fPIC" meson build --buildtype=release && ninja -C build -j$(distcc -j)
RUN ninja -C build install
RUN DESTDIR=$(pwd)/out ninja -C build install
WORKDIR /
RUN git clone --depth=1 https://github.com/freedesktop/fontconfig.git
WORKDIR /fontconfig
RUN CC="distcc clang-13" CXX="distcc clang++-13" CFLAGS="-fPIC" meson build --buildtype=release -Dtests=disabled && ninja -C build -j$(distcc -j)
RUN ninja -C build install
RUN DESTDIR=$(pwd)/out ninja -C build install
WORKDIR /
RUN git clone -v --depth=1 https://github.com/distcc/distcc.git && cd distcc && ./autogen.sh && source /opt/rh/devtoolset-10/enable && ./configure && make -j$(nproc) && make DESTDIR=$(pwd)/out install
WORKDIR /
RUN cd binutils-gdb/build && make DESTDIR=/binutils-gdb/out install
FROM buildbase
COPY --from=toolchains distcc/out/ /
COPY --from=toolchains git/out/ /
COPY --from=toolchains binutils-gdb/out/ /
COPY --from=toolchains gcc/build/out/ /
COPY --from=toolchains llvm-project/build/out/ /
COPY --from=toolchains gn/out/gn /usr/local/bin/
COPY --from=toolchains freetype/out/ /
COPY --from=toolchains fontconfig/out/ /
COPY --from=toolchains gn/out/gn /usr/bin/gn
RUN yum -y install mesa-libGL-devel.i686 glibc-devel.i686 make
RUN mkdir -p /usr/local/git/share/git-core/templates

Просмотреть файл

@ -0,0 +1,5 @@
FROM jameswalmsley/skiabuild:latest
RUN yum -y install sudo wget epel-release
RUN yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm && yum -y install git
RUN wget https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz && cd /usr && tar xvfh /nvim*.tar.gz --strip-components=1 && rm /nvim*.tar.gz

Просмотреть файл

@ -0,0 +1,34 @@
version: "2"
services:
skiabuild:
build:
context: .
dockerfile: devenv.Dockerfile
volumes:
- /home/${CURRENT_USER}:/home/${CURRENT_USER}
- ./entrypoint.sh:/entrypoint.sh
- ./userentry.sh:/userentry.sh
- /tmp/.X11-unix:/tmp/.X11-unix
- /dev:/dev
- /tmp:/tmp
environment:
- DISPLAY
- CURRENT_UID
- CURRENT_GID
- CURRENT_USER
- CURRENT_DIR
- TERM=xterm-256color
hostname: skiabuild
stdin_open: true
tty: true
privileged: true
entrypoint: /entrypoint.sh
working_dir: /work
skiabuild_ci:
build:
context: .
dockerfile: Dockerfile
image: jameswalmsley/skiabuild:latest
volumes:
- /home/${CURRENT_USER}:/home/${CURRENT_USER}

12
docker/skiabuild/entrypoint.sh Executable file
Просмотреть файл

@ -0,0 +1,12 @@
#!/bin/bash
groupadd -g ${CURRENT_GID} usergroup
useradd -M -u ${CURRENT_UID} -g ${CURRENT_GID} ${CURRENT_USER}
usermod -a -G wheel ${CURRENT_USER}
echo "root ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
echo "${CURRENT_USER} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
exec sudo -i -u ${CURRENT_USER} /userentry.sh ${CURRENT_DIR} $@

6
docker/skiabuild/userentry.sh Executable file
Просмотреть файл

@ -0,0 +1,6 @@
#!/bin/bash
export PATH="/usr/local/bin:$PATH"
cd $1
exec $2

Просмотреть файл

@ -0,0 +1,14 @@
LAYER:=avalonia_skia
include $(DEFINE_LAYER)
$(call meson_srcdir, avalonia_skia, $(BASE)/test)
DEPENDS += skia
include $(BUILD_LAYER)
$(L): $(BASE)/test/meson.build
$(L).clean:
rm -rf $(builddir)

Просмотреть файл

@ -0,0 +1,17 @@
LAYER:=fontconfig
include $(DEFINE_LAYER)
fontconfig_GIT_REF?=main
$(call git_clone, fontconfig, https://gitlab.freedesktop.org/fontconfig/fontconfig.git, $(fontconfig_GIT_REF))
$(call meson_srcdir, fontconfig, $(SRC_fontconfig)/fontconfig)
DEPENDS += freetype
include $(BUILD_LAYER)
$(L).clean:
rm -rf $(builddir)

Просмотреть файл

@ -0,0 +1,14 @@
LAYER:=freetype
include $(DEFINE_LAYER)
FREETYPE_GIT_REF?=master
$(call git_clone, freetype, https://gitlab.freedesktop.org/freetype/freetype.git, $(FREETYPE_GIT_REF))
$(call meson, freetype)
include $(BUILD_LAYER)
$(L).clean:
rm -rf $(builddir)

Просмотреть файл

@ -0,0 +1,70 @@
LAYER:=skia
include $(DEFINE_LAYER)
SKIA_GIT_REF?=main
skia:=$(LSTAMP)/skia
skia_sync_deps:=$(LSTAMP)/skia_sync_deps
skia_config:=$(LSTAMP)/skia_config
skia_install:=$(LSTAMP)/skia_install
skia_pkgconfig:=$(LSTAMP)/skia_pkgconfig
$(call git_clone, skia, https://github.com/google/skia.git, $(SKIA_GIT_REF))
$(L) += $(skia_sync_deps)
$(L) += $(skia_config)
$(L) += $(skia)
$(L) += $(skia_install)
$(L) += $(skia_pkgconfig)
DEPENDS += fontconfig
include $(BUILD_LAYER)
SKIA_ARCH=x86_64
$(skia_sync_deps):
cd $(srcdir)/skia && ./tools/git-sync-deps
$(stamp)
SKIA_ARGS:=
SKIA_ARGS += is_official_build=true
SKIA_ARGS += skia_enable_tools=false
SKIA_ARGS += extra_ldflags=[\"-L$(SYSROOT)/usr/local/lib64\"]
SKIA_ARGS += target_os=\"linux\" target_cpu=\"$(SKIA_ARCH)\"
SKIA_ARGS += skia_use_icu=false
SKIA_ARGS += skia_use_sfntly=false
SKIA_ARGS += skia_use_piex=true
SKIA_ARGS += skia_use_system_expat=false
SKIA_ARGS += skia_use_system_freetype2=false
SKIA_ARGS += skia_use_system_libjpeg_turbo=false
SKIA_ARGS += skia_use_system_libpng=false
SKIA_ARGS += skia_use_system_libwebp=false
SKIA_ARGS += skia_use_system_zlib=false
SKIA_ARGS += skia_enable_gpu=true
SKIA_ARGS += cc=\"distcc clang-13\"
SKIA_ARGS += cxx=\"distcc clang++-13\"
SKIA_ARGS += ar=\"$(AR)\"
$(skia_config): $(skia_sync_deps)
cd $(srcdir)/skia && gn gen $(builddir)/skia --args="$(SKIA_ARGS)"
$(stamp)
$(skia): $(skia_config)
cd $(builddir)/skia && ninja $(BUILD_JOBS)
$(stamp)
$(skia_install): $(skia)
mkdir -p $(SYSROOT)/usr/local/include/skia
cp -rv $(srcdir)/skia/include $(SYSROOT)/usr/local/include/skia
cp $(builddir)/skia/libskia.a $(SYSROOT)/usr/local/lib64/
$(stamp)
$(skia_pkgconfig): $(skia_install)
cp $(BASE_skia)/skia.pc.in $(SYSROOT)/usr/local/lib64/pkgconfig/skia.pc
$(L).clean:
rm -rf $(builddir)

Просмотреть файл

@ -0,0 +1,15 @@
prefix=/usr/local
libdir=${prefix}/lib64
includedir=${prefix}/include/skia
sysconfdir=/usr/local/etc
localstatedir=/var/local
confdir=${sysconfdir}/fonts
cachedir=${localstatedir}/cache/fontconfig
Name: Skia
Version: 1.0
Description: Skia graphics library
Libs: -L${libdir} -lskia
Cflags: -I${includedir}

36
recipes/skia/recipe.mk Normal file
Просмотреть файл

@ -0,0 +1,36 @@
include $(DEFINE_RECIPE)
SYSROOT?=$(OUT)/sysroot
export CC:=gcc-10
export CXX:=g++-10
PREFIX=usr/local
LIBDIR=lib64
export LIBRARY_PATH="$(SYSROOT)/$(PREFIX)/$(LIBDIR):$(SYSROOT)/usr/lib64"
ifneq ($(shell which distcc),)
export DISTCC_HOSTS=10.1.0.16/4 10.1.0.24/32 10.1.0.40/20 10.1.0.48/16
export CC:=distcc $(CC)
export CXX:=distcc $(CXX)
endif
ifneq ($(shell which distcc),)
ifdef DISTCC_HOSTS
BUILD_JOBS=-j $$(distcc -j)
testy:
echo $(BUILD_JOBS)
endif
endif
MESON_OPTIONS:=
LAYERS += meson
LAYERS += freetype
LAYERS += fontconfig
LAYERS += skia
LAYERS += avalonia_skia
LAYERS += sysroot/package
include $(BUILD_RECIPE)

29
test/meson.build Normal file
Просмотреть файл

@ -0,0 +1,29 @@
project(
'avalonia.skia',
['c','cpp']
)
gl_dep = dependency('gl', required: true)
fc_dep = dependency('fontconfig', static: true)
sk_dep = dependency('skia', static: true)
cpp = meson.get_compiler('cpp')
# sk_dep = declare_dependency(
# dependencies : cpp.find_library('skia', dirs : meson.current_source_dir()+'/../out/skia/sysroot/usr/local/lib64'),
# include_directories : include_directories('../out/skia/sysroot/usr/local/include/skia')
# )
lib = shared_library(
'avalonia.skia',
['testlib.cpp'],
dependencies: [fc_dep, gl_dep, sk_dep],
install: true,
)
testprog = executable(
'testprog',
['testprog.c'],
link_with: lib,
install: true
)

82
test/testlib.cpp Normal file
Просмотреть файл

@ -0,0 +1,82 @@
#include <stdio.h>
#include "include/c/sk_canvas.h"
#include "include/c/sk_data.h"
#include "include/c/sk_image.h"
#include "include/c/sk_imageinfo.h"
#include "include/c/sk_paint.h"
#include "include/c/sk_path.h"
#include "include/c/sk_surface.h"
static sk_surface_t* make_surface(int32_t w, int32_t h) {
sk_imageinfo_t* info = sk_imageinfo_new(w, h, RGBA_8888_SK_COLORTYPE,
PREMUL_SK_ALPHATYPE, NULL);
sk_surface_t* result = sk_surface_new_raster(info, NULL);
sk_imageinfo_delete(info);
return result;
}
static void emit_png(const char* path, sk_surface_t* surface) {
sk_image_t* image = sk_surface_new_image_snapshot(surface);
sk_data_t* data = sk_image_encode(image);
sk_image_unref(image);
FILE* f = fopen(path, "wb");
fwrite(sk_data_get_data(data), sk_data_get_size(data), 1, f);
fclose(f);
sk_data_unref(data);
}
void draw(sk_canvas_t* canvas) {
sk_paint_t* fill = sk_paint_new();
sk_paint_set_color(fill, sk_color_set_argb(0xFF, 0x00, 0x00, 0xFF));
sk_canvas_draw_paint(canvas, fill);
sk_paint_set_color(fill, sk_color_set_argb(0xFF, 0x00, 0xFF, 0xFF));
sk_rect_t rect;
rect.left = 100.0f;
rect.top = 100.0f;
rect.right = 540.0f;
rect.bottom = 380.0f;
sk_canvas_draw_rect(canvas, &rect, fill);
sk_paint_t* stroke = sk_paint_new();
sk_paint_set_color(stroke, sk_color_set_argb(0xFF, 0xFF, 0x00, 0x00));
sk_paint_set_antialias(stroke, true);
sk_paint_set_stroke(stroke, true);
sk_paint_set_stroke_width(stroke, 5.0f);
sk_pathbuilder_t* path_builder = sk_pathbuilder_new();
sk_pathbuilder_move_to(path_builder, 50.0f, 50.0f);
sk_pathbuilder_line_to(path_builder, 590.0f, 50.0f);
sk_pathbuilder_cubic_to(path_builder, -490.0f, 50.0f, 1130.0f, 430.0f, 50.0f, 430.0f);
sk_pathbuilder_line_to(path_builder, 590.0f, 430.0f);
sk_path_t* path = sk_pathbuilder_detach_path(path_builder);
sk_canvas_draw_path(canvas, path, stroke);
sk_paint_set_color(fill, sk_color_set_argb(0x80, 0x00, 0xFF, 0x00));
sk_rect_t rect2;
rect2.left = 120.0f;
rect2.top = 120.0f;
rect2.right = 520.0f;
rect2.bottom = 360.0f;
sk_canvas_draw_oval(canvas, &rect2, fill);
sk_pathbuilder_delete(path_builder);
sk_path_delete(path);
sk_paint_delete(stroke);
sk_paint_delete(fill);
}
extern "C" {
int do_draw();
}
int do_draw() {
sk_surface_t* surface = make_surface(640, 480);
sk_canvas_t* canvas = sk_surface_get_canvas(surface);
draw(canvas);
emit_png("skia-c-example.png", surface);
sk_surface_unref(surface);
return 0;
}

7
test/testprog.c Normal file
Просмотреть файл

@ -0,0 +1,7 @@
extern int do_draw();
int main() {
do_draw();
return 0;
}

1
ve-root Submodule

@ -0,0 +1 @@
Subproject commit 4b32eeb8a792a7d8859313b32282c924024251ef