From 0eea5c9fc5c064036cf54f833266667ed8e07885 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 2 Jul 2016 00:17:18 +0200 Subject: [PATCH 1/2] CircleCI: Check for missing Bindings dependencies This commit fails the CircleCI tests on purpose, so that we know that the check works. --- circle.yml | 4 +- src/Bindings/CheckBindingsDependencies.lua | 108 +++++++++++++++++++++ 2 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 src/Bindings/CheckBindingsDependencies.lua diff --git a/circle.yml b/circle.yml index 341c87a1d..f13d02ce8 100644 --- a/circle.yml +++ b/circle.yml @@ -8,5 +8,5 @@ dependencies: test: override: - - cd src && find . -name \*.cpp -or -name \*.h > AllFiles.lst - - cd src && lua CheckBasicStyle.lua + - cd src && find . -name \*.cpp -or -name \*.h > AllFiles.lst && lua CheckBasicStyle.lua + - cd src/Bindings && lua CheckBindingsDependencies.lua diff --git a/src/Bindings/CheckBindingsDependencies.lua b/src/Bindings/CheckBindingsDependencies.lua new file mode 100644 index 000000000..c0565ead8 --- /dev/null +++ b/src/Bindings/CheckBindingsDependencies.lua @@ -0,0 +1,108 @@ +-- CheckBindingsDependencies.lua + +-- This script checks whether all files listed in AllToLua.pkg are also in the dependencies for bindings regeneration. +-- This script is run as part of the CircleCI tests + + + + + +--- Filenames that should be ignored in the AllToLua.pkg file: +-- Dictionary of "filename" -> true for each ignored filename +local g_ShouldIgnorePkg = +{ + -- ["../IniFile.h"] = true, +} + +--- Filenames that should be ignored in the CMakeLists.txt file: +-- Dictionary of "filename" -> true for each ignored filename +local g_ShouldIgnoreCMake = +{ + ["tolua"] = true, + ["../Bindings/AllToLua.pkg"] = true, + ["../Bindings/BindingsProcessor.lua"] = true, +} + + + + + +--- Returns a sorted list of all files listed in AllToLua.pkg +-- The returned table has both an array part (list of files) and a dictionary part ("filename" -> true) +local function getAllToLuaPkgFiles() + local res = {} + for line in io.lines("AllToLua.pkg") do + line:gsub("$cfile \"(.+)\"", -- Parse each line with a $cfile directive + function (a_FileName) + if (g_ShouldIgnorePkg[a_FileName]) then + return + end + a_FileName = a_FileName:gsub("../Bindings/", "") -- Normalize the path + table.insert(res, a_FileName) + res[a_FileName] = true + end + ) + end + table.sort(res) + return res +end + + + + + +--- Returns a sorted list of all files listed as dependencies in CMakeLists.txt +-- The returned table has both an array part (list of files) and a dictionary part ("filename" -> true) +local function getCMakeListsFiles() + local f = assert(io.open("CMakeLists.txt", "r")) + local contents = f:read("*all") + f:close() + local res = {} + contents:gsub("set%s*(%b())", -- Process each CMake's "set" statement + function (a_SetStatement) + if not(a_SetStatement:find("%(BINDING_DEPENDENCIES")) then + return + end + -- This is the statement setting the dependencies, parse the files: + a_SetStatement:gsub("%s(%S+)%s", + function (a_FileName) + if (g_ShouldIgnoreCMake[a_FileName]) then + return + end + a_FileName = a_FileName:gsub("../Bindings/", "") -- Normalize the path + table.insert(res, a_FileName) + res[a_FileName] = true + end + ) + end + ) + table.sort(res) + return res +end + + + + + +-- Check each set of files against the other: +local pkgFiles = getAllToLuaPkgFiles() +local cmakeFiles = getCMakeListsFiles() +local numMissingFiles = 0 +for _, fnam in ipairs(pkgFiles) do + if not(cmakeFiles[fnam]) then + io.stderr:write("Bindings dependency file ", fnam, " is not listed in src/Bindings/CMakeLists.txt\n") + numMissingFiles = numMissingFiles + 1 + end +end +for _, fnam in ipairs(cmakeFiles) do + if not(pkgFiles[fnam]) then + io.stderr:write("Bindings dependency file ", fnam, " is not listed in src/Bindings/AllToLua.pkg\n") + numMissingFiles = numMissingFiles + 1 + end +end + +-- If any mismatch was found, exit with an error code: +if (numMissingFiles > 0) then + io.stderr:write("Bindings dependency mismatches found: ", numMissingFiles, "\n") + os.exit(1) +end From a184f57eb306256126ec70fdea43ee43e1551221 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 2 Jul 2016 00:23:21 +0200 Subject: [PATCH 2/2] Bindings: Added missing dependencies. Fixes #3245 --- src/Bindings/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt index 4f25f2cf4..5c79225cc 100644 --- a/src/Bindings/CMakeLists.txt +++ b/src/Bindings/CMakeLists.txt @@ -69,22 +69,27 @@ set(BINDING_DEPENDENCIES ../BlockEntities/BeaconEntity.h ../BlockEntities/BlockEntity.h ../BlockEntities/BlockEntityWithItems.h + ../BlockEntities/BrewingstandEntity.h ../BlockEntities/ChestEntity.h + ../BlockEntities/CommandBlockEntity.h ../BlockEntities/DispenserEntity.h ../BlockEntities/DropSpenserEntity.h ../BlockEntities/DropperEntity.h ../BlockEntities/FurnaceEntity.h ../BlockEntities/HopperEntity.h ../BlockEntities/JukeboxEntity.h + ../BlockEntities/MobSpawnerEntity.h ../BlockEntities/NoteEntity.h ../BlockEntities/SignEntity.h ../BlockEntities/MobHeadEntity.h ../BlockEntities/FlowerPotEntity.h ../BlockID.h + ../BlockInfo.h ../BoundingBox.h ../ChatColor.h ../ChunkDef.h ../ClientHandle.h + ../CompositeChat.h ../CraftingRecipes.h ../Cuboid.h ../Defines.h @@ -111,13 +116,20 @@ set(BINDING_DEPENDENCIES ../Entities/TNTEntity.h ../Entities/WitherSkullEntity.h ../Generating/ChunkDesc.h + ../IniFile.h ../Inventory.h ../Item.h ../ItemGrid.h + ../Map.h + ../MapManager.h ../Mobs/Monster.h + ../Mobs/MonsterTypes.h ../OSSupport/File.h + ../Protocol/MojangAPI.h ../Root.h + ../Scoreboard.h ../Server.h + ../Statistics.h ../StringUtils.h ../Tracer.h ../UI/Window.h