1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 Openismus GmbH.
4 ** Author: Peter Penz (ppenz@openismus.com)
5 ** Author: Patricia Santana Cruz (patriciasantanacruz@gmail.com)
6 ** Contact: https://www.qt.io/licensing/
7 **
8 ** This file is part of Qt Creator.
9 **
10 ** Commercial License Usage
11 ** Licensees holding valid commercial Qt licenses may use this file in
12 ** accordance with the commercial license agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and The Qt Company. For licensing terms
15 ** and conditions see https://www.qt.io/terms-conditions. For further
16 ** information use the contact form at https://www.qt.io/contact-us.
17 **
18 ** GNU General Public License Usage
19 ** Alternatively, this file may be used under the terms of the GNU
20 ** General Public License version 3 as published by the Free Software
21 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
22 ** included in the packaging of this file. Please review the following
23 ** information to ensure the GNU General Public License requirements will
24 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25 **
26 ****************************************************************************/
27 
28 #include "autotoolsbuildconfiguration.h"
29 
30 #include "autotoolsprojectconstants.h"
31 
32 #include <projectexplorer/buildinfo.h>
33 #include <projectexplorer/buildsteplist.h>
34 #include <projectexplorer/project.h>
35 #include <projectexplorer/projectexplorerconstants.h>
36 #include <projectexplorer/target.h>
37 
38 using namespace ProjectExplorer;
39 using namespace Utils;
40 
41 namespace AutotoolsProjectManager {
42 namespace Internal {
43 
44 // AutotoolsBuildConfiguration
45 
46 class AutotoolsBuildConfiguration : public BuildConfiguration
47 {
48     Q_DECLARE_TR_FUNCTIONS(AutotoolsProjectManager::Internal::AutotoolsBuildConfiguration)
49 
50 public:
AutotoolsBuildConfiguration(Target * target,Utils::Id id)51     AutotoolsBuildConfiguration(Target *target, Utils::Id id)
52         : BuildConfiguration(target, id)
53     {
54         // /<foobar> is used so the un-changed check in setBuildDirectory() works correctly.
55         // The leading / is to avoid the relative the path expansion in BuildConfiguration::buildDirectory.
56         setBuildDirectory(Utils::FilePath::fromString("/<foobar>"));
57         setBuildDirectoryHistoryCompleter("AutoTools.BuildDir.History");
58         setConfigWidgetDisplayName(tr("Autotools Manager"));
59 
60         // ### Build Steps Build ###
61         QFile autogenFile(target->project()->projectDirectory().toString() + "/autogen.sh");
62         if (autogenFile.exists())
63             appendInitialBuildStep(Constants::AUTOGEN_STEP_ID); // autogen.sh
64         else
65             appendInitialBuildStep(Constants::AUTORECONF_STEP_ID); // autoreconf
66 
67         appendInitialBuildStep(Constants::CONFIGURE_STEP_ID); // ./configure.
68         appendInitialBuildStep(Constants::MAKE_STEP_ID); // make
69 
70         // ### Build Steps Clean ###
71         appendInitialCleanStep(Constants::MAKE_STEP_ID); // make clean
72     }
73 };
74 
AutotoolsBuildConfigurationFactory()75 AutotoolsBuildConfigurationFactory::AutotoolsBuildConfigurationFactory()
76 {
77     registerBuildConfiguration<AutotoolsBuildConfiguration>
78             ("AutotoolsProjectManager.AutotoolsBuildConfiguration");
79 
80     setSupportedProjectType(Constants::AUTOTOOLS_PROJECT_ID);
81     setSupportedProjectMimeTypeName(Constants::MAKEFILE_MIMETYPE);
82 
83     setBuildGenerator([](const Kit *, const FilePath &projectPath, bool forSetup) {
84         BuildInfo info;
85         info.typeName = BuildConfiguration::tr("Build");
86         info.buildDirectory = forSetup
87                 ? FilePath::fromString(projectPath.toFileInfo().absolutePath()) : projectPath;
88         if (forSetup) {
89             //: The name of the build configuration created by default for a autotools project.
90             info.displayName = BuildConfiguration::tr("Default");
91         }
92         return QList<BuildInfo>{info};
93     });
94 }
95 
96 } // Internal
97 } // AutotoolsProjectManager
98