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

Commit 6ec58216 authored by Cole Faust's avatar Cole Faust
Browse files

Remove unassigned event log tags feature

.logtags files are a mapping of an integer -> name. However, there
is an unused feature where you could put a '?' instead of an integer,
and then the build system would assign a number to it, taking care
to avoid all other already-assigned numbers across the source tree.

This feature makes it hard to support some things we're working towards,
like incremental soong and treble common system images, so remove it.

Also modernize the python scripts a little.

Bug: 382515940
Test: m event-log-tags
Change-Id: I33550daf66e00683c95c53a5958d59d25b37470a
parent f65a4a21
Loading
Loading
Loading
Loading
+3 −18
Original line number Diff line number Diff line
@@ -970,27 +970,12 @@ systemimage:

# -----------------------------------------------------------------

.PHONY: event-log-tags

# Produce an event logs tag file for everything we know about, in order
# to properly allocate numbers.  Then produce a file that's filtered
# for what's going to be installed.

all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt

event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags

# Include tags from all packages that we know about
all_event_log_tags_src := \
    $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))

$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
$(all_event_log_tags_file): $(all_event_log_tags_src) $(MERGETAGS) build/make/tools/event_log_tags.py
	$(hide) mkdir -p $(dir $@)
	$(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)

$(call declare-0p-target,$(all_event_log_tags_file))

# Include tags from all packages included in this product, plus all
# tags that are part of the system (ie, not in a vendor/ or device/
# directory).
@@ -1002,13 +987,13 @@ event_log_tags_src := \
      $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))

$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) $(MERGETAGS) build/make/tools/event_log_tags.py
$(event_log_tags_file): $(event_log_tags_src) $(MERGETAGS)
	$(hide) mkdir -p $(dir $@)
	$(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
	$(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)

$(eval $(call declare-0p-target,$(event_log_tags_file)))

.PHONY: event-log-tags
event-log-tags: $(event_log_tags_file)

ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
+1 −1
Original line number Diff line number Diff line
@@ -731,7 +731,7 @@ PROGUARD_HOME := external/proguard
PROGUARD := $(PROGUARD_HOME)/bin/proguard.sh
PROGUARD_DEPS := $(PROGUARD) $(PROGUARD_HOME)/lib/proguard.jar
JAVATAGS := build/make/tools/java-event-log-tags.py
MERGETAGS := build/make/tools/merge-event-log-tags.py
MERGETAGS := $(HOST_OUT_EXECUTABLES)/merge-event-log-tags
APPEND2SIMG := $(HOST_OUT_EXECUTABLES)/append2simg
VERITY_SIGNER := $(HOST_OUT_EXECUTABLES)/verity_signer
BUILD_VERITY_METADATA := $(HOST_OUT_EXECUTABLES)/build_verity_metadata
+1 −1
Original line number Diff line number Diff line
@@ -1555,7 +1555,7 @@ endef
define transform-logtags-to-java
@mkdir -p $(dir $@)
@echo "logtags: $@ <= $<"
$(hide) $(JAVATAGS) -o $@ $< $(PRIVATE_MERGED_TAG)
$(hide) $(JAVATAGS) -o $@ $<
endef


+0 −1
Original line number Diff line number Diff line
@@ -140,7 +140,6 @@ ifneq ($(strip $(logtags_sources)),)
logtags_java_sources := $(patsubst %.logtags,%.java,$(addprefix $(intermediates.COMMON)/logtags/, $(logtags_sources)))
logtags_sources := $(addprefix $(LOCAL_PATH)/, $(logtags_sources))

$(logtags_java_sources): PRIVATE_MERGED_TAG := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
$(logtags_java_sources): $(intermediates.COMMON)/logtags/%.java: $(LOCAL_PATH)/%.logtags $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt $(JAVATAGS) build/make/tools/event_log_tags.py
	$(transform-logtags-to-java)

+17 −20
Original line number Diff line number Diff line
@@ -14,21 +14,21 @@

"""A module for reading and parsing event-log-tags files."""

import dataclasses
import re
import sys
from typing import Optional

class Tag(object):
  __slots__ = ["tagnum", "tagname", "description", "filename", "linenum"]

  def __init__(self, tagnum, tagname, description, filename, linenum):
    self.tagnum = tagnum
    self.tagname = tagname
    self.description = description
    self.filename = filename
    self.linenum = linenum
@dataclasses.dataclass
class Tag:
  tagnum: int
  tagname: str
  description: Optional[str]
  filename: str
  linenum: int


class TagFile(object):
class TagFile:
  """Read an input event-log-tags file."""
  def AddError(self, msg, linenum=None):
    if linenum is None:
@@ -76,13 +76,10 @@ class TagFile(object):
          self.options[parts[1]] = parts[2:]
          continue

        if parts[0] == "?":
          tag = None
        else:
        try:
          tag = int(parts[0])
        except ValueError:
            self.AddError("\"%s\" isn't an integer tag or '?'" % (parts[0],))
          self.AddError("\"%s\" isn't an integer tag" % (parts[0],))
          continue

        tagname = parts[1]
@@ -128,8 +125,8 @@ def WriteOutput(output_file, data):
      out = sys.stdout
      output_file = "<stdout>"
    else:
      out = open(output_file, "wb")
    out.write(str.encode(data))
      out = open(output_file, "w")
    out.write(data)
    out.close()
  except (IOError, OSError) as e:
    print("failed to write %s: %s" % (output_file, e), file=sys.stderr)
Loading