Closed Bug 1937701 Opened 11 months ago Closed 11 months ago

Update python/mozbuild/mozbuild/repackaging/msix.py to support comments inside AppConstants.sys.mjs

Categories

(Firefox Build System :: General, task)

task

Tracking

(firefox135 fixed)

RESOLVED FIXED
135 Branch
Tracking Status
firefox135 --- fixed

People

(Reporter: arai, Assigned: arai)

References

Details

Attachments

(1 file)

bug 1936088 is going to resurrect the line annotation in AppConstants module (AppConstants.jsm had the line annotation I think, and the migration to AppConstants.sys.mjs had lost it)

mozbuild.repackaging.msix::get_appconstants_sys_mjs_values logic doesn't expect any comment in between the property key and value, and that results in build bustage with the bug 1936088 patch.

https://searchfox.org/mozilla-central/rev/66aaf96f955d9bdc4bdb087a5075d5fbff2b9c8d/python/mozbuild/mozbuild/repackaging/msix.py#172-193

def get_appconstants_sys_mjs_values(finder, *args):
    r"""Extract values, such as the display version like `MOZ_APP_VERSION_DISPLAY:
    "...";`, from the omnijar.  This allows to determine the beta number, like
    `X.YbW`, where the regular beta version is only `X.Y`.  Takes a list of
    names and returns an iterator of the unique such value found for each name.
    Raises an exception if a name is not found or if multiple values are found.
    """
    lines = defaultdict(list)
    for _, f in finder.find("**/modules/AppConstants.sys.mjs"):
        # MOZ_OFFICIAL_BRANDING is split across two lines, so remove line breaks
        # immediately following ":"s so those values can be read.
        data = f.open().read().decode("utf-8").replace(":\n", ":")
        for line in data.splitlines():
            for arg in args:
                if arg in line:
                    lines[arg].append(line)

    for arg in args:
        (value,) = lines[arg]  # We expect exactly one definition.
        _, _, value = value.partition(":")
        value = value.strip().strip('",;')
        yield value

After the patch Part 1 in bug 1936088, the processed AppConstants.sys.mjs looks like the following:

export var AppConstants = Object.freeze({
  // See this wiki page for more details about channel specific build
  // defines: https://wiki.mozilla.org/Platform/Channel-specific_build_defines
  NIGHTLY_BUILD:
//@line 17 "$SRCDIR/toolkit/modules/AppConstants.sys.mjs"
  true,
//@line 21 "$SRCDIR/toolkit/modules/AppConstants.sys.mjs"

...

  MOZ_OFFICIAL_BRANDING:
//@line 71 "$SRCDIR/toolkit/modules/AppConstants.sys.mjs"
  false,
//@line 73 "$SRCDIR/toolkit/modules/AppConstants.sys.mjs"

Just to make sure, is this expected?
Is the line annotation supposed to be a part of distributed files?

Flags: needinfo?(mh+mozilla)

Well, yes, that's what your change does.

Flags: needinfo?(mh+mozilla)
Assignee: nobody → arai.unmht
Status: NEW → ASSIGNED
Pushed by arai_a@mac.com: https://hg.mozilla.org/integration/autoland/rev/9ea2e33d2c81 Update python/mozbuild/mozbuild/repackaging/msix.py to support comments inside AppConstants.sys.mjs. r=firefox-build-system-reviewers,nalexander
Status: ASSIGNED → RESOLVED
Closed: 11 months ago
Resolution: --- → FIXED
Target Milestone: --- → 135 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: