KiCad PCB EDA Suite
Loading...
Searching...
No Matches
lib_parser.cpp File Reference
#include <qa_utils/utility_registry.h>
#include <chrono>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#include <fmt/format.h>
#include <wx/cmdline.h>
#include <wx/msgout.h>
#include <common.h>
#include <core/profile.h>
#include <ki_exception.h>
#include <libraries/library_table.h>
#include <lib_symbol.h>
#include <paths.h>
#include <project.h>
#include <richio.h>
#include <sch_io/kicad_sexpr/sch_io_kicad_sexpr.h>
#include <sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h>
#include <settings/common_settings.h>
#include <settings/settings_manager.h>
#include <symbol_library_common.h>
#include <wx_filename.h>

Go to the source code of this file.

Typedefs

using PARSE_DURATION = std::chrono::microseconds
 

Enumerations

enum  LIB_PARSER_RET_CODES { PARSE_FAILED = KI_TEST::RET_CODES::TOOL_SPECIFIC }
 

Functions

static void loadKiCadEnvVars ()
 Load the KiCad common settings and set any configured environment variables (e.g.
 
static int parseLibraryFile (const wxString &aPath, bool aVerbose)
 Parse a single library file path and return the number of symbols loaded.
 
static bool parseStdin ()
 Parse symbol library content from stdin (for fuzzing).
 
static int parseLibTable (const wxString &aTablePath, bool aVerbose, std::set< wxString > &aVisited)
 Load libraries from a symbol library table file.
 
int lib_parser_main_func (int argc, char **argv)
 

Variables

static const wxCmdLineEntryDesc g_cmdLineDesc []
 
static bool registered
 

Typedef Documentation

◆ PARSE_DURATION

using PARSE_DURATION = std::chrono::microseconds

Definition at line 48 of file lib_parser.cpp.

Enumeration Type Documentation

◆ LIB_PARSER_RET_CODES

Enumerator
PARSE_FAILED 

Definition at line 308 of file lib_parser.cpp.

Function Documentation

◆ lib_parser_main_func()

int lib_parser_main_func ( int argc,
char ** argv )

◆ loadKiCadEnvVars()

static void loadKiCadEnvVars ( )
static

Load the KiCad common settings and set any configured environment variables (e.g.

KICAD10_SYMBOL_DIR) so that library table URI references like ${KICAD10_SYMBOL_DIR}/Device.kicad_sym can be resolved.

Definition at line 56 of file lib_parser.cpp.

References SETTINGS_MANAGER::GetCommonSettings(), SETTINGS_MANAGER::Load(), COMMON_SETTINGS::m_Env, name, and COMMON_SETTINGS::ENVIRONMENT::vars.

Referenced by lib_parser_main_func().

◆ parseLibraryFile()

static int parseLibraryFile ( const wxString & aPath,
bool aVerbose )
static

Parse a single library file path and return the number of symbols loaded.

Returns
the number of symbols found, or -1 on failure.

Definition at line 86 of file lib_parser.cpp.

References SCH_IO_KICAD_SEXPR::EnumerateSymbolLib(), PROF_TIMER::SinceStart(), and IO_ERROR::What().

Referenced by lib_parser_main_func(), and parseLibTable().

◆ parseLibTable()

static int parseLibTable ( const wxString & aTablePath,
bool aVerbose,
std::set< wxString > & aVisited )
static

Load libraries from a symbol library table file.

Parameters
aVisitedset of already-visited table paths
Returns
the number of libraries successfully parsed, or -1 if the table itself could not be loaded.

Definition at line 179 of file lib_parser.cpp.

References ExpandEnvVarSubstitutions(), parseLibraryFile(), parseLibTable(), PROJECT, WX_FILENAME::ResolvePossibleSymlinks(), SYMBOL, table, and LIBRARY_TABLE_ROW::TABLE_TYPE_NAME.

Referenced by lib_parser_main_func(), and parseLibTable().

◆ parseStdin()

static bool parseStdin ( )
static

Parse symbol library content from stdin (for fuzzing).

Returns
true if parsing succeeded.

Definition at line 140 of file lib_parser.cpp.

References SCH_IO_KICAD_SEXPR_PARSER::ParseLib().

Referenced by lib_parser_main_func().

Variable Documentation

◆ g_cmdLineDesc

const wxCmdLineEntryDesc g_cmdLineDesc[]
static

Definition at line 265 of file lib_parser.cpp.

◆ registered

bool registered
static
Initial value:
"lib_parser",
"Parse schematic symbol library files",
} )
static bool Register(const KI_TEST::UTILITY_PROGRAM &aProgInfo)
Register a utility program factory function against an ID string.
int lib_parser_main_func(int argc, char **argv)

Definition at line 421 of file lib_parser.cpp.