func cnv_atlas_install_trfs(wscript *hlib.Wscript_t, stmt Stmt) error {
	x := stmt.(*ApplyPattern)
	margs := cmt_arg_map(x.Args)
	jo := margs["jo"]
	tfs := margs["tfs"]
	pkgname := filepath.Base(wscript.Package.Name)
	tgtname := fmt.Sprintf("%s-install-trfs", pkgname)

	itgt, tgt := find_tgt(wscript, tgtname)
	if itgt < 0 {
		wscript.Build.Targets = append(
			wscript.Build.Targets,
			hlib.Target_t{Name: tgtname},
		)
		itgt, tgt = find_tgt(wscript, tgtname)
	}
	tgt.Features = []string{"atlas_install_trfs"}
	tgt.Source = nil
	if tgt.KwArgs == nil {
		tgt.KwArgs = make(map[string][]hlib.Value)
	}
	if jo != "" {
		tgt.KwArgs["trf_jo"] = []hlib.Value{hlib.DefaultValue("trf_jo", []string{jo})}
	}
	if tfs != "" {
		tgt.KwArgs["trf_tfs"] = []hlib.Value{hlib.DefaultValue("trf_tfs", []string{tfs})}
	}
	return nil
}
Beispiel #2
0
func parseCxxFlags(p *Parser) error {
	var err error
	tokens := p.tokens
	wtgt := &p.req.Wscript.Build.Targets[0]
	cxxflags := []string{}
	defines := []string{}
	includes := []string{}

	for _, flag := range tokens[1:] {
		flag = strings.Trim(flag, " \t")
		if len(flag) == 0 {
			continue
		}
		if strings.HasPrefix(flag, "-D") {
			defines = append(defines, flag[len("-D"):])
		} else if strings.HasPrefix(flag, "-I") {
			includes = append(includes, flag[len("-I"):])
		} else {
			cxxflags = append(cxxflags, flag)
		}
	}
	if len(cxxflags) > 0 {
		wtgt.CxxFlags = []hlib.Value{hlib.DefaultValue("cxxflags", cxxflags)}
	}
	if len(defines) > 0 {
		wtgt.Defines = []hlib.Value{hlib.DefaultValue("defines", defines)}
	}
	if len(includes) > 0 {
		wtgt.Includes = []hlib.Value{hlib.DefaultValue("includes", includes)}
	}
	return err
}
Beispiel #3
0
func cnv_tdaq_application(wscript *hlib.Wscript_t, stmt Stmt) error {
	x := stmt.(*ApplyPattern)
	margs := cmt_arg_map(x.Args)
	appname := margs["name"]
	if appname == "" {
		return fmt.Errorf(
			"cmt2yml: empty tdaq_application name (package=%s, args=%v)",
			wscript.Package.Name,
			x.Args,
		)
	}
	tgtname := appname

	itgt, tgt := find_tgt(wscript, tgtname)
	if itgt < 0 {
		wscript.Build.Targets = append(
			wscript.Build.Targets,
			hlib.Target_t{Name: tgtname},
		)
		itgt, tgt = find_tgt(wscript, tgtname)
	}
	tgt.Features = []string{"tdaq_application"}

	source := []string{fmt.Sprintf("src/%s.cxx", appname)}
	tgt.Source = []hlib.Value{hlib.DefaultValue("source", source)}

	uses := []string{filepath.Base(wscript.Package.Name), "boost-thread"}
	uses = append(uses, use_list(wscript)...)
	tgt.Use = []hlib.Value{hlib.DefaultValue("uses", uses)}

	//fmt.Printf(">>> [%v] \n", *tgt)
	return nil
}
func cnv_detcommon_generic_install(wscript *hlib.Wscript_t, stmt Stmt) error {
	x := stmt.(*ApplyPattern)
	margs := cmt_arg_map(x.Args)
	name := margs["name"]
	source := margs["files"]
	kind := margs["kind"]
	prefix := margs["prefix"]
	pkgname := filepath.Base(wscript.Package.Name)
	tgtname := fmt.Sprintf("%s-generic-install-%s-%s", pkgname, name, kind)

	itgt, tgt := find_tgt(wscript, tgtname)
	if itgt < 0 {
		wscript.Build.Targets = append(
			wscript.Build.Targets,
			hlib.Target_t{Name: tgtname},
		)
		itgt, tgt = find_tgt(wscript, tgtname)
	}
	tgt.Features = []string{"detcommon_generic_install"}
	tgt.Source = []hlib.Value{hlib.DefaultValue("source", []string{source})}
	if prefix != "" {
		if tgt.KwArgs == nil {
			tgt.KwArgs = make(map[string][]hlib.Value)
		}
		tgt.KwArgs["install_prefix"] = []hlib.Value{hlib.DefaultValue("prefix", []string{prefix})}
	}
	return nil
}
func cnv_atlas_unittest(wscript *hlib.Wscript_t, stmt Stmt) error {
	x := stmt.(*ApplyPattern)
	margs := cmt_arg_map(x.Args)
	pkgname := filepath.Base(wscript.Package.Name)
	name := margs["unit_test"]
	tgtname := fmt.Sprintf("%s-test-%s", pkgname, name)
	extra := margs["extrapatterns"]
	source := fmt.Sprintf("test/%s_test.cxx", name)

	itgt, tgt := find_tgt(wscript, tgtname)
	if itgt < 0 {
		wscript.Build.Targets = append(
			wscript.Build.Targets,
			hlib.Target_t{Name: tgtname},
		)
		itgt, tgt = find_tgt(wscript, tgtname)
	}
	tgt.Features = []string{"atlas_unittest"}
	tgt.Source = []hlib.Value{hlib.DefaultValue("source", []string{source})}
	if tgt.KwArgs == nil {
		tgt.KwArgs = make(map[string][]hlib.Value)
	}
	if extra != "" {
		tgt.KwArgs["extrapatterns"] = []hlib.Value{
			hlib.DefaultValue("extrapatterns", []string{extra}),
		}
	}
	//tgt.Use = []hlib.Value{hlib.DefaultValue("uses", use_list(wscript))}
	uses := use_list(wscript)
	if len(uses) > 0 {
		tgt.Use = []hlib.Value{hlib.DefaultValue("uses", uses)}
	}
	//fmt.Printf(">>> %v\n", *tgt)
	return nil
}
func cnv_atlas_dictionary(wscript *hlib.Wscript_t, stmt Stmt) error {
	x := stmt.(*ApplyPattern)
	margs := cmt_arg_map(x.Args)
	pkgname := filepath.Base(wscript.Package.Name)
	libname := margs["dict"] + "Dict"
	selfile := pkgname + "/" + margs["selectionfile"]
	hdrfiles := strings.Split(margs["headerfiles"], " ")
	hdrfiles, _ = sanitize_srcs(hdrfiles, "")

	itgt, tgt := find_tgt(wscript, libname)
	if itgt < 0 {
		wscript.Build.Targets = append(
			wscript.Build.Targets,
			hlib.Target_t{Name: libname},
		)
		itgt, tgt = find_tgt(wscript, libname)
	}
	tgt.Features = []string{"atlas_dictionary"}
	tgt.Source = []hlib.Value{hlib.DefaultValue("source", hdrfiles)}
	if tgt.KwArgs == nil {
		tgt.KwArgs = make(map[string][]hlib.Value)
	}
	tgt.KwArgs["selection_file"] = []hlib.Value{hlib.DefaultValue("selfile", []string{selfile})}
	//tgt.Use = []hlib.Value{hlib.DefaultValue("uses", use_list(wscript))}
	uses := use_list(wscript)
	if len(uses) > 0 {
		tgt.Use = []hlib.Value{hlib.DefaultValue("uses", uses)}
	}
	//fmt.Printf(">>> %v\n", *tgt)
	return nil
}
Beispiel #7
0
func parseReflex(p *Parser) error {
	var err error
	tokens := p.tokens
	wtgt := &p.req.Wscript.Build.Targets[0]
	if len(tokens) > 1 && tokens[1] == "1" {
		pkgname := p.req.Wscript.Package.Name
		delete(wtgt.KwArgs, "rootcint_linkdef")
		wtgt.KwArgs["selection_file"] = []hlib.Value{
			hlib.DefaultValue(
				"selection_file",
				[]string{
					fmt.Sprintf("%s/selection.xml", pkgname),
				},
			),
		}

		features := make([]string, 0, len(wtgt.Features))
		for _, x := range wtgt.Features {
			if x != "atlas_dictionary" {
				features = append(features, x)
			}
		}
		wtgt.Features = features
	}
	return err
}
Beispiel #8
0
func parseLdFlags(p *Parser) error {
	var err error
	tokens := p.tokens
	wtgt := &p.req.Wscript.Build.Targets[0]
	ldflags := []string{}
	for _, flag := range tokens[1:] {
		flag = strings.Trim(flag, " \t")
		if len(flag) == 0 {
			continue
		}
		if strings.HasPrefix(flag, "-L") {
			// should be handled by hwaf.uses
			continue
		}
		if strings.HasPrefix(flag, "-l") {
			// should be handled by hwaf uses too
			continue
		}
		ldflags = append(ldflags, flag)
	}
	if len(ldflags) > 0 {
		wtgt.LinkFlags = []hlib.Value{hlib.DefaultValue("linkflags", ldflags)}
	}
	return err
}
Beispiel #9
0
func cnv_tdaq_install_scripts(wscript *hlib.Wscript_t, stmt Stmt) error {
	pkgname := filepath.Base(wscript.Package.Name)
	tgt := hlib.Target_t{Name: pkgname + "-install-scripts"}
	tgt.Features = []string{"tdaq_install_scripts"}
	tgt.Source = []hlib.Value{hlib.DefaultValue(
		"script-files",
		[]string{"scripts/*"},
	)}
	wscript.Build.Targets = append(wscript.Build.Targets, tgt)
	return nil
}
func cnv_atlas_install_data(wscript *hlib.Wscript_t, stmt Stmt) error {
	//x := stmt.(*ApplyPattern)
	//fmt.Printf(">>> [%s] \n", x.Name)
	pkgname := filepath.Base(wscript.Package.Name)
	tgt := hlib.Target_t{Name: pkgname + "-install-data"}
	tgt.Features = []string{"atlas_install_data"}
	tgt.Source = []hlib.Value{hlib.DefaultValue(
		"data-files",
		[]string{"data/*"},
	)}
	wscript.Build.Targets = append(wscript.Build.Targets, tgt)
	return nil
}
Beispiel #11
0
func cnv_tdaq_library(wscript *hlib.Wscript_t, stmt Stmt) error {
	x := stmt.(*ApplyPattern)
	margs := cmt_arg_map(x.Args)
	libname := ""
	if _, ok := margs["library"]; ok {
		libname = margs["library"]
	} else {
		libname = filepath.Base(wscript.Package.Name)
	}
	source := []string{"src/*.cxx"}
	if _, ok := margs["files"]; ok {
		source = []string{margs["files"]}
	}

	if libname == "" {
		return fmt.Errorf(
			"cmt2yml: empty tdaq_library name (package=%s, args=%v)",
			wscript.Package.Name,
			x.Args,
		)
	}
	itgt, tgt := find_tgt(wscript, libname)
	if itgt < 0 {
		wscript.Build.Targets = append(
			wscript.Build.Targets,
			hlib.Target_t{Name: libname},
		)
		itgt, tgt = find_tgt(wscript, libname)
	}
	tgt.Features = []string{"tdaq_library"}
	uses := use_list(wscript)
	if len(uses) > 0 {
		tgt.Use = []hlib.Value{hlib.DefaultValue("uses", uses)}
	}

	tgt.Source = []hlib.Value{hlib.DefaultValue("source", source)}
	return nil
}
func cnv_atlas_athenarun_test(wscript *hlib.Wscript_t, stmt Stmt) error {
	x := stmt.(*ApplyPattern)
	margs := cmt_arg_map(x.Args)
	pkgname := filepath.Base(wscript.Package.Name)
	name := margs["name"]
	tgtname := fmt.Sprintf("%s-runtest-%s", pkgname, name)
	options := margs["options"]
	post := margs["post_script"]

	itgt, tgt := find_tgt(wscript, tgtname)
	if itgt < 0 {
		wscript.Build.Targets = append(
			wscript.Build.Targets,
			hlib.Target_t{Name: tgtname},
		)
		itgt, tgt = find_tgt(wscript, tgtname)
	}
	tgt.Features = []string{"atlas_athenarun_test"}
	if tgt.KwArgs == nil {
		tgt.KwArgs = make(map[string][]hlib.Value)
	}
	if options != "" {
		tgt.KwArgs["joboptions"] = []hlib.Value{
			hlib.DefaultValue("options", []string{options}),
		}
	}
	if post != "" {
		tgt.KwArgs["post_script"] = []hlib.Value{
			hlib.DefaultValue("post", []string{post}),
		}
	}
	tgt.Use = []hlib.Value{hlib.DefaultValue("uses", []string{pkgname})}

	//fmt.Printf(">>> %v\n", *tgt)
	return nil
}
func cnv_atlas_dual_use_library(wscript *hlib.Wscript_t, stmt Stmt) error {
	x := stmt.(*ApplyPattern)
	libname := ""
	switch len(x.Args) {
	case 0:
		// dual_use_library pattern
		libname = filepath.Base(wscript.Package.Name)
	default:
		// named_dual_use_library pattern
		margs := cmt_arg_map(x.Args)
		if _, ok := margs["library"]; ok {
			libname = margs["library"]
		} else {
			libname = filepath.Base(wscript.Package.Name)
		}

	}
	if libname == "" {
		return fmt.Errorf(
			"cmt2yml: empty atlas_dual_use_library name (package=%s, args=%v)",
			wscript.Package.Name,
			x.Args,
		)
	}
	itgt, tgt := find_tgt(wscript, libname)
	if itgt < 0 {
		wscript.Build.Targets = append(
			wscript.Build.Targets,
			hlib.Target_t{Name: libname},
		)
		itgt, tgt = find_tgt(wscript, libname)
	}
	tgt.Features = []string{"atlas_dual_use_library"}
	uses := use_list(wscript)
	if len(uses) > 0 {
		tgt.Use = []hlib.Value{hlib.DefaultValue("uses", uses)}
	}

	//fmt.Printf(">>> [%v] \n", *tgt)
	return nil
}
Beispiel #14
0
func parsePackage(p *Parser) error {
	var err error
	tokens := p.tokens
	name := tokens[1]

	p.req.Wscript.Package = hlib.Package_t{
		Name: name,
		Authors: []hlib.Author{
			"hwaf-rcore2yml",
		},
		Deps: []hlib.Dep_t{
			{
				Name: "AtlasPolicy",
				Type: hlib.PublicDep,
			},
			{
				Name: "External/AtlasROOT",
				Type: hlib.PublicDep,
			},
		},
	}
	p.req.Wscript.Build.Targets = append(
		p.req.Wscript.Build.Targets,
		hlib.Target_t{
			Name:     name,
			Features: []string{"atlas_library", "atlas_dictionary"},
			Target:   name,
			Source: []hlib.Value{
				hlib.DefaultValue("source",
					[]string{
						"Root/*.cxx",
						fmt.Sprintf("%s/%sDict.h", name, name),
					},
				),
			},
			Use: []hlib.Value{
				hlib.DefaultValue(
					"use",
					[]string{
						"ROOT",
					},
				),
			},
			KwArgs: map[string][]hlib.Value{
				"rootcint_linkdef": []hlib.Value{
					hlib.DefaultValue("linkdef", []string{"Root/LinkDef.h"}),
				},
			},
		},
	)

	progs := []string{}
	dir := filepath.Join(filepath.Dir(filepath.Dir(p.f.Name())), "util")
	err = filepath.Walk(dir, func(path string, fi os.FileInfo, err error) error {
		//fmt.Printf("::> [%s]...\n", path)
		fname := filepath.Base(path)
		if !strings.HasSuffix(fname, ".cxx") {
			return nil
		} else {
			progs = append(progs, fname[:len(fname)-len(".cxx")])
			//fmt.Printf("::> [%s]...\n", path)
		}
		return err
	})

	for _, prog := range progs {
		p.req.Wscript.Build.Targets = append(
			p.req.Wscript.Build.Targets,
			hlib.Target_t{
				Name:     prog,
				Features: []string{"atlas_application"},
				Target:   prog,
				Source: []hlib.Value{
					hlib.DefaultValue("source",
						[]string{
							filepath.Join("util", fmt.Sprintf("%s.cxx", prog)),
						},
					),
				},
				Use: []hlib.Value{
					hlib.DefaultValue(
						"use",
						[]string{
							name,
							"ROOT",
						},
					),
				},
			},
		)
	}
	return err
}
Beispiel #15
0
func waf_get_wscript(data map[string]interface{}) (*hlib.Wscript_t, error) {
	var err error
	var wscript hlib.Wscript_t

	wpkg := &wscript.Package

	// validate sections layout
	err = waf_validate_sections(
		data,
		"package",
		"options",
		"configure",
		"build",
	)
	if err != nil {
		return nil, fmt.Errorf("invalid hscript:\n%v", err)
	}

	// ---------- package section ---------------------------------------------
	if _, ok := data["package"]; !ok {
		return nil, fmt.Errorf("missing mandatory 'package' section")
	}

	pkg := waf_get_yaml_map(data["package"])
	err = waf_validate_sections(
		pkg,
		"name", "authors", "managers", "version", "deps",
	)
	if err != nil {
		return nil, fmt.Errorf("invalid 'package' section:\n%v", err)
	}

	switch pkgname := pkg["name"].(type) {
	case string:
		wpkg.Name = pkgname
	default:
		return nil, fmt.Errorf("invalid type (%T) for 'package.name' field (expected a string)", pkgname)

	}

	if _, ok := pkg["authors"]; ok {
		switch v := pkg["authors"].(type) {
		case []interface{}:
			for _, vv := range v {
				wpkg.Authors = append(wpkg.Authors, hlib.Author(vv.(string)))
			}
		case string:
			wpkg.Authors = append(wpkg.Authors, hlib.Author(v))
		default:
			return nil, fmt.Errorf("unknown type (%T) for 'authors' field", v)
		}
	}

	if _, ok := pkg["managers"]; ok {
		switch v := pkg["managers"].(type) {
		case []interface{}:
			for _, vv := range v {
				wpkg.Managers = append(wpkg.Managers, hlib.Manager(vv.(string)))
			}
		case string:
			wpkg.Managers = append(wpkg.Managers, hlib.Manager(v))
		default:
			return nil, fmt.Errorf("unknown type (%T) for 'managers' field", v)
		}
	}

	if _, ok := pkg["version"]; ok {
		wpkg.Version = hlib.Version(pkg["version"].(string))
	}

	if _, ok := pkg["deps"]; ok {
		if _, ok := pkg["deps"].(map[interface{}]interface{}); !ok {
			return nil, fmt.Errorf("'deps' field has to be a map")
		}
		deps := waf_get_yaml_map(pkg["deps"])

		err = waf_validate_sections(
			deps,
			"public", "private", "runtime",
		)
		if err != nil {
			return nil, fmt.Errorf("invalid 'package.deps' section:\n%v", err)
		}

		all_deps := make(map[string]int)
		if _, ok := deps["public"]; ok {
			pub_deps := deps["public"].([]interface{})
			for _, idep := range pub_deps {
				dep := idep.(string)
				all_deps[dep] = len(wpkg.Deps)
				wpkg.Deps = append(
					wpkg.Deps,
					hlib.Dep_t{
						Name: dep,
						Type: hlib.PublicDep,
					},
				)
			}
		}

		if _, ok := deps["private"]; ok {
			pri_deps := deps["private"].([]interface{})
			for _, idep := range pri_deps {
				dep := idep.(string)
				all_deps[dep] = len(wpkg.Deps)
				wpkg.Deps = append(
					wpkg.Deps,
					hlib.Dep_t{
						Name: dep,
						Type: hlib.PrivateDep,
					},
				)
			}
		}

		if _, ok := deps["runtime"]; ok {
			r_deps := deps["runtime"].([]interface{})
			for _, idep := range r_deps {
				dep := idep.(string)
				if idx, ok := all_deps[dep]; ok {
					wpkg.Deps[idx].Type |= hlib.RuntimeDep
				} else {
					wpkg.Deps = append(
						wpkg.Deps,
						hlib.Dep_t{
							Name: dep,
							Type: hlib.RuntimeDep,
						},
					)
				}
			}
		}

	}

	// ---------- options section ---------------------------------------------
	if _, ok := data["options"]; ok {
		wopt := &wscript.Options
		opt := waf_get_yaml_map(data["options"])
		err = waf_validate_sections(
			opt,
			"tools", "hwaf-call",
		)
		if err != nil {
			return nil, fmt.Errorf("invalid 'options' section:\n%v", err)
		}

		if _, ok := opt["tools"]; ok {
			tools := opt["tools"].([]interface{})
			for _, itool := range tools {
				wopt.Tools = append(wopt.Tools, itool.(string))
			}
		}

		if _, ok := opt["hwaf-call"]; ok {
			calls := opt["hwaf-call"].([]interface{})
			for _, icall := range calls {
				wopt.HwafCall = append(wopt.HwafCall, icall.(string))
			}
		}
	}

	// ---------- configure section -------------------------------------------
	if _, ok := data["configure"]; ok {
		wcfg := &wscript.Configure
		cfg := waf_get_yaml_map(data["configure"])

		err = waf_validate_sections(
			cfg,
			"tools", "hwaf-call", "env", "alias",
			"declare-tags",
			"apply-tags",
		)
		if err != nil {
			return nil, fmt.Errorf("invalid 'configure' section:\n%v", err)
		}

		if _, ok := cfg["tools"]; ok {
			tools := cfg["tools"].([]interface{})
			for _, itool := range tools {
				wcfg.Tools = append(wcfg.Tools, itool.(string))
			}
		}

		//  handle 'env' section
		if _, ok := cfg["env"]; ok {
			env := waf_get_yaml_map(cfg["env"])
			for k, iv := range env {
				switch v := iv.(type) {
				case string:
					if strings.HasSuffix(v, fmt.Sprintf(":${%s}", k)) {
						// gamble: path_prepend
						str := v[:len(v)-len(fmt.Sprintf(":${%s}", k))]
						stmt := hlib.PathPrependStmt{
							Value: hlib.Value{
								Name: k,
								Set: []hlib.KeyValue{
									{Tag: "default", Value: []string{str}},
								},
							},
						}
						wcfg.Stmts = append(
							wcfg.Stmts,
							&stmt,
						)
					} else if strings.HasPrefix(v, fmt.Sprintf("${%s}:", k)) {
						// gamble: path_append
						str := v[len(fmt.Sprintf("${%s}:", k)):]
						stmt := hlib.PathAppendStmt{
							Value: hlib.Value{
								Name: k,
								Set: []hlib.KeyValue{
									{Tag: "default", Value: []string{str}},
								},
							},
						}
						wcfg.Stmts = append(
							wcfg.Stmts,
							&stmt,
						)
					} else {
						// gamble declare_path
						stmt := hlib.PathStmt{
							Value: hlib.Value{
								Name: k,
								Set: []hlib.KeyValue{
									{Tag: "default", Value: []string{v}},
								},
							},
						}
						wcfg.Stmts = append(
							wcfg.Stmts,
							&stmt,
						)
					}
				case []interface{}:
					for _, v := range v {
						switch v := v.(type) {
						default:
							return nil, fmt.Errorf("unknown type (%T) for 'configure.env[%v]' field", v, k)

						}
					}
				default:
					return nil, fmt.Errorf("unknown type (%T) for 'configure.env' field", v)
				}
			}
		}

		//  handle 'declare-tags' section
		if _, ok := cfg["declare-tags"]; ok {
			add_tag := func(name string, data ...string) {
				content := make([]string, len(data))
				copy(content, data)
				stmt := hlib.TagStmt{
					Name:    name,
					Content: content,
				}
				wcfg.Stmts = append(
					wcfg.Stmts,
					&stmt,
				)
			}
			switch tags := cfg["declare-tags"].(type) {
			case []interface{}:
				for _, iv := range tags {
					tags := waf_get_yaml_map(iv)
					for name, content := range tags {
						switch content := content.(type) {
						case string:
							add_tag(name, content)
						case []interface{}:
							tag_content := make([]string, 0, len(content))
							for _, tag := range content {
								tag_content = append(tag_content, tag.(string))
							}
							add_tag(name, tag_content...)
						case []string:
							add_tag(name, content...)
						default:
							return nil, fmt.Errorf("unknown type (%T) for 'configure.declare-tags' field", tags)
						}
					}
				}
			default:
				return nil, fmt.Errorf("unknown type (%T) for 'configure.declare-tags' field", tags)

			}
		}

		//  handle 'apply-tag' section
		if _, ok := cfg["apply-tags"]; ok {
			add_tag := func(data ...string) {
				tags := make([]string, len(data))
				copy(tags, data)
				stmt := hlib.ApplyTagStmt{
					Value: hlib.Value{
						Name: "",
						Set: []hlib.KeyValue{
							{Tag: "default", Value: tags},
						},
					},
				}
				wcfg.Stmts = append(
					wcfg.Stmts,
					&stmt,
				)
			}
			switch tags := cfg["apply-tags"].(type) {
			case string:
				add_tag(tags)
			case []string:
				add_tag(tags...)
			case []interface{}:
				for _, iv := range tags {
					switch iv := iv.(type) {
					case string:
						add_tag(iv)
					default:
						return nil, fmt.Errorf("unknown type (%T) for 'configure.apply-tags' field", tags)

					}
				}
			default:
				return nil, fmt.Errorf("unknown type (%T) for 'configure.apply-tags' field", tags)

			}
		}

		// FIXME:
		//  handle 'export-tools' section ?

		if _, ok := cfg["hwaf-call"]; ok {
			calls := cfg["hwaf-call"].([]interface{})
			for _, icall := range calls {
				wcfg.HwafCall = append(wcfg.HwafCall, icall.(string))
			}
		}
	}

	// ---------- build section -----------------------------------------------
	if _, ok := data["build"]; ok {
		wbld := &wscript.Build
		bld := waf_get_yaml_map(data["build"])
		if _, ok := bld["tools"]; ok {
			tools := bld["tools"].([]interface{})
			for _, itool := range tools {
				wbld.Tools = append(wbld.Tools, itool.(string))
			}
		}
		if _, ok := bld["hwaf-call"]; ok {
			calls := bld["hwaf-call"].([]interface{})
			for _, icall := range calls {
				wbld.HwafCall = append(wbld.HwafCall, icall.(string))
			}
		}
		// FIXME:
		//  handle 'env' section
		//  handle 'tag' section

		tgt_names := make([]string, 0, len(bld))
		for k := range bld {
			if k != "hwaf-call" && k != "tools" && k != "env" {
				tgt_names = append(tgt_names, k)
			}
		}
		for _, n := range tgt_names {
			tgt := waf_get_yaml_map(bld[n])
			wtgt := hlib.Target_t{
				Name:   n,
				KwArgs: make(map[string][]hlib.Value),
			}
			if v, ok := tgt["features"]; ok {
				switch v := v.(type) {
				case string:
					tmps := strings.Split(v, " ")
					for _, tmp := range tmps {
						tmp = strings.Trim(tmp, " ")
						if tmp != "" {
							wtgt.Features = append(wtgt.Features, tmp)
						}
					}

				case []interface{}:
					for _, iv := range v {
						v := iv.(string)
						tmps := strings.Split(v, " ")
						for _, tmp := range tmps {
							tmp = strings.Trim(tmp, " ")
							if tmp != "" {
								wtgt.Features = append(wtgt.Features, tmp)
							}
						}
					}

				case []string:
					for _, iv := range v {
						tmps := strings.Split(iv, " ")
						for _, tmp := range tmps {
							tmp = strings.Trim(tmp, " ")
							if tmp != "" {
								wtgt.Features = append(wtgt.Features, tmp)
							}
						}
					}

				default:
					return nil, fmt.Errorf("unknown type (%T) for target [%s] in 'build' section", v, n)
				}
				delete(tgt, "features")
			}

			if _, ok := tgt["name"]; ok {
				nn := tgt["name"].(string)
				if nn != wtgt.Name {
					return nil, fmt.Errorf("inconsistency in target [%s] declaration: name=%q but key=%q", n, nn, wtgt.Name)
				}
				delete(tgt, "name")
			}

			if _, ok := tgt["target"]; ok {
				wtgt.Target = tgt["target"].(string)
				delete(tgt, "target")
			}

			if _, ok := tgt["group"]; ok {
				wtgt.Group = tgt["group"].(string)
				delete(tgt, "group")
			}

			if _, ok := tgt["env"]; ok {
				m := tgt["env"].(map[interface{}]interface{})
				wtgt.Env = make(hlib.Env_t, len(m))
				for k, v := range m {
					kk := k.(string)
					vv := v.(string)
					wtgt.Env[kk] = hlib.DefaultValue(kk, []string{vv})
				}
				delete(tgt, "env")
			}

			cnvmap := map[string]*[]hlib.Value{
				"source":          &wtgt.Source,
				"use":             &wtgt.Use,
				"defines":         &wtgt.Defines,
				"cflags":          &wtgt.CFlags,
				"cxxflags":        &wtgt.CxxFlags,
				"linkflags":       &wtgt.LinkFlags,
				"shlibflags":      &wtgt.ShlibFlags,
				"stlibflags":      &wtgt.StlibFlags,
				"rpath":           &wtgt.RPath,
				"includes":        &wtgt.Includes,
				"export_includes": &wtgt.ExportIncludes,
				"install_path":    &wtgt.InstallPath,
			}
			for k, v := range tgt {
				vv := waf_gen_hvalue_from(k, v)
				if dst, ok := cnvmap[k]; ok {
					*dst = append(*dst, vv)
				} else {
					wtgt.KwArgs[k] = append(wtgt.KwArgs[k], vv)
				}
			}
			wbld.Targets = append(wbld.Targets, wtgt)
		}

	}
	return &wscript, err
}