Summary: | Changing version in project options does not affect configure.in.in | ||
---|---|---|---|
Product: | [Applications] kdevelop | Reporter: | Alexander Reinholdt <alexander.reinholdt> |
Component: | Build tools: Automake | Assignee: | kdevelop-bugs-null |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | grueffelokatze, mattr, slaout |
Priority: | NOR | ||
Version: | 3.0.0b1 | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Alexander Reinholdt
2003-11-10 10:09:14 UTC
Confirmed. It appears someone forgot to implement it... :) *** Bug 71561 has been marked as a duplicate of this bug. *** This is a regression from KDevelop 2.x This still happens in kdevelop 3.0.3 under linux 2.6.4 gentoo amd64. It doesn't just affect config.h either, it also effects the output file name and output file contents of 'make dist'. Even in KDevelop 3.0.4 it still here. I'm obligated to find/replace (thank you KFindReplace) all version number by hand. So, start a new project, and give it an unprobable version number (like "FooX452..bar;G" :-) ) and use KFindReplace to find all occurences, and be asured KDevelop update all those files when version number is changed. With this process we could be sure the version will be REALLY changed. My 1 cent. Basicaly it only needs to change configure.in.in (In autotools based projects) In other project types I'm not sure :( Bug stil in kdevelop version 3.3.3. *** Bug 132436 has been marked as a duplicate of this bug. *** r599871 /branches/kdevelop/3.4/src/ (generalinfowidget.cpp generalinfowidget.h) When project/options/version is changed, update the configure.in file with the new version. Uses regex to update AC_INIT, AM_INIT_AUTOMAKE, and AC_DEFINE macros. Build tools detect that configure.in is newer and rebuilds config.h with correct version. Index: src/generalinfowidget.h =================================================================== --- src/generalinfowidget.h (revision 599866) +++ src/generalinfowidget.h (working copy) @@ -47,6 +47,7 @@ QString projectDirectory(); void setProjectDirectoryError( const QString& error ); void setProjectDirectorySuccess(); + void configureinUpdateVersion( QString configureinpath, QString newVersion ); }; #endif Index: src/generalinfowidget.cpp =================================================================== --- src/generalinfowidget.cpp (revision 599866) +++ src/generalinfowidget.cpp (working copy) @@ -19,6 +19,8 @@ #include <klocale.h> #include <kiconloader.h> #include <kcharsets.h> +#include <qregexp.h> +#include <kmessagebox.h> #include "generalinfowidget.h" #include "generalinfowidget.moc" @@ -75,13 +77,103 @@ } } +/** + * Update the configure.in file with the version value from project options. + * Very basic updating - uses regex to update the field in + * AC_INIT, AM_INIT_AUTOMAKE, and AC_DEFINE macros. + * On next make, the build system re-runs configure to update config.h + * version info. + * + * @param configureinpath Full path to configure.in file + * @param newVersion The new version number or string +*/ +void GeneralInfoWidget::configureinUpdateVersion( QString configureinpath, QString newVersion ) +{ + QFile configurein(configureinpath); + if ( !configurein.open( IO_ReadOnly ) ){ + KMessageBox::error(this, i18n("Could not open %1 for reading.").arg(configureinpath)); + return; + } + + QTextStream stream( &configurein); + QStringList list; + + // Options for version: + + // we ignore old AC_INIT that had no version.. + // only match the if there is a comma and at least two args.. + // AC_INIT (package, version, [bug-report], [tarname]) + QRegExp ac_init("^AC_INIT\\s*\\(\\s*([^,]+),([^,\\)]+)(.*)"); + + // AM_INIT_AUTOMAKE([OPTIONS]) + // example: AM_INIT_AUTOMAKE([gnits 1.5 no-define dist-bzip2]) + QRegExp am_autoSpace("^AM_INIT_AUTOMAKE\\s{0,}\\(\\s{0,}([\\[\\s]{0,}[^\\s]+)\\s+([^\\s\\)\\]]+)(.*)"); + + // AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) + QRegExp am_autoComma("^AM_INIT_AUTOMAKE\\s*\\(\\s*([^,]+),([^,\\)]+)(.*)"); + + // look for version in a define. + // AC_DEFINE(VERSION, "5.6") + QRegExp ac_define("^AC_DEFINE\\s*\\("); + QRegExp version("(\\bversion\\b)"); + version.setCaseSensitive(FALSE); + + while ( !stream.eof() ) { + QString line = stream.readLine(); + if ( ac_init.search(line) >= 0){ + line = "AC_INIT(" + ac_init.cap(1).stripWhiteSpace(); + line += ", "; + line += newVersion; + line += ac_init.cap(3).stripWhiteSpace(); + } + else if ( am_autoComma.search(line) >= 0 ){ + line="AM_INIT_AUTOMAKE("; + line += am_autoComma.cap(1).stripWhiteSpace(); + line += ", "; + line += newVersion; + line += am_autoComma.cap(3).stripWhiteSpace(); + } + else if ( am_autoSpace.search(line) >= 0 ){ + line = "AM_INIT_AUTOMAKE(" + am_autoSpace.cap(1).stripWhiteSpace(); + line += " "; + line += newVersion; + line += " "; + line += am_autoSpace.cap(3).stripWhiteSpace(); + } + else if ( ac_define.search(line) >=0 && version.search(line) >=0) { + // replace version in: AC_DEFINE(VERSION,"0.1") + line="AC_DEFINE(" + version.cap(1).stripWhiteSpace()+", \"" + newVersion +"\")"; + } + list.push_back(line); + } + configurein.close(); + + // write our changes.. + QFile configureout(configureinpath); + if ( !configureout.open( IO_WriteOnly ) ){ + KMessageBox::error(this, i18n("Could not open %1 for writing.").arg(configureinpath)); + return ; + } + QTextStream output( &configureout); + for(QStringList::iterator iter = list.begin();iter!=list.end();iter++){ + output << (*iter) <<"\n"; + } + configureout.close(); + +} + + void GeneralInfoWidget::writeConfig() { DomUtil::writeEntry(m_projectDom,"/general/projectdirectory",project_directory_edit->text()); DomUtil::writeBoolEntry(m_projectDom,"/general/absoluteprojectpath",isProjectDirectoryAbsolute()); DomUtil::writeEntry(m_projectDom,"/general/email",email_edit->text()); DomUtil::writeEntry(m_projectDom,"/general/author",author_edit->text()); DomUtil::writeEntry(m_projectDom,"/general/email",email_edit->text()); + if ( DomUtil::readEntry(m_projectDom,"/general/version") != version_edit->text() ){ + // update the configure.in file. + configureinUpdateVersion( projectDirectory() + "/configure.in", version_edit->text() ); + } DomUtil::writeEntry(m_projectDom,"/general/version",version_edit->text()); DomUtil::writeEntry(m_projectDom,"/general/description",description_edit->text()); Fixed in KDevelop 3.4 by revision 599871 Actually fixed in KDevelop 3.4 by revision 601133. I didn't notice this bug talking about configure.in.in. KDE use this to make the configure.in file. We now check for configure.in.in, configure.in and configure.ac and change the version. |