Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0cc5b215 authored by Patrice Arruda's avatar Patrice Arruda
Browse files

Soong: Fix the package name in metrics.proto file

The metrics.proto needs to be imported to Google3 in order to unmarshal
the build metrics data from bigstore. Cleaned up the enum names to use
the Camel naming convention and renamed the build_metrics to
soong_metrics to be more specific to soong and to allow quering
soong_metrics files from bigstore.

Bug: b/135280521
Test: lunch andf m -j. Checked if soong_metrics was generated correctly
      by using printproto command.

Change-Id: I998c8d05db592e94a653d6ca32250b80df3c9b21
parent ad13e118
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -158,7 +158,7 @@ func main() {
	stat.AddOutput(status.NewVerboseLog(log, filepath.Join(logsDir, "verbose.log")))
	stat.AddOutput(status.NewErrorLog(log, filepath.Join(logsDir, "error.log")))

	defer met.Dump(filepath.Join(logsDir, "build_metrics"))
	defer met.Dump(filepath.Join(logsDir, "soong_metrics"))

	if start, ok := os.LookupEnv("TRACE_BEGIN_SOONG"); ok {
		if !strings.HasSuffix(start, "N") {
+1 −1
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ func (c ContextImpl) CompleteTrace(name, desc string, begin, end uint64) {
	if c.Metrics != nil {
		realTime := end - begin
		c.Metrics.SetTimeMetrics(
			metrics_proto.PerfInfo{
			soong_metrics_proto.PerfInfo{
				Desc:      &desc,
				Name:      &name,
				StartTime: &begin,
+13 −13
Original line number Diff line number Diff line
@@ -33,19 +33,19 @@ const (
)

type Metrics struct {
	metrics    metrics_proto.MetricsBase
	metrics    soong_metrics_proto.MetricsBase
	TimeTracer TimeTracer
}

func New() (metrics *Metrics) {
	m := &Metrics{
		metrics:    metrics_proto.MetricsBase{},
		metrics:    soong_metrics_proto.MetricsBase{},
		TimeTracer: &timeTracerImpl{},
	}
	return m
}

func (m *Metrics) SetTimeMetrics(perf metrics_proto.PerfInfo) {
func (m *Metrics) SetTimeMetrics(perf soong_metrics_proto.PerfInfo) {
	switch perf.GetName() {
	case RunKati:
		m.metrics.KatiRuns = append(m.metrics.KatiRuns, &perf)
@@ -76,11 +76,11 @@ func (m *Metrics) SetMetadataMetrics(metadata map[string]string) {
		case "TARGET_BUILD_VARIANT":
			switch v {
			case "user":
				m.metrics.TargetBuildVariant = metrics_proto.MetricsBase_USER.Enum()
				m.metrics.TargetBuildVariant = soong_metrics_proto.MetricsBase_USER.Enum()
			case "userdebug":
				m.metrics.TargetBuildVariant = metrics_proto.MetricsBase_USERDEBUG.Enum()
				m.metrics.TargetBuildVariant = soong_metrics_proto.MetricsBase_USERDEBUG.Enum()
			case "eng":
				m.metrics.TargetBuildVariant = metrics_proto.MetricsBase_ENG.Enum()
				m.metrics.TargetBuildVariant = soong_metrics_proto.MetricsBase_ENG.Enum()
			default:
				// ignored
			}
@@ -112,18 +112,18 @@ func (m *Metrics) SetMetadataMetrics(metadata map[string]string) {
	}
}

func (m *Metrics) getArch(arch string) *metrics_proto.MetricsBase_ARCH {
func (m *Metrics) getArch(arch string) *soong_metrics_proto.MetricsBase_Arch {
	switch arch {
	case "arm":
		return metrics_proto.MetricsBase_ARM.Enum()
		return soong_metrics_proto.MetricsBase_ARM.Enum()
	case "arm64":
		return metrics_proto.MetricsBase_ARM64.Enum()
		return soong_metrics_proto.MetricsBase_ARM64.Enum()
	case "x86":
		return metrics_proto.MetricsBase_X86.Enum()
		return soong_metrics_proto.MetricsBase_X86.Enum()
	case "x86_64":
		return metrics_proto.MetricsBase_X86_64.Enum()
		return soong_metrics_proto.MetricsBase_X86_64.Enum()
	default:
		return metrics_proto.MetricsBase_UNKNOWN.Enum()
		return soong_metrics_proto.MetricsBase_UNKNOWN.Enum()
	}
}

@@ -148,7 +148,7 @@ func (m *Metrics) Dump(outputPath string) (err error) {
		return err
	}
	tempPath := outputPath + ".tmp"
	err = ioutil.WriteFile(tempPath, []byte(data), 0777)
	err = ioutil.WriteFile(tempPath, []byte(data), 0644)
	if err != nil {
		return err
	}
+154 −137

File changed.

Preview size limit exceeded, changes collapsed.

+10 −12
Original line number Diff line number Diff line
@@ -14,10 +14,8 @@

syntax = "proto2";

option optimize_for = LITE_RUNTIME;

package build_metrics;
option go_package = "metrics_proto";
package soong_build_metrics;
option go_package = "soong_metrics_proto";

message MetricsBase {
  // Timestamp generated when the build starts.
@@ -32,15 +30,15 @@ message MetricsBase {
  // The target product information, eg. aosp_arm.
  optional string target_product = 4;

  enum BUILDVARIANT {
  enum BuildVariant {
    USER = 0;
    USERDEBUG = 1;
    ENG = 2;
  }
  // The target build variant information, eg. eng.
  optional BUILDVARIANT target_build_variant = 5 [default = ENG];
  optional BuildVariant target_build_variant = 5 [default = ENG];

  enum ARCH {
  enum Arch {
    UNKNOWN = 0;
    ARM = 1;
    ARM64 = 2;
@@ -48,7 +46,7 @@ message MetricsBase {
    X86_64 = 4;
  }
  // The target arch information, eg. arm.
  optional ARCH target_arch = 6 [default = UNKNOWN];
  optional Arch target_arch = 6 [default = UNKNOWN];

  // The target arch variant information, eg. armv7-a-neon.
  optional string target_arch_variant = 7;
@@ -57,10 +55,10 @@ message MetricsBase {
  optional string target_cpu_variant = 8;

  // The host arch information, eg. x86_64.
  optional ARCH host_arch = 9 [default = UNKNOWN];
  optional Arch host_arch = 9 [default = UNKNOWN];

  // The host 2nd arch information, eg. x86.
  optional ARCH host_2nd_arch = 10 [default = UNKNOWN];
  optional Arch host_2nd_arch = 10 [default = UNKNOWN];

  // The host os information, eg. linux.
  optional string host_os = 11;
@@ -113,13 +111,13 @@ message PerfInfo {
}

message ModuleTypeInfo {
  enum BUILDSYSTEM {
  enum BuildSystem {
    UNKNOWN = 0;
    SOONG = 1;
    MAKE = 2;
  }
  // The build system, eg. Soong or Make.
  optional BUILDSYSTEM build_system = 1 [default = UNKNOWN];
  optional BuildSystem build_system = 1 [default = UNKNOWN];

  // The module type, eg. java_library, cc_binary, and etc.
  optional string module_type = 2;
Loading