New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 604972 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Add more breadcrumbs to GN error messages when things fail

Project Member Reported by agrieve@chromium.org, Apr 20 2016

Issue description

The error messages when an error occurs in a template are really good!

E.g.:
ERROR at //build/config/android/internal_rules.gni:27:3: Assertion failed.
  assert(false)
  ^-----
See //build/config/android/internal_rules.gni:1731:7: whence it was called.
      android_lint("${_template_name}__lint") {
      ^----------------------------------------



However, when a top-level assert() fails in a .gni or .gn file, there are no breadcrumbs.

A common pattern is to use assert(!is_android) at the top of a BUILD.gn file or .gni file, and it's not obvious what caused the file to be included. 

 
Project Member

Comment 1 by bugdroid1@chromium.org, Apr 22 2016

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

commit dbecf02976975b93db37c3b5e3aa26d6fc92c517
Author: agrieve <agrieve@chromium.org>
Date: Fri Apr 22 00:58:08 2016

GN: Print the import trail when parse errors occur.

This is especially useful when asserts fail when the file should not be
included in the first place.

Example error message:
ERROR at //build/config/android/internal_rules.gni:11:1: Assertion failed.
assert(false)
^-----
See //build/config/android/rules.gni:7:1: whence it was imported.
import("//build/config/android/internal_rules.gni")
^-------------------------------------------------
See //media/midi/BUILD.gn:13:3: whence it was imported.
  import("//build/config/android/rules.gni")
  ^----------------------------------------
See //BUILD.gn:193:7: which caused the package to be included.
      "//media/midi:midi_unittests",
      ^----------------------------

BUG= 604972 

Review URL: https://codereview.chromium.org/1905473003

Cr-Commit-Position: refs/heads/master@{#388986}

[modify] https://crrev.com/dbecf02976975b93db37c3b5e3aa26d6fc92c517/tools/gn/import_manager.cc
[modify] https://crrev.com/dbecf02976975b93db37c3b5e3aa26d6fc92c517/tools/gn/loader.cc
[modify] https://crrev.com/dbecf02976975b93db37c3b5e3aa26d6fc92c517/tools/gn/loader.h
[modify] https://crrev.com/dbecf02976975b93db37c3b5e3aa26d6fc92c517/tools/gn/location.h

Status: Fixed (was: Started)

Sign in to add a comment