Bug 58217 - Implement custom build tools (jam, scons, ... instead of make)
Summary: Implement custom build tools (jam, scons, ... instead of make)
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: general (show other bugs)
Version: 3.0.0a4
Platform: Gentoo Packages Linux
: NOR wishlist
Target Milestone: ---
Assignee: KDevelop Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-07 19:25 UTC by Matthias Braun
Modified: 2007-02-28 03:10 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Adds a "other" build tool to buildtools/customakefiles (35.39 KB, patch)
2005-09-13 17:06 UTC, Achim Herwig
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Braun 2003-05-07 19:25:39 UTC
Version:           3.0rc4 (using KDE KDE 3.1.1a)
Installed from:    Gentoo Packages
OS:          Linux

Feature Request:
kdevelop only works with make-like tools at the moment. This is primarily because of kdevelop assumes all make tools use the same commandline switches like make (-k -j2), or makes assumption about targetnames like "all" or "clean". It would be nice to be able to customize this part of kdevelop so that you can at least specify own commands for cleaning, rebuilding all and incremental rebuilding. (Example "jam -dax clean" would be a command to clean all objects in a jam based build.) This should be fairly simple to implement I assume.

Following some advanced Whishlist (dreaming about future features is always good :)
-Having plugins for the build which are able to add/remove files/projects/packages to the build. Along with possibilities to compile only parts of the project...
Comment 1 Amilcar do Carmo Lucas 2003-05-07 22:42:41 UTC
Currently all you need to do is to copy autoproject and rename it to jamproject or 
sconsproject. 
And afterwords make the changes you need to this files. 
There is already a qmakeproject (the actual name is trollproject) and a antproject. 
 
Your second whish is already implemented in autoproject 
 
Amilcar Lucas 
 
Comment 2 Amilcar do Carmo Lucas 2003-11-23 15:29:27 UTC
This changed a bit. KDevelop's official build tools are:
Ant,
Autotools,
CustomMakefiles (You need to edit them by hand),
Generic,
QMake,

If you want to do this you should implement a generic build tool instead.

Read
http://developer.kde.org/documentation/library/cvs-api/kdevelop/html/howToAddGenericBuildTools.html

Currently (2003.11.23) the document is not finished but in the future it will have more info.
Comment 3 John T. Ellis 2004-03-21 23:30:40 UTC
Jam would be a nice, integrated feature (as Ant and Make currently are)
Comment 4 Arne Schmitz 2004-04-12 20:24:18 UTC
Could the above page be updated some time? I would love to add another custom make tool, but I can't figure out how.
Comment 5 Alexander Dymo 2004-04-12 21:54:16 UTC
The page wasn't updated because there is ongoing work to implement project management and this work isn't based on generic project manager. But I can't say when will it be finished.
Comment 6 seeksthemoon 2004-08-07 13:43:35 UTC
what is the status of the generic project manager? I have to work with a jam-project and need a rough estimate when the project manager and/or jam-support may be ready...
Comment 7 Achim Herwig 2005-09-13 17:06:54 UTC
Created attachment 12549 [details]
Adds a "other" build tool to buildtools/customakefiles

I extended the selection of buildtools for the custommakefile project type.

Instead of only supporting ant (AFAIK with no options) and make (implicitely
adding make-specific command line arguments), I added an "other" tool where
anyone can specify his/her buildtool directly (we use jam with a bash wrapper
script called build.sh).

It's mostly copy&paste from the make part and I did not touch the environment
part (that is totaly duplicated), but it works for me...
Comment 8 Andreas Pakulat 2007-02-28 03:10:21 UTC
SVN commit 637881 by apaku:

Add the possibility to run a buildtool other than make or ant

Initial patch from Achim Herwig <achim.herwig@wodca.de>, thanks.
BUG:58217


 M  +3 -2      Makefile.am  
 M  +26 -3     custombuildoptionswidget.cpp  
 M  +8 -4      custombuildoptionswidget.h  
 M  +26 -4     custombuildoptionswidgetbase.ui  
 A             customotherconfigwidget.cpp   [License: GPL (v2+)]
 A             customotherconfigwidget.h   [License: GPL (v2+)]
 A             customotherconfigwidgetbase.ui  
 M  +27 -9     customprojectpart.cpp  


--- branches/kdevelop/3.4/buildtools/custommakefiles/Makefile.am #637880:637881
@@ -12,7 +12,8 @@
 
 libkdevcustomproject_la_SOURCES = custombuildoptionswidget.cpp \
 	custombuildoptionswidgetbase.ui custommakeconfigwidget.cpp custommakeconfigwidgetbase.ui \
-	custommanagerwidget.cpp custommanagerwidgetbase.ui customprojectpart.cpp
+	custommanagerwidget.cpp custommanagerwidgetbase.ui customotherconfigwidget.cpp \
+	customotherconfigwidgetbase.ui customprojectpart.cpp
 
 METASOURCES = AUTO
 
@@ -21,4 +22,4 @@
 
 rcdir = $(kde_datadir)/kdevcustomproject
 rc_DATA = kdevcustomproject.rc
-noinst_HEADERS = custommanagerwidget.h
+noinst_HEADERS = custommanagerwidget.h customotherconfigwidget.h
--- branches/kdevelop/3.4/buildtools/custommakefiles/custombuildoptionswidget.cpp #637880:637881
@@ -26,6 +26,7 @@
       m_dom(dom)
 {
     ant_button->setChecked(DomUtil::readEntry(dom, "/kdevcustomproject/build/buildtool") == "ant");
+    other_button->setChecked(DomUtil::readEntry(dom, "/kdevcustomproject/build/buildtool") == "other");
     builddir_edit->setURL(DomUtil::readEntry(dom, "/kdevcustomproject/build/builddir"));
     builddir_edit->completionObject()->setMode(KURLCompletion::DirCompletion);
     builddir_edit->setMode( KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly );
@@ -33,7 +34,9 @@
     // This connection must not be made before the ant->setChecked() line,
     // because at this time makeToggled() would crash
     connect( make_button, SIGNAL(toggled(bool)),
-             this, SLOT(makeToggled(bool)) );
+            this, SLOT(makeToggled(bool)) );
+    connect( other_button, SIGNAL(toggled(bool)),
+             this, SLOT(otherToggled(bool)) );
 }
 
 
@@ -43,19 +46,37 @@
 
 void CustomBuildOptionsWidget::accept()
 {
-    QString buildtool = ant_button->isChecked()? "ant" : "make";
+    QString buildtool;
+    if (ant_button->isChecked())
+    {
+        buildtool = "ant";
+    }
+    else if (other_button->isChecked())
+    {
+        buildtool = "other";
+    }
+    else
+    {
+        buildtool = "make";
+    }
     DomUtil::writeEntry(m_dom, "/kdevcustomproject/build/buildtool", buildtool);
     DomUtil::writeEntry(m_dom, "/kdevcustomproject/build/builddir", builddir_edit->url());
 }
 
 
-void CustomBuildOptionsWidget::setMakeOptionsWidget(QTabWidget *tw, QWidget *mow)
+void CustomBuildOptionsWidget::setMakeOptionsWidget(QTabWidget *tw, QWidget *mow, QWidget* oow)
 {
     m_tabWidget = tw;
     m_makeOptions = mow;
+    m_otherOptions = oow;
     makeToggled(make_button->isChecked());
+    otherToggled(other_button->isChecked());
 }
 
+void CustomBuildOptionsWidget::otherToggled(bool b)
+{
+    m_tabWidget->setTabEnabled(m_otherOptions, b);
+}
 
 void CustomBuildOptionsWidget::makeToggled(bool b)
 {
@@ -63,3 +84,5 @@
 }
 
 #include "custombuildoptionswidget.moc"
+
+// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on
--- branches/kdevelop/3.4/buildtools/custommakefiles/custombuildoptionswidget.h #637880:637881
@@ -21,22 +21,26 @@
 class CustomBuildOptionsWidget : public CustomBuildOptionsWidgetBase
 {
     Q_OBJECT
-    
+
 public:
     CustomBuildOptionsWidget( QDomDocument &dom, QWidget *parent=0, const char *name=0 );
     ~CustomBuildOptionsWidget();
 
-    void setMakeOptionsWidget(QTabWidget *tw, QWidget *mow);
-    
+    void setMakeOptionsWidget(QTabWidget *tw, QWidget *mow, QWidget *oow);
+
 public slots:
     void accept();
 
 private:
     virtual void makeToggled(bool b);
-    
+    virtual void otherToggled(bool b);
+
     QDomDocument &m_dom;
     QTabWidget *m_tabWidget;
     QWidget *m_makeOptions;
+    QWidget *m_otherOptions;
 };
 
 #endif
+
+// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on
--- branches/kdevelop/3.4/buildtools/custommakefiles/custombuildoptionswidgetbase.ui #637880:637881
@@ -37,6 +37,9 @@
                     <property name="text">
                         <string>&amp;Make</string>
                     </property>
+                    <property name="accel">
+                        <string>Alt+M</string>
+                    </property>
                     <property name="checked">
                         <bool>true</bool>
                     </property>
@@ -46,9 +49,29 @@
                         <cstring>ant_button</cstring>
                     </property>
                     <property name="text">
-                        <string>&amp;Ant</string>
+                        <string>A&amp;nt</string>
                     </property>
+                    <property name="accel">
+                        <string>Alt+N</string>
+                    </property>
                 </widget>
+                <widget class="QRadioButton">
+                    <property name="name">
+                        <cstring>other_button</cstring>
+                    </property>
+                    <property name="text">
+                        <string>Other</string>
+                    </property>
+                    <property name="accel">
+                        <string></string>
+                    </property>
+                    <property name="toolTip" stdset="0">
+                        <string>other custom build tool, e.g. script</string>
+                    </property>
+                    <property name="whatsThis" stdset="0">
+                        <string>There are myriads of buildtools out there that are not ant or make. If you use one of them (or have your own scripts), select this option.</string>
+                    </property>
+                </widget>
             </vbox>
         </widget>
         <spacer>
@@ -73,7 +96,7 @@
                 <cstring>builddir_label</cstring>
             </property>
             <property name="text">
-                <string>Run the &amp;build tool in the following directory:</string>
+                <string>Run &amp;the build tool in the following directory:</string>
             </property>
             <property name="buddy" stdset="0">
                 <cstring>builddir_edit</cstring>
@@ -130,13 +153,12 @@
         </spacer>
     </vbox>
 </widget>
-<customwidgets>
-</customwidgets>
 <includes>
     <include location="global" impldecl="in implementation">kdialog.h</include>
 </includes>
 <slots>
     <slot access="protected">makeToggled(bool)</slot>
+    <slot access="protected">otherToggled(bool)</slot>
 </slots>
 <layoutdefaults spacing="6" margin="11"/>
 <layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
--- branches/kdevelop/3.4/buildtools/custommakefiles/customprojectpart.cpp #637880:637881
@@ -48,6 +48,7 @@
 #include "makeoptionswidget.h"
 #include "custombuildoptionswidget.h"
 #include "custommakeconfigwidget.h"
+#include "customotherconfigwidget.h"
 #include "custommanagerwidget.h"
 #include "config.h"
 #include "envvartools.h"
@@ -185,10 +186,15 @@
     connect( dlg, SIGNAL( okClicked() ), w2, SLOT( accept() ) );
     buildtab->addTab( w2, i18n( "&Build" ) );
 
+    CustomOtherConfigWidget *w4 = new CustomOtherConfigWidget(this, "/kdevcustomproject", buildtab);
+    connect( dlg, SIGNAL( okClicked() ), w4, SLOT( accept() ) );
+    buildtab->addTab(w4, i18n("&Other"));
+
     CustomMakeConfigWidget *w3 = new CustomMakeConfigWidget( this, "/kdevcustomproject", buildtab );
     buildtab->addTab( w3, i18n( "Ma&ke" ) );
-    w2->setMakeOptionsWidget( buildtab, w3 );
+    w2->setMakeOptionsWidget( buildtab, w3, w4 );
     connect( dlg, SIGNAL( okClicked() ), w3, SLOT( accept() ) );
+
 }
 
 
@@ -378,11 +384,12 @@
     }
 
     // check if there is an old envvars entry (from old project file with single make environment)
+    QString buildtool = DomUtil::readEntry(dom , "/kdevcustomproject/build/buildtool" );
     QDomElement el =
-        DomUtil::elementByPath( dom , "/kdevcustomproject/make/envvars" );
+        DomUtil::elementByPath( dom , "/kdevcustomproject/"+buildtool+"/envvars" );
     if ( !el.isNull() )
     {
-        QDomElement envs = DomUtil::createElementByPath( dom , "/kdevcustomproject/make/environments" );
+        QDomElement envs = DomUtil::createElementByPath( dom , "/kdevcustomproject/"+buildtool+"/environments" );
         DomUtil::makeEmpty( envs );
         el.setTagName( "default" );
         envs.appendChild( el );
@@ -712,8 +719,9 @@
     // in the form of: "ENV_VARIABLE=ENV_VALUE"
     // Note that we quote the variable value due to the possibility of
     // embedded spaces
+    QString buildtool = DomUtil::readEntry( *projectDom(), "/kdevcustomproject/build/buildtool" );
     DomUtil::PairList envvars =
-        DomUtil::readPairListEntry( *projectDom(), "/kdevcustomproject/make/environments/" + currentMakeEnvironment(), "envvar", "name", "value" );
+        DomUtil::readPairListEntry( *projectDom(), "/kdevcustomproject/"+buildtool+"/environments/" + currentMakeEnvironment(), "envvar", "name", "value" );
 
     QString environstr;
     DomUtil::PairList::ConstIterator it;
@@ -734,15 +742,23 @@
         return; //user cancelled
 
     QDomDocument &dom = *projectDom();
-    bool ant = DomUtil::readEntry( dom, "/kdevcustomproject/build/buildtool" ) == "ant";
+    QString buildtool = DomUtil::readEntry( dom, "/kdevcustomproject/build/buildtool" );
 
     QString cmdline;
-    if ( ant )
+    if ( buildtool == "ant" )
     {
         cmdline = "ant";
     }
-    else
+    else if( buildtool == "other" )
     {
+        cmdline = DomUtil::readEntry(dom, "/kdevcustomproject/other/otherbin");
+        if (cmdline.isEmpty())
+            cmdline = "echo";
+        else if( cmdline.find("/") == -1 )
+            cmdline = "./"+cmdline;
+        cmdline += " " + DomUtil::readEntry(dom, "/kdevcustomproject/other/otheroptions");
+    }else
+    {
         cmdline = DomUtil::readEntry( dom, "/kdevcustomproject/make/makebin" );
         if ( cmdline.isEmpty() )
             cmdline = MAKE_COMMAND;
@@ -767,7 +783,7 @@
     dircmd += KProcess::quote( dir );
     dircmd += " && ";
 
-    int prio = DomUtil::readIntEntry( dom, "/kdevcustomproject/make/prio" );
+    int prio = DomUtil::readIntEntry( dom, "/kdevcustomproject/"+buildtool+"/prio" );
     QString nice;
     if ( prio != 0 )
     {
@@ -789,7 +805,9 @@
 void CustomProjectPart::slotBuild()
 {
     m_lastCompilationFailed = false;
-    startMakeCommand( buildDirectory(), DomUtil::readEntry( *projectDom(), "/kdevcustomproject/make/defaulttarget" ) );
+    QString buildtool = DomUtil::readEntry( *projectDom(), "/kdevcustomproject/build/buildtool" );
+    startMakeCommand( buildDirectory(), DomUtil::readEntry( *projectDom(),
+            "/kdevcustomproject/"+buildtool+"/defaulttarget" ) );
 }