当前位置: 首页>>代码示例>>Golang>>正文


Golang profiles.Target类代码示例

本文整理汇总了Golang中v/io/jiri/profiles.Target的典型用法代码示例。如果您正苦于以下问题:Golang Target类的具体用法?Golang Target怎么用?Golang Target使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Target类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestBackwardsCompatibility

func TestBackwardsCompatibility(t *testing.T) {
	profiles.Clear()

	getProfiles := func() []*profiles.Profile {
		db := []*profiles.Profile{}
		names := profiles.Profiles()
		sort.Strings(names)
		for _, name := range names {
			db = append(db, profiles.LookupProfile(name))
		}
		return db
	}

	ctx := tool.NewDefaultContext()
	if err := profiles.Read(ctx, "./testdata/legacy.xml"); err != nil {
		t.Fatal(err)
	}

	if got, want := profiles.SchemaVersion(), profiles.Original; got != want {
		t.Errorf("got %v, want %v", got, want)
	}

	oprofiles := getProfiles()
	if got, want := len(oprofiles), 5; got != want {
		t.Errorf("got %v, want %v", got, want)
	}
	filename := tmpFile()
	defer os.RemoveAll(filepath.Dir(filename))

	var t1 profiles.Target
	t1.Set("tag=cpu,os")
	profiles.AddProfileTarget("__first", t1)

	if err := profiles.Write(ctx, filename); err != nil {
		t.Fatal(err)
	}

	if err := profiles.Read(ctx, filename); err != nil {
		t.Fatal(err)
	}

	if got, want := profiles.SchemaVersion(), profiles.V3; got != want {
		t.Errorf("got %v, want %v", got, want)
	}
	nprofiles := getProfiles()
	if got, want := len(nprofiles), 6; got != want {
		t.Errorf("got %v, want %v", got, want)
	}

	if got, want := nprofiles[0].Name, "__first"; got != want {
		t.Errorf("got %v, want %v", got, want)
	}

	for i, v := range nprofiles[1:] {
		if got, want := v.Name, oprofiles[i].Name; got != want {
			t.Errorf("got %v, want %v", got, want)
		}
	}
}
开发者ID:4shome,项目名称:go.jiri,代码行数:59,代码来源:manifest_test.go

示例2: targetAtDefaultVersion

func targetAtDefaultVersion(mgr profiles.Manager, target profiles.Target) (profiles.Target, error) {
	def := target
	version, err := mgr.VersionInfo().Select(target.Version())
	if err != nil {
		return profiles.Target{}, err
	}
	def.SetVersion(version)
	return def, nil
}
开发者ID:vanadium,项目名称:go.jiri,代码行数:9,代码来源:manager_cmdline.go

示例3: ExampleProfileTarget

func ExampleProfileTarget() {
	var target profiles.Target
	flags := flag.NewFlagSet("test", flag.ContinueOnError)
	profiles.RegisterTargetAndEnvFlags(flags, &target)
	flags.Parse([]string{"--target=arm-linux", "--env=A=B,C=D", "--env=E=F"})
	fmt.Println(target.String())
	fmt.Println(target.DebugString())
	// Output:
	// [email protected]
	// [email protected] dir: --env=A=B,C=D,E=F envvars:[]
}
开发者ID:vanadium,项目名称:go.jiri,代码行数:11,代码来源:target_test.go

示例4: TestReadingV0

func TestReadingV0(t *testing.T) {
	pdb := profiles.NewDB()
	jirix, cleanup := jiritest.NewX(t)
	defer cleanup()

	if err := pdb.Read(jirix, "./testdata/legacy.xml"); err != nil {
		t.Fatal(err)
	}

	if got, want := pdb.SchemaVersion(), profiles.Original; got != want {
		t.Errorf("got %v, want %v", got, want)
	}

	oprofiles := pdb.Profiles()
	if got, want := len(oprofiles), 5; got != want {
		t.Errorf("got %v, want %v", got, want)
	}
	filename := tmpFile()
	defer os.RemoveAll(filepath.Dir(filename))

	var t1 profiles.Target
	t1.Set("[email protected]")
	pdb.InstallProfile("", "__first", "")
	if err := pdb.AddProfileTarget("", "__first", t1); err != nil {
		t.Fatal(err)
	}

	if err := pdb.Write(jirix, "", filename); err != nil {
		t.Fatal(err)
	}

	if err := pdb.Read(jirix, filename); err != nil {
		t.Fatal(err)
	}

	if got, want := pdb.SchemaVersion(), profiles.V5; got != want {
		t.Errorf("got %v, want %v", got, want)
	}
	nprofiles := pdb.Profiles()
	if got, want := len(nprofiles), 6; got != want {
		t.Fatalf("got %v, want %v", got, want)
	}

	if got, want := nprofiles[0].Name(), "__first"; got != want {
		t.Errorf("got %v, want %v", got, want)
	}

	for i, v := range nprofiles[1:] {
		if got, want := v.Name(), oprofiles[i].Name(); got != want {
			t.Errorf("got %v, want %v", got, want)
		}
	}
}
开发者ID:vanadium,项目名称:go.jiri,代码行数:53,代码来源:manifest_test.go

示例5: applyCommand

func applyCommand(names []string, env *cmdline.Env, ctx *tool.Context, target profiles.Target, fn func(profiles.Manager, *tool.Context, profiles.Target) error) error {
	for _, n := range names {
		mgr := profiles.LookupManager(n)
		version, err := mgr.VersionInfo().Select(target.Version())
		if err != nil {
			return err
		}
		target.SetVersion(version)
		mgr.SetRoot(rootDir)
		if err := fn(mgr, ctx, target); err != nil {
			return err
		}
	}
	return nil
}
开发者ID:4shome,项目名称:go.jiri,代码行数:15,代码来源:driver.go

示例6: Uninstall

func (eg *exampleManager) Uninstall(jirix *jiri.X, pdb *profiles.DB, root jiri.RelPath, target profiles.Target) error {
	version, err := eg.versionInfo.Select(target.Version())
	if err != nil {
		return err
	}
	dir := eg.filename(root, target).Abs(jirix)
	if err := jirix.NewSeq().WriteFile(filepath.Join(dir, "version"), []byte(version), profilesutil.DefaultFilePerm).
		WriteFile(filepath.Join(dir, version), []byte(version), profilesutil.DefaultFilePerm).
		Remove(filepath.Join(dir, version)).
		Done(); err != nil {
		return err
	}
	if pdb.RemoveProfileTarget(eg.installer, eg.name, target) {
		eg.profile = nil
	}
	return nil
}
开发者ID:vanadium,项目名称:go.jiri,代码行数:17,代码来源:eg.go

示例7: Install

func (eg *exampleManager) Install(jirix *jiri.X, pdb *profiles.DB, root jiri.RelPath, target profiles.Target) error {
	version, err := eg.versionInfo.Select(target.Version())
	if err != nil {
		return err
	}
	target.SetVersion(version)
	dir := eg.filename(root, target).Abs(jirix)
	if err := jirix.NewSeq().
		MkdirAll(dir, profilesutil.DefaultDirPerm).
		WriteFile(filepath.Join(dir, "version"), []byte(version), profilesutil.DefaultFilePerm).
		WriteFile(filepath.Join(dir, version), []byte(version), profilesutil.DefaultFilePerm).
		Done(); err != nil {
		return err
	}
	eg.profile = pdb.InstallProfile(eg.installer, eg.name, string(root))
	target.InstallationDir = string(root)
	return pdb.AddProfileTarget(eg.installer, eg.name, target)
}
开发者ID:vanadium,项目名称:go.jiri,代码行数:18,代码来源:eg.go

示例8: fmtInfo

func fmtInfo(jirix *jiri.X, infoFmt string, rd *profilesreader.Reader, profile *profiles.Profile, target *profiles.Target) (string, error) {
	// Populate an instance listInfo
	info := &listInfo{}
	name := profile.Name()
	installer, _ := profiles.SplitProfileName(name)
	info.SchemaVersion = rd.SchemaVersion()
	info.DBPath = rd.Path()
	if target != nil {
		info.Target.InstallationDir = jiri.NewRelPath(target.InstallationDir).Abs(jirix)
		info.Target.CommandLineEnv = target.CommandLineEnv().Vars
		info.Target.Env = target.Env.Vars
		clenv := ""
		if len(info.Target.CommandLineEnv) > 0 {
			clenv = fmt.Sprintf(" --env=\"%s\" ", strings.Join(info.Target.CommandLineEnv, ","))
		}
		if installer != "" {
			info.Target.Command = fmt.Sprintf("jiri profile install --target=%s %s%s", target, clenv, name)
		} else {
			// TODO(cnicolaou): remove this when the transition is complete.
			info.Target.Command = fmt.Sprintf("jiri v23-profile install --target=%s %s%s", target, clenv, name)
		}
	}
	if profile != nil {
		rp := jiri.NewRelPath(profile.Root())
		info.Profile.Root = rp.Abs(jirix)
		info.Profile.Name = name
		info.Profile.Installer = installer
		info.Profile.DBPath = info.DBPath
		if installer != "" {
			info.Profile.DBPath = filepath.Join(info.DBPath, installer)
		}
	}

	// Use a template to print out any field in our instance of listInfo.
	tmpl, err := template.New("list").Parse("{{ ." + infoFmt + "}}")
	if err != nil {
		return "", err
	}
	out := &bytes.Buffer{}
	if err = tmpl.Execute(out, info); err != nil {
		return "", fmt.Errorf("please specify a supported field:\n%s", infoUsage())
	}
	return out.String(), nil
}
开发者ID:vanadium,项目名称:go.jiri,代码行数:44,代码来源:reader_cmdline.go

示例9: RunMojoShell

func RunMojoShell(mojoUrl, configFile string, configAliases map[string]string, argsFor map[string][]string, target profiles.Target) *exec.Cmd {
	// ensure the profiles are loaded
	jirix, err := jiri.NewX(cmdline.EnvFromOS())
	if err != nil {
		panic(err)
	}
	rd, err := profilesreader.NewReader(jirix, profilesreader.UseProfiles, filepath.Join(jirix.Root, ".jiri_root", "profile_db"))
	if err != nil {
		panic(err)
	}

	envslice := rd.EnvFromProfile(mojoProfileName(), target)
	env := envvar.VarsFromSlice(envslice)
	jiri.ExpandEnv(jirix, env)
	var mojoDevtools, mojoShell, mojoServices string
	for _, e := range env.ToSlice() {
		parts := strings.SplitN(e, "=", 2)
		switch parts[0] {
		case "MOJO_DEVTOOLS":
			mojoDevtools = parts[1]
		case "MOJO_SHELL":
			mojoShell = parts[1]
		case "MOJO_SERVICES":
			mojoServices = parts[1]
		}
	}
	args := []string{
		mojoUrl,
		"--config-file", configFile,
		"--shell-path", mojoShell,
		"--enable-multiprocess"}
	if target.OS() == "android" {
		args = append(args, "--android")
		args = append(args, "--origin", mojoServices)
	}
	for alias, value := range configAliases {
		args = append(args, "--config-alias", fmt.Sprintf("%s=%s", alias, value))
	}
	for key, value := range argsFor {
		args = append(args, fmt.Sprintf("--args-for=%s %s", key, strings.Join(value, " ")))
	}
	return exec.Command(filepath.Join(mojoDevtools, "mojo_run"), args...)
}
开发者ID:vanadium,项目名称:mojo.v23proxy,代码行数:43,代码来源:mojo_shell_runner.go

示例10: ensureAction

// ensureAction ensures that the requested profile and target
// is installed/uninstalled, installing/uninstalling it if and only if necessary.
func ensureAction(jirix *jiri.X, pdb *profiles.DB, action profiles.Action, installer, profile string, root jiri.RelPath, target profiles.Target) error {
	verb := ""
	switch action {
	case profiles.Install:
		verb = "install"
	case profiles.Uninstall:
		verb = "uninstall"
	default:
		return fmt.Errorf("unrecognised action %v", action)
	}
	if jirix.Verbose() {
		fmt.Fprintf(jirix.Stdout(), "%s %v %s\n", verb, action, target)
	}
	if t := pdb.LookupProfileTarget(installer, profile, target); t != nil {
		if jirix.Verbose() {
			fmt.Fprintf(jirix.Stdout(), "%v %v is already %sed as %v\n", profile, target, verb, t)
		}
		return nil
	}
	mgr := LookupManager(profiles.QualifiedProfileName(installer, profile))
	if mgr == nil {
		return fmt.Errorf("profile %v is not supported", profile)
	}
	version, err := mgr.VersionInfo().Select(target.Version())
	if err != nil {
		return err
	}
	target.SetVersion(version)
	if jirix.Verbose() {
		fmt.Fprintf(jirix.Stdout(), "%s %s %s\n", verb, profile, target.DebugString())
	}
	if action == profiles.Install {
		return mgr.Install(jirix, pdb, root, target)
	}
	return mgr.Uninstall(jirix, pdb, root, target)
}
开发者ID:vanadium,项目名称:go.jiri,代码行数:38,代码来源:util.go

示例11: filename

func (eg *exampleManager) filename(root jiri.RelPath, target profiles.Target) jiri.RelPath {
	r := root.Join("eg")
	dir := target.TargetSpecificDirname()
	return r.Join(dir)
}
开发者ID:vanadium,项目名称:go.jiri,代码行数:5,代码来源:eg.go

示例12: fmtHeader

func fmtHeader(name string, target *profiles.Target) string {
	if target == nil {
		return name
	}
	return name + " " + target.String()
}
开发者ID:vanadium,项目名称:go.jiri,代码行数:6,代码来源:reader_cmdline.go


注:本文中的v/io/jiri/profiles.Target类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。