1import qbs.Environment
2import qbs.TextFile
3
4Module {
5    additionalProductTypes: ["m.target"]
6    Rule {
7        multiplex: true
8        Artifact {
9            filePath: "m.output"
10            fileTags: "m.target"
11        }
12        prepare: {
13            var cmd = new JavaScriptCommand();
14            cmd.description = "creating " + output.fileName;
15            cmd.sourceCode = function() {
16                var f = new TextFile(output.filePath, TextFile.WriteOnly);
17                var env = Environment.getEnv("BUILD_ENV_" + product.name.toUpperCase());
18                if (env)
19                    f.writeLine(env);
20                f.close();
21            };
22            return cmd;
23        }
24    }
25}
26