From 6729842441f6c8b292a533817483be5de52a2475 Mon Sep 17 00:00:00 2001 From: John Beard Date: Tue, 22 Jan 2019 22:56:10 +0000 Subject: [PATCH] QA: Reinstate polygon_generator as a sub-util of qa_pcbnew_tools This program has been disabled for some time, but it's not broken (even if the CMake was!). Merging into the pcbnew_tools QA program reduces the CMake burden and puts this tool in the same place as the others. --- qa/CMakeLists.txt | 1 - qa/pcbnew_tools/CMakeLists.txt | 2 + qa/pcbnew_tools/pcbnew_tools.cpp | 2 + .../polygon_generator/polygon_generator.cpp} | 33 +++++-- .../polygon_generator/polygon_generator.h | 32 +++++++ qa/polygon_generator/CMakeLists.txt | 92 ------------------- 6 files changed, 59 insertions(+), 103 deletions(-) rename qa/{polygon_generator/test_polygon_generator.cpp => pcbnew_tools/tools/polygon_generator/polygon_generator.cpp} (85%) create mode 100644 qa/pcbnew_tools/tools/polygon_generator/polygon_generator.h delete mode 100644 qa/polygon_generator/CMakeLists.txt diff --git a/qa/CMakeLists.txt b/qa/CMakeLists.txt index f178e775f6..179962ebe1 100644 --- a/qa/CMakeLists.txt +++ b/qa/CMakeLists.txt @@ -29,4 +29,3 @@ add_subdirectory( pcbnew_tools ) # add_subdirectory( pcb_test_window ) # add_subdirectory( polygon_triangulation ) -# add_subdirectory( polygon_generator ) diff --git a/qa/pcbnew_tools/CMakeLists.txt b/qa/pcbnew_tools/CMakeLists.txt index 1e0e09739d..9b01c24e10 100644 --- a/qa/pcbnew_tools/CMakeLists.txt +++ b/qa/pcbnew_tools/CMakeLists.txt @@ -33,6 +33,8 @@ add_executable( qa_pcbnew_tools tools/pcb_parser/pcb_parser_tool.cpp + tools/polygon_generator/polygon_generator.cpp + # Older CMakes cannot link OBJECT libraries # https://cmake.org/pipermail/cmake/2013-November/056263.html $ diff --git a/qa/pcbnew_tools/pcbnew_tools.cpp b/qa/pcbnew_tools/pcbnew_tools.cpp index 7c4c4824a6..dc19d03553 100644 --- a/qa/pcbnew_tools/pcbnew_tools.cpp +++ b/qa/pcbnew_tools/pcbnew_tools.cpp @@ -25,6 +25,7 @@ #include "tools/drc_tool/drc_tool.h" #include "tools/pcb_parser/pcb_parser_tool.h" +#include "tools/polygon_generator/polygon_generator.h" /** * List of registered tools. @@ -35,6 +36,7 @@ const static std::vector known_tools = { &drc_tool, &pcb_parser_tool, + &polygon_generator_tool, }; diff --git a/qa/polygon_generator/test_polygon_generator.cpp b/qa/pcbnew_tools/tools/polygon_generator/polygon_generator.cpp similarity index 85% rename from qa/polygon_generator/test_polygon_generator.cpp rename to qa/pcbnew_tools/tools/polygon_generator/polygon_generator.cpp index 5981d527c6..09af991443 100644 --- a/qa/polygon_generator/test_polygon_generator.cpp +++ b/qa/pcbnew_tools/tools/polygon_generator/polygon_generator.cpp @@ -3,6 +3,7 @@ * * Copyright (C) 2017 CERN * @author Tomasz Wlostowski + * Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -22,24 +23,26 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include -#include +#include "polygon_generator.h" + #include +#include +#include #include #include #include -#include -#include -#include #include #include +#include +#include +#include BOARD* loadBoard( const std::string& filename ) { PLUGIN::RELEASER pi( new PCB_IO ); - BOARD* brd = nullptr; + BOARD* brd = nullptr; try { @@ -47,8 +50,7 @@ BOARD* loadBoard( const std::string& filename ) } catch( const IO_ERROR& ioe ) { - wxString msg = wxString::Format( _( "Error loading board.\n%s" ), - ioe.Problem() ); + wxString msg = wxString::Format( _( "Error loading board.\n%s" ), ioe.Problem() ); printf( "%s\n", (const char*) msg.mb_str() ); return nullptr; @@ -72,12 +74,12 @@ void process( const BOARD_CONNECTED_ITEM* item, int net ) item->TransformShapeWithClearanceToPolygon( pset, 1, segsPerCircle, correctionFactor ); - SHAPE_FILE_IO shapeIo; // default = stdout + SHAPE_FILE_IO shapeIo; // default = stdout shapeIo.Write( &pset ); } -int main( int argc, char* argv[] ) +int polygon_gererator_main( int argc, char* argv[] ) { if( argc < 2 ) { @@ -109,4 +111,15 @@ int main( int argc, char* argv[] ) printf( "endnet\n" ); } + + return 0; } + +/* + * Define the tool interface + */ +UTILITY_PROGRAM polygon_generator_tool = { + "polygon_generator", + "Dump board geometry as a set of polygons", + polygon_gererator_main, +}; \ No newline at end of file diff --git a/qa/pcbnew_tools/tools/polygon_generator/polygon_generator.h b/qa/pcbnew_tools/tools/polygon_generator/polygon_generator.h new file mode 100644 index 0000000000..a1faee2988 --- /dev/null +++ b/qa/pcbnew_tools/tools/polygon_generator/polygon_generator.h @@ -0,0 +1,32 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef PCBNEW_TOOLS_POLYGON_GENERATOR_UTILITY_H +#define PCBNEW_TOOLS_POLYGON_GENERATOR_UTILITY_H + +#include + +/// A tool to parse kicad PCBs from the command line +extern UTILITY_PROGRAM polygon_generator_tool; + +#endif //PCBNEW_TOOLS_POLYGON_GENERATOR_UTILITY_H \ No newline at end of file diff --git a/qa/polygon_generator/CMakeLists.txt b/qa/polygon_generator/CMakeLists.txt deleted file mode 100644 index ba79297fbf..0000000000 --- a/qa/polygon_generator/CMakeLists.txt +++ /dev/null @@ -1,92 +0,0 @@ -# -# This program source code file is part of KiCad, a free EDA CAD application. -# -# Copyright (C) 2017 CERN -# @author Alejandro GarcĂ­a Montoro -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, you may find one here: -# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# or you may search the http://www.gnu.org website for the version 2 license, -# or you may write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - -#find_package(Boost COMPONENTS unit_test_framework REQUIRED) -#find_package( wxWidgets 3.0.0 COMPONENTS gl aui adv html core net base xml stc REQUIRED ) - -add_definitions(-DPCBNEW -DBOOST_TEST_DYN_LINK) - -if( BUILD_GITHUB_PLUGIN ) - set( GITHUB_PLUGIN_LIBRARIES github_plugin ) -endif() - -add_dependencies( pnsrouter pcbcommon pcad2kicadpcb ${GITHUB_PLUGIN_LIBRARIES} ) - -add_executable(test_polygon_generator - ../qa_utils/mocks.cpp - ../../common/base_units.cpp - test_polygon_generator.cpp -) - -include_directories( BEFORE ${INC_BEFORE} ) -include_directories( - ${CMAKE_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/include - ${CMAKE_SOURCE_DIR}/3d-viewer - ${CMAKE_SOURCE_DIR}/common - ${CMAKE_SOURCE_DIR}/pcbnew - ${CMAKE_SOURCE_DIR}/pcbnew/router - ${CMAKE_SOURCE_DIR}/pcbnew/tools - ${CMAKE_SOURCE_DIR}/pcbnew/dialogs - ${CMAKE_SOURCE_DIR}/polygon - ${CMAKE_SOURCE_DIR}/common/geometry - ${CMAKE_SOURCE_DIR}/qa/common - ${Boost_INCLUDE_DIR} - ${INC_AFTER} -) - -target_link_libraries( test_polygon_generator - polygon - pnsrouter - common - pcbcommon - bitmaps - polygon - pnsrouter - common - pcbcommon - bitmaps - polygon - pnsrouter - common - pcbcommon - bitmaps - polygon - pnsrouter - common - pcbcommon - bitmaps - gal - pcad2kicadpcb - common - pcbcommon - ${GITHUB_PLUGIN_LIBRARIES} - common - pcbcommon - ${Boost_FILESYSTEM_LIBRARY} - ${Boost_SYSTEM_LIBRARY} - ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} - ${wxWidgets_LIBRARIES} -) - -