Add support for static files

This commit is contained in:
Alex Yatskov 2015-11-07 13:49:35 +09:00
parent ce668ab5ad
commit 23d9ff7e00
2 changed files with 19 additions and 1 deletions

View File

@ -30,6 +30,10 @@ import (
"path/filepath"
)
const (
FILE_FLAG_STATIC = 1 << iota
)
type stage struct {
input, output chan *File
}
@ -149,7 +153,7 @@ func (gs *goldsmith) chain(s stage, c Chainer) {
go c.Chain(gs, allowed, s.output)
for file := range s.input {
if f.Filter(file.Path) {
if file.flags&FILE_FLAG_STATIC != 0 || f.Filter(file.Path) {
s.output <- file
} else {
allowed <- file
@ -171,6 +175,16 @@ func (gs *goldsmith) NewFile(path string) (*File, error) {
return file, nil
}
func (gs *goldsmith) NewFileStatic(path string) (*File, error) {
file, err := gs.NewFile(path)
if err != nil {
return nil, err
}
file.flags |= FILE_FLAG_STATIC
return file, nil
}
func (gs *goldsmith) RefFile(path string) error {
if filepath.IsAbs(path) {
return fmt.Errorf("absolute paths are not supported: %s", path)

View File

@ -42,10 +42,14 @@ type File struct {
Meta map[string]interface{}
Buff *bytes.Buffer
Err error
flags uint32
}
type Context interface {
NewFileStatic(path string) (*File, error)
NewFile(path string) (*File, error)
RefFile(path string) error
SrcDir() string