Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 -- Copyright 2011 the V8 project authors. All rights reserved. | 1 -- Copyright 2011 the V8 project authors. All rights reserved. |
| 2 -- Redistribution and use in source and binary forms, with or without | 2 -- Redistribution and use in source and binary forms, with or without |
| 3 -- modification, are permitted provided that the following conditions are | 3 -- modification, are permitted provided that the following conditions are |
| 4 -- met: | 4 -- met: |
| 5 -- | 5 -- |
| 6 -- * Redistributions of source code must retain the above copyright | 6 -- * Redistributions of source code must retain the above copyright |
| 7 -- notice, this list of conditions and the following disclaimer. | 7 -- notice, this list of conditions and the following disclaimer. |
| 8 -- * Redistributions in binary form must reproduce the above | 8 -- * Redistributions in binary form must reproduce the above |
| 9 -- copyright notice, this list of conditions and the following | 9 -- copyright notice, this list of conditions and the following |
| 10 -- disclaimer in the documentation and/or other materials provided | 10 -- disclaimer in the documentation and/or other materials provided |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 local pipe = io.popen(action) | 176 local pipe = io.popen(action) |
| 177 local success = SplitResults(pipe:lines(), func) | 177 local success = SplitResults(pipe:lines(), func) |
| 178 local closed = pipe:close() | 178 local closed = pipe:close() |
| 179 if not (success and closed) then error("Failed to run: " .. action) end | 179 if not (success and closed) then error("Failed to run: " .. action) end |
| 180 end | 180 end |
| 181 end | 181 end |
| 182 | 182 |
| 183 ------------------------------------------------------------------------------- | 183 ------------------------------------------------------------------------------- |
| 184 -- GYP file parsing | 184 -- GYP file parsing |
| 185 | 185 |
| 186 local function ParseGYPFile() | 186 local function ParseGYPFile() |
|
Michael Starzinger
2016/09/21 11:24:48
nit: Lets also add a TODO here that this will be r
Michael Achenbach
2016/09/21 11:40:56
Done in patch 9. Though, any attempt to remove our
| |
| 187 local result = {} | 187 local result = {} |
| 188 local gyp_files = { | 188 local gyp_files = { |
| 189 { "src/v8.gyp", "'([^']-%.cc)'", "src/" }, | 189 { "src/v8.gyp", "'([^']-%.cc)'", "src/" }, |
| 190 { "test/cctest/cctest.gyp", "'(test-[^']-%.cc)'", "test/cctest/" } | 190 { "test/cctest/cctest.gyp", "'(test-[^']-%.cc)'", "test/cctest/" } |
| 191 } | 191 } |
| 192 | 192 |
| 193 for i = 1, #gyp_files do | 193 for i = 1, #gyp_files do |
| 194 local filename = gyp_files[i][1] | 194 local filename = gyp_files[i][1] |
| 195 local pattern = gyp_files[i][2] | 195 local pattern = gyp_files[i][2] |
| 196 local prefix = gyp_files[i][3] | 196 local prefix = gyp_files[i][3] |
| 197 local gyp_file = assert(io.open(filename), "failed to open GYP file") | 197 local gyp_file = assert(io.open(filename), "failed to open GYP file") |
| 198 local gyp = gyp_file:read('*a') | 198 local gyp = gyp_file:read('*a') |
| 199 for condition, sources in | 199 for condition, sources in |
| 200 gyp:gmatch "%[.-### gcmole%((.-)%) ###(.-)%]" do | 200 gyp:gmatch "%[.-### gcmole%((.-)%) ###(.-)%]" do |
| 201 if result[condition] == nil then result[condition] = {} end | 201 if result[condition] == nil then result[condition] = {} end |
| 202 for file in sources:gmatch(pattern) do | 202 for file in sources:gmatch(pattern) do |
| 203 table.insert(result[condition], prefix .. file) | 203 table.insert(result[condition], prefix .. file) |
| 204 end | 204 end |
| 205 end | 205 end |
| 206 gyp_file:close() | 206 gyp_file:close() |
| 207 end | 207 end |
| 208 | 208 |
| 209 return result | 209 return result |
| 210 end | 210 end |
| 211 | 211 |
| 212 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.
| |
| 213 local result = {} | |
| 214 local gn_files = { | |
| 215 { "BUILD.gn", '"([^"]-%.cc)"', "" }, | |
| 216 { "test/cctest/BUILD.gn", '"(test-[^"]-%.cc)"', "test/cctest/" } | |
| 217 } | |
| 218 | |
| 219 for i = 1, #gn_files do | |
| 220 local filename = gn_files[i][1] | |
| 221 local pattern = gn_files[i][2] | |
| 222 local prefix = gn_files[i][3] | |
| 223 local gn_file = assert(io.open(filename), "failed to open GN file") | |
| 224 local gn = gn_file:read('*a') | |
| 225 for condition, sources in | |
| 226 gn:gmatch "### gcmole%((.-)%) ###(.-)%]" do | |
| 227 if result[condition] == nil then result[condition] = {} end | |
| 228 for file in sources:gmatch(pattern) do | |
| 229 table.insert(result[condition], prefix .. file) | |
| 230 end | |
| 231 end | |
| 232 gn_file:close() | |
| 233 end | |
| 234 | |
| 235 return result | |
| 236 end | |
| 237 | |
| 212 local function EvaluateCondition(cond, props) | 238 local function EvaluateCondition(cond, props) |
| 213 if cond == 'all' then return true end | 239 if cond == 'all' then return true end |
| 214 | 240 |
| 215 local p, v = cond:match "(%w+):(%w+)" | 241 local p, v = cond:match "(%w+):(%w+)" |
| 216 | 242 |
| 217 assert(p and v, "failed to parse condition: " .. cond) | 243 assert(p and v, "failed to parse condition: " .. cond) |
| 218 assert(props[p] ~= nil, "undefined configuration property: " .. p) | 244 assert(props[p] ~= nil, "undefined configuration property: " .. p) |
| 219 | 245 |
| 220 return props[p] == v | 246 return props[p] == v |
| 221 end | 247 end |
| 222 | 248 |
| 223 local function BuildFileList(sources, props) | 249 local function BuildFileList(sources, props) |
| 224 local list = {} | 250 local list = {} |
| 225 for condition, files in pairs(sources) do | 251 for condition, files in pairs(sources) do |
| 226 if EvaluateCondition(condition, props) then | 252 if EvaluateCondition(condition, props) then |
| 227 for i = 1, #files do table.insert(list, files[i]) end | 253 for i = 1, #files do table.insert(list, files[i]) end |
| 228 end | 254 end |
| 229 end | 255 end |
| 230 return list | 256 return list |
| 231 end | 257 end |
| 232 | 258 |
| 233 local sources = ParseGYPFile() | 259 |
| 260 local gyp_sources = ParseGYPFile() | |
| 261 local gn_sources = ParseGNFile() | |
| 262 | |
| 263 -- TODO(machenbach): Remove this comparison logic when deprecating gyp. | |
| 264 local function CompareSources(sources1, sources2, what) | |
| 265 for condition, files1 in pairs(sources1) do | |
| 266 local files2 = sources2[condition] | |
| 267 assert( | |
| 268 files2 ~= nil, | |
| 269 "Missing gcmole condition in " .. what .. ": " .. condition) | |
| 270 | |
| 271 -- Turn into set for speed. | |
| 272 files2_set = {} | |
| 273 for i, file in pairs(files2) do files2_set[file] = true end | |
| 274 | |
| 275 for i, file in pairs(files1) do | |
| 276 assert( | |
| 277 files2_set[file] ~= nil, | |
| 278 "Missing file " .. file .. " in " .. what .. " for condition " .. | |
| 279 condition) | |
| 280 end | |
| 281 end | |
| 282 end | |
| 283 | |
|
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!
| |
| 284 CompareSources(gyp_sources, gn_sources, "GN") | |
| 285 CompareSources(gn_sources, gyp_sources, "GYP") | |
| 286 | |
| 234 | 287 |
| 235 local function FilesForArch(arch) | 288 local function FilesForArch(arch) |
| 236 return BuildFileList(sources, { os = 'linux', | 289 return BuildFileList(gn_sources, { os = 'linux', |
| 237 arch = arch, | 290 arch = arch, |
| 238 mode = 'debug', | 291 mode = 'debug', |
| 239 simulator = ''}) | 292 simulator = ''}) |
| 240 end | 293 end |
| 241 | 294 |
| 242 local mtConfig = {} | 295 local mtConfig = {} |
| 243 | 296 |
| 244 mtConfig.__index = mtConfig | 297 mtConfig.__index = mtConfig |
| 245 | 298 |
| 246 local function config (t) return setmetatable(t, mtConfig) end | 299 local function config (t) return setmetatable(t, mtConfig) end |
| 247 | 300 |
| 248 function mtConfig:extend(t) | 301 function mtConfig:extend(t) |
| 249 local e = {} | 302 local e = {} |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 443 | 496 |
| 444 for _, arch in ipairs(ARCHS) do | 497 for _, arch in ipairs(ARCHS) do |
| 445 if not ARCHITECTURES[arch] then | 498 if not ARCHITECTURES[arch] then |
| 446 error ("Unknown arch: " .. arch) | 499 error ("Unknown arch: " .. arch) |
| 447 end | 500 end |
| 448 | 501 |
| 449 errors = SafeCheckCorrectnessForArch(arch, report) or errors | 502 errors = SafeCheckCorrectnessForArch(arch, report) or errors |
| 450 end | 503 end |
| 451 | 504 |
| 452 os.exit(errors and 1 or 0) | 505 os.exit(errors and 1 or 0) |
| OLD | NEW |