New issue
Advanced search Search tips

Issue 919916 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Jan 18
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Chrome , Mac
Pri: 2
Type: Bug

Blocking:
issue 915053



Sign in to add a comment

GRIT: Can't include auto-generated file in GRIT resource maps

Project Member Reported by dpa...@chromium.org, Jan 8

Issue description

This is a continuation from the discussion at https://bugs.chromium.org/p/chromium/issues/detail?id=899437#c35 and onward, filing as a separate issue.


Desired behavior:
1) Auto-generate a JS file under out/<out_folder>/gen/ui/webui/resources/
2) Include that file in the binary.
3) Serve that file from chrome://resources/ URL.

The above behavior is going to be used to auto-generate Javascript modules from existing non-modularized files, for example assert.js -> assert.m.js, see details at issue 915053.

This is currently impossible because of the following

As part of addressing  issue 899437  an assertion was added that checks whether the generated resource map keys contain any variables like ${root_gen_dir}. This is *indirectly* preventing any keys that would reference the name of the output directory to be inserted in the map, for example ../../../out/gchrome/${root_gen_dir}, which was the original goal of  issue 899437 .

Proposed fix:
1) Modify Grit to replace variables with their value, for example ${root_gen_dir} should be replaced with "gen"
2) Modify Grit to replace output folder name like "gchrome" with a fixed string like @out_folder@. This would allow generated resource maps to have entries that refer to generated files.

The proposed fix is implemented at https://chromium-review.googlesource.com/c/chromium/src/+/1385448/8/tools/grit/grit/format/resource_map.py.

 
Blocking: 915053
Components: Build
Summary: GRIT: Can't include auto-generated file in GRIT resource maps (was: GRIT: Can't serve auto-generated file from chrome://resources/ URLs)
Updating the title to be even more accurate
Project Member

Comment 5 by bugdroid1@chromium.org, Jan 17 (5 days ago)

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6c25a13996af639886d74c597e4ca568c7fce906

commit 6c25a13996af639886d74c597e4ca568c7fce906
Author: dpapad <dpapad@chromium.org>
Date: Thu Jan 17 22:50:32 2019

Grit: Provide a safe way to include generated files to resource maps.

This allows including generated files in the (also generated) Grit resource
map. For example this will convert the following path:

../../out/gchrome/${root_gen_dir}/ui/webui/resources/js/foo.js
to:
@out_folder@/gen/ui/webui/resources/js/foo.js

and include the latter in the map.

Consequently this allows leveraging the aliasing mechanism within
content/browser/webui/shared_resources_data_source.cc to serve generated
files under a chrome://resources/ URL, such as:

chrome://resources/js/assert.js -> existing file with a normal path in .pak file
chrome://resources/js/assert.m.js -> generated file with a TOTALLY DIFFERENT path
in the same .pak file.

The goal is to use this mechanism to auto-generate JS modularized files from
existing non-modularized files (for example assert.js -> assert.m.js), in an
effort to gradually migrate ui/webui/resources to use JS modules.

Bug:  919916 
Change-Id: If7ba10233094b2b88bb9011956752229a6ac720e
Reviewed-on: https://chromium-review.googlesource.com/c/1404377
Reviewed-by: Nico Weber <thakis@chromium.org>
Reviewed-by: Dan Beam <dbeam@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#623884}
[modify] https://crrev.com/6c25a13996af639886d74c597e4ca568c7fce906/tools/grit/grit/format/resource_map.py
[modify] https://crrev.com/6c25a13996af639886d74c597e4ca568c7fce906/tools/grit/grit/format/resource_map_unittest.py

Comment 6 by dpa...@chromium.org, Jan 18 (4 days ago)

Status: Fixed (was: Assigned)

Sign in to add a comment