Fixed the vcsubdirs workaround to support the .file modifier in nested subdirs.

This commit is contained in:
Mathew Sutcliffe
2015-12-12 03:11:36 +00:00
parent 1b8a2dff81
commit 16833e29a2

View File

@@ -8,16 +8,25 @@ equals(TEMPLATE, "vcsubdirs") {
# This function returns the absolute path of the .pro file referenced by subdir.
# \param subdir Any value which is valid to appear in the SUBDIRS variable.
# \param basedir The absolute directory of the .pro file containing the SUBDIRS variable.
# \note For now, it only supports .file and .subdir modifiers in the top-level project.
# \param profile The .pro file containing the SUBDIRS variable (empty if it is this very project).
defineReplace(subdirToProjectFile) {
SUBDIR = $$1
BASEDIR = $$2
PROFILE = $$3
BASENAME = $$basename(SUBDIR)
SUFFIX = $$section(SUBDIR, ".", -1, -1)
!isEmpty($${SUBDIR}.file): return($$BASEDIR/$$eval($${SUBDIR}.file))
!isEmpty($${SUBDIR}.subdir): return($$BASEDIR/$$eval($${SUBDIR}.subdir)/$${BASENAME}.pro)
equals(SUFFIX, "pro"): return($$BASEDIR/$$SUBDIR)
else: return($$BASEDIR/$$SUBDIR/$${BASENAME}.pro)
isEmpty(PROFILE) {
file = $$eval($${SUBDIR}.file)
subdir = $$eval($${SUBDIR}.subdir)
}
else {
file = $$fromfile($$PROFILE, $${SUBDIR}.file)
subdir = $$fromfile($$PROFILE, $${SUBDIR}.subdir)
}
!isEmpty(file): return($$BASEDIR/$$file)
!isEmpty(subdir): return($$BASEDIR/$$subdir/$${BASENAME}.pro)
equals(SUFFIX, "pro"): return($$BASEDIR/$$SUBDIR)
else: return($$BASEDIR/$$SUBDIR/$${BASENAME}.pro)
}
# flattenSubdirs(subdirs, basedir)
@@ -26,11 +35,13 @@ equals(TEMPLATE, "vcsubdirs") {
# project, recursively.
# \param subdirs The value of a SUBDIRS variable.
# \param basedir The absolute directory of the .pro file containing the SUBDIRS variable.
# \param profile The .pro file containing the SUBDIRS variable (empty if it is this very project).
defineReplace(flattenSubdirs) {
SUBDIRS = $$1
BASEDIR = $$2
PROFILE = $$3
for(subdir, SUBDIRS) {
SUBDIR_PROJECT = $$subdirToProjectFile($$subdir, $$BASEDIR)
SUBDIR_PROJECT = $$subdirToProjectFile($$subdir, $$BASEDIR, $$PROFILE)
INNER_REQUIRES = $$fromfile($$SUBDIR_PROJECT, REQUIRES)
REQUIRES_OK = 1
for(req, INNER_REQUIRES): !if($${req}): REQUIRES_OK = 0
@@ -38,7 +49,7 @@ equals(TEMPLATE, "vcsubdirs") {
INNER_TEMPLATE = $$fromfile($$SUBDIR_PROJECT, TEMPLATE)
equals(INNER_TEMPLATE, "vcsubdirs") {
INNER_SUBDIRS = $$fromfile($$SUBDIR_PROJECT, SUBDIRS)
SUBDIRS_FLAT += $$flattenSubdirs($$INNER_SUBDIRS, $$dirname(SUBDIR_PROJECT))
SUBDIRS_FLAT += $$flattenSubdirs($$INNER_SUBDIRS, $$dirname(SUBDIR_PROJECT), $$SUBDIR_PROJECT)
}
else: SUBDIRS_FLAT += $$SUBDIR_PROJECT
}