pulumi/pkg/tools/cidlc/paths.go
joeduffy 507a2609a7 Add an initial implementation of CIDLC
This is an initial implementation of the Coconut IDL Compiler (CIDLC).
This is described further in
https://github.com/pulumi/coconut/blob/master/docs/design/idl.md,
and the work is tracked by coconut/pulumi#133.

I've been kicking the tires with this locally enough to checkpoint the
current version.  There are quite a few loose ends not yet implemented,
most of them minor, with the exception of the RPC stub generation which
I need to flesh out more before committing.
2017-04-25 15:05:51 -07:00

20 lines
538 B
Go

// Copyright 2017 Pulumi, Inc. All rights reserved.
package cidlc
import (
"path/filepath"
"golang.org/x/tools/go/loader"
"github.com/pulumi/coconut/pkg/util/contract"
)
// RelFilename gets the target filename for any given position relative to the root.
func RelFilename(root string, prog *loader.Program, p goPos) string {
pos := p.Pos()
source := prog.Fset.Position(pos).Filename // the source filename.`
rel, err := filepath.Rel(root, source) // make it relative to the root.
contract.Assert(err == nil)
return rel
}