diff --git a/goldsmith.go b/goldsmith.go index 1da9bc7..e0b88d8 100644 --- a/goldsmith.go +++ b/goldsmith.go @@ -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) diff --git a/types.go b/types.go index 8cec53a..f7e5e1f 100644 --- a/types.go +++ b/types.go @@ -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