示例#1
0
func (pkgr *Packager) Build() {
	pkgr.resolveDependencies()

	// add the submixer boundary info
	// thisOffset := int32(len(pkgr.Mixer.Package.Functions))
	// info := &tp.SubmixerInfo{
	// 	Name: proto.String(pkgr.GetName()),
	// 	Version: proto.String(pkgr.GetVersion()),
	// 	Offset: proto.Int32(thisOffset),
	// 	// set the length below
	// }
	pkgr.resolveTypeDeclarations()
	pkgr.populateTypeList()
	pkgr.buildLib()
	// length of Functions array has changed; recompute it and subtract the last offset to get the length of this component
	// info.Length = proto.Int32(int32(len(pkgr.Mixer.Package.Functions))-thisOffset)
	// pkgr.Mixer.Submixers = append(pkgr.Mixer.Submixers, info)

	if pkgr.IsHttpTransformer {
		pkgr.Mixer.IsHttpTransformer = proto.Bool(true)
		pkgr.Mixer.Rewriters = tp.CollectFiles(filepath.Join(pkgr.MixerDir, SCRIPTS_DIR))
		if pkgr.Mixer.Package.Dependencies == nil {
			pkgr.Mixer.Package.Dependencies = make([]string, 0)
		}
		for name, version := range pkgr.Dependencies {
			pkgr.Mixer.Package.Dependencies = append(pkgr.Mixer.Package.Dependencies, fmt.Sprintf("%s:%s", name, version))
		}
	}
}
示例#2
0
文件: mixer.go 项目: nmakiya/tritium
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
}
示例#3
0
func (pkgr *Packager) Build() {
	pkgr.resolveDependencies()
	pkgr.resolveTypeDeclarations()
	pkgr.populateTypeList()
	pkgr.buildLib()
	if pkgr.IsHttpTransformer {
		pkgr.Mixer.IsHttpTransformer = proto.Bool(true)
		pkgr.Mixer.Rewriters = tp.CollectFiles(filepath.Join(pkgr.MixerDir, SCRIPTS_DIR))
		if pkgr.Mixer.Package.Dependencies == nil {
			pkgr.Mixer.Package.Dependencies = make([]string, 0)
		}
		for name, version := range pkgr.Dependencies {
			pkgr.Mixer.Package.Dependencies = append(pkgr.Mixer.Package.Dependencies, fmt.Sprintf("%s:%s", name, version))
		}
	}
}