having trouble Adding a basic include_dirs = [ ] in GN

2,229 views
Skip to first unread message

Patrick Wright

unread,
Jan 27, 2017, 4:57:48 PM1/27/17
to Chromium-dev
I must be overlooking something fundamental. 


I am trying to include a file because during build i get the following:

 'platform/PlatformExport.h' file not found
#include "platform/PlatformExport.h"


I include the variable in my BUILD.gn file at src/chrome:

include_dirs = [ platform1 ]


I define it in the follow gni file:


in the following way

tried both:

platform1 = "/third_party/WebKit/Source"    

and   


platform = "//third_party/WebKit/Source"


import the config.gni at the top of the BUILD.gn with: import("//build/config/android/config.gni")

I get the following error:

[1/1] Regenerating ninja files
FAILED: build.ninja 
/home/c/chromium/src/buildtools/linux64/gn --root=/home/c/chromium/src -q gen .
ERROR at //chrome/BUILD.gn:121:24: Undefined identifier
      include_dirs = [ platform1 ]
                       ^--------
See //BUILD.gn:500:7: which caused the file to be included.
      "//chrome:manpage",
      ^-----------------
ninja: error: rebuilding 'build.ninja': subcommand failed

What does manpage have to do with this?

manpage section in the same BUILD.gn file shows the following:

action("manpage") {
    if (is_chrome_branded) {
      name = "Google Chrome"
      filename = "google-chrome"
      confdir = "google-chrome"
    } else {
      name = "Chromium"
      filename = "chromium-browser"
      confdir = "chromium"
    }

    script = "//chrome/tools/build/linux/sed.py"
    infile = "app/resources/manpage.1.in"
    inputs = [
      infile,
    ]

    outfile = "$root_out_dir/chrome.1"
    outputs = [
      outfile,
    ]

    args = [
      rebase_path(infile, root_build_dir),
      rebase_path(outfile, root_build_dir),
      "-e s/@@NAME@@/$name/",
      "-e s/@@FILENAME@@/$filename/",
      "-e s/@@CONFDIR@@/$confdir/",
    ]
  }


I have checked the manpage.1.in and it has many symbols that I am not sure relate to the include dirs. 


Should i label a variable as my source directory and edit may platform1 definition to use that?

Dmitry Skiba

unread,
Jan 27, 2017, 6:23:28 PM1/27/17
to wrig...@gmail.com, Chromium-dev
I think it should be "platform1", i.e. quoted.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.

Dirk Pranke

unread,
Jan 27, 2017, 7:31:36 PM1/27/17
to Dmitry Skiba, Patrick Wright, Chromium-dev
No, it probably shouldn't be "platform1", assuming that you actually defined platform1, above.

However, the rest of your message doesn't completely make sense to me. 

Would it be possible for you to post the changes you've made as a patch somewhere?

-- Dirk

Patrick Wright

unread,
Jan 28, 2017, 12:36:07 PM1/28/17
to Chromium-dev, dsk...@google.com, wrig...@gmail.com
Thank you for the responses. 

In order for GN to include the directory I had to put the following under the executable command:

platform1 = []
  platform1 = "/home/c/chromium/src/third_party/WebKit/Source/"
include_dirs = [ platform1 ]

I still included the two definitions in  the config.gni and imported that config file:

platform1 = "/third_party/WebKit/Source"    

platform = "//third_party/WebKit/Source"

at

As far as posting the code. I really dont have much to post other that the include files I have that caused the errors thus far and commented out code that allows me to read .cpp and .cc files easier. I am  trying to do a web request with webkit and get the data back to render a view/video in exomediplayer as fast as  possible. Once i get closer to this I will be happy to post. 

I included the following in my .cc file:

#include "build/build_config.h"
#define LOG_TAG "WebUrlLoaderClient"
#include "sdch/linux/config.h"
#include "third_party/WebKit/public/platform/WebURLLoaderClient.h"



#include "third_party/skia/src/gpu/GrResourceHandle.h"

#include "third_party/WebKit/Source/platform/network/ResourceResponse.h"
#include "platform/UserGestureIndicator.h"

#include <wtf/text/CString.h>


I am doing it loosely based off of this file here from webkit in android:




To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.

Dirk Pranke

unread,
Jan 28, 2017, 3:21:01 PM1/28/17
to Patrick Wright, Chromium-dev, Dmitry Skiba
Hi,

I'm sorry, but it's still hard to give you much advice, since I cannot tell which lines you are modifying in which files or targets.

In your original message, you talk about added `include_dirs = [ platform1 ]` to //chrome/BUILD.gn, but I can't tell *where* in that file you're adding that line, and where you're adding it matters very much. 

The error message you quoted was:

  ERROR at //chrome/BUILD.gn:121:24: Undefined identifier


That's in the middle of a windows-only target, at least on the current tip-of-tree build. And, I don't know why you would think that target would need a reference to something in Blink.

If you've modified the file to strip out everything before the `if (is_linux)` block on line 1523, then looking at the "manpage" target, adding something called `include_dirs = [ platform1]` doesn't make sense because the manpage target is an action() that generates a man page, i.e., a call to a Python script, and it knows nothing about include dirs. Or needing to have dependencies on Blink, either.

Are you trying to add a new file to some target and compile it?

-- Dirk

Patrick Wright

unread,
Jan 30, 2017, 9:50:39 AM1/30/17
to Chromium-dev, wrig...@gmail.com, dsk...@google.com
 thanks,

yes, I am trying to add a new target and give it my own include directories. so sadly, The line numbers will not match up with the source code on cs.chromium.org. I will paste to clarify anything upload when asked for sure. I am guessing github would be an appropriate place for this unless otherwise noted.  I have not run into any "manpage" error since getting the proper includes correct though. :>)

In order to help with code completion when navigating webkit/webcore and and the render process I  loaded Chromium into Eclipse. However, I sill compile with the command line and ninja, hence needing the include directories for GN.  

I tried to execute "chrome" or "chrome_initial" build target in eclipse and it wasn't an executable. it is a shared library yet acts just like an executable when i execute it on Linux: "./chrome_initial". navigating the code base and seeing how it works/designed  is a lesson in itself, as least for me. 



Thanks again

Patrick Wright

unread,
Feb 2, 2017, 6:51:57 PM2/2/17
to Chromium-dev, wrig...@gmail.com, dsk...@google.com
Still haven't got the include directories correct.

I add a new executible  to the build.gn in the web directory: 

/src/third_party/WebKit/Source/web


if (is_linux) { executable("hello_world1") {


d1 = [] d1 = "/home/c/chromium1/src/third_party/WebKit/Source/" d2 = "/home/c/chromium1/src/third_party/WebKit/Source/platform/geometry/FloatPoint.h" include_dirs = [d1,d2]



sources = [ "hello_world.cc",]


}

}


But yet it still doesn't include the dirctories that i need. Why does this method work on the chrome_initial executible but not my own executible. Is it because I am not including the right config files?


I add the following variables to the very bottom of the gni folder located at: //src/third_party/WebKit/Source/config.gni


if (is_linux) { d1 = "//third_party/WebKit/Source/" d1 = "/home/c/chromium1/src/third_party/WebKit/Source/" }

Patrick Wright

unread,
Feb 2, 2017, 7:00:50 PM2/2/17
to Chromium-dev, wrig...@gmail.com, dsk...@google.com
I tried creating my own .gni file, web.gni, and that did not go very well:

ERROR at //third_party/WebKit/Source/web/BUILD.gn:39:1: Can't load input file.
import("//third_party/Webkit/Source/web/web.gni")
^-----------------------------------------------
Unable to load:
  /home/c/chromium1/src/third_party/Webkit/Source/web/web.gni
I also checked in the secondary tree for:
  /home/c/chromium1/src/build/secondary/third_party/Webkit/Source/web/web.gni
See //BUILD.gn:318:7: which caused the file to be included.
      "//third_party/WebKit/Source/web:webkit_unit_tests",
      ^--------------------------------------------------
ninja: error: rebuilding 'build.ninja': subcommand failed
c@c:~/chromium1/src$ ninja -C out/Default hello_world11
ninja: Entering directory `out/Default'
[1/1] Regenerating ninja files
FAILED: build.ninja 


I know this is overkill. I do not really know the consequences of this. I have included the following config files in my BUILD.gn file in hopes that it may trigger somethign that would allow the include_dirs to work but of course it still does not:

import("//build/config/ui.gni")
import("//testing/test.gni")
import("//third_party/WebKit/Source/bindings/bindings.gni")
import("//third_party/WebKit/Source/config.gni")
import("//third_party/WebKit/Source/core/core.gni")
import("//third_party/WebKit/Source/modules/modules.gni")

import("//build/config/ui.gni")
import("//testing/test.gni")
import("//third_party/WebKit/Source/bindings/bindings.gni")
import("//third_party/WebKit/Source/config.gni")
import("//third_party/WebKit/Source/core/core.gni")
import("//third_party/WebKit/Source/modules/modules.gni")

import("//build/buildflag_header.gni")
import("//build/config/chrome_build.gni")
import("//build/config/compiler/compiler.gni")
import("//build/config/compiler/pgo/pgo.gni")
import("//build/config/features.gni")
import("//build/config/locales.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/ui.gni")
import("//build/config/win/console_app.gni")
import("//build/config/win/manifest.gni")
import("//build/toolchain/toolchain.gni")
import("//chrome/chrome_paks.gni")
import("//chrome/common/features.gni")
import("//chrome/process_version_rc_template.gni")
import("//extensions/features/features.gni")
import("//ppapi/features/features.gni")
import("//third_party/WebKit/public/public_features.gni")
import("//third_party/widevine/cdm/widevine.gni")
import("//tools/resources/generate_resource_whitelist.gni")
import("//v8/gni/v8.gni")

//the unique .gni file I included/created
import("//third_party/Webkit/Source/web/web.gni")

Brett Wilson

unread,
Feb 3, 2017, 12:31:43 PM2/3/17
to wrig...@gmail.com, Chromium-dev, Dmitry Skiba
The error message is telling you it can't find the file. It tells you where it's looking:

  /home/c/chromium1/src/third_
party/Webkit/Source/web/web.gni

If that's not where your file is, you need to move it or change the import path.

Brett

Patrick Wright

unread,
Feb 4, 2017, 5:24:11 PM2/4/17
to Chromium-dev, wrig...@gmail.com, dsk...@google.com
thanks,

Yeah, I am not sure why it would not find it. I thought the path was correct but I will be sure it is when I make my next .gni file.   I removed it and am coming back to it later. 

I figured out why the "include_dirs = " was not working.

One can not include more than one "include_dirs = " in a BUILD.gn file. The system will not see it and will not tell the developer. 

I learned the by putting the "include_dirs=" in to a .gni file and it pointed out that it was already defined within the BUILD.gn and where it was.e but having two "include_dirs =" caused no errors, just did not include the specified include directories. 

Jeremy Roman

unread,
Feb 4, 2017, 7:56:43 PM2/4/17
to wrig...@gmail.com, Chromium-dev, Dmitry Skiba
Your filesystem is probably case-sensitive, and the K in WebKit should be uppercase.
Reply all
Reply to author
Forward
0 new messages