Commit 33e26b27 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

KIWAY in progress...

parent 2eb99fef
Loading
Loading
Loading
Loading
+33 −13
Original line number Original line Diff line number Diff line
@@ -24,7 +24,7 @@ set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules )
#
#


option( USE_KIWAY_DLLS
option( USE_KIWAY_DLLS
    "Build the major modules as DLLs or DSOs, will soon be the norm." OFF )
    "Build the major modules as KIFACE DLLs or DSOs, will soon be the norm." OFF )


# The desire is to migrate designs *away from* case independence, and to create designs which use
# The desire is to migrate designs *away from* case independence, and to create designs which use
# literally (case specific) interpreted component names.  But for backwards compatibility,
# literally (case specific) interpreted component names.  But for backwards compatibility,
@@ -240,6 +240,8 @@ if( USE_WX_GRAPHICS_CONTEXT )
    add_definitions( -DUSE_WX_GRAPHICS_CONTEXT )
    add_definitions( -DUSE_WX_GRAPHICS_CONTEXT )
endif()
endif()




# Allow user to override the default settings for adding images to menu items.  By default
# Allow user to override the default settings for adding images to menu items.  By default
# images in menu items are enabled on all platforms except OSX.  This can be over ridden by
# images in menu items are enabled on all platforms except OSX.  This can be over ridden by
# defining -DUSE_IMAGES_IN_MENUS=ON/OFF to force the preferred behavior.
# defining -DUSE_IMAGES_IN_MENUS=ON/OFF to force the preferred behavior.
@@ -253,6 +255,25 @@ else()
    endif()
    endif()
endif()
endif()



# KIFACE_SUFFIX is the file extension used for top level program modules which
# implement the KIFACE interface.  A valid suffix starts with a period '.'.

if( false )
    # This is the eventual situation near milestone C) of modular-kicad blueprint.
    # Until then we use .kiface extension so we don't collide with python DSO.
    set( KIFACE_SUFFIX  ${CMAKE_SHARED_MODULE_SUFFIX} )
else()
    # Temporary situation until we can dovetail the python DSO into the kiface DSO.
    set( KIFACE_SUFFIX  ".kiface" )
endif()

# KIFACE_PREFIX is a basename prefix used for top level program modules which
# implement the KIFACE.
set( KIFACE_PREFIX  "_" )
#message( STATUS "KIFACE_SUFFIX:${KIFACE_SUFFIX}  KIFACE_PREFIX:${KIFACE_PREFIX}" )


#================================================
#================================================
# Locations for install targets.
# Locations for install targets.
set( KICAD_BIN bin
set( KICAD_BIN bin
@@ -341,7 +362,7 @@ if ( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC )
    else()
    else()
        include( download_wxwidgets )
        include( download_wxwidgets )
        add_dependencies( lib-dependencies libwx )
        add_dependencies( lib-dependencies libwx )
    endif( KICAD_SCRIPTING_WXPYTHON )
    endif()


    include( download_pkgconfig )
    include( download_pkgconfig )
        set( PKG_CONFIG_EXECUTABLE "${PKGCONFIG_ROOT}/bin/pkg-config" )
        set( PKG_CONFIG_EXECUTABLE "${PKGCONFIG_ROOT}/bin/pkg-config" )
@@ -359,7 +380,6 @@ if ( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC )
        add_custom_command(TARGET osx_fix_bundles POST_BUILD COMMAND scripts/osx_fixbundle.sh COMMENT "Migrating dylibs to bundles")
        add_custom_command(TARGET osx_fix_bundles POST_BUILD COMMAND scripts/osx_fixbundle.sh COMMENT "Migrating dylibs to bundles")
    endif()
    endif()



endif( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC)
endif( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC)


#####################
#####################
+6 −1
Original line number Original line Diff line number Diff line
@@ -67,9 +67,14 @@
/// When defined, build the GITHUB_PLUGIN for pcbnew.
/// When defined, build the GITHUB_PLUGIN for pcbnew.
#cmakedefine BUILD_GITHUB_PLUGIN
#cmakedefine BUILD_GITHUB_PLUGIN


/// When defined, use KIWAY and DSOs
/// When defined, use KIWAY and KIFACE DSOs
#cmakedefine USE_KIWAY_DLLS
#cmakedefine USE_KIWAY_DLLS


/// A file extension with a leading '.' is a suffix, and this one is used on
/// top level program modules which implement the KIFACE.
#define KIFACE_SUFFIX                   wxT( "@KIFACE_SUFFIX@" )
#define KIFACE_PREFIX                   wxT( "@KIFACE_PREFIX@" )

/// Name of repo from which this build came.
/// Name of repo from which this build came.
#define KICAD_REPO_NAME                 "@KICAD_REPO_NAME@"
#define KICAD_REPO_NAME                 "@KICAD_REPO_NAME@"


+4 −2
Original line number Original line Diff line number Diff line
@@ -23,9 +23,11 @@
 */
 */


#include <kiway.h>
#include <kiway.h>
#include <config.h>
#include <wx/debug.h>
#include <wx/debug.h>
#include <string.h>
#include <string.h>



// one for each FACE_T
// one for each FACE_T
wxDynamicLibrary KIWAY::s_sch_dso;
wxDynamicLibrary KIWAY::s_sch_dso;
wxDynamicLibrary KIWAY::s_pcb_dso;
wxDynamicLibrary KIWAY::s_pcb_dso;
@@ -41,8 +43,8 @@ const wxString KIWAY::dso_name( FACE_T aFaceId )
{
{
    switch( aFaceId )
    switch( aFaceId )
    {
    {
    case FACE_SCH:  return wxT( "_eeschema." ) DSO_EXT;
    case FACE_SCH:  return KIFACE_PREFIX wxT( "eeschema" ) KIFACE_SUFFIX;
    case FACE_PCB:  return wxT( "_pcbnew."   ) DSO_EXT;
    case FACE_PCB:  return KIFACE_PREFIX wxT( "pcbnew"   ) KIFACE_SUFFIX;


    default:
    default:
        wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) );
        wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) );
+31 −29
Original line number Original line Diff line number Diff line
@@ -25,9 +25,9 @@


/*
/*


    This is a program launcher for a single DSO. Initially it will only mimic a
    This is a program launcher for a single KIFACE DSO. Initially it will only
    KIWAY not actually implement one, since only a single DSO is supported by
    mimic a KIWAY, not actually implement one, since only a single DSO is
    it.
    supported by it.


*/
*/


@@ -107,8 +107,8 @@ static wxString wxJoin(const wxArrayString& arr, const wxChar sep,
#endif
#endif




// POLICY CHOICE: return the name of the DSO to load as single_top.
// POLICY CHOICE: return the full path of the DSO to load from single_top.
static const wxString dso_name( const wxString& aAbsoluteArgv0 )
static const wxString dso_full_path( const wxString& aAbsoluteArgv0 )
{
{
    // Prefix basename with '_' and change extension to DSO_EXT.
    // Prefix basename with '_' and change extension to DSO_EXT.


@@ -129,11 +129,14 @@ static const wxString dso_name( const wxString& aAbsoluteArgv0 )
    // too many masters here: python, windows, linux, OSX, multiple versions of wx...
    // too many masters here: python, windows, linux, OSX, multiple versions of wx...


    wxFileName  fn( aAbsoluteArgv0 );
    wxFileName  fn( aAbsoluteArgv0 );
    wxString    basename( wxT( '_' ) );
    wxString    basename( KIFACE_PREFIX );  // start with special prefix


    basename += fn.GetName();
    basename += fn.GetName();               // add argv[0]'s basename
    fn.SetName( basename );
    fn.SetName( basename );
    fn.SetExt( DSO_EXT );

    // here a suffix == an extension with a preceding '.',
    // so skip the preceding '.' to get an extension
    fn.SetExt( KIFACE_SUFFIX + 1 );         // special extension, + 1 => &KIFACE_SUFFIX[1]


    return fn.GetFullPath();
    return fn.GetFullPath();
}
}
@@ -157,10 +160,11 @@ void SetLibEnvVar( const wxString& aAbsoluteArgv0 )
    // POLICY CHOICE: Keep same path, so that installer MAY put the
    // POLICY CHOICE: Keep same path, so that installer MAY put the
    // "subsidiary shared libraries" in the same directory as the top process module.
    // "subsidiary shared libraries" in the same directory as the top process module.
    // A subsidiary shared library is one that is not a top level DSO, but rather
    // A subsidiary shared library is one that is not a top level DSO, but rather
    // some shared library that a top level DSO needs to even be loaded.
    // some shared library that a top level DSO needs to even be loaded.  It is
    // a static link to a shared object from a top level DSO.


    // This directory POLICY CHOICE is not the only dir in play, since LIB_ENV_VAR
    // This directory POLICY CHOICE is not the only dir in play, since LIB_ENV_VAR
    // has numerous path options in it, as does DSO searching on linux.
    // has numerous path options in it, as does DSO searching on linux, windows, and OSX.
    // See "man ldconfig" on linux. What's being done here is for quick installs
    // See "man ldconfig" on linux. What's being done here is for quick installs
    // into a non-standard place, and especially for Windows users who may not
    // into a non-standard place, and especially for Windows users who may not
    // know what the PATH environment variable is or how to set it.
    // know what the PATH environment variable is or how to set it.
@@ -183,7 +187,7 @@ void SetLibEnvVar( const wxString& aAbsoluteArgv0 )
}
}




// Only a single KIWAY is supported in this single_top to level component,
// Only a single KIWAY is supported in this single_top top level component,
// which is dedicated to loading only a single DSO.
// which is dedicated to loading only a single DSO.
static KIWAY    standalone;
static KIWAY    standalone;


@@ -199,7 +203,8 @@ static wxDynamicLibrary dso;
 * @param aDSOName is an absolute full path to the DSO to load and find KIFACE_GETTER_FUNC within.
 * @param aDSOName is an absolute full path to the DSO to load and find KIFACE_GETTER_FUNC within.
 *
 *
 * @return KIFACE_GETTER_FUNC* - a pointer to a function which can be called to get the KIFACE
 * @return KIFACE_GETTER_FUNC* - a pointer to a function which can be called to get the KIFACE
 *   or NULL if not found or not version compatible.
 *  or NULL if the getter func was not found.  If not found, it is possibly not version compatible
 *  since the lookup is done by name and the name contains the API version.
 */
 */
static KIFACE_GETTER_FUNC* get_kiface_getter( const wxString& aDSOName )
static KIFACE_GETTER_FUNC* get_kiface_getter( const wxString& aDSOName )
{
{
@@ -234,16 +239,18 @@ bool PROCESS::OnInit()


    wxStandardPathsBase& paths = wxStandardPaths::Get();
    wxStandardPathsBase& paths = wxStandardPaths::Get();


#if defined(DEBUG)
    wxString dir = paths.GetLocalizedResourcesDir( wxT( "de" ),
    wxString dir = paths.GetLocalizedResourcesDir( wxT( "de" ),
                        wxStandardPaths::ResourceCat_None );
                        wxStandardPaths::ResourceCat_None );


    printf( "LocalizeResourcesDir:'%s'\n",  TO_UTF8( dir ) );
    printf( "LocalizeResourcesDir:'%s'\n",  TO_UTF8( dir ) );


    wxString dummy( _( "translate this" ) );
    wxString dummy( _( "translate this" ) );
#endif


    wxString absoluteArgv0 = paths.GetExecutablePath();
    wxString absoluteArgv0 = paths.GetExecutablePath();


#if 0 || defined(DEBUG)
#if 0 && defined(DEBUG)
    printf( "argv[0]:'%s' absoluteArgv0:'%s'\n",
    printf( "argv[0]:'%s' absoluteArgv0:'%s'\n",
        TO_UTF8( wxString( argv[0] ) ),
        TO_UTF8( wxString( argv[0] ) ),
        TO_UTF8( absoluteArgv0 )
        TO_UTF8( absoluteArgv0 )
@@ -256,36 +263,31 @@ bool PROCESS::OnInit()
        return false;
        return false;
    }
    }


    // Set LIB_ENV_VAR *before* loading the DSO, in case the module holding the
    // Set LIB_ENV_VAR *before* loading the DSO, in case the top-level DSO holding the
    // KIFACE has hard dependencies on subsidiary DSOs below it, *before* loading
    // KIFACE has hard dependencies on subsidiary DSOs below it.
    // the KIFACE.
    SetLibEnvVar( absoluteArgv0 );
    SetLibEnvVar( absoluteArgv0 );


    wxString dname = dso_name( absoluteArgv0 );
    wxString dname = dso_full_path( absoluteArgv0 );


    // Get the getter.
    // Get the getter.
    KIFACE_GETTER_FUNC* getter = get_kiface_getter( dname );
    KIFACE_GETTER_FUNC* getter = get_kiface_getter( dname );


    // get_kiface_getter() returned NULL? If so it handled the UI message, so
    // we can fail without any further UI.
    if( !getter )
    if( !getter )
    {
        // get_kiface_getter() failed & already showed the UI message.
        // Return failure without any further UI.
        return false;
        return false;
    }


    // Get the KIFACE, and give the DSO a single chance to do its
    // Get the KIFACE, and give the DSO a single chance to do its
    // "process level" initialization.
    // "process level" initialization.
    kiface = getter( &kiface_version, KIFACE_VERSION, &wxGetApp() );
    kiface = getter( &kiface_version, KIFACE_VERSION, &wxGetApp() );


    if( !kiface )
    // KIFACE_GETTER_FUNC function comment (API) says the non-NULL is uconditional.
    {
    wxASSERT_MSG( kiface, wxT( "attempted DSO has a bug, failed to return a KIFACE*" ) );
        // get_kiface_getter() did its own UI error window, because it called
        // functions in wxDynamicLibrary which did so using wxLogSysError().
        // Therefore say nothing on failure, it's already been said.
        // Return false telling startup code to fail the program immediately.
        return false;
    }


    // Using the KIFACE, create a window that the KIFACE knows about,
    // Use KIFACE to create a window that the KIFACE knows about,
    // pass classId=0 for now.  This uses a virtual function KIFACE::CreateWindow()
    // pass classId=0 for now.  KIFACE::CreateWindow() is a virtual
    // so we don't need to link to it.
    // so we don't need to link to it.
    wxFrame* frame = (wxFrame*) kiface->CreateWindow( 0, &standalone );
    wxFrame* frame = (wxFrame*) kiface->CreateWindow( 0, &standalone );


+14 −12
Original line number Original line Diff line number Diff line
@@ -236,7 +236,7 @@ set_source_files_properties( dialogs/dialog_bom.cpp




# not ready for even building yet:
# not ready for even building yet:
if( false AND USE_KIWAY_DLLS )
if( USE_KIWAY_DLLS )


    add_executable( eeschema WIN32 MACOSX_BUNDLE
    add_executable( eeschema WIN32 MACOSX_BUNDLE
        ../common/single_top.cpp
        ../common/single_top.cpp
@@ -246,33 +246,33 @@ if( false AND USE_KIWAY_DLLS )
        ${wxWidgets_LIBRARIES}
        ${wxWidgets_LIBRARIES}
        )
        )


    add_library( eeschema_dso MODULE
    add_library( eeschema_kiface MODULE
        ${EESCHEMA_SRCS}
        ${EESCHEMA_SRCS}
        ${EESCHEMA_COMMON_SRCS}
        ${EESCHEMA_COMMON_SRCS}
        ${EESCHEMA_RESOURCES}
        ${EESCHEMA_RESOURCES}
        )
        )

    set_target_properties( eeschema_kiface PROPERTIES
    set_target_properties( eeschema_dso PROPERTIES
        # Decorate OUTPUT_NAME with PREFIX and SUFFIX, creating something like
        # keep whatever file extension is supplied by SUFFIX, do not use the PREFIX,
        # _eeschema.so, _eeschema.dll, or _eeschema.kiface
        # and set the basename.  The result is eeschema.so or eeschema.dll.
        OUTPUT_NAME     eeschema
        OUTPUT_NAME     eeschema
        PREFIX          ""
        PREFIX          ${KIFACE_PREFIX}
        SUFFIX          ${KIFACE_SUFFIX}
        )
        )


    if( APPLE )
    if( APPLE )
        set_target_properties( eeschema_dso PROPERTIES
        set_target_properties( eeschema_kiface PROPERTIES
            MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
            MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
            )
            )
    endif()
    endif()


    if( MAKE_LINK_MAPS )
    if( MAKE_LINK_MAPS )
        # generate a link map with cross reference
        # generate a link map with cross reference
        set_target_properties( eeschema_dso PROPERTIES
        set_target_properties( eeschema_kiface PROPERTIES
            LINK_FLAGS "-Wl,-cref -Wl,-Map=eeschema_dso.map"
            LINK_FLAGS "-Wl,-cref -Wl,-Map=${KIFACE_PRE}eeschema.${KIFACE_EXT}.map"
            )
            )
    endif()
    endif()


    target_link_libraries( eeschema_dso
    target_link_libraries( eeschema_kiface
        common
        common
        bitmaps
        bitmaps
        polygon
        polygon
@@ -280,7 +280,9 @@ if( false AND USE_KIWAY_DLLS )
        ${GDI_PLUS_LIBRARIES}
        ${GDI_PLUS_LIBRARIES}
        )
        )


    install( TARGETS eeschema_dso
    # Note that this filename is subject to change at milestone C) of
    # modular-kicad blueprint.
    install( TARGETS eeschema_kiface
        DESTINATION ${KICAD_BIN}
        DESTINATION ${KICAD_BIN}
        COMPONENT binary
        COMPONENT binary
        )
        )
Loading