chromium.src icon indicating copy to clipboard operation
chromium.src copied to clipboard

Chromium resources build fails when nwjs_sdk=false.

Open llamasoft opened this issue 5 years ago • 4 comments
trafficstars

When configured with gn gen "out/nw" '--args=is_debug=false is_component_ffmpeg=true target_cpu="x64" symbol_level=1 is_component_build=false nwjs_sdk=false ffmpeg_branding="Chromium"' (taken directly from this nw44_linux64 buildbot step), building the chrome/browser:resources_grit results in the following error:

/data/nwjs/src$ ninja -C out/nw 'chrome/browser:resources_grit'
ninja: Entering directory `out/nw'
[1/2] ACTION //chrome/browser:resources_grit(//build/toolchain/linux:clang_x64)
FAILED: gen/chrome/resources_stamp.d.stamp gen/chrome/grit/browser_resources.h gen/chrome/browser_resources.pak gen/chrome/browser_resources.pak.info
python ../../tools/grit/grit.py -i ../../chrome/browser/nwjs_resources.grd build -o gen/chrome --depdir . --depfile gen/chrome/resources_stamp.d --write-only-new=1 --depend-on-stamp -D scale_factors=2x -D _chromium -E CHROMIUM_BUILD=chromium -D desktop_linux -D toolkit_views -D use_aura -D use_nss_certs --brotli brotli -D enable_arcore=false -D enable_background_mode=true -D enable_background_contents=true -D enable_extensions=true -D enable_hangout_services_extension=false -D enable_plugins=true -D enable_print_preview=true -D enable_printing=true -D enable_service_discovery=true -D enable_supervised_users=false -D enable_vr=true -D enable_webui_tab_strip=false -D safe_browsing_mode=0 -D optimize_webui=true -E additional_modules_list_file=gen/chrome/browser/internal/additional_modules_list.txt -E root_gen_dir=gen -f ../../tools/gritsettings/resource_ids --assert-file-list=obj/chrome/browser/resources_expected_outputs.txt
Error processing node <?xml version="1.0" encoding="UTF-8"?>
<include allowexternalscript="true" compress="gzip" file="${root_gen_dir}\chrome\browser\resources\discards\graph_tab.html" name="IDR_DISCARDS_GRAPH_TAB_HTML" type="BINDATA" use_base_dir="false" />: [Errno 2] No such file or directory: u'../../out/nw/gen/chrome/browser/resources/discards/graph_tab.html'
Traceback (most recent call last):
  File "../../tools/grit/grit.py", line 23, in <module>
    sys.exit(grit.grit_runner.Main(sys.argv[1:]))
  File "/data/nwjs/src/tools/grit/grit/grit_runner.py", line 310, in Main
    return toolobject.Run(options, args[1:])
  File "/data/nwjs/src/tools/grit/grit/tool/build.py", line 272, in Run
    self.Process()
  File "/data/nwjs/src/tools/grit/grit/tool/build.py", line 404, in Process
    self.ProcessNode(self.res, output, outfile)
  File "/data/nwjs/src/tools/grit/grit/tool/build.py", line 331, in ProcessNode
    formatted = formatter(node, output_node.GetLanguage(), output_dir=base_dir)
  File "/data/nwjs/src/tools/grit/grit/format/data_pack.py", line 88, in Format
    value = node.GetDataPackValue(lang, UTF8)
  File "/data/nwjs/src/tools/grit/grit/node/include.py", line 107, in GetDataPackValue
    data = util.ReadFile(filename, util.BINARY)
  File "/data/nwjs/src/tools/grit/grit/util.py", line 210, in ReadFile
    with open(filename, mode) as f:
IOError: [Errno 2] No such file or directory: u'../../out/nw/gen/chrome/browser/resources/discards/graph_tab.html'
ninja: build stopped: subcommand failed.

This was done from a clean working environment building off of the nw44 branch.
@LeonardLaszlo was encountering a similar grit-related error as well.

The cause seems to be that the nwjs_sdk flag causes a different set of resources to be build. This is taken from chrome/browser/BUILD.gn:

grit("resources") {
  if (nwjs_sdk) {
    source = "browser_resources.grd"
  } else {
    source = "nwjs_resources.grd"
  }

The specific case regarding graph_tab.html seems to stem from the commit updating to Chromium 80.0.3987.0. It removes the graph_tab.html output from chrome/browser/resources/discards/BUILD.gn in favor of graph_tab.js instead.
Again, I think the reason this isn't an issue for nwjs_sdk=true builds is because browser_resources.grd only requires graph_tab.js, but nwjs_resources.grd requires graph_tab.js and graph_tab.html. I haven't done much digging aside from that, but it wouldn't surprise me if other resources are missing as well.

llamasoft avatar Feb 20 '20 17:02 llamasoft

It appears that patching chrome/browser/BUILD.gn to always use browser_resources.grd is a potential workaround. I've managed to successfully complete a non-SDK build after applying such a patch, but this doesn't seem like the "correct" solution as it likely results in building more files than necessary.

If you want, I can submit a PR with the BUILD.gn patch. It's what I'm using in my NW.js ARM build script.

llamasoft avatar Feb 21 '20 22:02 llamasoft

When I build the non SDK versions of nwjs with the following parameters:

export GYP_CHROMIUM_NO_ACTION=0
export GYP_DEFINES="building_nw=1 nwjs_sdk=0 disable_nacl=1 buildtype=Official clang=1 OS=linux target_arch=arm target_cpu=arm arm_float_abi=hard"
export GN_ARGS="is_debug=false target_os=\"linux\" is_component_ffmpeg=true ffmpeg_branding=\"Chrome\" symbol_level=1 enable_nacl=false enable_nacl=false target_cpu=\"arm\" arm_float_abi=\"hard\""

the resulting artifacts are still sdk artifacts.

Creating packages...
Making "nwjs-sdk-v0.44.3-linux-arm.tar.gz"
Making "nwjs-sdk-symbol-v0.44.3-linux-arm.tar.gz"
Copying nw-headers-v0.44.3.tar.gz
Copying SHASUMS256.txt

How is this possible?

LeonardLaszlo avatar Feb 27 '20 08:02 LeonardLaszlo

@LeonardLaszlo You have nwjs_sdk=0 in your GYP_DEFINES, but not nwjs_sdk=false in your GN_ARGS. The output of the gn command is what creates the dist step and nwjs_sdk=true is the default value (as per src/build/config/BUILDCONFIG.gn).

llamasoft avatar Feb 27 '20 22:02 llamasoft

@llamasoft I encountered the same error when building the win32 flavors version. I will try your solution for a temporary fix.

cecilpeng avatar Mar 07 '20 01:03 cecilpeng