Start a kicommon shared lib
This commit is contained in:
parent
c96b7bb472
commit
b5d5eb842a
|
@ -39,6 +39,7 @@
|
|||
when: always
|
||||
paths:
|
||||
- build/linux/3d-viewer/
|
||||
- build/linux/common/libkicommon.so*
|
||||
- build/linux/eeschema/_eeschema.kiface
|
||||
- build/linux/kicad/kicad-cli
|
||||
- build/linux/pcbnew/pcbnew.py
|
||||
|
|
|
@ -42,25 +42,61 @@ add_library( singletop STATIC EXCLUDE_FROM_ALL
|
|||
# surely needed and certainly used from more than one place without recompilation.
|
||||
# Functions and data all need to use the #include <import_export.h> and be declared
|
||||
# as APIEXPORT
|
||||
set( LIB_KICAD_SRCS
|
||||
set( KICOMMON_SRCS
|
||||
exceptions.cpp
|
||||
richio.cpp
|
||||
string_utils.cpp
|
||||
)
|
||||
|
||||
if( future )
|
||||
add_library( lib_kicad SHARED
|
||||
add_library( kicommon SHARED
|
||||
${KICOMMON_SRCS}
|
||||
)
|
||||
target_link_libraries( lib_kicad
|
||||
|
||||
target_link_libraries( kicommon
|
||||
core
|
||||
kiplatform
|
||||
fmt::fmt
|
||||
${wxWidgets_LIBRARIES}
|
||||
)
|
||||
set_target_properties( lib_kicad PROPERTIES
|
||||
OUTPUT_NAME ki
|
||||
|
||||
include( ${KICAD_CMAKE_MODULE_PATH}/KiCadVersion.cmake )
|
||||
include( ${KICAD_CMAKE_MODULE_PATH}/CreateGitVersionHeader.cmake )
|
||||
create_git_version_header(${CMAKE_SOURCE_DIR})
|
||||
|
||||
# Extract the major and minor build version as a string
|
||||
string( REGEX MATCH
|
||||
"([0-9]+)\\.([0-9]+)\\.([0-9]+)"
|
||||
KICAD_MAJOR_MINOR_PATCH_VERSION
|
||||
"${KICAD_VERSION}"
|
||||
)
|
||||
install( TARGETS lib_kicad
|
||||
DESTINATION ${KICAD_BIN}
|
||||
|
||||
set_target_properties( kicommon PROPERTIES
|
||||
OUTPUT_NAME kicommon
|
||||
SOVERSION ${KICAD_MAJOR_MINOR_PATCH_VERSION}
|
||||
)
|
||||
|
||||
install( TARGETS kicommon
|
||||
RUNTIME DESTINATION ${KICAD_LIB}
|
||||
LIBRARY DESTINATION ${KICAD_LIB}
|
||||
COMPONENT binary
|
||||
)
|
||||
|
||||
if( APPLE )
|
||||
# puts library into the main kicad.app bundle in build tree
|
||||
set_target_properties( kicommon PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY "${OSX_BUNDLE_BUILD_LIB_DIR}"
|
||||
INSTALL_NAME_DIR "${OSX_BUNDLE_BUILD_LIB_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions( kicommon PRIVATE KICOMMON_DLL=1 )
|
||||
|
||||
target_include_directories( kicommon
|
||||
PUBLIC
|
||||
.
|
||||
${CMAKE_BINARY_DIR}
|
||||
)
|
||||
|
||||
# The build version string defaults to the value in the KiCadVersion.cmake file.
|
||||
# If being built inside a git repository, the git tag and commit hash are used to create
|
||||
# a new version string instead. The user can supply an additional string to be appended
|
||||
|
@ -389,7 +425,6 @@ set( COMMON_SRCS
|
|||
refdes_utils.cpp
|
||||
render_settings.cpp
|
||||
reporter.cpp
|
||||
richio.cpp
|
||||
scintilla_tricks.cpp
|
||||
search_stack.cpp
|
||||
searchhelpfilefullpath.cpp
|
||||
|
@ -502,6 +537,7 @@ target_link_libraries( common
|
|||
libcontext
|
||||
kimath
|
||||
kiplatform
|
||||
kicommon
|
||||
core
|
||||
fmt::fmt
|
||||
gal
|
||||
|
|
|
@ -118,6 +118,8 @@ principle should be easily implemented by adapting the current STL containers.
|
|||
|
||||
// TODO: wrapper of BASE_SET (see std::bitset<PCB_LAYER_ID_COUNT> BASE_SET;)
|
||||
|
||||
#define KICOMMON_API
|
||||
|
||||
|
||||
// header files that must be wrapped
|
||||
%include <outline_mode.h>
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2023 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/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <import_export.h>
|
||||
|
||||
#ifndef SWIG
|
||||
#if defined( KICOMMON_DLL )
|
||||
#define KICOMMON_API APIEXPORT
|
||||
#else
|
||||
#define KICOMMON_API APIIMPORT
|
||||
#endif
|
||||
#else
|
||||
#define KICOMMON_API
|
||||
#endif
|
|
@ -39,7 +39,7 @@
|
|||
#include <wx/stream.h>
|
||||
|
||||
#include <ki_exception.h>
|
||||
|
||||
#include <kicommon.h>
|
||||
|
||||
/**
|
||||
* This is like sprintf() but the output is appended to a std::string instead of to a
|
||||
|
@ -49,7 +49,7 @@
|
|||
* @param aFormat is a printf() style format string.
|
||||
* @return the count of bytes appended to the result string, no terminating nul is included.
|
||||
*/
|
||||
int
|
||||
KICOMMON_API int
|
||||
#if defined(__GNUG__)
|
||||
__attribute__ ((format (printf, 2, 3)))
|
||||
#endif
|
||||
|
@ -63,7 +63,7 @@ int
|
|||
* @param format is a printf() style format string.
|
||||
* @return std::string - the result of the sprintf().
|
||||
*/
|
||||
std::string
|
||||
KICOMMON_API std::string
|
||||
#if defined(__GNUG__)
|
||||
__attribute__ ((format (printf, 1, 2)))
|
||||
#endif
|
||||
|
@ -79,7 +79,7 @@ std::string
|
|||
* @throw IO_ERROR if the file can't be opened
|
||||
* @return the file contents
|
||||
*/
|
||||
wxString SafeReadFile( const wxString& aFilePath, const wxString& aReadType );
|
||||
KICOMMON_API wxString SafeReadFile( const wxString& aFilePath, const wxString& aReadType );
|
||||
|
||||
|
||||
#define LINE_READER_LINE_DEFAULT_MAX 1000000
|
||||
|
@ -89,7 +89,7 @@ wxString SafeReadFile( const wxString& aFilePath, const wxString& aReadType );
|
|||
* An abstract class from which implementation specific LINE_READERs may be derived to
|
||||
* read single lines of text and manage a line number counter.
|
||||
*/
|
||||
class LINE_READER
|
||||
class KICOMMON_API LINE_READER
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -181,7 +181,7 @@ protected:
|
|||
*
|
||||
* File must be already open so that this class can exist without any UI policy.
|
||||
*/
|
||||
class FILE_LINE_READER : public LINE_READER
|
||||
class KICOMMON_API FILE_LINE_READER : public LINE_READER
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -249,7 +249,7 @@ protected:
|
|||
/**
|
||||
* Is a #LINE_READER that reads from a multiline 8 bit wide std::string
|
||||
*/
|
||||
class STRING_LINE_READER : public LINE_READER
|
||||
class KICOMMON_API STRING_LINE_READER : public LINE_READER
|
||||
{
|
||||
protected:
|
||||
std::string m_lines;
|
||||
|
@ -283,7 +283,7 @@ public:
|
|||
/**
|
||||
* A #LINE_READER that reads from a wxInputStream object.
|
||||
*/
|
||||
class INPUTSTREAM_LINE_READER : public LINE_READER
|
||||
class KICOMMON_API INPUTSTREAM_LINE_READER : public LINE_READER
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -318,7 +318,7 @@ protected:
|
|||
* Since this is an abstract interface, only classes derived from this one may actually be
|
||||
* used.
|
||||
*/
|
||||
class OUTPUTFORMATTER
|
||||
class KICOMMON_API OUTPUTFORMATTER
|
||||
{
|
||||
protected:
|
||||
OUTPUTFORMATTER( int aReserve = OUTPUTFMTBUFZ, char aQuoteChar = '"' ) :
|
||||
|
@ -423,7 +423,7 @@ private:
|
|||
*
|
||||
* After Print()ing the string is available through GetString()
|
||||
*/
|
||||
class STRING_FORMATTER : public OUTPUTFORMATTER
|
||||
class KICOMMON_API STRING_FORMATTER : public OUTPUTFORMATTER
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -465,7 +465,7 @@ private:
|
|||
*
|
||||
* It is about 8 times faster than STREAM_OUTPUTFORMATTER for file streams.
|
||||
*/
|
||||
class FILE_OUTPUTFORMATTER : public OUTPUTFORMATTER
|
||||
class KICOMMON_API FILE_OUTPUTFORMATTER : public OUTPUTFORMATTER
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -495,7 +495,7 @@ protected:
|
|||
*
|
||||
* The stream is neither opened nor closed by this class.
|
||||
*/
|
||||
class STREAM_OUTPUTFORMATTER : public OUTPUTFORMATTER
|
||||
class KICOMMON_API STREAM_OUTPUTFORMATTER : public OUTPUTFORMATTER
|
||||
{
|
||||
wxOutputStream& m_os;
|
||||
|
||||
|
|
|
@ -29,20 +29,21 @@
|
|||
#include <wx/string.h>
|
||||
#include <wx/filename.h>
|
||||
|
||||
#include <kicommon.h>
|
||||
|
||||
void ConvertMarkdown2Html( const wxString& aMarkdownInput, wxString& aHtmlOutput );
|
||||
|
||||
/**
|
||||
* Convert the old `~...~` overbar notation to the new `~{...}` one.
|
||||
*/
|
||||
wxString ConvertToNewOverbarNotation( const wxString& aOldStr );
|
||||
KICOMMON_API wxString ConvertToNewOverbarNotation( const wxString& aOldStr );
|
||||
|
||||
/**
|
||||
* Convert curly quotes and em/en dashes to straight quotes and dashes.
|
||||
*
|
||||
* @return true if any characters required conversion.
|
||||
*/
|
||||
bool ConvertSmartQuotesAndDashes( wxString* aString );
|
||||
KICOMMON_API bool ConvertSmartQuotesAndDashes( wxString* aString );
|
||||
|
||||
/**
|
||||
* Escape/Unescape routines to safely encode reserved-characters in various contexts.
|
||||
|
@ -68,19 +69,19 @@ enum ESCAPE_CONTEXT
|
|||
* (b) used as control characters in LIB_IDs
|
||||
* (c) used to delineate hierarchical paths
|
||||
*/
|
||||
wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext );
|
||||
KICOMMON_API wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext );
|
||||
|
||||
wxString UnescapeString( const wxString& aSource );
|
||||
KICOMMON_API wxString UnescapeString( const wxString& aSource );
|
||||
|
||||
/**
|
||||
* Remove markup (such as overbar or subscript) that we can't render to menu items.
|
||||
*/
|
||||
wxString PrettyPrintForMenu( const wxString& aString );
|
||||
KICOMMON_API wxString PrettyPrintForMenu( const wxString& aString );
|
||||
|
||||
/**
|
||||
* Capitalize the first letter in each word.
|
||||
*/
|
||||
wxString TitleCaps( const wxString& aString );
|
||||
KICOMMON_API wxString TitleCaps( const wxString& aString );
|
||||
|
||||
/**
|
||||
* Copy bytes from @a aSource delimited string segment to @a aDest buffer.
|
||||
|
@ -95,7 +96,7 @@ wxString TitleCaps( const wxString& aString );
|
|||
* due to escaping of double quotes and the escape byte itself.
|
||||
* @deprecated should use the one which fetches a wxString, below.
|
||||
*/
|
||||
int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize );
|
||||
KICOMMON_API int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize );
|
||||
|
||||
/**
|
||||
* Copy bytes from @a aSource delimited string segment to @a aDest wxString.
|
||||
|
@ -105,7 +106,7 @@ int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize );
|
|||
* @return the number of bytes read from source, which may be more than the number copied,
|
||||
* due to escaping of double quotes and the escape byte itself.
|
||||
*/
|
||||
int ReadDelimitedText( wxString* aDest, const char* aSource );
|
||||
KICOMMON_API int ReadDelimitedText( wxString* aDest, const char* aSource );
|
||||
|
||||
/**
|
||||
* Return an 8 bit UTF8 string given aString in Unicode form.
|
||||
|
@ -116,47 +117,47 @@ int ReadDelimitedText( wxString* aDest, const char* aSource );
|
|||
* @param aString is the input string to convert.
|
||||
* @return the escaped input text, without the wrapping double quotes.
|
||||
*/
|
||||
std::string EscapedUTF8( const wxString& aString );
|
||||
KICOMMON_API std::string EscapedUTF8( const wxString& aString );
|
||||
|
||||
/**
|
||||
* Return a new wxString escaped for embedding in HTML.
|
||||
*/
|
||||
wxString EscapeHTML( const wxString& aString );
|
||||
KICOMMON_API wxString EscapeHTML( const wxString& aString );
|
||||
|
||||
/**
|
||||
* Return a new wxString unescaped from HTML format.
|
||||
*/
|
||||
wxString UnescapeHTML( const wxString& aString );
|
||||
KICOMMON_API wxString UnescapeHTML( const wxString& aString );
|
||||
|
||||
/**
|
||||
* Read one line line from \a aFile.
|
||||
*
|
||||
* @return a pointer the first useful line read by eliminating blank lines and comments.
|
||||
*/
|
||||
char* GetLine( FILE* aFile, char* Line, int* LineNum = nullptr, int SizeLine = 255 );
|
||||
KICOMMON_API char* GetLine( FILE* aFile, char* Line, int* LineNum = nullptr, int SizeLine = 255 );
|
||||
|
||||
/**
|
||||
* Return true if the string is empty or contains only whitespace.
|
||||
*/
|
||||
bool NoPrintableChars( const wxString& aString );
|
||||
KICOMMON_API bool NoPrintableChars( const wxString& aString );
|
||||
|
||||
/**
|
||||
* Return the number of printable (ie: non-formatting) chars. Used to approximate rendered
|
||||
* text size when speed is more important than accuracy.
|
||||
*/
|
||||
int PrintableCharCount( const wxString& aString );
|
||||
KICOMMON_API int PrintableCharCount( const wxString& aString );
|
||||
|
||||
/**
|
||||
* Remove leading and training spaces, tabs and end of line chars in \a text
|
||||
*
|
||||
* @return a pointer on the first n char in text
|
||||
*/
|
||||
char* StrPurge( char* text );
|
||||
KICOMMON_API char* StrPurge( char* text );
|
||||
|
||||
/**
|
||||
* @return a string giving the current date and time.
|
||||
*/
|
||||
wxString GetISO8601CurrentDateTime();
|
||||
KICOMMON_API wxString GetISO8601CurrentDateTime();
|
||||
|
||||
/**
|
||||
* Compare two strings with alphanumerical content.
|
||||
|
@ -172,14 +173,15 @@ wxString GetISO8601CurrentDateTime();
|
|||
* \a aString1 is equal to \a aString2, or 1 if \a aString1 is greater
|
||||
* than \a aString2.
|
||||
*/
|
||||
int StrNumCmp( const wxString& aString1, const wxString& aString2, bool aIgnoreCase = false );
|
||||
KICOMMON_API int StrNumCmp( const wxString& aString1, const wxString& aString2,
|
||||
bool aIgnoreCase = false );
|
||||
|
||||
/**
|
||||
* Compare a string against wild card (* and ?) pattern using the usual rules.
|
||||
*
|
||||
* @return true if pattern matched otherwise false.
|
||||
*/
|
||||
bool WildCompareString( const wxString& pattern,
|
||||
KICOMMON_API bool WildCompareString( const wxString& pattern,
|
||||
const wxString& string_to_tst,
|
||||
bool case_sensitive = true );
|
||||
|
||||
|
@ -190,7 +192,7 @@ bool WildCompareString( const wxString& pattern,
|
|||
* @return -1 if first string is less than the second, 0 if the strings are equal, or
|
||||
* 1 if the first string is greater than the second.
|
||||
*/
|
||||
int ValueStringCompare( const wxString& strFWord, const wxString& strSWord );
|
||||
KICOMMON_API int ValueStringCompare( const wxString& strFWord, const wxString& strSWord );
|
||||
|
||||
/**
|
||||
* Break a string into three parts: he alphabetic preamble, the numeric part, and any
|
||||
|
@ -198,7 +200,7 @@ int ValueStringCompare( const wxString& strFWord, const wxString& strSWord );
|
|||
*
|
||||
* For example C10A is split to C 10 A
|
||||
*/
|
||||
int SplitString( const wxString& strToSplit,
|
||||
KICOMMON_API int SplitString( const wxString& strToSplit,
|
||||
wxString* strBeginning,
|
||||
wxString* strDigits,
|
||||
wxString* strEnd );
|
||||
|
@ -209,12 +211,12 @@ int SplitString( const wxString& strToSplit,
|
|||
* @param aStr the string to check.
|
||||
* @return the trailing int or 0 if none found.
|
||||
*/
|
||||
int GetTrailingInt( const wxString& aStr );
|
||||
KICOMMON_API int GetTrailingInt( const wxString& aStr );
|
||||
|
||||
/**
|
||||
* @return a wxString object containing the illegal file name characters for all platforms.
|
||||
*/
|
||||
wxString GetIllegalFileNameWxChars();
|
||||
KICOMMON_API wxString GetIllegalFileNameWxChars();
|
||||
|
||||
/**
|
||||
* Checks \a aName for illegal file name characters.
|
||||
|
@ -230,8 +232,8 @@ wxString GetIllegalFileNameWxChars();
|
|||
* @param aReplaceChar (if not 0) is the replacement char.
|
||||
* @return true if any characters have been replaced in \a aName.
|
||||
*/
|
||||
bool ReplaceIllegalFileNameChars( std::string* aName, int aReplaceChar = 0 );
|
||||
bool ReplaceIllegalFileNameChars( wxString& aName, int aReplaceChar = 0 );
|
||||
KICOMMON_API bool ReplaceIllegalFileNameChars( std::string* aName, int aReplaceChar = 0 );
|
||||
KICOMMON_API bool ReplaceIllegalFileNameChars( wxString& aName, int aReplaceChar = 0 );
|
||||
|
||||
|
||||
/**
|
||||
|
@ -333,7 +335,7 @@ inline void AccumulateDescription( wxString& aDesc, const wxString& aItem )
|
|||
* @param aStrings will contain the split lines.
|
||||
* @param aSplitter is the 'split' character.
|
||||
*/
|
||||
void wxStringSplit( const wxString& aText, wxArrayString& aStrings, wxChar aSplitter );
|
||||
KICOMMON_API void wxStringSplit( const wxString& aText, wxArrayString& aStrings, wxChar aSplitter );
|
||||
|
||||
/**
|
||||
* Remove trailing zeros from a string containing a converted float number.
|
||||
|
@ -341,7 +343,7 @@ void wxStringSplit( const wxString& aText, wxArrayString& aStrings, wxChar aSpli
|
|||
* The trailing zeros are removed if the mantissa has more than \a aTrailingZeroAllowed
|
||||
* digits and some trailing zeros.
|
||||
*/
|
||||
void StripTrailingZeros( wxString& aStringValue, unsigned aTrailingZeroAllowed = 1 );
|
||||
KICOMMON_API void StripTrailingZeros( wxString& aStringValue, unsigned aTrailingZeroAllowed = 1 );
|
||||
|
||||
/**
|
||||
* Print a float number without using scientific notation and no trailing 0
|
||||
|
@ -352,7 +354,7 @@ void StripTrailingZeros( wxString& aStringValue, unsigned aTrailingZeroAllowed =
|
|||
* this helper function uses the %f format when needed, or %g when %f is
|
||||
* not well working and then removes trailing 0
|
||||
*/
|
||||
std::string UIDouble2Str( double aValue );
|
||||
KICOMMON_API std::string UIDouble2Str( double aValue );
|
||||
|
||||
/**
|
||||
* Print a float number without using scientific notation and no trailing 0
|
||||
|
@ -362,7 +364,7 @@ std::string UIDouble2Str( double aValue );
|
|||
* this helper function uses the %f format when needed, or %g when %f is
|
||||
* not well working and then removes trailing 0
|
||||
*/
|
||||
std::string FormatDouble2Str( double aValue );
|
||||
KICOMMON_API std::string FormatDouble2Str( double aValue );
|
||||
|
||||
/**
|
||||
* Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
|
||||
|
@ -380,7 +382,7 @@ std::string FormatDouble2Str( double aValue );
|
|||
* If fails, tray to convert using current locale
|
||||
* If still fails, return the initial string (can be already a converted string)
|
||||
*/
|
||||
wxString From_UTF8( const std::string& aString );
|
||||
wxString From_UTF8( const char* cstring );
|
||||
KICOMMON_API wxString From_UTF8( const std::string& aString );
|
||||
KICOMMON_API wxString From_UTF8( const char* cstring );
|
||||
|
||||
#endif // STRING_UTILS_H
|
||||
|
|
|
@ -120,6 +120,7 @@ if( APPLE )
|
|||
target_link_libraries( kicad
|
||||
nlohmann_json
|
||||
common
|
||||
kicommon
|
||||
core
|
||||
${wxWidgets_LIBRARIES}
|
||||
)
|
||||
|
|
|
@ -24,7 +24,6 @@ include_directories(
|
|||
#
|
||||
|
||||
add_library( s3d_plugin_vrml MODULE
|
||||
${CMAKE_SOURCE_DIR}/common/richio.cpp
|
||||
${CMAKE_SOURCE_DIR}/common/exceptions.cpp
|
||||
vrml.cpp
|
||||
x3d.cpp
|
||||
|
@ -65,7 +64,7 @@ add_library( s3d_plugin_vrml MODULE
|
|||
x3d/x3d_transform.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( s3d_plugin_vrml kicad_3dsg core ${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES} kiplatform ZLIB::ZLIB )
|
||||
target_link_libraries( s3d_plugin_vrml kicad_3dsg kicommon core ${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES} kiplatform ZLIB::ZLIB )
|
||||
|
||||
target_include_directories( s3d_plugin_vrml PRIVATE
|
||||
$<TARGET_PROPERTY:gzip-hpp,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
|
|
Loading…
Reference in New Issue