Add BOM file extension to BOM plugin command line
Attempt to parse BOM output file extension from BOM plugin header, and
append it to the "%O" argument in the BOM plugin command line.
Fixes #6943
(cherry picked from commit f54ab830f6
)
This commit is contained in:
parent
db1bf4351b
commit
38d7ac6d9c
|
@ -48,24 +48,28 @@ BOM_PLUGIN::BOM_PLUGIN( const wxString& aFile )
|
||||||
if( extension == "xsl" )
|
if( extension == "xsl" )
|
||||||
{
|
{
|
||||||
m_info = readHeader( "-->" );
|
m_info = readHeader( "-->" );
|
||||||
m_cmd = wxString::Format( "xsltproc -o \"%%O\" \"%s\" \"%%I\"", m_file.GetFullPath() );
|
m_cmd = wxString::Format( "xsltproc -o \"%%O%s\" \"%s\" \"%%I\"",
|
||||||
|
getOutputExtension( m_info ), m_file.GetFullPath() );
|
||||||
}
|
}
|
||||||
else if( extension == "py" )
|
else if( extension == "py" )
|
||||||
{
|
{
|
||||||
m_info = readHeader( "\"\"\"" );
|
m_info = readHeader( "\"\"\"" );
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
m_cmd = wxString::Format( "python \"%s/%s\" \"%%I\" \"%%O\"",
|
m_cmd = wxString::Format( "python \"%s/%s\" \"%%I\" \"%%O%s\"",
|
||||||
m_file.GetPath(), m_file.GetFullName() );
|
m_file.GetPath(), m_file.GetFullName(),
|
||||||
|
getOutputExtension( m_info ) );
|
||||||
#else
|
#else
|
||||||
m_cmd = wxString::Format( "python \"%s\" \"%%I\" \"%%O\"", m_file.GetFullPath() );
|
m_cmd = wxString::Format( "python \"%s\" \"%%I\" \"%%O%s\"", m_file.GetFullPath(),
|
||||||
|
getOutputExtension( m_info ) );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
else if( extension == "pyw" )
|
else if( extension == "pyw" )
|
||||||
{
|
{
|
||||||
m_info = readHeader( "\"\"\"" );
|
m_info = readHeader( "\"\"\"" );
|
||||||
m_cmd = wxString::Format( "pythonw \"%s/%s\" \"%%I\" \"%%O\"",
|
m_cmd = wxString::Format( "pythonw \"%s/%s\" \"%%I\" \"%%O%s\"",
|
||||||
m_file.GetPath(),m_file.GetFullName() );
|
m_file.GetPath(), m_file.GetFullName(),
|
||||||
|
getOutputExtension( m_info ) );
|
||||||
}
|
}
|
||||||
#endif /* __WINDOWS__ */
|
#endif /* __WINDOWS__ */
|
||||||
else // fallback
|
else // fallback
|
||||||
|
@ -112,7 +116,7 @@ wxString BOM_PLUGIN::readHeader( const wxString& aEndSection )
|
||||||
strstart += header.Length();
|
strstart += header.Length();
|
||||||
int strend = data.find( aEndSection, strstart );
|
int strend = data.find( aEndSection, strstart );
|
||||||
|
|
||||||
if( strend == wxNOT_FOUND)
|
if( strend == wxNOT_FOUND )
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
|
|
||||||
// Remove empty line if any
|
// Remove empty line if any
|
||||||
|
@ -121,3 +125,24 @@ wxString BOM_PLUGIN::readHeader( const wxString& aEndSection )
|
||||||
|
|
||||||
return data.SubString( strstart, strend - 1 );
|
return data.SubString( strstart, strend - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString BOM_GENERATOR_HANDLER::getOutputExtension( const wxString& aHeader )
|
||||||
|
{
|
||||||
|
// search header for extension after %O (extension includes '.')
|
||||||
|
// looks for output argument of the form `"%O.extension"`
|
||||||
|
const wxString outputarg( "\"%O" );
|
||||||
|
|
||||||
|
int strstart = aHeader.Find( outputarg );
|
||||||
|
|
||||||
|
if( strstart == wxNOT_FOUND )
|
||||||
|
return wxEmptyString;
|
||||||
|
|
||||||
|
strstart += outputarg.Length();
|
||||||
|
int strend = aHeader.find( "\"", strstart );
|
||||||
|
|
||||||
|
if( strend == wxNOT_FOUND )
|
||||||
|
return wxEmptyString;
|
||||||
|
|
||||||
|
return aHeader.SubString( strstart, strend - 1 );
|
||||||
|
}
|
||||||
|
|
|
@ -121,6 +121,14 @@ protected:
|
||||||
*/
|
*/
|
||||||
wxString readHeader( const wxString& aEndSection );
|
wxString readHeader( const wxString& aEndSection );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts the output BOM file's extension, including the '.', from the
|
||||||
|
* plugin file header. If the output extension cannot be determined from
|
||||||
|
* the plugin header, returns wxEmptyString.
|
||||||
|
* @param aHeader is the plugin file's header, as returned by readHeader()
|
||||||
|
**/
|
||||||
|
static wxString getOutputExtension( const wxString& aHeader );
|
||||||
|
|
||||||
///> true if the plugin is working (i.e. if the plugin file exists and was read
|
///> true if the plugin is working (i.e. if the plugin file exists and was read
|
||||||
bool m_isOk;
|
bool m_isOk;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue