diff options
Diffstat (limited to 'src/lib/corelib/api')
-rw-r--r-- | src/lib/corelib/api/internaljobs.cpp | 3 | ||||
-rw-r--r-- | src/lib/corelib/api/project.cpp | 18 | ||||
-rw-r--r-- | src/lib/corelib/api/project.h | 1 | ||||
-rw-r--r-- | src/lib/corelib/api/projectdata.cpp | 6 | ||||
-rw-r--r-- | src/lib/corelib/api/projectdata.h | 1 | ||||
-rw-r--r-- | src/lib/corelib/api/projectdata_p.h | 1 | ||||
-rw-r--r-- | src/lib/corelib/api/projectfileupdater.cpp | 7 | ||||
-rw-r--r-- | src/lib/corelib/api/runenvironment.cpp | 25 |
8 files changed, 59 insertions, 3 deletions
diff --git a/src/lib/corelib/api/internaljobs.cpp b/src/lib/corelib/api/internaljobs.cpp index 2899bbc6c..cf56f1b8a 100644 --- a/src/lib/corelib/api/internaljobs.cpp +++ b/src/lib/corelib/api/internaljobs.cpp @@ -229,6 +229,9 @@ TopLevelProjectPtr InternalSetupProjectJob::project() const void InternalSetupProjectJob::start() { try { + const ErrorInfo err = m_parameters.expandBuildConfiguration(); + if (err.hasError()) + throw err; execute(); } catch (const ErrorInfo &error) { m_project.clear(); diff --git a/src/lib/corelib/api/project.cpp b/src/lib/corelib/api/project.cpp index bea570aa3..6919a1b94 100644 --- a/src/lib/corelib/api/project.cpp +++ b/src/lib/corelib/api/project.cpp @@ -585,6 +585,14 @@ void ProjectPrivate::prepareChangeToProject() retrieveProjectData(m_projectData, internalProject); } +static bool productIsRunnable(const ResolvedProductConstPtr &product) +{ + return product->fileTags.contains("application") + || (product->fileTags.contains("applicationbundle") + && product->moduleProperties->qbsPropertyValue(QLatin1String("targetOS")) + .toStringList().contains(QLatin1String("darwin"))); +} + void ProjectPrivate::retrieveProjectData(ProjectData &projectData, const ResolvedProjectConstPtr &internalProject) { @@ -596,6 +604,7 @@ void ProjectPrivate::retrieveProjectData(ProjectData &projectData, product.d->name = resolvedProduct->name; product.d->location = resolvedProduct->location; product.d->isEnabled = resolvedProduct->enabled; + product.d->isRunnable = productIsRunnable(resolvedProduct); foreach (const GroupPtr &resolvedGroup, resolvedProduct->groups) product.d->groups << createGroupDataFromGroup(resolvedGroup); if (resolvedProduct->enabled) { @@ -655,6 +664,15 @@ bool Project::isValid() const return d && d->internalProject; } +/*! + * \brief The top-level profile for building this project. + */ +QString Project::profile() const +{ + QBS_ASSERT(isValid(), return QString()); + return d->internalProject->profile(); +} + Project &Project::operator=(const Project &other) { d = other.d; diff --git a/src/lib/corelib/api/project.h b/src/lib/corelib/api/project.h index 0118977c5..871f6210d 100644 --- a/src/lib/corelib/api/project.h +++ b/src/lib/corelib/api/project.h @@ -81,6 +81,7 @@ public: ~Project(); bool isValid() const; + QString profile() const; ProjectData projectData() const; QString targetExecutable(const ProductData &product, const InstallOptions &installoptions) const; diff --git a/src/lib/corelib/api/projectdata.cpp b/src/lib/corelib/api/projectdata.cpp index a5cc6093e..31ba1ef33 100644 --- a/src/lib/corelib/api/projectdata.cpp +++ b/src/lib/corelib/api/projectdata.cpp @@ -414,6 +414,12 @@ bool ProductData::isEnabled() const return d->isEnabled; } +bool ProductData::isRunnable() const +{ + QBS_ASSERT(isValid(), return false); + return d->isRunnable; +} + bool operator==(const ProductData &lhs, const ProductData &rhs) { return lhs.name() == rhs.name() diff --git a/src/lib/corelib/api/projectdata.h b/src/lib/corelib/api/projectdata.h index ba0016d0c..1d7625b82 100644 --- a/src/lib/corelib/api/projectdata.h +++ b/src/lib/corelib/api/projectdata.h @@ -176,6 +176,7 @@ public: QList<TargetArtifact> targetArtifacts() const; QList<GroupData> groups() const; bool isEnabled() const; + bool isRunnable() const; private: QExplicitlySharedDataPointer<Internal::ProductDataPrivate> d; diff --git a/src/lib/corelib/api/projectdata_p.h b/src/lib/corelib/api/projectdata_p.h index 2eda4d932..b0006e89a 100644 --- a/src/lib/corelib/api/projectdata_p.h +++ b/src/lib/corelib/api/projectdata_p.h @@ -84,6 +84,7 @@ public: QList<GroupData> groups; QList<TargetArtifact> targetArtifacts; bool isEnabled; + bool isRunnable; bool isValid; }; diff --git a/src/lib/corelib/api/projectfileupdater.cpp b/src/lib/corelib/api/projectfileupdater.cpp index e7d879b28..c792dc806 100644 --- a/src/lib/corelib/api/projectfileupdater.cpp +++ b/src/lib/corelib/api/projectfileupdater.cpp @@ -323,9 +323,10 @@ void ProjectFileFilesAdder::doApply(QString &fileContent, UiProgram *ast) Rewriter::ScriptBinding); } - setLineOffset(getLineOffsetForChangedBinding(changeSet, getNodeRepresentation(fileContent, - filesBinding->statement))); - const int insertionLine = getBindingLine(changeSet, fileContent) + 1; + setLineOffset(getLineOffsetForChangedBinding(changeSet, + filesBinding ? getNodeRepresentation(fileContent, filesBinding->statement) + : QString())); + const int insertionLine = getBindingLine(changeSet, fileContent); const int insertionColumn = (filesBinding ? arrayElemIndentation : bindingIndentation) + 1; setItemPosition(CodeLocation(projectFile(), insertionLine, insertionColumn)); changeSet.apply(&fileContent); diff --git a/src/lib/corelib/api/runenvironment.cpp b/src/lib/corelib/api/runenvironment.cpp index b0be216f8..386a1769d 100644 --- a/src/lib/corelib/api/runenvironment.cpp +++ b/src/lib/corelib/api/runenvironment.cpp @@ -129,6 +129,21 @@ int RunEnvironment::runShell() return system(command.toLocal8Bit().constData()); } +static QString findExecutable(const QStringList &fileNames) +{ + const QStringList path = QString::fromLocal8Bit(qgetenv("PATH")) + .split(HostOsInfo::pathListSeparator(), QString::SkipEmptyParts); + + foreach (const QString &fileName, fileNames) { + foreach (const QString &ppath, path) { + const QString fullPath = ppath + QLatin1Char('/') + fileName; + if (QFileInfo(fullPath).exists()) + return QDir::cleanPath(fullPath); + } + } + return QString(); +} + int RunEnvironment::runTarget(const QString &targetBin, const QStringList &arguments) { const QStringList targetOS = PropertyFinder().propertyValue( @@ -154,6 +169,15 @@ int RunEnvironment::runTarget(const QString &targetBin, const QStringList &argum } } + if (completeSuffix == QLatin1String("js")) { + // The Node.js binary is called nodejs on Debian/Ubuntu-family operating systems due to a + // conflict with another package containing a binary named node + targetExecutable = findExecutable(QStringList() + << QLatin1String("nodejs") + << QLatin1String("node")); + targetArguments.prepend(targetBin); + } + // Only check if the target is executable if we're not running it through another // known application such as msiexec or wine, as we can't check in this case anyways if (targetBin == targetExecutable && !QFileInfo(targetExecutable).isExecutable()) { @@ -166,6 +190,7 @@ int RunEnvironment::runTarget(const QString &targetBin, const QStringList &argum d->logger.qbsInfo() << Tr::tr("Starting target '%1'.").arg(QDir::toNativeSeparators(targetBin)); QProcess process; + process.setWorkingDirectory(QFileInfo(targetBin).absolutePath()); process.setProcessEnvironment(d->resolvedProduct->runEnvironment); process.setProcessChannelMode(QProcess::ForwardedChannels); process.start(targetExecutable, targetArguments); |