summaryrefslogtreecommitdiffstats
path: root/tools/gn/target_unittest.cc
Commit message (Collapse)AuthorAgeFilesLines
* Windows precompiled header support in GN.brettw2015-06-291-0/+55
| | | | | | | | | | | | | | Introduces aprecompiled_header_type flag on a tool to say whether it supports precompiled headers, and flags on configs/targets that allow one to specify which header is precompiled. This does not implement GCC precompiled headers, but the type flag will allow future expansion (the implementation will be mostly separate). Renames SOURCE_CC to SOURCE_CPP to avoid confusion with Toolchain::TYPE_CC (which is actually the C compiler). BUG=297678 Review URL: https://codereview.chromium.org/1207903002 Cr-Commit-Position: refs/heads/master@{#336674}
* Check for inputs not generated by depsbrettw2015-06-041-160/+148
| | | | | | | | | | | | | | | | | Adds a check in GN that looks for generated input files on a target that were not generated by a dependency of the current target. In order to depend on the output of a previous target, that target must be in your deps. This adds checking output files to "gn refs" to help in debugging these issues. Relaxes a wider range of checking when doing introspection commands like "desc", "refs", and "ls" so they can be run to debug such issues. Adds an additional test helper for setting up test targets that saves some code. Use this in the target unittests. Review URL: https://codereview.chromium.org/1126193005 Cr-Commit-Position: refs/heads/master@{#332925}
* Propagate GN public shared libraries through shared librariesbrettw2015-04-161-15/+69
| | | | | | | | | | | | Previously all dependencies would stop propagating for link purposes when a shared library or executable boundary is reached. This patch makes public shared library dependencies propagate through shared libraries. Since the ability to use header files is propagated through these boundaries, so do the link dependencies. See the comment in target.cc for more details. BUG=475091 Review URL: https://codereview.chromium.org/1083663007 Cr-Commit-Position: refs/heads/master@{#325471}
* GN: Fix dependency output file handling.Brett Wilson2014-09-221-0/+37
| | | | | | | | | | A copy and paste error meant it used the link output file for dependency tracking. This is valid but inefficient, which was why it wasn't caught. Added a new test for this case R=scottmg@chromium.org Review URL: https://codereview.chromium.org/583363003 Cr-Commit-Position: refs/heads/master@{#295985}
* GN: Complete static libs can't depend on static libscmasone2014-09-181-0/+49
| | | | | | | | | | | | | Trying to use ar to put a static lib inside a complete static lib doesn't work. GN should enforce and document this restriction. BUG=None TEST=gn_unittests, including new test for this case. R=brettw Review URL: https://codereview.chromium.org/582863002 Cr-Commit-Position: refs/heads/master@{#295609}
* GN fixes for group dependent configs.Brett Wilson2014-09-171-0/+54
| | | | | | | | | | | | | | | Adds a better tests for pulling dependent and public configs. These don't actually test the bug, but are important. The bug was removing the group conditional when pulling dependent configs. Previously the groups deps would get duplicated so we wouldn't want to pull a group's public deps. I didn't write a test for this since it seemed odd to test that there is not a special case for this. I just removed the condition. Fixes a misspelliung and and an extra newline in the help. BUG= R=jamesr@chromium.org Review URL: https://codereview.chromium.org/581723002 Cr-Commit-Position: refs/heads/master@{#295314}
* Add public deps to GN.brettw2014-09-171-122/+39
| | | | | | | | | | | | | | | | | | Renamed datadeps to data_deps for consistency. Renamed direct_dependent_configs to public_configs for consistency with the public deps. This is also easier to understand and hopefully will encourage people to do this instead of use all_dependent_configs. Now that there are so many types of deps, added a DepsIterator that allows easy iterating over all of them (or only the linked ones). This simplified some code. This simplified the header checker significantly since it had complicated logic to find direct_dependent_configs and prefer paths with those forwarded. Removed a bunch of weird group special-casing. Groups no longer have their deps copied into the target, but are dependents like everything else. For now, unless you explicitly specify public_deps, all group deps will default to public. I'd like to change this in a future pass. Added a bool return value to the target generator functions that fill values. Since I originally did that, I've started both returning a bool and setting an Err, which makes checking for the error and early-returning easier to remember. I did this because I found yet another case of forgetting to check err, which gives very strange results. Review URL: https://codereview.chromium.org/561273003 Cr-Commit-Position: refs/heads/master@{#295203}
* GN: fix datadeps visibility checkcjhopman2014-09-161-0/+22
| | | | | | | | | The visibility check was checking the origin of deps[i] instead of datadeps[i]. Review URL: https://codereview.chromium.org/551843006 Cr-Commit-Position: refs/heads/master@{#295102}
* GN: Add notion of 'complete' static libraries, akin to GYP.cmasone2014-09-131-0/+35
| | | | | | | | | | | | | | | | In general, GN assumes that static libraries are intermediate targets and will forward their child dependencies up the tree until a "final" target is reached. Until now, this meant only shared_library and executable targets. This change introduces the notion of a "complete" static_library target which is linked and, as such, suitable for distribution. BUG=413776 TEST=gn_unittests R=brettw@chromium.org Review URL: https://codereview.chromium.org/565283002 Cr-Commit-Position: refs/heads/master@{#294709}
* Add testonly flag to GNBrett Wilson2014-09-021-23/+132
| | | | | | | | | | | | | | | | | | This also reworks visibility so both it and the testonly flag are checked when a target is marked resolved, rather than when it is written out. The previous code would not check visibility when doing non-"gen" commands like "check", which is counterintuitive. This change required OnResolved to be able to report a failure, which required updating many callers. But it makes visibility mush easier to test, so I added some additional visibility tests. BUG=357779 R=hclam@chromium.org Review URL: https://codereview.chromium.org/524623005 Cr-Commit-Position: refs/heads/master@{#292976}
* Support more configurability in GN toolchainsbrettw@chromium.org2014-08-191-50/+106
| | | | | | | | | | | | | This uses substitution patterns in toolchains to allow the toolchain to specify more flexibly how files are to be named and generated at each step. The toolchain now has control over the naming of object and executable files, for example, where before these were hardcoded. This removes most of the OS-specific logic hardcoded into the GN tool. There is still a bunch in action invocation; this will be done in a followup. R=jamesr@chromium.org Review URL: https://codereview.chromium.org/440333002 Cr-Commit-Position: refs/heads/master@{#290685} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290685 0039d316-1c4b-4281-b951-d872f2087c98
* This is an ordered set tailored to GN's (simple) needs.brettw@chromium.org2014-08-061-7/+7
| | | | | | | | | | | | | | This vector is now used to store all config lists. Previously the code did a bunch of work to uniquify configs at certain points (in target.cc) but direct_dependent_configs still ended up with lots of duplicates. Before this patch the chrome/browser target has 41098 direct_dependent_configs, and after this patch it has 7. Apparently we were also spending a lot of time on these. Before this patch Windows wall clock time was 1031ms, and after this patch it's 831ms. Linux was 834ms before and 593ms after. Also fix minor build issues in base I noticed while working on this. R=viettrungluu@chromium.org Review URL: https://codereview.chromium.org/26537002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287865 0039d316-1c4b-4281-b951-d872f2087c98
* GN: Don't link source sets into static librariesbrettw@chromium.org2014-05-311-5/+4
| | | | | | | | | | | | | Previously if a static library depended on a source set, we'd link it in. This can easily cause multiple inclusions of the source set's code if there are multiple shared libraries that depend on it. This patch forwards the source set up the dependency chain to the next linkable target (shared library or executable). This solves the multiple-definition problem. The downside is that if you make a static library that depends on a source set, it won't be "complete" in the sense that you can give it to somebody and it will have all of the files in it. If we need that capability, we'll add some kind of "complete" flag. BUG= R=scottmg@chromium.org Review URL: https://codereview.chromium.org/302033004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274024 0039d316-1c4b-4281-b951-d872f2087c98
* Don't inherit source sets across static libs in GN.brettw@chromium.org2014-05-301-0/+39
| | | | | | | | | | | | | Previously, source sets would be inherited up the dependency chain up to shared library or executable boundaries. But if there is a static library in the middle, it will include the code from the source set and the resulting shared library or executable will get the source set's code twice. This patch stops inheriting of source sets at static library boundaries, since the static library will include the source sets's code. BUG=377890 TBR=thakis@chromium.org Review URL: https://codereview.chromium.org/301243002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273858 0039d316-1c4b-4281-b951-d872f2087c98
* Forward dependent configs from groups properly in GN.brettw@chromium.org2014-04-241-0/+30
| | | | | | | | | | | Depending on a group is like depending on that group's dependants. This wasn't working for forwarding dependent configs. BUG=366814 R=scottmg@chromium.org Review URL: https://codereview.chromium.org/255603004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266049 0039d316-1c4b-4281-b951-d872f2087c98
* GN: toolchain threading cleanupbrettw@chromium.org2013-11-041-6/+7
| | | | | | | | | | | | | | | | | | Remove the thread-unsafe toolchain pointer on the otherwise-threadsafe Settings object. I replaced it with the toolchain label, and moved the is_default flag from the toolchain to the Settings object. This required that I pass the toolchain around in a few more places, but also simplifies some other cases. I removed the toolchain prefix from Ninja rules for the default toolchain since that's not necessary any more for GYP compat. This fixes an annoying double-free in the toolchain manager. I think my current refactor will clean this up in a later phase. R=scottmg@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=232657 Review URL: https://codereview.chromium.org/51693002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232755 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 232657 "GN: toolchain threading cleanup"thakis@chromium.org2013-11-031-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Broke linux clang bots: ../../tools/gn/ninja_helper_unittest.cc:20:9:error: field 'settings' will be initialized after field 'toolchain' [-Werror,-Wreorder] This happened on your try jobs too. > GN: toolchain threading cleanup > > Remove the thread-unsafe toolchain pointer on the otherwise-threadsafe Settings object. I replaced it with the toolchain label, and moved the is_default flag from the toolchain to the Settings object. > > This required that I pass the toolchain around in a few more places, but also simplifies some other cases. > > I removed the toolchain prefix from Ninja rules for the default toolchain since that's not necessary any more for GYP compat. > > This fixes an annoying double-free in the toolchain manager. I think my current refactor will clean this up in a later phase. > > R=scottmg@chromium.org > > Review URL: https://codereview.chromium.org/51693002 TBR=brettw@chromium.org Review URL: https://codereview.chromium.org/46313006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232661 0039d316-1c4b-4281-b951-d872f2087c98
* GN: toolchain threading cleanupbrettw@chromium.org2013-11-031-6/+7
| | | | | | | | | | | | | | | | Remove the thread-unsafe toolchain pointer on the otherwise-threadsafe Settings object. I replaced it with the toolchain label, and moved the is_default flag from the toolchain to the Settings object. This required that I pass the toolchain around in a few more places, but also simplifies some other cases. I removed the toolchain prefix from Ninja rules for the default toolchain since that's not necessary any more for GYP compat. This fixes an annoying double-free in the toolchain manager. I think my current refactor will clean this up in a later phase. R=scottmg@chromium.org Review URL: https://codereview.chromium.org/51693002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232657 0039d316-1c4b-4281-b951-d872f2087c98
* This is the first step of a refactor I'm going to do to separate filling out ↵brettw@chromium.org2013-11-011-26/+26
| | | | | | | | | | | | | | the target and connecting the dependency tree. I'm hoping this refactor will dramatically simplify the threading code and fix some flakiness. This change is mostly mechanical and replaces the lists of targets and config in the target object with a new pair that consists of a label and the pointer. Currently, they're still filled out at the same time. The new structure also tracks the origin of the thing which simplifies some of the tracking in the describe function. R=scottmg@chromium.org Review URL: https://codereview.chromium.org/48523006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232475 0039d316-1c4b-4281-b951-d872f2087c98
* Add inherited libs and lib_dirs to GN.brettw@chromium.org2013-10-071-16/+26
| | | | | | | | | | | | | | | | | The libs and lib_dirs are pushed up the tree until they reach a shared library or executable. Additionally, I added prefixes in the toolchain to specify these. This converts ldflags to be per-target rather than inherited which was previously used to implement this feature. Rename includes to include_dirs for consistency with lib_dirs. Remove the sill swap_in_* inline functions and just do foo().swap(). BUG= R=scottmg@chromium.org Review URL: https://codereview.chromium.org/26074002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227328 0039d316-1c4b-4281-b951-d872f2087c98
* Enable compiling GN by default.brettw@chromium.org2013-09-301-1/+1
| | | | | | | | | | | This removes the call to RestoreDefaultExceptionHandler on Mac. This isn't exported by base so breaks on the component build. IT doesn't matter since this is only related to breakpad which we don't use, so I just removed the call. BUG=288991 R=scottmg@chromium.org Review URL: https://codereview.chromium.org/25153002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@226050 0039d316-1c4b-4281-b951-d872f2087c98
* The ldflags are now inherited across module boundaries until a shared ↵brettw@chromium.org2013-09-101-0/+160
library or executable is encountered. This is necessary for the ldflags to actually have any effect in most cases. Since this flag is special there is some minor refactording in Target to make it work. The GYP command will now request that GYP itself output library dependencies which we'll suck in and use so that libraries inherited up the dependency tree in GYP will also be inherited into the GN portion of the build. Minor changes to label to make it easier to construct one with no toolchain specified. I added a helper class for iterating over the config values associated with a target and used it in a number of places. This ensures we always use the same order for walking these. I did a bunch of work on groups to make it so that if you depend on a group it is like depending directly on that group's deps. The chrome target will now compile on Linux with GN, using GYP versions of everything else. I added a number of other third_party libraries it needs. There are still some hacks and TODOs in this. R=thakis@chromium.org Review URL: https://codereview.chromium.org/23550007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222368 0039d316-1c4b-4281-b951-d872f2087c98