buildskia

package
v0.0.0-...-2887efe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2024 License: BSD-3-Clause Imports: 24 Imported by: 7

Documentation

Overview

Utility functions for downloading, building, and compiling programs against Skia.

Index

Constants

View Source
const (
	CMAKE_OUTDIR            = "cmakeout"
	CMAKE_COMPILE_ARGS_FILE = "skia_compile_arguments.txt"
	CMAKE_LINK_ARGS_FILE    = "skia_link_arguments.txt"
)
View Source
const (
	GOOD_BUILDS_FILENAME = "goodbuilds.txt"

	// PRESERVE_DURATION is used to determine if an LKGR commit should be
	// preserved.  i.e. if a the distance between two commits is greater than
	// PRESERVER_DURATION then they both should be preserved.
	PRESERVE_DURATION = 30 * 24 * time.Hour

	// DECIMATION_PERIOD is the time between decimation runs.
	DECIMATION_PERIOD = time.Hour

	// BUILD_TYPE is the type of build we use throughout.
	BUILD_TYPE = RELEASE_BUILD
)

Variables

View Source
var (
	AlreadyExistsErr = errors.New("Checkout already exists.")
)

errors

Functions

func CMakeBuild

func CMakeBuild(ctx context.Context, path, depotTools string, build ReleaseType) error

CMakeBuild runs /skia/cmake/cmake_build to build Skia.

path       - The absolute path to the Skia checkout.
depotTools - The path to depot_tools.
build      - Is the type of build to perform.

The results of the build are stored in path/CMAKE_OUTDIR.

func CMakeCompile

func CMakeCompile(ctx context.Context, path, out string, filenames []string, extraIncludeDirs []string, build ReleaseType) error

CMakeCompile will compile the given files into an executable.

path - the absolute path to the Skia checkout.
out - A filename, either absolute, or relative to path, to write the .o file.
filenames - Absolute paths to the files to compile.

Should run something like:

$ c++ @skia_compile_arguments.txt fiddle_main.cpp \
      -o fiddle_main.o
func CMakeCompileAndLink(ctx context.Context, path, out string, filenames []string, extraIncludeDirs []string, extraLinkFlags []string, build ReleaseType) (string, error)

CMakeCompileAndLink will compile the given files into an executable.

path - the absolute path to the Skia checkout.
out - A filename, either absolute, or relative to path, to write the exe.
filenames - Absolute paths to the files to compile.
extraIncludeDirs - Entra directories to search for includes.
extraLinkFlags - Entra linker flags.

Returns the stdout+stderr of the compiler and a non-nil error if the compile failed.

Should run something like:

$ c++ @skia_compile_arguments.txt fiddle_main.cpp \
      draw.cpp @skia_link_arguments.txt -lOSMesa \
      -o myexample

func DownloadSkia

func DownloadSkia(ctx context.Context, branch, gitHash, path, depotToolsPath string, clean bool, installDeps bool) (*vcsinfo.LongCommit, error)

DownloadSkia uses git to clone Skia from googlesource.com and check it out to the specified gitHash for the specified branch. Upon success, any dependencies needed to compile Skia have been installed (e.g. the latest version of gyp).

branch - The empty string signifies the main branch.
gitHash - The git hash to check out Skia at.
path - The path to check Skia out into.
depotToolsPath - The depot_tools directory.
clean - If true clean out the directory before cloning Skia.
installDeps - If true then run tools/install_dependencies.sh before
    sync. The calling user should be sudo capable.

It returns an error on failure.

func GNDownloadSkia

func GNDownloadSkia(ctx context.Context, branch, gitHash, path, depotToolsPath string, clean bool, installDeps bool) (*vcsinfo.LongCommit, error)

GNDownloadSkia uses depot_tools fetch to clone Skia from googlesource.com and check it out to the specified gitHash for the specified branch. Upon success, any dependencies needed to compile Skia have been installed.

branch - The empty string signifies the main branch.
gitHash - The git hash to check out Skia at.
path - The path to check Skia out into.
depotToolsPath - The depot_tools directory.
clean - If true clean out the directory before cloning Skia.
installDeps - If true then run tools/install_dependencies.sh before
    syncing. The calling user should be sudo capable.

It returns an error on failure.

func GNGen

func GNGen(ctx context.Context, path, depotTools, outSubDir string, args []string) error

GNGen runs GN on Skia.

path       - The absolute path to the Skia checkout, should be the same
             path passed to DownloadSkiaGN.
depotTools - The path to depot_tools.
outSubDir  - The name of the sub-directory under 'out' to build in.
args       - A slice of strings to pass to gn --args. See the skia
             BUILD.gn and https://skia.org/user/quick/gn.

The results of the build are stored in path/skia/out/<outSubDir>.

func GNNinjaBuild

func GNNinjaBuild(ctx context.Context, path, depotToolsPath, outSubDir, target string, verbose bool) (string, error)

GNNinjaBuild builds the given target using ninja.

path - The absolute path to the Skia checkout as passed into DownloadSkiaGN.
depotToolsPath - The depot_tools directory.
outSubDir - The name of the sub-directory under 'out' to build in.
target - The specific target to build. Pass in the empty string to build all targets.
verbose - If the build's std out should be logged (usally quite long)

Returns the build logs and any errors on failure.

func GetSkiaHash

func GetSkiaHash(client *http.Client) (string, error)

GetSkiaHash returns Skia's LKGR commit hash as recorded in chromium's DEPS file.

If client is nil then a default timeout client is used.

func GetSkiaHead

func GetSkiaHead(client *http.Client) (string, error)

GetSkiaHead returns the most recent commit hash on Skia's main branch.

If client is nil then a default timeout client is used.

func NinjaBuild

func NinjaBuild(ctx context.Context, skiaPath, depotToolsPath string, extraEnv []string, build ReleaseType, target string, numCores int, verbose bool) error

NinjaBuild builds the given target using ninja.

skiaPath - The absolute path to the Skia checkout.
depotToolsPath - The depot_tools directory.
extraEnv - Any additional environment variables that need to be set.  Can be nil.
build - The type of build to perform.
target - The build target, e.g. "SampleApp" or "most".
verbose - If the build's std out should be logged (usally quite long)

Returns an error on failure.

Types

type ContinuousBuilder

type ContinuousBuilder struct {
	// contains filtered or unexported fields
}

ContinuousBuilder is for building versions of the Skia library and then compiling and running command-line apps against those built versions.

For each LKGR of Skia, that version of code will be checked out under workDir/"versions"/<git hash>.

func New

func New(ctx context.Context, workRoot, depotTools string, repo vcsinfo.VCS, perBuild PerBuild, preserve int, timeBetweenBuilds time.Duration, useGn bool) *ContinuousBuilder

New returns a new ContinuousBuilder instance.

workRoot - The root directory where work is stored.
depotTools - The directory where depot_tools is checked out.
repo - A vcs to pull hash info from.
perBuild - A PerBuild callback that gets called every time a new successful build of Skia is available.
preserve - The number of LKGR builds to preserve after decimation.
timeBetweenBuilds - The duration between attempts to pull LGKR and built it.
useGn - Use GN as the meta build system, as opposed to GYP.

Call Start() to begin the continous build Go routine.

func (*ContinuousBuilder) AvailableBuilds

func (b *ContinuousBuilder) AvailableBuilds() ([]string, error)

AvailableBuilds returns a list of git hashes, all the versions of Skia that can be built against. This returns the list with the newest builds last. The list will always be of length > 1, otherwise and error is returned.

func (*ContinuousBuilder) BuildLatestSkia

func (b *ContinuousBuilder) BuildLatestSkia(ctx context.Context, force bool, head bool, deps bool) (*vcsinfo.LongCommit, error)

BuildLatestSkia builds the LKGR of Skia in the given workRoot directory.

The library will be checked out into workRoot + "/" + githash, where githash is the githash of the LKGR of Skia.

force - If true then checkout and build even if the directory already exists.
head - If true then build Skia at HEAD, otherwise build Skia at LKGR.
deps - If true then install Skia dependencies.

Returns the commit info for the revision of Skia checked out. Returns an error if any step fails, or return AlreadyExistsErr if the target checkout directory already exists and force is false.

In GN mode ninja files are not generated, the caller must call GNGen in their PerBuild callback before calling GNNinjaBuild.

func (*ContinuousBuilder) Current

func (b *ContinuousBuilder) Current() *vcsinfo.LongCommit

func (*ContinuousBuilder) Start

func (b *ContinuousBuilder) Start(ctx context.Context)

Start the continuous build latest LKGR Go routine.

type PerBuild

type PerBuild func(ctx context.Context, checkout, depotTools string) error

PerBuild is a callback function where ContinuousBuilder clients can perform specific builds within the newest Skia checkout.

type ReleaseType

type ReleaseType string
const (
	RELEASE_BUILD           ReleaseType = "Release"
	DEBUG_BUILD             ReleaseType = "Debug"
	RELEASE_DEVELOPER_BUILD ReleaseType = "Release_Developer"
)

ReleaseType constants.

Directories

Path Synopsis
skia_build is a command line application to trigger or force builds of Skia that are done using go/buildskia.
skia_build is a command line application to trigger or force builds of Skia that are done using go/buildskia.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL