KiCad PCB EDA Suite
Loading...
Searching...
No Matches
project_downgrade.cpp File Reference
#include "project_downgrade.h"
#include <filesystem>
#include <system_error>
#include <utility>
#include <json_common.h>
#include <wx/dir.h>
#include <wx/ffile.h>
#include <wx/filefn.h>
#include <wx/filename.h>
#include <downgrade_scan.h>
#include <downgrade_target.h>
#include <drc_rules_downgrade.h>
#include <jobs/job_pcb_downgrade.h>
#include <jobs/job_sch_downgrade.h>
#include <kiway.h>
#include <libraries/library_table_parser.h>
#include <project/project_file_downgrade.h>
#include <wildcards_and_files_ext.h>

Go to the source code of this file.

Classes

class  ERROR_COLLECTING_REPORTER
 

Functions

static bool quoteLegacyLibraryTableValue (const std::string &aValue, bool aPreTen, std::string &aQuoted)
 
static bool legacyLibraryTables (const wxString &aDir, const DOWNGRADE_TARGET &aTarget, std::vector< std::pair< wxString, wxString > > &aTables, wxString &aError)
 
static bool downgradeProjectFileOnDisk (const wxString &aPath, const DOWNGRADE_TARGET &aTarget, COMPATIBILITY_REPORT &aReport)
 
static int readSexprVersion (const wxString &aPath)
 
static wxString firstTooNewFile (const wxString &aDir, const DOWNGRADE_TARGET &aTarget)
 
bool ClassifyProjectForDowngrade (KIWAY &aKiway, const wxString &aProjectDir, const wxString &aProjectName, const wxString &aTargetName, COMPATIBILITY_REPORT &aReport, wxString &aError, std::vector< wxString > *aFoundVariants, bool aDropInsteadOfApproximate, const wxString &aVariant)
 Run the board and schematic classification for a whole project without writing anything.
 
bool ExportProjectForDowngrade (KIWAY &aKiway, const wxString &aProjectDir, const wxString &aProjectName, const wxString &aTargetName, const wxString &aDestDir, wxString &aError, const wxString &aVariant, bool aDropInsteadOfApproximate)
 Export a downgraded copy of the project into aDestDir.
 

Function Documentation

◆ ClassifyProjectForDowngrade()

bool ClassifyProjectForDowngrade ( KIWAY & aKiway,
const wxString & aProjectDir,
const wxString & aProjectName,
const wxString & aTargetName,
COMPATIBILITY_REPORT & aReport,
wxString & aError,
std::vector< wxString > * aFoundVariants = nullptr,
bool aDropInsteadOfApproximate = false,
const wxString & aVariant = wxEmptyString )

Run the board and schematic classification for a whole project without writing anything.

Returns false with aError set when a document or requested variant cannot be exported. When the target drops variants, aFoundVariants receives the schematic's variant names for a picker. Use the same aVariant and aDropInsteadOfApproximate policy for the preview and the real export.

Definition at line 307 of file project_downgrade.cpp.

References _, COMPATIBILITY_REPORT::Add(), BLOCK, FILEEXT::DesignRulesFileExtension, DowngradeProjectFileJson(), DROP, KIWAY::FACE_PCB, KIWAY::FACE_SCH, FilterDrcRulesForTarget(), FindDowngradeTarget(), COMPATIBILITY_REPORT::IsBlocked(), FILEEXT::KiCadPcbFileExtension, FILEEXT::KiCadSchematicFileExtension, legacyLibraryTables(), JOB_PCB_DOWNGRADE::m_dropInsteadOfApproximate, JOB_SCH_DOWNGRADE::m_dropInsteadOfApproximate, DRC_RULES_FILTER_RESULT::m_dropped, JOB_PCB_DOWNGRADE::m_dryRun, JOB_SCH_DOWNGRADE::m_dryRun, DRC_RULES_FILTER_RESULT::m_error, JOB_PCB_DOWNGRADE::m_filename, JOB_SCH_DOWNGRADE::m_filename, JOB_SCH_DOWNGRADE::m_foundVariants, JOB_PCB_DOWNGRADE::m_libraryDir, JOB_SCH_DOWNGRADE::m_libraryDir, JOB_PCB_DOWNGRADE::m_report, JOB_SCH_DOWNGRADE::m_report, JOB_PCB_DOWNGRADE::m_target, JOB_SCH_DOWNGRADE::m_target, JOB_PCB_DOWNGRADE::m_variant, JOB_SCH_DOWNGRADE::m_variant, COMPATIBILITY_REPORT::Merge(), name, KIWAY::ProcessJob(), FILEEXT::ProjectFileExtension, reporter, and text.

Referenced by CLI::PROJECT_DOWNGRADE_COMMAND::doPerform(), and KICAD_MANAGER_CONTROL::ExportForOlderVersion().

◆ downgradeProjectFileOnDisk()

static bool downgradeProjectFileOnDisk ( const wxString & aPath,
const DOWNGRADE_TARGET & aTarget,
COMPATIBILITY_REPORT & aReport )
static

◆ ExportProjectForDowngrade()

bool ExportProjectForDowngrade ( KIWAY & aKiway,
const wxString & aProjectDir,
const wxString & aProjectName,
const wxString & aTargetName,
const wxString & aDestDir,
wxString & aError,
const wxString & aVariant = wxEmptyString,
bool aDropInsteadOfApproximate = false )

Export a downgraded copy of the project into aDestDir.

The destination must be a new or empty folder. Copies design files only, downgrades them in the copy, and verifies the result. Fails closed: on any failure the destination is removed and aError explains why. The caller is expected to have classified first and obtained user consent. A non-empty aVariant is flattened into the export.

Definition at line 425 of file project_downgrade.cpp.

References _, FILEEXT::DesignRulesFileExtension, downgradeProjectFileOnDisk(), DowngradeTargetNames(), KIWAY::FACE_PCB, KIWAY::FACE_SCH, FilterDrcRulesForTarget(), FindDowngradeTarget(), firstTooNewFile(), IsDowngradeDesignFile(), IsDowngradeWorkingArtifact(), FILEEXT::KiCadPcbFileExtension, FILEEXT::KiCadSchematicFileExtension, legacyLibraryTables(), JOB_PCB_DOWNGRADE::m_dropInsteadOfApproximate, JOB_SCH_DOWNGRADE::m_dropInsteadOfApproximate, DRC_RULES_FILTER_RESULT::m_error, JOB_PCB_DOWNGRADE::m_filename, JOB_SCH_DOWNGRADE::m_filename, JOB_PCB_DOWNGRADE::m_force, JOB_SCH_DOWNGRADE::m_force, JOB_PCB_DOWNGRADE::m_inPlace, JOB_SCH_DOWNGRADE::m_inPlace, JOB_PCB_DOWNGRADE::m_libraryDir, JOB_SCH_DOWNGRADE::m_libraryDir, DOWNGRADE_TARGET::m_name, JOB_PCB_DOWNGRADE::m_outputFile, JOB_PCB_DOWNGRADE::m_target, JOB_SCH_DOWNGRADE::m_target, DRC_RULES_FILTER_RESULT::m_text, JOB_PCB_DOWNGRADE::m_variant, JOB_SCH_DOWNGRADE::m_variant, KIWAY::ProcessJob(), FILEEXT::ProjectFileExtension, reporter, source, and text.

Referenced by CLI::PROJECT_DOWNGRADE_COMMAND::doPerform(), and KICAD_MANAGER_CONTROL::ExportForOlderVersion().

◆ firstTooNewFile()

static wxString firstTooNewFile ( const wxString & aDir,
const DOWNGRADE_TARGET & aTarget )
static

◆ legacyLibraryTables()

◆ quoteLegacyLibraryTableValue()

static bool quoteLegacyLibraryTableValue ( const std::string & aValue,
bool aPreTen,
std::string & aQuoted )
static

Definition at line 76 of file project_downgrade.cpp.

Referenced by legacyLibraryTables().

◆ readSexprVersion()

static int readSexprVersion ( const wxString & aPath)
static

Definition at line 250 of file project_downgrade.cpp.

References StripSexprStrings().

Referenced by firstTooNewFile().