Chromium Code Reviews| Index: tools/gcmole/gcmole.lua |
| diff --git a/tools/gcmole/gcmole.lua b/tools/gcmole/gcmole.lua |
| index bdbdf36a416c6a5f62a184cc2844bb242ca6cc88..c9e8f3a970d093fb0020f998764ed93b1d512f99 100644 |
| --- a/tools/gcmole/gcmole.lua |
| +++ b/tools/gcmole/gcmole.lua |
| @@ -209,6 +209,32 @@ local function ParseGYPFile() |
| return result |
| end |
| +local function ParseGNFile() |
|
Michael Achenbach
2016/09/21 11:11:19
c:p of the function above with modifications. The
Michael Starzinger
2016/09/21 11:24:48
Acknowledged.
|
| + local result = {} |
| + local gn_files = { |
| + { "BUILD.gn", '"([^"]-%.cc)"', "" }, |
| + { "test/cctest/BUILD.gn", '"(test-[^"]-%.cc)"', "test/cctest/" } |
| + } |
| + |
| + for i = 1, #gn_files do |
| + local filename = gn_files[i][1] |
| + local pattern = gn_files[i][2] |
| + local prefix = gn_files[i][3] |
| + local gn_file = assert(io.open(filename), "failed to open GN file") |
| + local gn = gn_file:read('*a') |
| + for condition, sources in |
| + gn:gmatch "### gcmole%((.-)%) ###(.-)%]" do |
| + if result[condition] == nil then result[condition] = {} end |
| + for file in sources:gmatch(pattern) do |
| + table.insert(result[condition], prefix .. file) |
| + end |
| + end |
| + gn_file:close() |
| + end |
| + |
| + return result |
| +end |
| + |
| local function EvaluateCondition(cond, props) |
| if cond == 'all' then return true end |
| @@ -230,13 +256,40 @@ local function BuildFileList(sources, props) |
| return list |
| end |
| -local sources = ParseGYPFile() |
| + |
| +local gyp_sources = ParseGYPFile() |
| +local gn_sources = ParseGNFile() |
| + |
| +-- TODO(machenbach): Remove this comparison logic when deprecating gyp. |
| +local function CompareSources(sources1, sources2, what) |
| + for condition, files1 in pairs(sources1) do |
| + local files2 = sources2[condition] |
| + assert( |
| + files2 ~= nil, |
| + "Missing gcmole condition in " .. what .. ": " .. condition) |
| + |
| + -- Turn into set for speed. |
| + files2_set = {} |
| + for i, file in pairs(files2) do files2_set[file] = true end |
| + |
| + for i, file in pairs(files1) do |
| + assert( |
| + files2_set[file] ~= nil, |
| + "Missing file " .. file .. " in " .. what .. " for condition " .. |
| + condition) |
| + end |
| + end |
| +end |
| + |
|
Michael Achenbach
2016/09/21 11:11:19
The outcome of this comparison can be seen in patc
Michael Starzinger
2016/09/21 11:24:48
Acknowledged. Thanks!
|
| +CompareSources(gyp_sources, gn_sources, "GN") |
| +CompareSources(gn_sources, gyp_sources, "GYP") |
| + |
| local function FilesForArch(arch) |
| - return BuildFileList(sources, { os = 'linux', |
| - arch = arch, |
| - mode = 'debug', |
| - simulator = ''}) |
| + return BuildFileList(gn_sources, { os = 'linux', |
| + arch = arch, |
| + mode = 'debug', |
| + simulator = ''}) |
| end |
| local mtConfig = {} |