func BuildMixer(buildPath string, name string, dataPath string) *Mixer { rawPath, err := findInBuildPath(buildPath, name) if err != nil { panic(err.Error()) } path := *rawPath raw_mixer := tp.NewMixer(filepath.Clean(path)) mixer := &Mixer{ Mixer: raw_mixer, LibraryPath: buildPath, DefinitionPath: path, DataPath: dataPath, } // println("func BuildMixer") // println("build path:", buildPath) // println("definition path:", path) // println() rewritersDirectory := filepath.Join(path, "/rewriters") mixer.Rewriters = tp.CollectFiles(rewritersDirectory) packageDirectory := filepath.Join(path, "/package") mixer.RootPackage = NewRootPackage(packageDirectory, null.GetString(mixer.Name), dataPath) mixer.loadDependentMixers() error := BuildRootPackage(mixer.RootPackage, packageDirectory, null.GetString(mixer.Name)) if error == nil { //mixer.RootPackage = pkg // Now that we're done resolving, slice off the members! (Ouch) mixer.Package = mixer.RootPackage.Package } else if error.Code != NOT_FOUND { //TODO : Put this into a debug log panic(error.Message) } versionFile := filepath.Join(mixer.DefinitionPath, "..", "..", "JENKINS") buildNumber, err := ioutil.ReadFile(versionFile) if err == nil { mixer.Version = proto.String(null.GetString(mixer.Version) + "." + strings.Trim(string(buildNumber), "\n\r ")) } return mixer }
func New(relSrcDir, libDir string, mayBuildHttpTransformers bool, logger *golog.Logger, mixerDownloader downloader) *Packager { pkgr := new(Packager) wd, wdErr := os.Getwd() if wdErr != nil { panic("unable to determine current directory for mixer creation") } absSrcDir, absErr := filepath.Abs(relSrcDir) if absErr != nil { panic("unable to absolutize mixer source directory for mixer creation") } absSrcDir = filepath.Clean(absSrcDir) pkgr.MixerDir = absSrcDir pkgr.LibDir = libDir pkgr.IncludePaths = make([]string, 2) // support more in the future as a command-line option pkgr.IncludePaths[0] = wd pkgr.IncludePaths[1] = filepath.Dir(absSrcDir) pkgr.Mixer = tp.NewMixer(absSrcDir) pkgr.PackagerVersion = proto.Int32(PACKAGER_VERSION) pkgr.readDependenciesFile() pkgr.AlreadyLoaded = make(map[string]bool) pkgr.Logger = logger pkgr.downloader = mixerDownloader pkgr.Mixer.Package = new(tp.Package) pkgr.Mixer.Package.Functions = make([]*tp.Function, 0) pkgr.MayBuildHttpTransformers = mayBuildHttpTransformers tSigThere, _ := fileutil.Exists(filepath.Join(pkgr.MixerDir, HTTP_TRANSFORMERS_SIGNATURE)) if tSigThere { pkgr.IsHttpTransformer = true if !pkgr.MayBuildHttpTransformers { panic("you are not authorized to build HTTP transformer mixers") } } return pkgr }