forked from qt-creator/qt-creator
qbs build: Get rid of CopyTransformer.
That item was using a directory as an output artifact, which was only working by accident and often caused warning messages about failure to remove files. Use a proper module instead, which is the nicer solution anyway. Change-Id: Ib75a0ce26a24c78eb5421367995a8fc72f6a3c2a Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import QtcProduct
|
|||||||
QtcProduct {
|
QtcProduct {
|
||||||
type: "application"
|
type: "application"
|
||||||
Depends { name: "Qt.test" }
|
Depends { name: "Qt.test" }
|
||||||
|
Depends { name: "copyable_resource" }
|
||||||
targetName: "tst_" + name.split(' ').join("")
|
targetName: "tst_" + name.split(' ').join("")
|
||||||
|
|
||||||
// This needs to be absolute, because it is passed to one of the source files.
|
// This needs to be absolute, because it is passed to one of the source files.
|
||||||
|
32
qbs/modules/copyable_resource/copyable-resource.qbs
Normal file
32
qbs/modules/copyable_resource/copyable-resource.qbs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import qbs
|
||||||
|
import qbs.File
|
||||||
|
import qbs.FileInfo
|
||||||
|
|
||||||
|
Module {
|
||||||
|
property path targetDirectory
|
||||||
|
additionalProductTypes: "copied_resource"
|
||||||
|
Rule {
|
||||||
|
inputs: ["copyable_resource"]
|
||||||
|
outputFileTags: ["copied_resource"]
|
||||||
|
outputArtifacts: {
|
||||||
|
var destinationDir = input.moduleProperty("copyable_resource", "targetDirectory");
|
||||||
|
if (!destinationDir) {
|
||||||
|
// If the destination directory has not been explicitly set, replicate the
|
||||||
|
// structure from the source directory in the build directory.
|
||||||
|
destinationDir = project.buildDirectory + '/'
|
||||||
|
+ FileInfo.relativePath(project.sourceDirectory, input.filePath);
|
||||||
|
}
|
||||||
|
return [{
|
||||||
|
filePath: destinationDir + '/' + input.fileName,
|
||||||
|
fileTags: ["copied_resource"]
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
prepare: {
|
||||||
|
var cmd = new JavaScriptCommand();
|
||||||
|
cmd.description = "Copying " + FileInfo.fileName(input.fileName);
|
||||||
|
cmd.highlight = "codegen";
|
||||||
|
cmd.sourceCode = function() { File.copy(input.filePath, output.filePath); };
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,26 +0,0 @@
|
|||||||
import qbs
|
|
||||||
import qbs.File
|
|
||||||
import qbs.FileInfo
|
|
||||||
|
|
||||||
Transformer {
|
|
||||||
property pathList sourceFiles
|
|
||||||
property path targetDirectory
|
|
||||||
inputs: sourceFiles
|
|
||||||
Artifact { fileName: targetDirectory }
|
|
||||||
prepare: {
|
|
||||||
var commands = []
|
|
||||||
for (var tag in inputs) {
|
|
||||||
for (var index in inputs[tag]) {
|
|
||||||
var artifact = inputs[tag][index];
|
|
||||||
var cmd = new JavaScriptCommand();
|
|
||||||
cmd.sourceFile = artifact.filePath;
|
|
||||||
cmd.description = "Copying '" + cmd.sourceFile + "' to '" + output.filePath + "/'.";
|
|
||||||
cmd.highlight = "codegen";
|
|
||||||
cmd.targetFilePath = output.filePath + '/' + FileInfo.fileName(cmd.sourceFile);
|
|
||||||
cmd.sourceCode = function() { File.copy(sourceFile, targetFilePath); }
|
|
||||||
commands.push(cmd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return commands;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,6 +1,5 @@
|
|||||||
import qbs
|
import qbs
|
||||||
import qbs.FileInfo
|
import qbs.FileInfo
|
||||||
import "./copytransformer.qbs" as CopyTransformer
|
|
||||||
import QtcFunctions
|
import QtcFunctions
|
||||||
|
|
||||||
DynamicLibrary {
|
DynamicLibrary {
|
||||||
@@ -8,6 +7,7 @@ DynamicLibrary {
|
|||||||
Depends { name: "ExtensionSystem" }
|
Depends { name: "ExtensionSystem" }
|
||||||
Depends { name: "cpp" }
|
Depends { name: "cpp" }
|
||||||
Depends { name: "Qt.core" }
|
Depends { name: "Qt.core" }
|
||||||
|
Depends { name: "copyable_resource" }
|
||||||
targetName: QtcFunctions.qtLibraryName(qbs, name.split('_')[1])
|
targetName: QtcFunctions.qtLibraryName(qbs, name.split('_')[1])
|
||||||
destinationDirectory: project.buildDirectory + '/'
|
destinationDirectory: project.buildDirectory + '/'
|
||||||
+ FileInfo.relativePath(project.ide_source_tree, sourceDirectory)
|
+ FileInfo.relativePath(project.ide_source_tree, sourceDirectory)
|
||||||
@@ -17,8 +17,10 @@ DynamicLibrary {
|
|||||||
].concat(additionalRPaths)
|
].concat(additionalRPaths)
|
||||||
property pathList filesToCopy
|
property pathList filesToCopy
|
||||||
property pathList additionalRPaths: []
|
property pathList additionalRPaths: []
|
||||||
CopyTransformer {
|
Group {
|
||||||
sourceFiles: product.filesToCopy
|
name: "resources"
|
||||||
targetDirectory: product.destinationDirectory
|
fileTags: "copyable_resource"
|
||||||
|
copyable_resource.targetDirectory: product.destinationDirectory
|
||||||
|
files: product.filesToCopy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,6 @@ import "../../../plugin.qbs" as Plugin
|
|||||||
Plugin {
|
Plugin {
|
||||||
name: "circular_plugin1"
|
name: "circular_plugin1"
|
||||||
filesToCopy: "plugin.xml"
|
filesToCopy: "plugin.xml"
|
||||||
files: ["plugin1.h", "plugin1.cpp"].concat(filesToCopy)
|
files: ["plugin1.h", "plugin1.cpp"]
|
||||||
cpp.defines: base.concat(["PLUGIN1_LIBRARY"])
|
cpp.defines: base.concat(["PLUGIN1_LIBRARY"])
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,6 @@ import "../../../plugin.qbs" as Plugin
|
|||||||
Plugin {
|
Plugin {
|
||||||
name: "circular_plugin2"
|
name: "circular_plugin2"
|
||||||
filesToCopy: "plugin.xml"
|
filesToCopy: "plugin.xml"
|
||||||
files: ["plugin2.h", "plugin2.cpp"].concat(filesToCopy)
|
files: ["plugin2.h", "plugin2.cpp"]
|
||||||
cpp.defines: base.concat(["PLUGIN2_LIBRARY"])
|
cpp.defines: base.concat(["PLUGIN2_LIBRARY"])
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,6 @@ import "../../../plugin.qbs" as Plugin
|
|||||||
Plugin {
|
Plugin {
|
||||||
name: "circular_plugin3"
|
name: "circular_plugin3"
|
||||||
filesToCopy: "plugin.xml"
|
filesToCopy: "plugin.xml"
|
||||||
files: ["plugin3.h", "plugin3.cpp"].concat(filesToCopy)
|
files: ["plugin3.h", "plugin3.cpp"]
|
||||||
cpp.defines: base.concat(["PLUGIN3_LIBRARY"])
|
cpp.defines: base.concat(["PLUGIN3_LIBRARY"])
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,6 @@ Plugin {
|
|||||||
destinationDirectory + "/../plugin2",
|
destinationDirectory + "/../plugin2",
|
||||||
destinationDirectory + "/../plugin3"
|
destinationDirectory + "/../plugin3"
|
||||||
]
|
]
|
||||||
files: ["plugin1.h", "plugin1.cpp"].concat(filesToCopy)
|
files: ["plugin1.h", "plugin1.cpp"]
|
||||||
cpp.defines: base.concat(["PLUGIN1_LIBRARY"])
|
cpp.defines: base.concat(["PLUGIN1_LIBRARY"])
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,6 @@ import "../../../plugin.qbs" as Plugin
|
|||||||
Plugin {
|
Plugin {
|
||||||
name: "correct_plugin2"
|
name: "correct_plugin2"
|
||||||
filesToCopy: "plugin.spec"
|
filesToCopy: "plugin.spec"
|
||||||
files: ["plugin2.h", "plugin2.cpp"].concat(filesToCopy)
|
files: ["plugin2.h", "plugin2.cpp"]
|
||||||
cpp.defines: base.concat(["PLUGIN2_LIBRARY"])
|
cpp.defines: base.concat(["PLUGIN2_LIBRARY"])
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,6 @@ Plugin {
|
|||||||
Depends { name: "correct_plugin2" }
|
Depends { name: "correct_plugin2" }
|
||||||
filesToCopy: "plugin.spec"
|
filesToCopy: "plugin.spec"
|
||||||
additionalRPaths: [destinationDirectory + "/../plugin2"]
|
additionalRPaths: [destinationDirectory + "/../plugin2"]
|
||||||
files: ["plugin3.h", "plugin3.cpp"].concat(filesToCopy)
|
files: ["plugin3.h", "plugin3.cpp"]
|
||||||
cpp.defines: base.concat(["PLUGIN3_LIBRARY"])
|
cpp.defines: base.concat(["PLUGIN3_LIBRARY"])
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import qbs
|
import qbs
|
||||||
import QtcAutotest
|
import QtcAutotest
|
||||||
import "../copytransformer.qbs" as CopyTransformer
|
|
||||||
|
|
||||||
QtcAutotest {
|
QtcAutotest {
|
||||||
name: "PluginManager autotest"
|
name: "PluginManager autotest"
|
||||||
@@ -15,6 +14,8 @@ QtcAutotest {
|
|||||||
Group {
|
Group {
|
||||||
id: pluginGroup
|
id: pluginGroup
|
||||||
name: "plugins"
|
name: "plugins"
|
||||||
|
fileTags: "copyable_resource"
|
||||||
|
copyable_resource.targetDirectory: product.destinationDirectory + "/plugins"
|
||||||
files: [
|
files: [
|
||||||
"plugins/otherplugin.xml",
|
"plugins/otherplugin.xml",
|
||||||
"plugins/plugin1.xml",
|
"plugins/plugin1.xml",
|
||||||
@@ -22,11 +23,6 @@ QtcAutotest {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyTransformer {
|
|
||||||
sourceFiles: pluginGroup.files
|
|
||||||
targetDirectory: product.destinationDirectory + "/plugins"
|
|
||||||
}
|
|
||||||
|
|
||||||
files: "tst_pluginmanager.cpp"
|
files: "tst_pluginmanager.cpp"
|
||||||
cpp.defines: base.concat(['PLUGINMANAGER_TESTS_DIR="' + destinationDirectory + '"'])
|
cpp.defines: base.concat(['PLUGINMANAGER_TESTS_DIR="' + destinationDirectory + '"'])
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
import qbs
|
import qbs
|
||||||
|
|
||||||
import QtcAutotest
|
import QtcAutotest
|
||||||
import "../copytransformer.qbs" as CopyTransformer
|
|
||||||
|
|
||||||
QtcAutotest {
|
QtcAutotest {
|
||||||
name: "ExtensionSystem pluginspec autotest"
|
name: "ExtensionSystem pluginspec autotest"
|
||||||
@@ -13,6 +11,8 @@ QtcAutotest {
|
|||||||
Group {
|
Group {
|
||||||
id: testSpecsGroup
|
id: testSpecsGroup
|
||||||
name: "test specs"
|
name: "test specs"
|
||||||
|
fileTags: "copyable_resource"
|
||||||
|
copyable_resource.targetDirectory: product.destinationDirectory + "/testspecs"
|
||||||
files: [
|
files: [
|
||||||
"testspecs/simplespec.xml",
|
"testspecs/simplespec.xml",
|
||||||
"testspecs/simplespec_experimental.xml",
|
"testspecs/simplespec_experimental.xml",
|
||||||
@@ -28,6 +28,8 @@ QtcAutotest {
|
|||||||
Group {
|
Group {
|
||||||
id: testDependenciesGroup
|
id: testDependenciesGroup
|
||||||
name: "test dependencies"
|
name: "test dependencies"
|
||||||
|
fileTags: "copyable_resource"
|
||||||
|
copyable_resource.targetDirectory: product.destinationDirectory + "/testdependencies"
|
||||||
files: [
|
files: [
|
||||||
"testdependencies/spec1.xml",
|
"testdependencies/spec1.xml",
|
||||||
"testdependencies/spec2.xml",
|
"testdependencies/spec2.xml",
|
||||||
@@ -39,21 +41,8 @@ QtcAutotest {
|
|||||||
Group {
|
Group {
|
||||||
id: specGroup
|
id: specGroup
|
||||||
name: "spec"
|
name: "spec"
|
||||||
|
fileTags: "copyable_resource"
|
||||||
|
copyable_resource.targetDirectory: product.destinationDirectory + "/testdir"
|
||||||
files: ["testdir/spec.xml"]
|
files: ["testdir/spec.xml"]
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyTransformer {
|
|
||||||
sourceFiles: testSpecsGroup.files
|
|
||||||
targetDirectory: product.destinationDirectory + "/testspecs"
|
|
||||||
}
|
|
||||||
|
|
||||||
CopyTransformer {
|
|
||||||
sourceFiles: testDependenciesGroup.files
|
|
||||||
targetDirectory: product.destinationDirectory + "/testdependencies"
|
|
||||||
}
|
|
||||||
|
|
||||||
CopyTransformer {
|
|
||||||
sourceFiles: specGroup.files
|
|
||||||
targetDirectory: product.destinationDirectory + "/testdir"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ Plugin {
|
|||||||
files: [
|
files: [
|
||||||
"testplugin.h", "testplugin.cpp",
|
"testplugin.h", "testplugin.cpp",
|
||||||
"testplugin_global.h"
|
"testplugin_global.h"
|
||||||
].concat(filesToCopy)
|
]
|
||||||
filesToCopy: "testplugin.xml"
|
filesToCopy: "testplugin.xml"
|
||||||
cpp.defines: base.concat(["MYPLUGIN_LIBRARY"])
|
cpp.defines: base.concat(["MYPLUGIN_LIBRARY"])
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user