Fix windows help path bug. (fixes lp:1313412)
* SearchHelpFileFullPath(): clean up platform specific path code, add executable path sans bin directory on non-osx platforms, and move KICAD path variable to the beginning of the search list. * Minor search stack debug output improvements.
This commit is contained in:
parent
3adff48dcd
commit
66a9b04487
|
@ -2,7 +2,7 @@
|
||||||
* 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) 2014 CERN
|
* Copyright (C) 2014 CERN
|
||||||
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
|
* Copyright (C) 2014-2015 KiCad Developers, see CHANGELOG.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
|
||||||
|
@ -198,12 +198,13 @@ const wxString SEARCH_STACK::LastVisitedPath( const wxString& aSubPathToSearch )
|
||||||
|
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
void SEARCH_STACK::Show( const char* aPrefix ) const
|
void SEARCH_STACK::Show( const wxString& aPrefix ) const
|
||||||
{
|
{
|
||||||
printf( "%s SEARCH_STACK:\n", aPrefix );
|
wxLogDebug( wxT( "%s SEARCH_STACK:" ), GetChars( aPrefix ) );
|
||||||
|
|
||||||
for( unsigned i=0; i<GetCount(); ++i )
|
for( unsigned i=0; i<GetCount(); ++i )
|
||||||
{
|
{
|
||||||
printf( " [%2u]:%s\n", i, TO_UTF8( (*this)[i] ) );
|
wxLogDebug( wxT( " [%2u]:%s" ), i, TO_UTF8( (*this)[i] ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <pgm_base.h>
|
#include <pgm_base.h>
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <config.h> // to define DEFAULT_INSTALL_PATH
|
#include <config.h> // to define DEFAULT_INSTALL_PATH
|
||||||
|
#include <macros.h>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,6 +50,8 @@ wxString FindFileInSearchPaths( const SEARCH_STACK& aStack,
|
||||||
fn.AppendDir( (*aSubdirs)[j] );
|
fn.AppendDir( (*aSubdirs)[j] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxLogDebug( wxT( " %s" ), GetChars( fn.GetFullPath() ) );
|
||||||
|
|
||||||
if( fn.DirExists() )
|
if( fn.DirExists() )
|
||||||
{
|
{
|
||||||
paths.Add( fn.GetPath() );
|
paths.Add( fn.GetPath() );
|
||||||
|
@ -68,38 +71,15 @@ wxString SearchHelpFileFullPath( const SEARCH_STACK& aSStack, const wxString& aB
|
||||||
|
|
||||||
// It might already be in aSStack, but why depend on other code
|
// It might already be in aSStack, but why depend on other code
|
||||||
// far away when it's so easy to add it again (to our copy) as the first place to look.
|
// far away when it's so easy to add it again (to our copy) as the first place to look.
|
||||||
// This is CMAKE_INSTALL_PREFIX:
|
|
||||||
ss.AddPaths( wxT( DEFAULT_INSTALL_PATH ), 0 );
|
|
||||||
|
|
||||||
// If there's a KICAD environment variable set, use that guy's path also
|
// This is CMAKE_INSTALL_PREFIX unless DEFAULT_INSTALL_PATH was defined during
|
||||||
ss.AddPaths( Pgm().GetKicadEnvVariable(), 0 );
|
// build configuration:
|
||||||
|
ss.AddPaths( wxT( DEFAULT_INSTALL_PATH ), 0 );
|
||||||
|
|
||||||
#if defined(__WXMAC__)
|
#if defined(__WXMAC__)
|
||||||
ss.AddPaths( GetOSXKicadMachineDataDir() );
|
ss.AddPaths( GetOSXKicadMachineDataDir() );
|
||||||
ss.AddPaths( Pgm().GetExecutablePath(), 0 );
|
ss.AddPaths( Pgm().GetExecutablePath(), 0 );
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ! defined(__WXMAC__) // && defined(__linux__)
|
|
||||||
// Based on kicad-doc.bzr/CMakeLists.txt, line 20, the help files are
|
|
||||||
// installed into "<CMAKE_INSTALL_PREFIX>/share/doc/kicad/help" for linux.
|
|
||||||
// This is ${KICAD_HELP} var in that CMakeLists.txt file.
|
|
||||||
// Below we account for an international subdirectory.
|
|
||||||
subdirs.Add( wxT( "share" ) );
|
|
||||||
subdirs.Add( wxT( "doc" ) );
|
|
||||||
subdirs.Add( wxT( "kicad" ) );
|
|
||||||
subdirs.Add( wxT( "help" ) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ! defined(__WXMAC__) // && defined(__WINDOWS__)
|
|
||||||
// Based on kicad-doc.bzr/CMakeLists.txt, line 35, the help files are
|
|
||||||
// installed into "<CMAKE_INSTALL_PREFIX>/doc/help" for Windows.
|
|
||||||
// This is ${KICAD_HELP} var in that CMakeLists.txt file.
|
|
||||||
// Below we account for an international subdirectory.
|
|
||||||
altsubdirs.Add( wxT( "doc" ) );
|
|
||||||
altsubdirs.Add( wxT( "help" ) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (__WXMAC__)
|
|
||||||
// OS X packages can have the help files in
|
// OS X packages can have the help files in
|
||||||
// /Library/Application\ Support/kicad/help,
|
// /Library/Application\ Support/kicad/help,
|
||||||
// and in Contents/SharedSupport/help inside the
|
// and in Contents/SharedSupport/help inside the
|
||||||
|
@ -111,6 +91,37 @@ wxString SearchHelpFileFullPath( const SEARCH_STACK& aSStack, const wxString& aB
|
||||||
altsubdirs.Add( wxT( "help" ) );
|
altsubdirs.Add( wxT( "help" ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ! defined(__WXMAC__) // && defined(__linux__)
|
||||||
|
// This is the executable path minus the trailing bin directory used on Windows and Linux.
|
||||||
|
wxFileName tmp( Pgm().GetExecutablePath(), wxEmptyString );
|
||||||
|
wxArrayString binDirs = tmp.GetDirs();
|
||||||
|
|
||||||
|
if( !binDirs.IsEmpty() && binDirs[ binDirs.GetCount() - 1 ].CmpNoCase( wxT( "bin" ) ) == 0 )
|
||||||
|
tmp.RemoveLastDir();
|
||||||
|
|
||||||
|
ss.AddPaths( tmp.GetPath(), 0 );
|
||||||
|
|
||||||
|
// Based on kicad-doc.bzr/CMakeLists.txt, line 20, the help files are
|
||||||
|
// installed into "<CMAKE_INSTALL_PREFIX>/share/doc/kicad/help" for linux.
|
||||||
|
// This is ${KICAD_HELP} var in that CMakeLists.txt file.
|
||||||
|
// Below we account for an international subdirectory.
|
||||||
|
subdirs.Add( wxT( "share" ) );
|
||||||
|
subdirs.Add( wxT( "doc" ) );
|
||||||
|
subdirs.Add( wxT( "kicad" ) );
|
||||||
|
subdirs.Add( wxT( "help" ) );
|
||||||
|
|
||||||
|
// Based on kicad-doc.bzr/CMakeLists.txt, line 35, the help files are
|
||||||
|
// installed into "<CMAKE_INSTALL_PREFIX>/doc/help" for Windows.
|
||||||
|
// This is ${KICAD_HELP} var in that CMakeLists.txt file.
|
||||||
|
// Below we account for an international subdirectory.
|
||||||
|
altsubdirs.Add( wxT( "doc" ) );
|
||||||
|
altsubdirs.Add( wxT( "help" ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// If there's a KICAD environment variable set, always use that guy's path first.
|
||||||
|
if( !Pgm().GetKicadEnvVariable().IsEmpty() )
|
||||||
|
ss.AddPaths( Pgm().GetKicadEnvVariable(), 0 );
|
||||||
|
|
||||||
/* Search for a help file.
|
/* Search for a help file.
|
||||||
* we *must* find a help file.
|
* we *must* find a help file.
|
||||||
* so help is searched in directories in this order:
|
* so help is searched in directories in this order:
|
||||||
|
@ -126,15 +137,18 @@ wxString SearchHelpFileFullPath( const SEARCH_STACK& aSStack, const wxString& aB
|
||||||
// If fails, try to find help file in help/en
|
// If fails, try to find help file in help/en
|
||||||
wxArrayString locale_name_dirs;
|
wxArrayString locale_name_dirs;
|
||||||
locale_name_dirs.Add( i18n->GetCanonicalName() ); // canonical name like fr_FR
|
locale_name_dirs.Add( i18n->GetCanonicalName() ); // canonical name like fr_FR
|
||||||
|
|
||||||
// wxLocale::GetName() does not return always the short name
|
// wxLocale::GetName() does not return always the short name
|
||||||
locale_name_dirs.Add( i18n->GetName().BeforeLast( '_' ) ); // short canonical name like fr
|
locale_name_dirs.Add( i18n->GetName().BeforeLast( '_' ) ); // short canonical name like fr
|
||||||
locale_name_dirs.Add( wxT( "en" ) ); // default (en)
|
locale_name_dirs.Add( wxT( "en" ) ); // default (en)
|
||||||
|
|
||||||
#if defined(DEBUG) && 0
|
#if defined(DEBUG) && 1
|
||||||
ss.Show( __func__ );
|
ss.Show( wxString( __func__ ) );
|
||||||
printf( "%s: m_help_file:'%s'\n", __func__, TO_UTF8( aBaseName ) );
|
wxLogDebug( wxT( "%s: m_help_file:'%s'" ), __func__, GetChars( aBaseName ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
wxLogDebug( wxT( "Checking SEARCH_STACK for file %s" ), GetChars( aBaseName ) );
|
||||||
|
|
||||||
// Help files can be html (.html ext) or pdf (.pdf ext) files.
|
// Help files can be html (.html ext) or pdf (.pdf ext) files.
|
||||||
// Therefore, <BaseName>.html file is searched and if not found,
|
// Therefore, <BaseName>.html file is searched and if not found,
|
||||||
// <BaseName>.pdf file is searched in the same paths
|
// <BaseName>.pdf file is searched in the same paths
|
||||||
|
|
|
@ -43,7 +43,7 @@ class SEARCH_STACK : public wxPathList, public PROJECT::_ELEM
|
||||||
public:
|
public:
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
void Show( const char* aPrefix ) const;
|
void Show( const wxString& aPrefix ) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue