QA: Move PCB parse util to combined tools exec
This means all the current Pcbnew utilities are all in a single executable. The tool is now run by: $ qa/pcbnew_tools/qa_pcbnew_tools pcb_parser <same arguments as before>
This commit is contained in:
parent
d7563c55c4
commit
e8afb14046
|
@ -26,7 +26,6 @@ add_subdirectory( shape_poly_set_refactor )
|
|||
# Utility/debugging/profiling programs
|
||||
add_subdirectory( common_tools )
|
||||
add_subdirectory( pcbnew_tools )
|
||||
add_subdirectory( pcb_parse_input )
|
||||
|
||||
# add_subdirectory( pcb_test_window )
|
||||
# add_subdirectory( polygon_triangulation )
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
# This program source code file is part of KiCad, a free EDA CAD application.
|
||||
#
|
||||
# Copyright (C) 2018 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
|
||||
|
||||
|
||||
if( BUILD_GITHUB_PLUGIN )
|
||||
set( GITHUB_PLUGIN_LIBRARIES github_plugin )
|
||||
endif()
|
||||
|
||||
add_dependencies( pnsrouter pcbcommon pcad2kicadpcb ${GITHUB_PLUGIN_LIBRARIES} )
|
||||
|
||||
add_executable( qa_pcb_parse_input
|
||||
# This is needed for the global mock objects
|
||||
../qa_utils/mocks.cpp
|
||||
|
||||
main.cpp
|
||||
|
||||
../../common/base_units.cpp
|
||||
../../common/xnode.cpp
|
||||
../../common/base_screen.cpp
|
||||
)
|
||||
|
||||
include_directories( BEFORE ${INC_BEFORE} )
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/polygon
|
||||
${CMAKE_SOURCE_DIR}/pcbnew
|
||||
${CMAKE_SOURCE_DIR}/common
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/router
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/tools
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/dialogs
|
||||
${Boost_INCLUDE_DIR}
|
||||
${INC_AFTER}
|
||||
)
|
||||
|
||||
target_link_libraries( qa_pcb_parse_input
|
||||
pcbcommon
|
||||
legacy_wx
|
||||
polygon
|
||||
pnsrouter
|
||||
common
|
||||
pcbcommon
|
||||
bitmaps
|
||||
polygon
|
||||
pnsrouter
|
||||
common
|
||||
pcbcommon
|
||||
bitmaps
|
||||
polygon
|
||||
pnsrouter
|
||||
common
|
||||
pcbcommon
|
||||
bitmaps
|
||||
polygon
|
||||
pnsrouter
|
||||
common
|
||||
pcbcommon
|
||||
3d-viewer
|
||||
bitmaps
|
||||
gal
|
||||
pcad2kicadpcb
|
||||
common
|
||||
pcbcommon
|
||||
${GITHUB_PLUGIN_LIBRARIES}
|
||||
qa_utils
|
||||
${wxWidgets_LIBRARIES}
|
||||
)
|
||||
|
||||
# we need to pretend to be something to appease the units code
|
||||
target_compile_definitions( qa_pcb_parse_input
|
||||
PRIVATE PCBNEW
|
||||
)
|
|
@ -31,6 +31,8 @@ add_executable( qa_pcbnew_tools
|
|||
|
||||
tools/drc_tool/drc_tool.cpp
|
||||
|
||||
tools/pcb_parser/pcb_parser_tool.cpp
|
||||
|
||||
# Older CMakes cannot link OBJECT libraries
|
||||
# https://cmake.org/pipermail/cmake/2013-November/056263.html
|
||||
$<TARGET_OBJECTS:pcbnew_kiface_objects>
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <utility_program.h>
|
||||
|
||||
#include "tools/drc_tool/drc_tool.h"
|
||||
#include "tools/pcb_parser/pcb_parser_tool.h"
|
||||
|
||||
/**
|
||||
* List of registered tools.
|
||||
|
@ -33,6 +34,7 @@
|
|||
*/
|
||||
const static std::vector<UTILITY_PROGRAM*> known_tools = {
|
||||
&drc_tool,
|
||||
&pcb_parser_tool,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2018 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
* 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
|
||||
|
@ -21,19 +21,28 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "pcb_parser_tool.h"
|
||||
|
||||
#include <kicad_plugin.h>
|
||||
#include <pcb_parser.h>
|
||||
#include <richio.h>
|
||||
#include <class_board_item.h>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
|
||||
#include <common.h>
|
||||
|
||||
#include <wx/cmdline.h>
|
||||
|
||||
#include <class_board_item.h>
|
||||
#include <kicad_plugin.h>
|
||||
#include <pcb_parser.h>
|
||||
#include <richio.h>
|
||||
|
||||
#include <wx/cmdline.h>
|
||||
|
||||
#include <stdstream_line_reader.h>
|
||||
#include <scoped_timer.h>
|
||||
#include <stdstream_line_reader.h>
|
||||
|
||||
using PARSE_DURATION = std::chrono::microseconds;
|
||||
|
||||
|
||||
/**
|
||||
* Parse a PCB or footprint file from the given input stream
|
||||
*
|
||||
|
@ -74,29 +83,23 @@ bool parse(std::istream& aStream, bool aVerbose )
|
|||
}
|
||||
|
||||
|
||||
static const wxCmdLineEntryDesc g_cmdLineDesc [] =
|
||||
{
|
||||
{ wxCMD_LINE_SWITCH, "h", "help",
|
||||
_( "displays help on the command line parameters" ).mb_str(),
|
||||
static const wxCmdLineEntryDesc g_cmdLineDesc[] = {
|
||||
{ wxCMD_LINE_SWITCH, "h", "help", _( "displays help on the command line parameters" ).mb_str(),
|
||||
wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
|
||||
{ wxCMD_LINE_SWITCH, "v", "verbose",
|
||||
_( "print parsing information").mb_str() },
|
||||
{ wxCMD_LINE_PARAM, nullptr, nullptr,
|
||||
_( "input file" ).mb_str(),
|
||||
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE },
|
||||
{ wxCMD_LINE_SWITCH, "v", "verbose", _( "print parsing information" ).mb_str() },
|
||||
{ wxCMD_LINE_PARAM, nullptr, nullptr, _( "input file" ).mb_str(), wxCMD_LINE_VAL_STRING,
|
||||
wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE },
|
||||
{ wxCMD_LINE_NONE }
|
||||
};
|
||||
|
||||
|
||||
enum RET_CODES
|
||||
enum PARSER_RET_CODES
|
||||
{
|
||||
OK = 0,
|
||||
BAD_CMDLINE = 1,
|
||||
PARSE_FAILED = 2,
|
||||
PARSE_FAILED = RET_CODES::TOOL_SPECIFIC,
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int pcb_parser_main_func( int argc, char** argv )
|
||||
{
|
||||
#ifdef __AFL_COMPILER
|
||||
__AFL_INIT();
|
||||
|
@ -105,7 +108,8 @@ int main(int argc, char** argv)
|
|||
wxMessageOutput::Set( new wxMessageOutputStderr );
|
||||
wxCmdLineParser cl_parser( argc, argv );
|
||||
cl_parser.SetDesc( g_cmdLineDesc );
|
||||
cl_parser.AddUsageText( _("This program parses PCB files, either from the "
|
||||
cl_parser.AddUsageText(
|
||||
_( "This program parses PCB files, either from the "
|
||||
"stdin stream or from the given filenames. This can be used either for "
|
||||
"standalone testing of the parser or for fuzz testing." ) );
|
||||
|
||||
|
@ -119,7 +123,6 @@ int main(int argc, char** argv)
|
|||
const bool verbose = cl_parser.Found( "verbose" );
|
||||
|
||||
bool ok = true;
|
||||
PARSE_DURATION duration;
|
||||
|
||||
const auto file_count = cl_parser.GetParamCount();
|
||||
|
||||
|
@ -152,7 +155,17 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
if( !ok )
|
||||
return RET_CODES::PARSE_FAILED;
|
||||
return PARSER_RET_CODES::PARSE_FAILED;
|
||||
|
||||
return RET_CODES::OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Define the tool interface
|
||||
*/
|
||||
UTILITY_PROGRAM pcb_parser_tool = {
|
||||
"pcb_parser",
|
||||
"Parse a KiCad PCB file",
|
||||
pcb_parser_main_func,
|
||||
};
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2018 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_PCB_PARSER_UTILITY_H
|
||||
#define PCBNEW_TOOLS_PCB_PARSER_UTILITY_H
|
||||
|
||||
#include <utility_program.h>
|
||||
|
||||
/// A tool to parse kicad PCBs from the command line
|
||||
extern UTILITY_PROGRAM pcb_parser_tool;
|
||||
|
||||
#endif //PCBNEW_TOOLS_PCB_PARSER_UTILITY_H
|
Loading…
Reference in New Issue