Index: tools/gcmole/gcmole.lua |
diff --git a/tools/gcmole/gcmole.lua b/tools/gcmole/gcmole.lua |
index f16ad8fd5d8010ddf1a3a9082ed4ebd521f84c13..5c5e502926a5a60f88dcc8460ff62897902ff458 100644 |
--- a/tools/gcmole/gcmole.lua |
+++ b/tools/gcmole/gcmole.lua |
@@ -184,26 +184,26 @@ end |
-- GYP file parsing |
local function ParseGYPFile() |
- local gyp = "" |
- local gyp_files = { "src/v8.gyp", "test/cctest/cctest.gyp" } |
- for i = 1, #gyp_files do |
- local f = assert(io.open(gyp_files[i]), "failed to open GYP file") |
- local t = f:read('*a') |
- gyp = gyp .. t |
- f:close() |
- end |
- |
local result = {} |
+ local gyp_files = { |
+ { "src/v8.gyp", "'([^']-%.cc)'", "src/" }, |
+ { "test/cctest/cctest.gyp", "'(test-[^']-%.cc)'", "test/cctest/" } |
+ } |
- for condition, sources in |
- gyp:gmatch "'sources': %[.-### gcmole%((.-)%) ###(.-)%]" do |
- if result[condition] == nil then result[condition] = {} end |
- for file in sources:gmatch "'%.%./%.%./src/([^']-%.cc)'" do |
- table.insert(result[condition], "src/" .. file) |
- end |
- for file in sources:gmatch "'(test-[^']-%.cc)'" do |
- table.insert(result[condition], "test/cctest/" .. file) |
+ for i = 1, #gyp_files do |
+ local filename = gyp_files[i][1] |
+ local pattern = gyp_files[i][2] |
+ local prefix = gyp_files[i][3] |
+ local gyp_file = assert(io.open(filename), "failed to open GYP file") |
+ local gyp = gyp_file:read('*a') |
+ for condition, sources in |
+ gyp:gmatch "'sources': %[.-### 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 |
+ gyp_file:close() |
end |
return result |