Documentation
¶
Index ¶
- Constants
- Variables
- func BlobSizeAfterCompressed(fileSize int64) int64
- func ChrootTransform(path, chroot string) string
- func CloseErrCheck(c io.Closer, err *error)
- func DecodeObject(content []byte) (string, []byte, error)
- func FirstError(errs ...error) error
- func IgnoreNotExistErr(err error) error
- func IsDev() bool
- func IsHash(s string) bool
- func IsNotExist(err error) bool
- func IsSHA256(s string) bool
- func ModeToString(m FileMode) string
- func NotExistErrf(format string, a ...any) error
- func PathApply(a, b string) string
- func PathDiff(a, b string) string
- func TapTypes() string
- func WrapNotExist(err error) error
- func WriteObject(objType string, content []byte, w io.Writer) error
- type BlobStore
- type CASStore
- type DeepEntry
- type DeepTree
- type DeletePatch
- type EntryType
- type FSConfig
- type FileEntry
- type FileMode
- func (m FileMode) IsDir() bool
- func (m FileMode) IsFile() bool
- func (m FileMode) IsFileOrSymlink() bool
- func (m FileMode) IsStat() bool
- func (m *FileMode) SetStat()
- func (m FileMode) String() string
- func (m FileMode) ToLetter() string
- func (m FileMode) ToOSFileMode() (os.FileMode, error)
- func (m *FileMode) UnsetStat()
- type Hash
- type HashStat
- type MapStore
- type NSJailAllowReadWrite
- type NSJailBuildConfig
- type NSJailConfig
- type NSJailConfigElement
- type NSJailFlag
- type NSJailGoal
- type NSJailOverlay
- type NSJailPath
- type NSJailTarget
- type NSJailView
- type NotExistErr
- type ObjectHeader
- type ObjectStore
- type ObjectType
- type Patch
- type PatchEntry
- type PatchEntryState
- type ProjectRefHash
- type RefHash
- type RefStore
- type SHA256
- type Sizer
- type StatInfo
- type SyncHashSet
- type TapCmdResult
- type TapData
- type TapFSEntry
- type TapType
- type TappingType
- type TreeMeta
Constants ¶
const ( EntryTypeDevNode = EntryType(iota) EntryTypeDir EntryTypeFile EntryTypeSymlink )
const ( // Git standard modes, as defined by go-git. FileModeEmpty = FileMode(filemode.Empty) FileModeDir = FileMode(filemode.Dir) FileModeRegular = FileMode(filemode.Regular) FileModeDeprecated = FileMode(filemode.Deprecated) FileModeExecutable = FileMode(filemode.Executable) FileModeSymlink = FileMode(filemode.Symlink) FileModeSubmodule = FileMode(filemode.Submodule) // Modes after this are not git standard modes FileModeDevNode FileMode = 0200000 FileModeDeepTree FileMode = 0210000 )
const ( // HashSize is the number of bytes in a Hash. HashSize = hash.Size // HashHexSize is the length of a Hash in hexadecimal notation. HashHexSize = hash.HexSize )
const ( ABFSMetaServer = "default-server" ABFSMetaProject = "abfs-meta" )
const ( // SHA256Size is the number of bytes in a SHA256. SHA256Size = plumbing.SHA256Size // SHA256HexSize is the length of a SHA256 in hexadecimal notation. SHA256HexSize = plumbing.SHA256HexSize )
const ABFSSocketFileName = ".abfs.sock"
const DistDirVar = "DIST_DIR"
const MismatchesLogFile = ".abfs_mismatches"
const ( // NSJailConfigPathEnv names the environment variable holding the path, relative to the // top of the source tree, of the NSJail build config XML. If unset, no config is loaded. NSJailConfigPathEnv = "ABFS_NSJAIL_CONFIG" )
const OutDirVar = "OUT_DIR"
Variables ¶
var ( ErrEntryNotFound = errors.New("entry not found") ErrNotADirectory = errors.New("entry is not a directory") ErrEntryADirectory = errors.New("entry is a directory") ErrNotAFile = errors.New("entry is not a file") ErrEntryExists = errors.New("entry already exists") ErrNotADirectoryObject = errors.New("expected a directory object") ErrDirNotEmpty = errors.New("directory not empty") )
var DistDir = path.Join(OutDir, "dist")
var EmptyDirContent = []byte("tree 0\x00")
var EmptyFileContent = []byte("blob 0\x00")
var ErrNotExist = fs.ErrNotExist
var ErrObjectParse = errors.New("failed to parse the object")
var OutDir = "out"
var PatchEntryMapName = map[PatchEntryState]string{ PatchEntryStateUnassigned: "unassigned", PatchEntryStateDirModified: "dir-modified", PatchEntryStateDir: "dir", PatchEntryStateIn: "input", PatchEntryStateDep: "dep", PatchEntryStateRSP: "rsp", PatchEntryStateExtraIn: "extra-input", PatchEntryStateExtraRead: "hidden", PatchEntryStateNotReadRSP: "not-read-rsp", PatchEntryStateNotReadDep: "not-read-dep", PatchEntryStateOrderOnly: "order-only", PatchEntryStateNotReadOrderOnly: "not-read-order-only", PatchEntryInfoAutoSnapshot: "auto-snapshot", PatchEntryStateOut: "target", PatchEntryStateDepFile: "depfile", PatchEntryStateExtraWrite: "extra-write", PatchEntryStateMissingDepFile: "missing-depfile", PatchEntryStateMissingOut: "missing-target", }
Const patch entry names
var (
ZeroSHA256 = SHA256(plumbing.ZeroSHA256)
)
Functions ¶
func BlobSizeAfterCompressed ¶
Note: This only handle the case of compression level 0
func ChrootTransform ¶
Transform paths to remove the input 'chroot'.
func CloseErrCheck ¶
func FirstError ¶
func IgnoreNotExistErr ¶
func IsNotExist ¶
func ModeToString ¶
func NotExistErrf ¶
func WrapNotExist ¶
Types ¶
type CASStore ¶
type CASStore interface {
BlobStore
ObjectStore
MapStore
RefStore
io.Closer
CAS() cas.Store
// TODO: Optimize keep alive: change the interface to keys []entities.Hash
KeepAlive(ctx context.Context, key Hash) error
// IsObjectRemote is for both objects and blobs.
// It will firstly check the remote attribute if the object is in the local cache.
// If it's not, it will then check if it's on the remote server by requesting the header.
IsObjectRemote(ctx context.Context, key Hash) (bool, error)
StartGC(ctx context.Context) error
HealthCheck() error
}
type DeletePatch ¶
type DeletePatch []string
func (DeletePatch) ChrootTransform ¶
func (p DeletePatch) ChrootTransform(chroot string)
func (DeletePatch) MarshalJSON ¶
func (p DeletePatch) MarshalJSON() ([]byte, error)
func (*DeletePatch) UnmarshalJSON ¶
func (p *DeletePatch) UnmarshalJSON(data []byte) error
type FileEntry ¶
func DecodeDirPlain ¶
DecodeDirPlain is similar to DecodeDir, but the sizes of the entries won't be present in the returned objects since they weren't provided.
type FileMode ¶
type FileMode uint32
FileMode is a Git file mode, extended with ABFS-specific modes (see FileModeDevNode and FileModeDeepTree) and a stat-operation bit. String, ToOSFileMode and FileModeNew delegate to the go-git code in third_party/go-git.
const ( PatchStatOperation FileMode = 01000000 SrcDir = "/src" )
func FileModeFromLetter ¶
func FileModeNew ¶
FileModeNew parses the octal string representation of a FileMode. On error it returns FileModeEmpty.
func ModeToFileMode ¶
func (FileMode) IsFileOrSymlink ¶
func (FileMode) ToOSFileMode ¶
ToOSFileMode returns the os.FileMode to use for a file system entry with Git mode m, or an error if m has no file system equivalent.
type Hash ¶
Hash is a SHA-1 object hash.
func NewHash ¶
NewHash parses a hexadecimal hash. Invalid input yields a zero or partial hash; use IsHash to validate first.
func (Hash) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for Hash.
func (Hash) MarshalText ¶
MarshalText implements encoding.TextMarshaler
func (*Hash) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface for Hash.
func (*Hash) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler
type HashStat ¶
HashStat is useful because it is the info needed to recreate a file. The Hash will allow the store to look up the content and the mode stores permission bits. The size is also useful for creation so a stat can work without needing a server lookup of the hash.
type NSJailAllowReadWrite ¶
type NSJailAllowReadWrite struct {
XMLName xml.Name `xml:"allow_readwrite"`
Path string `xml:"path,attr"`
}
NSJailAllowReadWrite represents an <allow_readwrite> element
type NSJailBuildConfig ¶
type NSJailBuildConfig struct {
XMLName xml.Name `xml:"build_config"`
Name string `xml:"name,attr,omitempty"`
AndroidTarget string `xml:"android_target,attr,omitempty"`
Goals []NSJailGoal `xml:"goal"`
Flags []NSJailFlag `xml:"flag"`
Configs []NSJailConfigElement `xml:"config"` // For fetch_target within build_config
// contains filtered or unexported fields
}
NSJailBuildConfig represents a <build_config> element
type NSJailConfig ¶
type NSJailConfig struct {
XMLName xml.Name `xml:"config"`
Targets []*NSJailTarget `xml:"target"`
Views []NSJailView `xml:"view"` // Keep Views here for unmarshaling
BuildConfigMap map[string]*NSJailBuildConfig `xml:"-"`
}
NSJailConfig is the root element
func LoadNSJailConfig ¶
func LoadNSJailConfig(mountPoint string) (NSJailConfig, error)
LoadNSJailConfig will load the NSJail config.
func (*NSJailConfig) LunchableAndroidTarget ¶
func (n *NSJailConfig) LunchableAndroidTarget(target string) string
LunchableAndroidTarget target will return a lunchable Android target given a target.
func (*NSJailConfig) OverlaysForBuildTarget ¶
func (n *NSJailConfig) OverlaysForBuildTarget(buildTarget string) []string
OverlaysForBuildTarget returns the names of each overlay directory for a given build target.
func (*NSJailConfig) ViewsForBuildTarget ¶
func (n *NSJailConfig) ViewsForBuildTarget(buildTarget string) []string
type NSJailConfigElement ¶
type NSJailConfigElement struct {
XMLName xml.Name `xml:"config"`
Name string `xml:"name,attr,omitempty"` // For name="fetch_build" or "fetch_target"
Value string `xml:"value,attr,omitempty"` // For value="8061540" or "<target>_partial-userdebug""
}
NSJailConfigElement represents a <config> element inside a <target> or <build_config> Renamed to avoid conflict with the root NSJailConfig struct
type NSJailFlag ¶
type NSJailFlag struct {
XMLName xml.Name `xml:"flag"`
Name string `xml:"name,attr"`
Contexts string `xml:"contexts,attr,omitempty"` // omitempty if contexts might not be present
}
NSJailFlag represents a <flag> element
type NSJailGoal ¶
NSJailGoal represents a <goal> element
type NSJailOverlay ¶
NSJailOverlay represents an <overlay> element
type NSJailPath ¶
type NSJailPath struct {
XMLName xml.Name `xml:"path"`
Source string `xml:"source,attr"`
Destination string `xml:"destination,attr"`
}
NSJailPath represents a <path> element within a <view>
type NSJailTarget ¶
type NSJailTarget struct {
XMLName xml.Name `xml:"target"`
Name string `xml:"name,attr"`
Tags string `xml:"tags,attr,omitempty"`
Overlays []NSJailOverlay `xml:"overlay"`
AllowReadWrites []NSJailAllowReadWrite `xml:"allow_readwrite"`
BuildConfigs []*NSJailBuildConfig `xml:"build_config"`
Configs []NSJailConfigElement `xml:"config"` // For fetch_build, fetch_target inside vf_targets
Views []NSJailView `xml:"view"` // This will store just a name
}
NSJailTarget represents a <target> element
type NSJailView ¶
type NSJailView struct {
XMLName xml.Name `xml:"view"`
Name string `xml:"name,attr"`
Paths []NSJailPath `xml:"path"`
}
NSJailView represents a <view> element
type NotExistErr ¶
type NotExistErr struct {
// contains filtered or unexported fields
}
func (*NotExistErr) Error ¶
func (e *NotExistErr) Error() string
func (*NotExistErr) Unwrap ¶
func (e *NotExistErr) Unwrap() []error
type ObjectHeader ¶
type ObjectHeader struct {
Type ObjectType
Size int64
CompressedSize int64 // size after zlib compressed
}
func (*ObjectHeader) FileSize ¶
func (h *ObjectHeader) FileSize() int64
func (*ObjectHeader) IsBlob ¶
func (h *ObjectHeader) IsBlob() bool
func (*ObjectHeader) IsEmpty ¶
func (h *ObjectHeader) IsEmpty() bool
type ObjectStore ¶
type ObjectStore interface {
OpenObjectFile(ctx context.Context, key Hash) (io.ReadCloser, error)
GetObject(ctx context.Context, key Hash) ([]byte, error)
GetTree(ctx context.Context, key Hash) ([]byte, TreeMeta, error)
PutObject(ctx context.Context, key Hash, content []byte) error
PutTree(ctx context.Context, key Hash, content []byte, meta TreeMeta) error
WriteObject(ctx context.Context, key Hash, reader io.Reader) error
ObjectHeader(ctx context.Context, key Hash) (ObjectHeader, error)
}
type ObjectType ¶
type ObjectType string
const ( ObjectTypeBlob ObjectType = "blob" ObjectTypeUnknown ObjectType = "unknown" )
type Patch ¶
type Patch []*PatchEntry
func (Patch) ChrootTransform ¶
func (Patch) HashForPath ¶
func (Patch) HashStatForPath ¶
func (Patch) MarshalJSON ¶
func (*Patch) UnmarshalJSON ¶
type PatchEntry ¶
type PatchEntry struct {
Path string
Mode FileMode
Hash Hash
Size int64
State PatchEntryState
}
func (*PatchEntry) SetState ¶
func (p *PatchEntry) SetState(s PatchEntryState)
type PatchEntryState ¶
type PatchEntryState int
const ( // Default state before the state evaluation PatchEntryStateUnassigned PatchEntryState = 0 // The patch is associated with a directory but the directory is modified during the build step PatchEntryStateDirModified PatchEntryState = 1 // The patch is associated with a directory PatchEntryStateDir PatchEntryState = 2 // Read states: // Declared input in ninja and is read by the build process PatchEntryStateIn PatchEntryState = 3 // Found in the dep-file (.d file) and is read by the build process PatchEntryStateDep PatchEntryState = 4 // Declared as RSP file and is read by the build process PatchEntryStateRSP PatchEntryState = 5 // Declared input in ninja, but the build process has not read it PatchEntryStateExtraIn PatchEntryState = 6 // Not declared in the ninja, but the build process has read it (hidden dependency) PatchEntryStateExtraRead PatchEntryState = 7 // Declared as RSP file, but the build process has not read it PatchEntryStateNotReadRSP PatchEntryState = 8 // Found in the dep-file (.d file), but the build process has not read it PatchEntryStateNotReadDep PatchEntryState = 9 // Declared as Order-only input and the build process has read it PatchEntryStateOrderOnly PatchEntryState = 20 // Declared as Order-only input and but the build process has not read it PatchEntryStateNotReadOrderOnly PatchEntryState = 21 // Found read file that was not committed, file was auto snapshot PatchEntryInfoAutoSnapshot PatchEntryState = 22 // Write states: // Declared as a target in ninja and is written by the build process PatchEntryStateOut PatchEntryState = 10 // Declared as a depfile in ninja and is written by the build process PatchEntryStateDepFile PatchEntryState = 11 // Not declared in the ninja, but is written by the build process PatchEntryStateExtraWrite PatchEntryState = 12 // Declared as a depfile in ninja, but build process has not written it PatchEntryStateMissingDepFile PatchEntryState = 13 // Declared as a target in ninja, but build process has not written it PatchEntryStateMissingOut PatchEntryState = 14 )
func PatchEntryStateByName ¶
func PatchEntryStateByName(s string) (PatchEntryState, error)
func (PatchEntryState) IsOrderOnly ¶
func (s PatchEntryState) IsOrderOnly() bool
func (PatchEntryState) IsStateSetByTap ¶
func (s PatchEntryState) IsStateSetByTap() bool
IsStateSetByTap identifies the "low-level" states that tap sets and shouldn't be overwritten
func (PatchEntryState) String ¶
func (s PatchEntryState) String() string
type ProjectRefHash ¶
type SHA256 ¶
type SHA256 [SHA256Size]byte
SHA256 is a SHA-256 content hash.
func NewSHA256 ¶
NewSHA256 parses a hexadecimal SHA-256 hash. Invalid input yields a zero or partial hash; use IsSHA256 to validate first.
func (SHA256) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for SHA256.
func (SHA256) MarshalText ¶
MarshalText implements encoding.TextMarshaler
func (*SHA256) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface for SHA256.
func (*SHA256) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler
type StatInfo ¶
type StatInfo struct {
Size int64
Mode FileMode
GitType ObjectType
}
type SyncHashSet ¶
func NewHashSet ¶
func NewHashSet() SyncHashSet
func (SyncHashSet) Has ¶
func (s SyncHashSet) Has(h Hash) bool
func (SyncHashSet) Put ¶
func (s SyncHashSet) Put(h Hash) bool
type TapCmdResult ¶
type TapData ¶
type TapData struct {
ReadPatch Patch
WritePatch Patch
Deletes DeletePatch
TapEntries []*TapFSEntry
}
type TapFSEntry ¶
type TapFSEntry struct {
Type TapType
Dirty bool
IsARI bool
Path string
ARI string
Hash Hash
AuxPath string
Mode fs.FileMode
Size int64
}
Use one generic type for all entries
type TappingType ¶
type TappingType string
const ( TapFS TappingType = "fs" TapEntries TappingType = "entries" )
func (*TappingType) Set ¶
func (t *TappingType) Set(value string) error
func (*TappingType) String ¶
func (t *TappingType) String() string
func (*TappingType) Type ¶
func (t *TappingType) Type() string