1. added wfstream.cpp to wxBase (needed by filesys.cpp)
2. small enchancements in wxCmdLineParser (handles "help" options correctly) 3. use wxCmdLineParser in makegen git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5266 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# This file was automatically generated by tmake at 18:17, 2000/01/05
|
# This file was automatically generated by tmake at 19:06, 2000/01/05
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -166,6 +166,7 @@ BASE_HEADERS = \
|
|||||||
utils.h \
|
utils.h \
|
||||||
variant.h \
|
variant.h \
|
||||||
version.h \
|
version.h \
|
||||||
|
wfstream.h \
|
||||||
wx.h \
|
wx.h \
|
||||||
wxchar.h \
|
wxchar.h \
|
||||||
wxprec.h
|
wxprec.h
|
||||||
@@ -1873,6 +1874,7 @@ BASE_OBJS = \
|
|||||||
txtstrm.o \
|
txtstrm.o \
|
||||||
utilscmn.o \
|
utilscmn.o \
|
||||||
variant.o \
|
variant.o \
|
||||||
|
wfstream.o \
|
||||||
wxchar.o \
|
wxchar.o \
|
||||||
dir.o \
|
dir.o \
|
||||||
threadpsx.o \
|
threadpsx.o \
|
||||||
@@ -1911,6 +1913,7 @@ BASE_DEPS = \
|
|||||||
txtstrm.d \
|
txtstrm.d \
|
||||||
utilscmn.d \
|
utilscmn.d \
|
||||||
variant.d \
|
variant.d \
|
||||||
|
wfstream.d \
|
||||||
wxchar.d \
|
wxchar.d \
|
||||||
dir.d \
|
dir.d \
|
||||||
threadpsx.d \
|
threadpsx.d \
|
||||||
|
@@ -187,7 +187,7 @@ valgen.cpp C
|
|||||||
validate.cpp C
|
validate.cpp C
|
||||||
valtext.cpp C
|
valtext.cpp C
|
||||||
variant.cpp C B
|
variant.cpp C B
|
||||||
wfstream.cpp C
|
wfstream.cpp C B
|
||||||
wincmn.cpp C
|
wincmn.cpp C
|
||||||
wxchar.cpp C B
|
wxchar.cpp C B
|
||||||
wxexpr.cpp C
|
wxexpr.cpp C
|
||||||
@@ -695,7 +695,7 @@ valtext.h W
|
|||||||
variant.h W B
|
variant.h W B
|
||||||
version.h W B
|
version.h W B
|
||||||
wave.h W
|
wave.h W
|
||||||
wfstream.h W
|
wfstream.h W B
|
||||||
window.h W
|
window.h W
|
||||||
wizard.h W
|
wizard.h W
|
||||||
wx.h W B
|
wx.h W B
|
||||||
|
@@ -126,6 +126,9 @@ public:
|
|||||||
void EnableLongOptions(bool enable = TRUE);
|
void EnableLongOptions(bool enable = TRUE);
|
||||||
void DisableLongOptions() { EnableLongOptions(FALSE); }
|
void DisableLongOptions() { EnableLongOptions(FALSE); }
|
||||||
|
|
||||||
|
// extra text may be shown by Usage() method if set by this function
|
||||||
|
void SetLogo(const wxString& logo);
|
||||||
|
|
||||||
// construct the cmd line description
|
// construct the cmd line description
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
@@ -181,7 +184,7 @@ public:
|
|||||||
size_t GetParamCount() const;
|
size_t GetParamCount() const;
|
||||||
|
|
||||||
// gets the value of Nth parameter (as string only for now)
|
// gets the value of Nth parameter (as string only for now)
|
||||||
wxString GetParam(size_t n) const;
|
wxString GetParam(size_t n = 0u) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// common part of all ctors
|
// common part of all ctors
|
||||||
|
@@ -142,8 +142,8 @@ struct wxCmdLineParserData
|
|||||||
{
|
{
|
||||||
// options
|
// options
|
||||||
wxString m_switchChars; // characters which may start an option
|
wxString m_switchChars; // characters which may start an option
|
||||||
|
|
||||||
bool m_enableLongOptions; // TRUE if long options are enabled
|
bool m_enableLongOptions; // TRUE if long options are enabled
|
||||||
|
wxString m_logo; // some extra text to show in Usage()
|
||||||
|
|
||||||
// cmd line data
|
// cmd line data
|
||||||
wxArrayString m_arguments; // == argv, argc == m_arguments.GetCount()
|
wxArrayString m_arguments; // == argv, argc == m_arguments.GetCount()
|
||||||
@@ -264,6 +264,11 @@ void wxCmdLineParser::EnableLongOptions(bool enable)
|
|||||||
m_data->m_enableLongOptions = enable;
|
m_data->m_enableLongOptions = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxCmdLineParser::SetLogo(const wxString& logo)
|
||||||
|
{
|
||||||
|
m_data->m_logo = logo;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// command line construction
|
// command line construction
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -275,7 +280,8 @@ void wxCmdLineParser::SetDesc(const wxCmdLineEntryDesc *desc)
|
|||||||
switch ( desc->kind )
|
switch ( desc->kind )
|
||||||
{
|
{
|
||||||
case wxCMD_LINE_SWITCH:
|
case wxCMD_LINE_SWITCH:
|
||||||
AddSwitch(desc->shortName, desc->longName, desc->description);
|
AddSwitch(desc->shortName, desc->longName, desc->description,
|
||||||
|
desc->flags);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxCMD_LINE_OPTION:
|
case wxCMD_LINE_OPTION:
|
||||||
@@ -842,6 +848,11 @@ void wxCmdLineParser::Usage()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !!m_data->m_logo )
|
||||||
|
{
|
||||||
|
wxLogMessage(m_data->m_logo);
|
||||||
|
}
|
||||||
|
|
||||||
wxLogMessage(brief);
|
wxLogMessage(brief);
|
||||||
wxLogMessage(detailed);
|
wxLogMessage(detailed);
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
# This file was automatically generated by tmake at 18:17, 2000/01/05
|
# This file was automatically generated by tmake at 19:06, 2000/01/05
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE B32.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE B32.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
# This file was automatically generated by tmake at 18:17, 2000/01/05
|
# This file was automatically generated by tmake at 19:06, 2000/01/05
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# This file was automatically generated by tmake at 18:17, 2000/01/05
|
# This file was automatically generated by tmake at 19:06, 2000/01/05
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE DOS.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE DOS.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# This file was automatically generated by tmake at 18:17, 2000/01/05
|
# This file was automatically generated by tmake at 19:06, 2000/01/05
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE G95.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE G95.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
# This file was automatically generated by tmake at 18:17, 2000/01/05
|
# This file was automatically generated by tmake at 19:06, 2000/01/05
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE SC.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE SC.T!
|
||||||
|
|
||||||
# Symantec C++ makefile for the msw objects
|
# Symantec C++ makefile for the msw objects
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# This file was automatically generated by tmake at 18:17, 2000/01/05
|
# This file was automatically generated by tmake at 19:06, 2000/01/05
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T!
|
||||||
|
|
||||||
# File: makefile.vc
|
# File: makefile.vc
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#!/binb/wmake.exe
|
#!/binb/wmake.exe
|
||||||
|
|
||||||
# This file was automatically generated by tmake at 18:17, 2000/01/05
|
# This file was automatically generated by tmake at 19:06, 2000/01/05
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@@ -9,6 +9,13 @@
|
|||||||
// Licence: wxWindows license
|
// Licence: wxWindows license
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* 1. support for programs with multiple object files
|
||||||
|
* 2. support for programs under utils and demos, not only samples
|
||||||
|
*/
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// declarations
|
// declarations
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -29,6 +36,7 @@
|
|||||||
#include <wx/dir.h>
|
#include <wx/dir.h>
|
||||||
#include <wx/textfile.h>
|
#include <wx/textfile.h>
|
||||||
#include <wx/datetime.h>
|
#include <wx/datetime.h>
|
||||||
|
#include <wx/cmdline.h>
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// the application class
|
// the application class
|
||||||
@@ -37,18 +45,20 @@
|
|||||||
class MakeGenApp : public wxApp
|
class MakeGenApp : public wxApp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
MakeGenApp() { m_quiet = FALSE; }
|
||||||
|
|
||||||
virtual bool OnInit();
|
virtual bool OnInit();
|
||||||
|
|
||||||
virtual int OnRun();
|
virtual int OnRun();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Usage(); // give the usage message
|
|
||||||
|
|
||||||
bool GenerateMakefile(const wxString& filename);
|
bool GenerateMakefile(const wxString& filename);
|
||||||
|
|
||||||
wxString m_sampleName, // the name of the sample
|
wxString m_progname, // the name of the sample
|
||||||
m_dirname, // directory with the template files
|
m_dirname, // directory with the template files
|
||||||
m_outputDir; // directory to output files to
|
m_outdir; // directory to output files to
|
||||||
|
|
||||||
|
bool m_quiet; // don't give non essential messages
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_APP(MakeGenApp);
|
IMPLEMENT_APP(MakeGenApp);
|
||||||
@@ -61,11 +71,6 @@ IMPLEMENT_APP(MakeGenApp);
|
|||||||
// MakeGenApp
|
// MakeGenApp
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void MakeGenApp::Usage()
|
|
||||||
{
|
|
||||||
wxLogError(_T("Usage: %s [-o output_dir] sample_name"), argv[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MakeGenApp::GenerateMakefile(const wxString& filename)
|
bool MakeGenApp::GenerateMakefile(const wxString& filename)
|
||||||
{
|
{
|
||||||
wxTextFile fileIn(m_dirname + filename);
|
wxTextFile fileIn(m_dirname + filename);
|
||||||
@@ -76,7 +81,7 @@ bool MakeGenApp::GenerateMakefile(const wxString& filename)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFFile fileOut(m_outputDir + filename, "w");
|
wxFFile fileOut(m_outdir + filename, "w");
|
||||||
if ( !fileOut.IsOpened() )
|
if ( !fileOut.IsOpened() )
|
||||||
{
|
{
|
||||||
wxLogError(_T("Makefile '%s' couldn't be generated."), filename.c_str());
|
wxLogError(_T("Makefile '%s' couldn't be generated."), filename.c_str());
|
||||||
@@ -84,13 +89,16 @@ bool MakeGenApp::GenerateMakefile(const wxString& filename)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxLogVerbose(_T("Generating '%s' for '%s'..."),
|
||||||
|
(m_outdir + filename).c_str(), m_progname.c_str());
|
||||||
|
|
||||||
size_t count = fileIn.GetLineCount();
|
size_t count = fileIn.GetLineCount();
|
||||||
for ( size_t n = 0; n < count; n++ )
|
for ( size_t n = 0; n < count; n++ )
|
||||||
{
|
{
|
||||||
wxString line = fileIn[n];
|
wxString line = fileIn[n];
|
||||||
|
|
||||||
line.Replace(_T("#DATE"), wxDateTime::Now().FormatISODate());
|
line.Replace(_T("#DATE"), wxDateTime::Now().FormatISODate());
|
||||||
line.Replace(_T("#NAME"), m_sampleName);
|
line.Replace(_T("#NAME"), m_progname);
|
||||||
|
|
||||||
fileOut.Write(line + _T('\n'));
|
fileOut.Write(line + _T('\n'));
|
||||||
}
|
}
|
||||||
@@ -98,28 +106,65 @@ bool MakeGenApp::GenerateMakefile(const wxString& filename)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parse the cmd line
|
||||||
bool MakeGenApp::OnInit()
|
bool MakeGenApp::OnInit()
|
||||||
{
|
{
|
||||||
// parse the cmd line
|
static const wxCmdLineEntryDesc cmdLineDesc[] =
|
||||||
if ( (argc == 1) || (argc == 3) ||
|
|
||||||
(argv[1][0] == _T('-') && argv[1][1] != _T('o')) ||
|
|
||||||
(argc == 2 && argv[1][0] == _T('-')) )
|
|
||||||
{
|
{
|
||||||
Usage();
|
{ wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("give this usage message"),
|
||||||
|
wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
|
||||||
|
{ wxCMD_LINE_SWITCH, _T("v"), _T("verbose"), _T("be more verbose") },
|
||||||
|
{ wxCMD_LINE_SWITCH, _T("q"), _T("quiet"), _T("be quiet") },
|
||||||
|
|
||||||
|
{ wxCMD_LINE_OPTION, _T("i"), _T("input"), _T("directory with template files") },
|
||||||
|
|
||||||
|
{ wxCMD_LINE_PARAM, NULL, NULL, _T("output_directory") },
|
||||||
|
|
||||||
|
{ wxCMD_LINE_NONE }
|
||||||
|
};
|
||||||
|
|
||||||
|
wxCmdLineParser parser(cmdLineDesc, argc, argv);
|
||||||
|
parser.SetLogo(_T("MakeGen: a makefile generator for wxWindows\n"
|
||||||
|
"Copyright (c) 2000 Vadim Zeitlin"));
|
||||||
|
|
||||||
|
if ( parser.Parse() != 0 )
|
||||||
|
{
|
||||||
|
// failed to parse the cmd line or help was requested (and given)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sampleName = argv[1];
|
(void)parser.Found(_T("i"), &m_dirname);
|
||||||
if ( m_sampleName[0u] == _T('-') )
|
if ( parser.Found(_T("q")) )
|
||||||
{
|
{
|
||||||
m_outputDir = argv[2];
|
m_quiet = TRUE;
|
||||||
if ( !wxEndsWithPathSeparator(m_outputDir) )
|
|
||||||
|
wxLog::GetActiveTarget()->SetVerbose(FALSE);
|
||||||
|
}
|
||||||
|
else if ( parser.Found(_T("v")) )
|
||||||
{
|
{
|
||||||
m_outputDir += _T('/');
|
wxLog::GetActiveTarget()->SetVerbose();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sampleName = argv[3];
|
m_outdir = parser.GetParam();
|
||||||
|
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
m_outdir.Replace(_T("\\"), _T("/"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ( !!m_outdir && m_outdir.Last() == _T('/') )
|
||||||
|
{
|
||||||
|
m_outdir.Truncate(m_outdir.length() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_progname = m_outdir.AfterLast(_T('/'));
|
||||||
|
|
||||||
|
if ( !m_progname )
|
||||||
|
{
|
||||||
|
wxLogError(_T("Output directory should be specified."));
|
||||||
|
|
||||||
|
parser.Usage();
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -127,11 +172,14 @@ bool MakeGenApp::OnInit()
|
|||||||
|
|
||||||
int MakeGenApp::OnRun()
|
int MakeGenApp::OnRun()
|
||||||
{
|
{
|
||||||
|
if ( !m_dirname )
|
||||||
|
{
|
||||||
m_dirname = wxGetenv(_T("MAKEGEN_PATH"));
|
m_dirname = wxGetenv(_T("MAKEGEN_PATH"));
|
||||||
if ( !m_dirname )
|
if ( !m_dirname )
|
||||||
{
|
{
|
||||||
m_dirname = wxGetCwd();
|
m_dirname = wxGetCwd();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( !wxEndsWithPathSeparator(m_dirname) )
|
if ( !wxEndsWithPathSeparator(m_dirname) )
|
||||||
{
|
{
|
||||||
@@ -153,7 +201,7 @@ int MakeGenApp::OnRun()
|
|||||||
|
|
||||||
wxString filename;
|
wxString filename;
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
bool cont = dir.GetFirst(&filename, _T("?akefile.*"), wxDIR_FILES);
|
bool cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_FILES);
|
||||||
while ( cont )
|
while ( cont )
|
||||||
{
|
{
|
||||||
n++;
|
n++;
|
||||||
@@ -171,9 +219,9 @@ int MakeGenApp::OnRun()
|
|||||||
if ( n )
|
if ( n )
|
||||||
{
|
{
|
||||||
wxLogVerbose(_T("Successfully generated %u makefiles in '%s'."),
|
wxLogVerbose(_T("Successfully generated %u makefiles in '%s'."),
|
||||||
n, m_outputDir.c_str());
|
n, m_outdir.c_str());
|
||||||
}
|
}
|
||||||
else
|
else if ( !m_quiet )
|
||||||
{
|
{
|
||||||
wxLogWarning(_T("No makefiles found: either set MAKEGEN_PATH variable "
|
wxLogWarning(_T("No makefiles found: either set MAKEGEN_PATH variable "
|
||||||
"or run the program from its directory"));
|
"or run the program from its directory"));
|
||||||
|
Reference in New Issue
Block a user