示例#1
0
func (ctx *Context) DefaultCmtcfg() string {
	hwaf_os := runtime.GOOS
	hwaf_arch := runtime.GOARCH
	hwaf_comp := "gcc"
	switch hwaf_arch {
	case "amd64":
		hwaf_arch = "x86_64"
	case "386":
		hwaf_arch = "i686"
	default:
		//hwaf_arch = "unknown"
		panic(fmt.Sprintf("unknown architecture [%s]", hwaf_arch))
	}
	//FIXME: is 'gcc' a good enough default ?
	cmtcfg := fmt.Sprintf("%s-%s-%s-opt", hwaf_arch, hwaf_os, hwaf_comp)

	pinfos, err := platform.Infos()
	if err != nil {
		//println("*** error:" + err.Error())
		return cmtcfg
	}

	// try harder...
	cmtcfg2, err := ctx.infer_cmtcfg(pinfos, hwaf_arch, hwaf_os, hwaf_comp)
	if err != nil {
		//println("*** error:" + err.Error())
		return cmtcfg
	}
	cmtcfg = cmtcfg2
	return cmtcfg
}
func hwaf_run_cmd_waf_show_platform(cmd *commander.Command, args []string) {
	var err error
	//n := "hwaf-" + cmd.Name()

	pinfos, err := platform.Infos()
	handle_err(err)

	fmt.Printf("%s\ndefault cmtcfg: %s\n", pinfos, g_ctx.DefaultCmtcfg())
}
示例#3
0
func hwaf_run_cmd_waf_show_platform(cmd *commander.Command, args []string) error {
	var err error
	//n := "hwaf-" + cmd.Name()

	pinfos, err := platform.Infos()
	if err != nil {
		return err
	}

	fmt.Printf("%s\ndefault variant: %s\n", pinfos, g_ctx.DefaultVariant())

	return err
}
示例#4
0
文件: asetup.go 项目: hwaf/hwaf
// FIXME: this should be more thought out... and structured!
func (a *asetup_t) process(args []string) error {
	var err error
	opts := new_options()

	pinfos, err := platform.Infos()
	if err != nil {
		return err
	}

	//cfg_fname := a.cmd.Flag.Lookup("cfg").Value.Get().(string)
	cli_variant := a.cmd.Flag.Lookup("variant").Value.Get().(string)
	cli_arch := a.cmd.Flag.Lookup("arch").Value.Get().(string)
	cli_comp := a.cmd.Flag.Lookup("comp").Value.Get().(string)
	cli_os := a.cmd.Flag.Lookup("os").Value.Get().(string)
	cli_type := a.cmd.Flag.Lookup("type").Value.Get().(string)

	unprocessed := make([]string, 0, len(args))
	projname := "mana-core"
	version := ""
	hwaf_os := pinfos.DistId()
	// fold slX into slcX (ie: all Scientific Linuces are SLCs)
	if pinfos.DistName == "sl" {
		rel := strings.Split(pinfos.DistVers, ".")
		major := rel[0]
		hwaf_os = "slc" + major
	}
	hwaf_comp := "gcc"
	hwaf_arch := ""
	switch runtime.GOARCH {
	case "amd64":
		hwaf_arch = "x86_64"
	case "386":
		hwaf_arch = "i686"
	default:
		//hwaf_arch = "unknown"
		panic(fmt.Sprintf("unknown architecture [%s]", hwaf_arch))
	}
	hwaf_bld := "opt"
	for _, arg := range args {
		has_prefix := func(prefix ...string) bool {
			for _, p := range prefix {
				ok := strings.HasPrefix(arg, p)
				if ok {
					return ok
				}
			}
			return false
		}
		switch arg {
		case "32b":
			hwaf_arch = "i686"
		case "64b":
			hwaf_arch = "x86_64"
		case "opt":
			hwaf_bld = "opt"
		case "dbg":
			hwaf_bld = "dbg"
		case "mana", "mana-core":
			projname = "mana-core"
		case "mana-ext", "lcg":
			projname = arg
		case "tdaq", "tdaq-common":
			projname = "tdaq-common"
		default:
			if has_prefix(
				"2012", "2013",
				"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
			) {
				version = arg
			} else if has_prefix("gcc") || has_prefix("clang") {
				hwaf_comp = arg
			} else if infer_version(arg, projname, &version) {
				//version = version
			} else {
				unprocessed = append(unprocessed, arg)
			}
		}
	}
	if len(unprocessed) > 0 {
		err = fmt.Errorf("unprocessed asetup options: %v", unprocessed)
	}

	// honour CLI args
	for _, v := range [][]*string{
		{&cli_arch, &hwaf_arch},
		{&cli_os, &hwaf_os},
		{&cli_comp, &hwaf_comp},
		{&cli_type, &hwaf_bld},
	} {
		if *v[0] != "" {
			*v[1] = *v[0]
		}
	}

	sitedir := a.ctx.Sitedir()
	if sitedir == "" {
		sitedir = filepath.Join("", "opt", "sw", "atlas")
		a.ctx.Warnf("no $HWAF_SITEDIR env. variable. will use [%s]\n", sitedir)
	}

	if a.verbose {
		a.ctx.Infof("using sitedir: [%s]\n", sitedir)
	}

	if !path_exists(sitedir) {
		err = fmt.Errorf("no such directory [%s]", sitedir)
		return err
	}

	usr_variant := fmt.Sprintf("%s-%s-%s-%s", hwaf_arch, hwaf_os, hwaf_comp, hwaf_bld)
	proj_root := filepath.Join(sitedir, projname)
	if !path_exists(proj_root) {
		err = fmt.Errorf("no such directory [%s]", proj_root)
		return err
	}

	if a.verbose {
		a.ctx.Infof("using project root [%s]\n", proj_root)
	}

	if version == "" {
		// get the latest one.
		var versions []string
		versions, err = filepath.Glob(filepath.Join(proj_root, "*"))
		if err != nil {
			return err
		}
		sort.Strings(versions)
		version = versions[len(versions)-1]
		version, _ = filepath.Abs(version)
		version = filepath.Base(version)
	}
	opts.projdir = filepath.Join(proj_root, version)
	if !path_exists(opts.projdir) {
		err = fmt.Errorf("no such directory [%s]", opts.projdir)
		return err
	}

	if a.verbose {
		a.ctx.Infof("using project dir [%s]\n", opts.projdir)
	}

	// dft_variant is a variation on DefaultVariant.
	dft_variant := fmt.Sprintf(
		"%s-%s-%s-%s",
		hwaf_arch,
		hwaf_os,
		strings.Split(a.ctx.DefaultVariant(), "-")[2], // compiler
		hwaf_bld,
	)

	found := false
	for ii, variant := range []string{
		cli_variant,
		usr_variant,
		a.ctx.Variant(),
		a.ctx.DefaultVariant(),
		dft_variant,
	} {
		if variant == "" {
			continue
		}
		dir := filepath.Join(opts.projdir, variant)
		if a.verbose {
			fmt.Printf("---> (%03d) [%s]... ", ii, dir)
		}
		if !path_exists(dir) {
			if a.verbose {
				fmt.Printf("[err]\n")
			}
			continue
		}
		opts.projdir = dir
		opts.variant = variant
		if a.verbose {
			fmt.Printf("[ok]\n")
		}
		found = true
		break
	}
	if !found {
		return fmt.Errorf("hwaf: could not find a suitable project")
	}
	a.opts = opts
	return err
}