예제 #1
0
func (r *Renderer) render_wscript() error {
	var err error

	enc := hlib.NewHscriptPyEncoder(r.w)
	if enc == nil {
		return fmt.Errorf("got invalid hscript-py encoder")
	}

	err = enc.Encode(&r.pkg)
	if err != nil {
		return err
	}

	return err
}
예제 #2
0
파일: wafcontext.go 프로젝트: hwaf/hwaf
func waf_gen_wscript_from_yml(fname string) error {
	var err error
	hscript := filepath.Join(filepath.Dir(fname), "hscript.yml")
	f, err := os.Open(hscript)
	if err != nil {
		return err
	}
	// FIXME: don't gobble up the whole file. read piecewise
	buf, err := ioutil.ReadAll(f)
	if err != nil {
		return err
	}

	f, err = os.Create(fname)
	if err != nil {
		return err
	}
	defer f.Close()

	err = waf_gen_wscript_hdr(f)
	if err != nil {
		return err
	}

	data := make(map[string]interface{})
	err = yaml.Unmarshal(buf, data)
	if err != nil {
		return fmt.Errorf("error decoding file [%s]: %v", hscript, err)
	}

	wscript, err := waf_get_wscript(data)
	if err != nil {
		return fmt.Errorf("error parsing file [%s]:\n%v", hscript, err)
	}

	enc := hlib.NewHscriptPyEncoder(f)
	if enc == nil {
		return fmt.Errorf("error creating HscriptPyEncoder for file [%s]", fname)
	}

	err = enc.Encode(wscript)
	if err != nil {
		return err
	}

	return err
}