示例#1
0
文件: build.go 项目: sbinet/fubsy
func (self *BuildState) parentChanged(
	parent dag.Node, pstate dag.NodeState, oldsig []byte) (
	bool, error) {

	var cursig []byte
	var err error
	if !(pstate == dag.SOURCE || pstate == dag.BUILT || self.checkAll()) {
		// parent is an intermediate target that has not been built in
		// the current run. We don't want the expense of calling
		// Signature() for target nodes, because people don't normally
		// modify targets behind their build tool's back. But it might
		// have been modified by a previous build, in which case we'll
		// use the signature previously recorded for parent *as a
		// target*. This can still be fooled by modifying intermediate
		// targets behind Fubsy's back, but that's what --check-all is
		// for.
		precord, err := self.db.LookupNode(parent.Name())
		if err != nil {
			return false, err
		}
		if precord != nil {
			cursig = precord.TargetSignature()
		}
	}

	if cursig == nil {
		cursig, err = parent.Signature()
		if err != nil {
			// This should not happen: parent should exist and be readable,
			// since we've already visited it earlier in the build and we
			// avoid looking at failed/tainted parents.
			return false, err
		}
	}
	changed := parent.Changed(cursig, oldsig)
	//log.Verbose("parent %s: oldsig=%v, cursig=%v, changed=%v",
	//	parent, oldsig, cursig, changed)
	return changed, nil
}
示例#2
0
文件: build.go 项目: sbinet/fubsy
func (self *BuildState) recordNode(node dag.Node) error {
	log.Debug(log.BUILD, "recording successful build of %s %s", node.Typename(), node)
	sig, err := node.Signature()
	log.Debug(log.BUILD, "sig=%v, err=%v", sig, err)
	if err != nil {
		return fmt.Errorf("could not compute signature of target %s: %s",
			node, err)
	}

	record := db.NewBuildRecord()
	record.SetTargetSignature(sig)
	for _, parent := range self.graph.ParentNodes(node) {
		sig, err = parent.Signature()
		if err != nil {
			return err
		}
		record.AddParent(parent.Name(), sig)
	}
	err = self.db.WriteNode(node.Name(), record)
	if err != nil {
		return err
	}
	return nil
}