Commit 2cda6f4b authored by Dick Hollenbeck's avatar Dick Hollenbeck

early work on DLL exports for sweet lib, stop using <cstdio> which mingw seems...

early work on DLL exports for sweet lib, stop using <cstdio> which mingw seems not to like cuz snprintf()
parent 77c64161
...@@ -50,7 +50,10 @@ macro(perform_feature_checks) ...@@ -50,7 +50,10 @@ macro(perform_feature_checks)
# mean won't fail somewhere down the line. # mean won't fail somewhere down the line.
check_include_file("iso646.h" HAVE_ISO646_H) check_include_file("iso646.h" HAVE_ISO646_H)
check_include_file("strings.h" HAVE_STRINGS_H) # no place is this used, and "HAVE_STRINGS_H", if present in config.h then
# conflicts with /usr/include/python2.6/Python.h. Please rename the macro if
# re-introduce this.
# check_include_file("strings.h" HAVE_STRINGS_H)
include(CheckSymbolExists) include(CheckSymbolExists)
check_symbol_exists(strcasecmp "string.h" HAVE_STRCASECMP) check_symbol_exists(strcasecmp "string.h" HAVE_STRCASECMP)
...@@ -68,7 +71,7 @@ macro(perform_feature_checks) ...@@ -68,7 +71,7 @@ macro(perform_feature_checks)
check_symbol_exists(_hypot "math.h" HAVE_ISO_HYPOT) check_symbol_exists(_hypot "math.h" HAVE_ISO_HYPOT)
# Generate config.h. # Generate config.h.
configure_file(${CMAKE_SOURCE_DIR}/CMakeModules/config.h.cmake configure_file(${PROJECT_SOURCE_DIR}/CMakeModules/config.h.cmake
${CMAKE_BINARY_DIR}/config.h) ${CMAKE_BINARY_DIR}/config.h)
endmacro(perform_feature_checks) endmacro(perform_feature_checks)
...@@ -35,8 +35,6 @@ ...@@ -35,8 +35,6 @@
#include <iso646.h> #include <iso646.h>
#endif #endif
#cmakedefine HAVE_STRINGS_H
#if defined( HAVE_STRCASECMP ) #if defined( HAVE_STRCASECMP )
#define stricmp strcasecmp #define stricmp strcasecmp
#elif defined( HAVE_ISO_STRICMP ) #elif defined( HAVE_ISO_STRICMP )
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#ifndef DSNLEXER_H_ #ifndef DSNLEXER_H_
#define DSNLEXER_H_ #define DSNLEXER_H_
#include <cstdio> #include <stdio.h>
#include <string> #include <string>
#include <vector> #include <vector>
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
// I really did not want to be dependent on wxWidgets in richio // I really did not want to be dependent on wxWidgets in richio
// but the errorText needs to be wide char so wxString rules. // but the errorText needs to be wide char so wxString rules.
#include <wx/wx.h> #include <wx/wx.h>
#include <cstdio> #include <stdio.h>
/** /**
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
// use one of the following __LOC__ defs, depending on whether your // use one of the following __LOC__ defs, depending on whether your
// compiler supports __func__ or not, and how it handles __LINE__ // compiler supports __func__ or not, and how it handles __LINE__
#define __LOC__ ((std::string(__func__) + " : ") + TOSTRING(__LINE__)).c_str() #define __LOC__ ((std::string(__func__) + "() : line ") + TOSTRING(__LINE__)).c_str()
//#define __LOC__ TOSTRING(__LINE__) //#define __LOC__ TOSTRING(__LINE__)
/// macro which captures the "call site" values of __FILE_ & __LOC__ /// macro which captures the "call site" values of __FILE_ & __LOC__
......
...@@ -24,6 +24,10 @@ if( STAND_ALONE ) ...@@ -24,6 +24,10 @@ if( STAND_ALONE )
check_find_package_result( wxWidgets_FOUND "wxWidgets" ) check_find_package_result( wxWidgets_FOUND "wxWidgets" )
# make config.h
include(PerformFeatureChecks)
perform_feature_checks()
# Include wxWidgets macros. # Include wxWidgets macros.
include( ${wxWidgets_USE_FILE} ) include( ${wxWidgets_USE_FILE} )
...@@ -59,6 +63,7 @@ endif() ...@@ -59,6 +63,7 @@ endif()
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
include_directories( ${CMAKE_BINARY_DIR} )
#=====<on standby for possible C++ unit testing>================================ #=====<on standby for possible C++ unit testing>================================
if( false ) if( false )
...@@ -95,6 +100,7 @@ make_lexer( ...@@ -95,6 +100,7 @@ make_lexer(
PR PR
) )
add_library( sweet SHARED add_library( sweet SHARED
sch_lib_table.cpp sch_lib_table.cpp
sch_lib_table_keywords.cpp sch_lib_table_keywords.cpp
...@@ -108,7 +114,17 @@ add_library( sweet SHARED ...@@ -108,7 +114,17 @@ add_library( sweet SHARED
) )
target_link_libraries( sweet ${wxWidgets_LIBRARIES} ) target_link_libraries( sweet ${wxWidgets_LIBRARIES} )
# talk to import_export.h
set_target_properties( sweet PROPERTIES
DEFINE_SYMBOL COMPILING_DLL
)
add_executable( test_sch_lib_table test_sch_lib_table.cpp ) add_executable( test_sch_lib_table test_sch_lib_table.cpp )
if( MINGW )
set_target_properties( test_sch_lib_table PROPERTIES
LINK_FLAGS -Wl,--enable-auto-import
)
endif()
target_link_libraries( test_sch_lib_table sweet ) target_link_libraries( test_sch_lib_table sweet )
...@@ -116,7 +132,7 @@ target_link_libraries( test_sch_lib_table sweet ) ...@@ -116,7 +132,7 @@ target_link_libraries( test_sch_lib_table sweet )
# if you want a Python scripting layer on top for unit testing or driving. # if you want a Python scripting layer on top for unit testing or driving.
# reference: http://www.swig.org/Doc1.3/Introduction.html#Introduction_build_system # reference: http://www.swig.org/Doc1.3/Introduction.html#Introduction_build_system
option( USE_SWIG "Use SWIG to build a python scripting interface (default ON)." ON) option( USE_SWIG "Use SWIG to build a python scripting interface (default OFF)." OFF)
if( USE_SWIG ) if( USE_SWIG )
find_package( SWIG REQUIRED ) find_package( SWIG REQUIRED )
......
/* /*
* This program source code file is part of KICAD, a free EDA CAD application. * This program source code file is part of KICAD, a free EDA CAD application.
* *
* Copyright (C) 2010-2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2010 Kicad Developers, see change_log.txt for contributors. * Copyright (C) 2011 Kicad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -22,60 +22,39 @@ ...@@ -22,60 +22,39 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#ifndef SCH_LIBS_H_ #ifndef IMPORT_EXPORT_H_
#define SCH_LIBS_H_ #define IMPORT_EXPORT_H_
#include <sch_lib.h> // macros which export functions from a DLL/DSO. Not yet important with GCC,
// (either linux or mingw maybe OSX), until you compile with the hidden attribute:
// -fvisibility=hidden -fvisibility-inlines-hidden, which we are not yet.
/** // GCC >= 4.x
* Class LIBS #if defined(__GNUC__) && __GNUC__ >= 4
* houses a handful of functions that manage all the RAM resident LIBs, and # define APIEXPORT __attribute__ ((visibility("default")))
* provide for a global part lookup function, GetPart(), which can be the basis # define APIIMPORT __attribute__ ((visibility("default")))
* of a cross LIB hyperlink. # define APILOCAL __attribute__ ((visibility("hidden")))
*/
class LIBS
{
public:
/**
* Function GetPart
* finds and loads a PART, and parses it. As long as the part is
* accessible in any LIB_SOURCE, opened or not opened, this function
* will find it and load it into its containing LIB, even if that means
* having to load a new LIB as given in the library table.
*/
static PART* GetPart( const LPID& aLogicalPartID ) throw( IO_ERROR );
/**
* Function GetLib
* is first a lookup function and then if needed, a factory function.
* If aLogicalLibraryName has been opened, then return the already opened
* LIB. If not, then instantiate the library and fill the initial
* library PARTs (unparsed) and categories, and add it to LIB::libraries
* for future reference.
*/
static LIB* GetLib( const STRING& aLogicalLibraryName ) throw( IO_ERROR );
/**
* Function GetOpenedLibNames
* returns the logical library names of LIBs that are already opened.
* @see LPID::GetLogicalLibraries()
*/
static STRINGS GetOpendedLogicalLibNames();
/** // windows
* Function CloseLibrary #elif (defined(__WINDOWS__) || defined(__CYGWIN__) || defined(_WIN32))
* closes an open library @a aLibrary and removes it from class LIBS. # define APIEXPORT __declspec(dllexport)
*/ # define APIIMPORT __declspec(dllimport)
static void CloseLibrary( LIB* aLibrary ) throw( IO_ERROR ); # define APILOCAL
#else // not windows nor GCC >= 4.x
# define APIEXPORT
# define APIIMPORT
# define APILOCAL
#endif
private:
/// collection of LIBs, searchable by logical name. #ifdef COMPILING_DLL // by CMake magically when compiling implementation.
static std::map< STRING, LIB* > libraries; // owns the LIBs. # define MY_API APIEXPORT
}; #else
# define MY_API APIIMPORT
#endif
#define MY_LOCAL APILOCAL
#endif // SCH_LIBS_H_ #endif // IMPORT_EXPORTS_H_
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <utf8.h> #include <utf8.h>
#include <richio.h> #include <richio.h>
#include <import_export.h>
namespace SCH { namespace SCH {
...@@ -199,7 +200,7 @@ class PARTS; ...@@ -199,7 +200,7 @@ class PARTS;
* *
* @author Dick Hollenbeck * @author Dick Hollenbeck
*/ */
class LIB class MY_API LIB
{ {
friend class LIB_TABLE; ///< protected constructor, LIB_TABLE may construct friend class LIB_TABLE; ///< protected constructor, LIB_TABLE may construct
......
...@@ -44,7 +44,7 @@ LIB_TABLE::LIB_TABLE( LIB_TABLE* aFallBackTable ) : ...@@ -44,7 +44,7 @@ LIB_TABLE::LIB_TABLE( LIB_TABLE* aFallBackTable ) :
} }
void LIB_TABLE::Parse( SCH_LIB_TABLE_LEXER* in ) throw( IO_ERROR ) void LIB_TABLE::Parse( SCH_LIB_TABLE_LEXER* in ) throw( IO_ERROR, PARSE_ERROR )
{ {
/* grammar: /* grammar:
......
...@@ -28,10 +28,12 @@ ...@@ -28,10 +28,12 @@
#include <string> #include <string>
#include <boost/ptr_container/ptr_map.hpp> #include <boost/ptr_container/ptr_map.hpp>
#include <import_export.h>
#include <sch_lib.h> #include <sch_lib.h>
class SCH_LIB_TABLE_LEXER; // outside namespace SCH, since make_lexer() Functions.cmake can't do namespace
class OUTPUTFORMATTER; class OUTPUTFORMATTER;
class SCH_LIB_TABLE_LEXER;
namespace SCH { namespace SCH {
...@@ -80,7 +82,7 @@ class PART; ...@@ -80,7 +82,7 @@ class PART;
* *
* @author Dick Hollenbeck * @author Dick Hollenbeck
*/ */
class LIB_TABLE class MY_API LIB_TABLE
{ {
public: public:
...@@ -213,7 +215,7 @@ public: ...@@ -213,7 +215,7 @@ public:
/** /**
* Function Parse * Function Parse
* fills this table fragment from information in the input stream \a aLexer, which * fills this table fragment from information in the input stream \a aParser, which
* is a DSNLEXER customized for the grammar needed to describe instances of this object. * is a DSNLEXER customized for the grammar needed to describe instances of this object.
* The entire textual element spec is <br> * The entire textual element spec is <br>
* *
...@@ -225,14 +227,15 @@ public: ...@@ -225,14 +227,15 @@ public:
* ) * )
* </pre> * </pre>
* *
* When this function is called, the input token stream given by \a aLexer * When this function is called, the input token stream given by \a aParser
* is assumed to be positioned at the '^' in the following example, i.e. just after the * is assumed to be positioned at the '^' in the following example, i.e. just
* identifying keyword and before the content specifying stuff.<br> * after the identifying keyword and before the content specifying stuff.
* <br>
* (lib_table ^ (....) ) * (lib_table ^ (....) )
* *
* @param aLexer is the input token stream of keywords and symbols. * @param aParser is the input token stream of keywords and symbols.
*/ */
void Parse( SCH_LIB_TABLE_LEXER* aLexer ) throw( IO_ERROR ); void Parse( SCH_LIB_TABLE_LEXER* aParser ) throw( IO_ERROR, PARSE_ERROR );
/** /**
* Function Format * Function Format
......
/**
* Function GetPart
* finds and loads a PART, and parses it. As long as the part is
* accessible in any LIB_SOURCE, opened or not opened, this function
* will find it and load it into its containing LIB, even if that means
* having to load a new LIB as given in the library table.
*/
static PART* SCH_LIBS::GetPart( const LPID& aLogicalPartID ) throw( IO_ERROR )
{
}
...@@ -26,6 +26,7 @@ namespace SCH { ...@@ -26,6 +26,7 @@ namespace SCH {
%ignore PART::operator=( const PART& other ); %ignore PART::operator=( const PART& other );
} }
%include "import_export.h"
%include "richio.h" %include "richio.h"
%include "dsnlexer.h" %include "dsnlexer.h"
//%include "sch_lib_table_lexer.h" //%include "sch_lib_table_lexer.h"
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
using namespace SCH; using namespace SCH;
// If LIB_TABLE::Test() is conditioned on DEBUG being defined, build with // If LIB_TABLE::Test() is conditioned on DEBUG being defined, build with
// CMAKE_BUILD_TYPE=Debug, otherwise don't worry about it, because it will work // CMAKE_BUILD_TYPE=Debug, otherwise don't worry about it, because it will work
// on any CMAKE_BUILD_TYPE, including Release. // on any CMAKE_BUILD_TYPE, including Release.
......
...@@ -14,7 +14,7 @@ set( CMAKE_SYSTEM_NAME Linux ) ...@@ -14,7 +14,7 @@ set( CMAKE_SYSTEM_NAME Linux )
# configure only the lines within this <configure> block, typically # configure only the lines within this <configure> block, typically
# default is specific to Dick's machine, again for testing only: # default is specific to Dick's machine, again for testing only:
set( WX_MINGW_BASE /opt/wx2.8-mingw ) set( WX_MINGW_BASE /opt/wx2.9-mingw )
# specify the cross compiler # specify the cross compiler
set( CMAKE_C_COMPILER i586-mingw32msvc-gcc ) set( CMAKE_C_COMPILER i586-mingw32msvc-gcc )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment