Rename the bom cli to pythonbom since we'll have a real bom system later
This commit is contained in:
parent
f5770fe7e0
commit
bae8cb55c0
|
@ -18,32 +18,24 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef JOB_EXPORT_SCH_BOM_H
|
||||
#define JOB_EXPORT_SCH_BOM_H
|
||||
#ifndef JOB_EXPORT_SCH_PYTHONBOM_H
|
||||
#define JOB_EXPORT_SCH_PYTHONBOM_H
|
||||
|
||||
#include <wx/string.h>
|
||||
#include "job.h"
|
||||
|
||||
class JOB_EXPORT_SCH_BOM : public JOB
|
||||
class JOB_EXPORT_SCH_PYTHONBOM : public JOB
|
||||
{
|
||||
public:
|
||||
JOB_EXPORT_SCH_BOM( bool aIsCli ) :
|
||||
JOB( "bom", aIsCli ),
|
||||
JOB_EXPORT_SCH_PYTHONBOM( bool aIsCli ) :
|
||||
JOB( "pythonbom", aIsCli ),
|
||||
m_filename(),
|
||||
m_outputFile()
|
||||
{
|
||||
format = FORMAT::XML;
|
||||
}
|
||||
|
||||
wxString m_filename;
|
||||
wxString m_outputFile;
|
||||
|
||||
enum class FORMAT
|
||||
{
|
||||
XML
|
||||
};
|
||||
|
||||
FORMAT format;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "eeschema_jobs_handler.h"
|
||||
#include <cli/exit_codes.h>
|
||||
#include <jobs/job_export_sch_bom.h>
|
||||
#include <jobs/job_export_sch_pythonbom.h>
|
||||
#include <jobs/job_export_sch_netlist.h>
|
||||
#include <jobs/job_export_sch_pdf.h>
|
||||
#include <jobs/job_export_sch_svg.h>
|
||||
|
@ -53,8 +53,8 @@
|
|||
|
||||
EESCHEMA_JOBS_HANDLER::EESCHEMA_JOBS_HANDLER()
|
||||
{
|
||||
Register( "bom",
|
||||
std::bind( &EESCHEMA_JOBS_HANDLER::JobExportBom, this, std::placeholders::_1 ) );
|
||||
Register( "pythonbom",
|
||||
std::bind( &EESCHEMA_JOBS_HANDLER::JobExportPythonBom, this, std::placeholders::_1 ) );
|
||||
Register( "netlist",
|
||||
std::bind( &EESCHEMA_JOBS_HANDLER::JobExportNetlist, this, std::placeholders::_1 ) );
|
||||
Register( "pdf",
|
||||
|
@ -261,9 +261,9 @@ int EESCHEMA_JOBS_HANDLER::JobExportNetlist( JOB* aJob )
|
|||
}
|
||||
|
||||
|
||||
int EESCHEMA_JOBS_HANDLER::JobExportBom( JOB* aJob )
|
||||
int EESCHEMA_JOBS_HANDLER::JobExportPythonBom( JOB* aJob )
|
||||
{
|
||||
JOB_EXPORT_SCH_BOM* aNetJob = dynamic_cast<JOB_EXPORT_SCH_BOM*>( aJob );
|
||||
JOB_EXPORT_SCH_PYTHONBOM* aNetJob = dynamic_cast<JOB_EXPORT_SCH_PYTHONBOM*>( aJob );
|
||||
|
||||
SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aNetJob->m_filename, SCH_IO_MGR::SCH_KICAD );
|
||||
|
||||
|
@ -297,33 +297,28 @@ int EESCHEMA_JOBS_HANDLER::JobExportBom( JOB* aJob )
|
|||
wxPrintf( _( "Warning: duplicate sheet names.\n" ) );
|
||||
}
|
||||
|
||||
if( aNetJob->format == JOB_EXPORT_SCH_BOM::FORMAT::XML )
|
||||
std::unique_ptr<NETLIST_EXPORTER_XML> xmlNetlist =
|
||||
std::make_unique<NETLIST_EXPORTER_XML>( sch );
|
||||
|
||||
wxString fileExt = wxS( "xml" );
|
||||
|
||||
if( aNetJob->m_outputFile.IsEmpty() )
|
||||
{
|
||||
std::unique_ptr<NETLIST_EXPORTER_XML> xmlNetlist =
|
||||
std::make_unique<NETLIST_EXPORTER_XML>( sch );
|
||||
wxFileName fn = sch->GetFileName();
|
||||
fn.SetName( fn.GetName() + "-bom" );
|
||||
fn.SetExt( fileExt );
|
||||
|
||||
wxString fileExt = wxS( "xml" );
|
||||
|
||||
if( aNetJob->m_outputFile.IsEmpty() )
|
||||
{
|
||||
wxFileName fn = sch->GetFileName();
|
||||
fn.SetName( fn.GetName() + "-bom" );
|
||||
fn.SetExt( fileExt );
|
||||
|
||||
aNetJob->m_outputFile = fn.GetFullName();
|
||||
}
|
||||
|
||||
bool res = xmlNetlist->WriteNetlist( aNetJob->m_outputFile, GNL_OPT_BOM, *this );
|
||||
|
||||
if( !res )
|
||||
{
|
||||
return CLI::EXIT_CODES::ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
return CLI::EXIT_CODES::OK;
|
||||
aNetJob->m_outputFile = fn.GetFullName();
|
||||
}
|
||||
|
||||
return CLI::EXIT_CODES::ERR_UNKNOWN;
|
||||
bool res = xmlNetlist->WriteNetlist( aNetJob->m_outputFile, GNL_OPT_BOM, *this );
|
||||
|
||||
if( !res )
|
||||
{
|
||||
return CLI::EXIT_CODES::ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
return CLI::EXIT_CODES::OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class EESCHEMA_JOBS_HANDLER : public JOB_DISPATCHER, REPORTER
|
|||
{
|
||||
public:
|
||||
EESCHEMA_JOBS_HANDLER();
|
||||
int JobExportBom( JOB* aJob );
|
||||
int JobExportPythonBom( JOB* aJob );
|
||||
int JobExportNetlist( JOB* aJob );
|
||||
int JobExportPdf( JOB* aJob );
|
||||
int JobExportSvg( JOB* aJob );
|
||||
|
|
|
@ -54,15 +54,7 @@ bool NETLIST_EXPORTER_XML::WriteNetlist( const wxString& aOutFileName, unsigned
|
|||
return false;
|
||||
|
||||
wxXmlDocument xdoc;
|
||||
|
||||
unsigned aCtl = aNetlistOptions;
|
||||
|
||||
if( aNetlistOptions & GNL_OPT_BOM )
|
||||
aCtl |= ( GNL_SYMBOLS | GNL_HEADER | GNL_PARTS );
|
||||
else
|
||||
aCtl |= GNL_ALL;
|
||||
|
||||
xdoc.SetRoot( makeRoot( aCtl ) );
|
||||
xdoc.SetRoot( makeRoot( GNL_ALL | aNetlistOptions ) );
|
||||
|
||||
return xdoc.Save( stream, 2 /* indent bug, today was ignored by wxXml lib */ );
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ set( KICAD_SRCS
|
|||
cli/command_export_pcb_svg.cpp
|
||||
cli/command_fp_upgrade.cpp
|
||||
cli/command_pcb_export.cpp
|
||||
cli/command_export_sch_bom.cpp
|
||||
cli/command_export_sch_pythonbom.cpp
|
||||
cli/command_export_sch_netlist.cpp
|
||||
cli/command_export_sch_pdf.cpp
|
||||
cli/command_export_sch_svg.cpp
|
||||
|
|
|
@ -18,29 +18,26 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "command_export_sch_bom.h"
|
||||
#include "command_export_sch_pythonbom.h"
|
||||
#include <cli/exit_codes.h>
|
||||
#include "jobs/job_export_sch_bom.h"
|
||||
#include "jobs/job_export_sch_pythonbom.h"
|
||||
#include <kiface_base.h>
|
||||
#include <layer_ids.h>
|
||||
#include <wx/crt.h>
|
||||
|
||||
#include <macros.h>
|
||||
|
||||
#define ARG_FORMAT "--format"
|
||||
|
||||
CLI::EXPORT_SCH_BOM_COMMAND::EXPORT_SCH_BOM_COMMAND() : EXPORT_PCB_BASE_COMMAND( "bom" )
|
||||
CLI::EXPORT_SCH_PYTHONBOM_COMMAND::EXPORT_SCH_PYTHONBOM_COMMAND() :
|
||||
EXPORT_PCB_BASE_COMMAND( "python-bom" )
|
||||
{
|
||||
m_argParser.add_argument( ARG_FORMAT )
|
||||
.default_value( std::string( "xml" ) )
|
||||
.help( UTF8STDSTR( _( "Bom output format, valid options: xml" ) ) );
|
||||
}
|
||||
|
||||
|
||||
int CLI::EXPORT_SCH_BOM_COMMAND::Perform( KIWAY& aKiway )
|
||||
int CLI::EXPORT_SCH_PYTHONBOM_COMMAND::Perform( KIWAY& aKiway )
|
||||
{
|
||||
std::unique_ptr<JOB_EXPORT_SCH_BOM> bomJob =
|
||||
std::make_unique<JOB_EXPORT_SCH_BOM>( true );
|
||||
std::unique_ptr<JOB_EXPORT_SCH_PYTHONBOM> bomJob =
|
||||
std::make_unique<JOB_EXPORT_SCH_PYTHONBOM>( true );
|
||||
|
||||
bomJob->m_filename = FROM_UTF8( m_argParser.get<std::string>( ARG_INPUT ).c_str() );
|
||||
bomJob->m_outputFile = FROM_UTF8( m_argParser.get<std::string>( ARG_OUTPUT ).c_str() );
|
||||
|
@ -51,16 +48,6 @@ int CLI::EXPORT_SCH_BOM_COMMAND::Perform( KIWAY& aKiway )
|
|||
return EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
}
|
||||
|
||||
wxString format = FROM_UTF8( m_argParser.get<std::string>( ARG_FORMAT ).c_str() );
|
||||
if( format == "xml" )
|
||||
{
|
||||
bomJob->format = JOB_EXPORT_SCH_BOM::FORMAT::XML;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFprintf( stderr, _( "Invalid format\n" ) );
|
||||
return EXIT_CODES::ERR_ARGS;
|
||||
}
|
||||
|
||||
int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, bomJob.get() );
|
||||
|
|
@ -18,17 +18,17 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_EXPORT_SCH_BOM_H
|
||||
#define COMMAND_EXPORT_SCH_BOM_H
|
||||
#ifndef COMMAND_EXPORT_SCH_PYTHONBOM_H
|
||||
#define COMMAND_EXPORT_SCH_PYTHONBOM_H
|
||||
|
||||
#include "command_export_pcb_base.h"
|
||||
|
||||
namespace CLI
|
||||
{
|
||||
class EXPORT_SCH_BOM_COMMAND : public EXPORT_PCB_BASE_COMMAND
|
||||
class EXPORT_SCH_PYTHONBOM_COMMAND : public EXPORT_PCB_BASE_COMMAND
|
||||
{
|
||||
public:
|
||||
EXPORT_SCH_BOM_COMMAND();
|
||||
EXPORT_SCH_PYTHONBOM_COMMAND();
|
||||
|
||||
int Perform( KIWAY& aKiway ) override;
|
||||
};
|
|
@ -56,7 +56,7 @@
|
|||
#include "cli/command_export_pcb_pos.h"
|
||||
#include "cli/command_export_pcb_svg.h"
|
||||
#include "cli/command_export_pcb_step.h"
|
||||
#include "cli/command_export_sch_bom.h"
|
||||
#include "cli/command_export_sch_pythonbom.h"
|
||||
#include "cli/command_export_sch_netlist.h"
|
||||
#include "cli/command_export_sch_pdf.h"
|
||||
#include "cli/command_export_sch_svg.h"
|
||||
|
@ -113,25 +113,25 @@ struct COMMAND_ENTRY
|
|||
handler( aHandler ), subCommands( aSub ){};
|
||||
};
|
||||
|
||||
static CLI::EXPORT_PCB_DRILL_COMMAND exportPcbDrillCmd{};
|
||||
static CLI::EXPORT_PCB_DXF_COMMAND exportPcbDxfCmd{};
|
||||
static CLI::EXPORT_PCB_STEP_COMMAND exportPcbStepCmd{};
|
||||
static CLI::EXPORT_PCB_SVG_COMMAND exportPcbSvgCmd{};
|
||||
static CLI::EXPORT_PCB_PDF_COMMAND exportPcbPdfCmd{};
|
||||
static CLI::EXPORT_PCB_POS_COMMAND exportPcbPosCmd{};
|
||||
static CLI::EXPORT_PCB_GERBER_COMMAND exportPcbGerberCmd{};
|
||||
static CLI::EXPORT_PCB_COMMAND exportPcbCmd{};
|
||||
static CLI::PCB_COMMAND pcbCmd{};
|
||||
static CLI::EXPORT_SCH_COMMAND exportSchCmd{};
|
||||
static CLI::SCH_COMMAND schCmd{};
|
||||
static CLI::EXPORT_SCH_BOM_COMMAND exportSchBomCmd{};
|
||||
static CLI::EXPORT_SCH_NETLIST_COMMAND exportSchNetlistCmd{};
|
||||
static CLI::EXPORT_SCH_PDF_COMMAND exportSchPdfCmd{};
|
||||
static CLI::EXPORT_SCH_SVG_COMMAND exportSchSvgCmd{};
|
||||
static CLI::FP_COMMAND fpCmd{};
|
||||
static CLI::FP_UPGRADE_COMMAND fpUpgradeCmd{};
|
||||
static CLI::SYM_COMMAND symCmd{};
|
||||
static CLI::SYM_UPGRADE_COMMAND symUpgradeCmd{};
|
||||
static CLI::EXPORT_PCB_DRILL_COMMAND exportPcbDrillCmd{};
|
||||
static CLI::EXPORT_PCB_DXF_COMMAND exportPcbDxfCmd{};
|
||||
static CLI::EXPORT_PCB_STEP_COMMAND exportPcbStepCmd{};
|
||||
static CLI::EXPORT_PCB_SVG_COMMAND exportPcbSvgCmd{};
|
||||
static CLI::EXPORT_PCB_PDF_COMMAND exportPcbPdfCmd{};
|
||||
static CLI::EXPORT_PCB_POS_COMMAND exportPcbPosCmd{};
|
||||
static CLI::EXPORT_PCB_GERBER_COMMAND exportPcbGerberCmd{};
|
||||
static CLI::EXPORT_PCB_COMMAND exportPcbCmd{};
|
||||
static CLI::PCB_COMMAND pcbCmd{};
|
||||
static CLI::EXPORT_SCH_COMMAND exportSchCmd{};
|
||||
static CLI::SCH_COMMAND schCmd{};
|
||||
static CLI::EXPORT_SCH_PYTHONBOM_COMMAND exportSchPythonBomCmd{};
|
||||
static CLI::EXPORT_SCH_NETLIST_COMMAND exportSchNetlistCmd{};
|
||||
static CLI::EXPORT_SCH_PDF_COMMAND exportSchPdfCmd{};
|
||||
static CLI::EXPORT_SCH_SVG_COMMAND exportSchSvgCmd{};
|
||||
static CLI::FP_COMMAND fpCmd{};
|
||||
static CLI::FP_UPGRADE_COMMAND fpUpgradeCmd{};
|
||||
static CLI::SYM_COMMAND symCmd{};
|
||||
static CLI::SYM_UPGRADE_COMMAND symUpgradeCmd{};
|
||||
|
||||
static std::vector<COMMAND_ENTRY> commandStack = {
|
||||
{
|
||||
|
@ -163,9 +163,9 @@ static std::vector<COMMAND_ENTRY> commandStack = {
|
|||
{
|
||||
{ &exportSchCmd,
|
||||
{
|
||||
&exportSchBomCmd,
|
||||
&exportSchNetlistCmd,
|
||||
&exportSchPdfCmd,
|
||||
&exportSchPythonBomCmd,
|
||||
&exportSchSvgCmd
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue