mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 18:23:15 +02:00
ADDED: Add pcb/sch upgrade cli command
This commit is contained in:
parent
be57c1a380
commit
814f78f2b2
@ -103,6 +103,8 @@ set( KICOMMON_SRCS
|
|||||||
jobs/job_sch_erc.cpp
|
jobs/job_sch_erc.cpp
|
||||||
jobs/job_sym_export_svg.cpp
|
jobs/job_sym_export_svg.cpp
|
||||||
jobs/job_sym_upgrade.cpp
|
jobs/job_sym_upgrade.cpp
|
||||||
|
jobs/job_pcb_upgrade.cpp
|
||||||
|
jobs/job_sch_upgrade.cpp
|
||||||
|
|
||||||
kicad_curl/kicad_curl.cpp
|
kicad_curl/kicad_curl.cpp
|
||||||
kicad_curl/kicad_curl_easy.cpp
|
kicad_curl/kicad_curl_easy.cpp
|
||||||
|
27
common/jobs/job_pcb_upgrade.cpp
Normal file
27
common/jobs/job_pcb_upgrade.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright The KiCad Developers, see AUTHORS.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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <jobs/job_pcb_upgrade.h>
|
||||||
|
|
||||||
|
JOB_PCB_UPGRADE::JOB_PCB_UPGRADE() :
|
||||||
|
JOB( "upgrade", false ),
|
||||||
|
m_filename(),
|
||||||
|
m_force( false )
|
||||||
|
{
|
||||||
|
}
|
35
common/jobs/job_pcb_upgrade.h
Normal file
35
common/jobs/job_pcb_upgrade.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright The KiCad Developers, see AUTHORS.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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef JOB_PCB_UPGRADE_H
|
||||||
|
#define JOB_PCB_UPGRADE_H
|
||||||
|
|
||||||
|
#include <kicommon.h>
|
||||||
|
#include "job.h"
|
||||||
|
|
||||||
|
class KICOMMON_API JOB_PCB_UPGRADE : public JOB
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
JOB_PCB_UPGRADE();
|
||||||
|
|
||||||
|
wxString m_filename;
|
||||||
|
bool m_force;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
27
common/jobs/job_sch_upgrade.cpp
Normal file
27
common/jobs/job_sch_upgrade.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright The KiCad Developers, see AUTHORS.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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <jobs/job_sch_upgrade.h>
|
||||||
|
|
||||||
|
JOB_SCH_UPGRADE::JOB_SCH_UPGRADE() :
|
||||||
|
JOB( "upgrade", false ),
|
||||||
|
m_filename(),
|
||||||
|
m_force( false )
|
||||||
|
{
|
||||||
|
}
|
35
common/jobs/job_sch_upgrade.h
Normal file
35
common/jobs/job_sch_upgrade.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright The KiCad Developers, see AUTHORS.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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef JOB_SCH_UPGRADE_H
|
||||||
|
#define JOB_SCH_UPGRADE_H
|
||||||
|
|
||||||
|
#include <kicommon.h>
|
||||||
|
#include "job.h"
|
||||||
|
|
||||||
|
class KICOMMON_API JOB_SCH_UPGRADE : public JOB
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
JOB_SCH_UPGRADE();
|
||||||
|
|
||||||
|
wxString m_filename;
|
||||||
|
bool m_force;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -30,6 +30,7 @@
|
|||||||
#include <jobs/job_export_sch_netlist.h>
|
#include <jobs/job_export_sch_netlist.h>
|
||||||
#include <jobs/job_export_sch_plot.h>
|
#include <jobs/job_export_sch_plot.h>
|
||||||
#include <jobs/job_sch_erc.h>
|
#include <jobs/job_sch_erc.h>
|
||||||
|
#include <jobs/job_sch_upgrade.h>
|
||||||
#include <jobs/job_sym_export_svg.h>
|
#include <jobs/job_sym_export_svg.h>
|
||||||
#include <jobs/job_sym_upgrade.h>
|
#include <jobs/job_sym_upgrade.h>
|
||||||
#include <schematic.h>
|
#include <schematic.h>
|
||||||
@ -55,6 +56,7 @@
|
|||||||
#include <settings/settings_manager.h>
|
#include <settings/settings_manager.h>
|
||||||
|
|
||||||
#include <sch_file_versions.h>
|
#include <sch_file_versions.h>
|
||||||
|
#include <sch_io/sch_io.h>
|
||||||
#include <sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.h>
|
#include <sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.h>
|
||||||
|
|
||||||
#include <netlist.h>
|
#include <netlist.h>
|
||||||
@ -158,6 +160,11 @@ EESCHEMA_JOBS_HANDLER::EESCHEMA_JOBS_HANDLER( KIWAY* aKiway ) :
|
|||||||
DIALOG_ERC_JOB_CONFIG dlg( aParent, ercJob );
|
DIALOG_ERC_JOB_CONFIG dlg( aParent, ercJob );
|
||||||
return dlg.ShowModal() == wxID_OK;
|
return dlg.ShowModal() == wxID_OK;
|
||||||
} );
|
} );
|
||||||
|
Register( "upgrade", std::bind( &EESCHEMA_JOBS_HANDLER::JobUpgrade, this, std::placeholders::_1 ),
|
||||||
|
[]( JOB* job, wxWindow* aParent ) -> bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1070,8 +1077,8 @@ int EESCHEMA_JOBS_HANDLER::JobSymUpgrade( JOB* aJob )
|
|||||||
if( m_progressReporter )
|
if( m_progressReporter )
|
||||||
m_progressReporter->KeepRefreshing();
|
m_progressReporter->KeepRefreshing();
|
||||||
|
|
||||||
bool shouldSave = upgradeJob->m_force
|
bool shouldSave =
|
||||||
|| schLibrary.GetFileFormatVersionAtLoad() < SEXPR_SYMBOL_LIB_FILE_VERSION;
|
upgradeJob->m_force || schLibrary.GetFileFormatVersionAtLoad() < SEXPR_SYMBOL_LIB_FILE_VERSION;
|
||||||
|
|
||||||
if( shouldSave )
|
if( shouldSave )
|
||||||
{
|
{
|
||||||
@ -1198,6 +1205,54 @@ int EESCHEMA_JOBS_HANDLER::JobSchErc( JOB* aJob )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int EESCHEMA_JOBS_HANDLER::JobUpgrade( JOB* aJob )
|
||||||
|
{
|
||||||
|
JOB_SCH_UPGRADE* aUpgradeJob = dynamic_cast<JOB_SCH_UPGRADE*>( aJob );
|
||||||
|
|
||||||
|
if( aUpgradeJob == nullptr )
|
||||||
|
return CLI::EXIT_CODES::ERR_UNKNOWN;
|
||||||
|
|
||||||
|
SCHEMATIC* sch = getSchematic( aUpgradeJob->m_filename );
|
||||||
|
|
||||||
|
if( !sch )
|
||||||
|
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||||
|
|
||||||
|
bool shouldSave = aUpgradeJob->m_force;
|
||||||
|
|
||||||
|
if( sch->RootScreen()->GetFileFormatVersionAtLoad() < SEXPR_SCHEMATIC_FILE_VERSION )
|
||||||
|
shouldSave = true;
|
||||||
|
|
||||||
|
if( !shouldSave )
|
||||||
|
{
|
||||||
|
m_reporter->Report( _( "Schematic file was not updated\n" ), RPT_SEVERITY_ERROR );
|
||||||
|
return CLI::EXIT_CODES::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// needs an absolute path
|
||||||
|
wxFileName schPath( aUpgradeJob->m_filename );
|
||||||
|
schPath.MakeAbsolute();
|
||||||
|
const wxString schFullPath = schPath.GetFullPath();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IO_RELEASER<SCH_IO> pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
|
||||||
|
SCH_SHEET* loadedSheet = pi->LoadSchematicFile( schFullPath, sch );
|
||||||
|
pi->SaveSchematicFile( schFullPath, loadedSheet, sch );
|
||||||
|
}
|
||||||
|
catch( const IO_ERROR& ioe )
|
||||||
|
{
|
||||||
|
wxString msg =
|
||||||
|
wxString::Format( _( "Error saving schematic file '%s'.\n%s" ), schFullPath, ioe.What().GetData() );
|
||||||
|
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
|
||||||
|
return CLI::EXIT_CODES::ERR_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_reporter->Report( _( "Successfully saved schematic file using the latest format\n" ), RPT_SEVERITY_INFO );
|
||||||
|
|
||||||
|
return CLI::EXIT_CODES::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DS_PROXY_VIEW_ITEM* EESCHEMA_JOBS_HANDLER::getDrawingSheetProxyView( SCHEMATIC* aSch )
|
DS_PROXY_VIEW_ITEM* EESCHEMA_JOBS_HANDLER::getDrawingSheetProxyView( SCHEMATIC* aSch )
|
||||||
{
|
{
|
||||||
DS_PROXY_VIEW_ITEM* drawingSheet =
|
DS_PROXY_VIEW_ITEM* drawingSheet =
|
||||||
|
@ -45,6 +45,7 @@ public:
|
|||||||
int JobSchErc( JOB* aJob );
|
int JobSchErc( JOB* aJob );
|
||||||
int JobSymUpgrade( JOB* aJob );
|
int JobSymUpgrade( JOB* aJob );
|
||||||
int JobSymExportSvg( JOB* aJob );
|
int JobSymExportSvg( JOB* aJob );
|
||||||
|
int JobUpgrade( JOB* aJob );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure the SCH_RENDER_SETTINGS object with the correct data to be used with plotting.
|
* Configure the SCH_RENDER_SETTINGS object with the correct data to be used with plotting.
|
||||||
|
@ -70,8 +70,10 @@ set( KICAD_CLI_SRCS
|
|||||||
cli/command_pcb_export_pos.cpp
|
cli/command_pcb_export_pos.cpp
|
||||||
cli/command_pcb_export_ps.cpp
|
cli/command_pcb_export_ps.cpp
|
||||||
cli/command_pcb_export_svg.cpp
|
cli/command_pcb_export_svg.cpp
|
||||||
|
cli/command_pcb_upgrade.cpp
|
||||||
cli/command_fp_export_svg.cpp
|
cli/command_fp_export_svg.cpp
|
||||||
cli/command_fp_upgrade.cpp
|
cli/command_fp_upgrade.cpp
|
||||||
|
cli/command_sch_upgrade.cpp
|
||||||
cli/command_sch_export_bom.cpp
|
cli/command_sch_export_bom.cpp
|
||||||
cli/command_sch_export_pythonbom.cpp
|
cli/command_sch_export_pythonbom.cpp
|
||||||
cli/command_sch_export_netlist.cpp
|
cli/command_sch_export_netlist.cpp
|
||||||
|
54
kicad/cli/command_pcb_upgrade.cpp
Normal file
54
kicad/cli/command_pcb_upgrade.cpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright The KiCad Developers, see AUTHORS.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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "command_pcb_upgrade.h"
|
||||||
|
#include "jobs/job_pcb_upgrade.h"
|
||||||
|
#include "cli/exit_codes.h"
|
||||||
|
#include <wx/crt.h>
|
||||||
|
|
||||||
|
#define ARG_FORCE "--force"
|
||||||
|
|
||||||
|
CLI::PCB_UPGRADE_COMMAND::PCB_UPGRADE_COMMAND() :
|
||||||
|
COMMAND( "upgrade" )
|
||||||
|
{
|
||||||
|
addCommonArgs( true, false, false, false );
|
||||||
|
m_argParser.add_description( UTF8STDSTR( _( "Upgrade the board file's format to the latest one" ) ) );
|
||||||
|
|
||||||
|
m_argParser.add_argument( ARG_FORCE )
|
||||||
|
.help( UTF8STDSTR( _( "Forces the board file to be resaved regardless of versioning" ) ) )
|
||||||
|
.flag();
|
||||||
|
}
|
||||||
|
|
||||||
|
int CLI::PCB_UPGRADE_COMMAND::doPerform( KIWAY& aKiway )
|
||||||
|
{
|
||||||
|
std::unique_ptr<JOB_PCB_UPGRADE> upgradeJob = std::make_unique<JOB_PCB_UPGRADE>();
|
||||||
|
|
||||||
|
upgradeJob->m_filename = m_argInput;
|
||||||
|
upgradeJob->m_force = m_argParser.get<bool>( ARG_FORCE );
|
||||||
|
|
||||||
|
if( !wxFile::Exists( upgradeJob->m_filename ) )
|
||||||
|
{
|
||||||
|
wxFprintf( stderr, _( "Board file does not exist or is not accessible\n" ) );
|
||||||
|
return EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, upgradeJob.get() );
|
||||||
|
|
||||||
|
return exitCode;
|
||||||
|
}
|
36
kicad/cli/command_pcb_upgrade.h
Normal file
36
kicad/cli/command_pcb_upgrade.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright The KiCad Developers, see AUTHORS.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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMMAND_PCB_UPGRADE_H
|
||||||
|
#define COMMAND_PCB_UPGRADE_H
|
||||||
|
|
||||||
|
#include "command.h"
|
||||||
|
|
||||||
|
namespace CLI
|
||||||
|
{
|
||||||
|
struct PCB_UPGRADE_COMMAND : public COMMAND
|
||||||
|
{
|
||||||
|
PCB_UPGRADE_COMMAND();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int doPerform( KIWAY& aKiway ) override;
|
||||||
|
};
|
||||||
|
} // namespace CLI
|
||||||
|
|
||||||
|
#endif
|
54
kicad/cli/command_sch_upgrade.cpp
Normal file
54
kicad/cli/command_sch_upgrade.cpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright The KiCad Developers, see AUTHORS.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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "command_sch_upgrade.h"
|
||||||
|
#include "jobs/job_sch_upgrade.h"
|
||||||
|
#include "cli/exit_codes.h"
|
||||||
|
#include <wx/crt.h>
|
||||||
|
|
||||||
|
#define ARG_FORCE "--force"
|
||||||
|
|
||||||
|
CLI::SCH_UPGRADE_COMMAND::SCH_UPGRADE_COMMAND() :
|
||||||
|
COMMAND( "upgrade" )
|
||||||
|
{
|
||||||
|
addCommonArgs( true, false, false, false );
|
||||||
|
m_argParser.add_description( UTF8STDSTR( _( "Upgrade the schematic file's format to the latest one" ) ) );
|
||||||
|
|
||||||
|
m_argParser.add_argument( ARG_FORCE )
|
||||||
|
.help( UTF8STDSTR( _( "Forces the schematic file to be resaved regardless of versioning" ) ) )
|
||||||
|
.flag();
|
||||||
|
}
|
||||||
|
|
||||||
|
int CLI::SCH_UPGRADE_COMMAND::doPerform( KIWAY& aKiway )
|
||||||
|
{
|
||||||
|
std::unique_ptr<JOB_SCH_UPGRADE> upgradeJob = std::make_unique<JOB_SCH_UPGRADE>();
|
||||||
|
|
||||||
|
upgradeJob->m_filename = m_argInput;
|
||||||
|
upgradeJob->m_force = m_argParser.get<bool>( ARG_FORCE );
|
||||||
|
|
||||||
|
if( !wxFile::Exists( upgradeJob->m_filename ) )
|
||||||
|
{
|
||||||
|
wxFprintf( stderr, _( "Schematic file does not exist or is not accessible\n" ) );
|
||||||
|
return EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, upgradeJob.get() );
|
||||||
|
|
||||||
|
return exitCode;
|
||||||
|
}
|
36
kicad/cli/command_sch_upgrade.h
Normal file
36
kicad/cli/command_sch_upgrade.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright The KiCad Developers, see AUTHORS.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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMMAND_SCH_UPGRADE_H
|
||||||
|
#define COMMAND_SCH_UPGRADE_H
|
||||||
|
|
||||||
|
#include "command.h"
|
||||||
|
|
||||||
|
namespace CLI
|
||||||
|
{
|
||||||
|
struct SCH_UPGRADE_COMMAND : public COMMAND
|
||||||
|
{
|
||||||
|
SCH_UPGRADE_COMMAND();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int doPerform( KIWAY& aKiway ) override;
|
||||||
|
};
|
||||||
|
} // namespace CLI
|
||||||
|
|
||||||
|
#endif
|
@ -70,6 +70,7 @@
|
|||||||
#include "cli/command_sch_export_pythonbom.h"
|
#include "cli/command_sch_export_pythonbom.h"
|
||||||
#include "cli/command_sch_export_netlist.h"
|
#include "cli/command_sch_export_netlist.h"
|
||||||
#include "cli/command_sch_export_plot.h"
|
#include "cli/command_sch_export_plot.h"
|
||||||
|
#include "cli/command_pcb_upgrade.h"
|
||||||
#include "cli/command_fp.h"
|
#include "cli/command_fp.h"
|
||||||
#include "cli/command_fp_export.h"
|
#include "cli/command_fp_export.h"
|
||||||
#include "cli/command_fp_export_svg.h"
|
#include "cli/command_fp_export_svg.h"
|
||||||
@ -77,6 +78,7 @@
|
|||||||
#include "cli/command_sch.h"
|
#include "cli/command_sch.h"
|
||||||
#include "cli/command_sch_erc.h"
|
#include "cli/command_sch_erc.h"
|
||||||
#include "cli/command_sch_export.h"
|
#include "cli/command_sch_export.h"
|
||||||
|
#include "cli/command_sch_upgrade.h"
|
||||||
#include "cli/command_sym.h"
|
#include "cli/command_sym.h"
|
||||||
#include "cli/command_sym_export.h"
|
#include "cli/command_sym_export.h"
|
||||||
#include "cli/command_sym_export_svg.h"
|
#include "cli/command_sym_export_svg.h"
|
||||||
@ -117,6 +119,7 @@ static CLI::JOBSET_RUN_COMMAND jobsetRunCmd{};
|
|||||||
static CLI::PCB_COMMAND pcbCmd{};
|
static CLI::PCB_COMMAND pcbCmd{};
|
||||||
static CLI::PCB_DRC_COMMAND pcbDrcCmd{};
|
static CLI::PCB_DRC_COMMAND pcbDrcCmd{};
|
||||||
static CLI::PCB_RENDER_COMMAND pcbRenderCmd{};
|
static CLI::PCB_RENDER_COMMAND pcbRenderCmd{};
|
||||||
|
static CLI::PCB_UPGRADE_COMMAND pcbUpgradeCmd{};
|
||||||
static CLI::PCB_EXPORT_DRILL_COMMAND exportPcbDrillCmd{};
|
static CLI::PCB_EXPORT_DRILL_COMMAND exportPcbDrillCmd{};
|
||||||
static CLI::PCB_EXPORT_DXF_COMMAND exportPcbDxfCmd{};
|
static CLI::PCB_EXPORT_DXF_COMMAND exportPcbDxfCmd{};
|
||||||
static CLI::PCB_EXPORT_3D_COMMAND exportPcbGlbCmd{ "glb", UTF8STDSTR( _( "Export GLB (binary GLTF)" ) ), JOB_EXPORT_PCB_3D::FORMAT::GLB };
|
static CLI::PCB_EXPORT_3D_COMMAND exportPcbGlbCmd{ "glb", UTF8STDSTR( _( "Export GLB (binary GLTF)" ) ), JOB_EXPORT_PCB_3D::FORMAT::GLB };
|
||||||
@ -142,6 +145,7 @@ static CLI::PCB_EXPORT_COMMAND exportPcbCmd{};
|
|||||||
static CLI::SCH_EXPORT_COMMAND exportSchCmd{};
|
static CLI::SCH_EXPORT_COMMAND exportSchCmd{};
|
||||||
static CLI::SCH_COMMAND schCmd{};
|
static CLI::SCH_COMMAND schCmd{};
|
||||||
static CLI::SCH_ERC_COMMAND schErcCmd{};
|
static CLI::SCH_ERC_COMMAND schErcCmd{};
|
||||||
|
static CLI::SCH_UPGRADE_COMMAND schUpgradeCmd{};
|
||||||
static CLI::SCH_EXPORT_BOM_COMMAND exportSchBomCmd{};
|
static CLI::SCH_EXPORT_BOM_COMMAND exportSchBomCmd{};
|
||||||
static CLI::SCH_EXPORT_PYTHONBOM_COMMAND exportSchPythonBomCmd{};
|
static CLI::SCH_EXPORT_PYTHONBOM_COMMAND exportSchPythonBomCmd{};
|
||||||
static CLI::SCH_EXPORT_NETLIST_COMMAND exportSchNetlistCmd{};
|
static CLI::SCH_EXPORT_NETLIST_COMMAND exportSchNetlistCmd{};
|
||||||
@ -219,6 +223,9 @@ static std::vector<COMMAND_ENTRY> commandStack = {
|
|||||||
&exportPcbStlCmd,
|
&exportPcbStlCmd,
|
||||||
&exportPcbStepzCmd
|
&exportPcbStepzCmd
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
&pcbUpgradeCmd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -240,6 +247,9 @@ static std::vector<COMMAND_ENTRY> commandStack = {
|
|||||||
&exportSchPythonBomCmd,
|
&exportSchPythonBomCmd,
|
||||||
&exportSchSvgCmd
|
&exportSchSvgCmd
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
&schUpgradeCmd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#include <jobs/job_export_pcb_3d.h>
|
#include <jobs/job_export_pcb_3d.h>
|
||||||
#include <jobs/job_pcb_render.h>
|
#include <jobs/job_pcb_render.h>
|
||||||
#include <jobs/job_pcb_drc.h>
|
#include <jobs/job_pcb_drc.h>
|
||||||
|
#include <jobs/job_pcb_upgrade.h>
|
||||||
#include <lset.h>
|
#include <lset.h>
|
||||||
#include <cli/exit_codes.h>
|
#include <cli/exit_codes.h>
|
||||||
#include <exporters/place_file_exporter.h>
|
#include <exporters/place_file_exporter.h>
|
||||||
@ -136,6 +137,11 @@ PCBNEW_JOBS_HANDLER::PCBNEW_JOBS_HANDLER( KIWAY* aKiway ) :
|
|||||||
DIALOG_RENDER_JOB dlg( aParent, renderJob );
|
DIALOG_RENDER_JOB dlg( aParent, renderJob );
|
||||||
return dlg.ShowModal() == wxID_OK;
|
return dlg.ShowModal() == wxID_OK;
|
||||||
} );
|
} );
|
||||||
|
Register( "upgrade", std::bind( &PCBNEW_JOBS_HANDLER::JobUpgrade, this, std::placeholders::_1 ),
|
||||||
|
[]( JOB* job, wxWindow* aParent ) -> bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
} );
|
||||||
Register( "svg", std::bind( &PCBNEW_JOBS_HANDLER::JobExportSvg, this, std::placeholders::_1 ),
|
Register( "svg", std::bind( &PCBNEW_JOBS_HANDLER::JobExportSvg, this, std::placeholders::_1 ),
|
||||||
[aKiway]( JOB* job, wxWindow* aParent ) -> bool
|
[aKiway]( JOB* job, wxWindow* aParent ) -> bool
|
||||||
{
|
{
|
||||||
@ -2516,6 +2522,42 @@ int PCBNEW_JOBS_HANDLER::JobExportOdb( JOB* aJob )
|
|||||||
return CLI::EXIT_CODES::SUCCESS;
|
return CLI::EXIT_CODES::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PCBNEW_JOBS_HANDLER::JobUpgrade( JOB* aJob )
|
||||||
|
{
|
||||||
|
JOB_PCB_UPGRADE* job = dynamic_cast<JOB_PCB_UPGRADE*>( aJob );
|
||||||
|
|
||||||
|
if( job == nullptr )
|
||||||
|
return CLI::EXIT_CODES::ERR_UNKNOWN;
|
||||||
|
|
||||||
|
bool shouldSave = job->m_force;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IO_RELEASER<PCB_IO> pi( PCB_IO_MGR::PluginFind( PCB_IO_MGR::KICAD_SEXP ) );
|
||||||
|
BOARD* brd = getBoard( job->m_filename );
|
||||||
|
if( brd->GetFileFormatVersionAtLoad() < SEXPR_BOARD_FILE_VERSION )
|
||||||
|
shouldSave = true;
|
||||||
|
|
||||||
|
if( shouldSave )
|
||||||
|
{
|
||||||
|
pi->SaveBoard( brd->GetFileName(), brd );
|
||||||
|
m_reporter->Report( _( "Successfully saved board file using the latest format\n" ), RPT_SEVERITY_INFO );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_reporter->Report( _( "Board file was not updated\n" ), RPT_SEVERITY_ERROR );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( const IO_ERROR& ioe )
|
||||||
|
{
|
||||||
|
wxString msg =
|
||||||
|
wxString::Format( _( "Error saving board file '%s'.\n%s" ), job->m_filename, ioe.What().GetData() );
|
||||||
|
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
|
||||||
|
return CLI::EXIT_CODES::ERR_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CLI::EXIT_CODES::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
DS_PROXY_VIEW_ITEM* PCBNEW_JOBS_HANDLER::getDrawingSheetProxyView( BOARD* aBrd )
|
DS_PROXY_VIEW_ITEM* PCBNEW_JOBS_HANDLER::getDrawingSheetProxyView( BOARD* aBrd )
|
||||||
{
|
{
|
||||||
|
@ -56,6 +56,7 @@ public:
|
|||||||
int JobExportIpc2581( JOB* aJob );
|
int JobExportIpc2581( JOB* aJob );
|
||||||
int JobExportOdb( JOB* aJob );
|
int JobExportOdb( JOB* aJob );
|
||||||
int JobExportIpcD356( JOB* aJob );
|
int JobExportIpcD356( JOB* aJob );
|
||||||
|
int JobUpgrade( JOB* aJob );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BOARD* getBoard( const wxString& aPath = wxEmptyString );
|
BOARD* getBoard( const wxString& aPath = wxEmptyString );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user