if (!projectDef.getOverwrite() && projectFile.exists()) {
throw new BuildException("Not allowed to overwrite project file "
+ projectFile.toString());
}
CommandLineCompilerConfiguration compilerConfig =
getBaseCompilerConfiguration(targets);
if (compilerConfig == null) {
throw new BuildException(
"Unable to generate C++ BuilderX project when gcc or bcc is not used.");
}
OutputStream outStream = new FileOutputStream(projectFile);
OutputFormat format = new OutputFormat("xml", "UTF-8", true);
Serializer serializer = new XMLSerializer(outStream, format);
ContentHandler content = serializer.asContentHandler();
content.startDocument();
AttributesImpl emptyAttrs = new AttributesImpl();
content.startElement(null, "project", "project", emptyAttrs);
PropertyWriter propertyWriter = new PropertyWriter(content);
propertyWriter.write("build.config", "active", "0");
propertyWriter.write("build.config", "count", "0");
propertyWriter.write("build.config", "excludedefaultforzero", "0");
propertyWriter.write("build.config.0", "builddir", "Debug");
propertyWriter.write("build.config.0", "key", "Debug_Build");
propertyWriter.write("build.config.0", "linux.builddir",
"linux/Debug_Build");
propertyWriter.write("build.config.0", "settings.MinGW",
"default;debug");
propertyWriter.write("build.config.0", "settings.gnuc++",
"default;debug");
propertyWriter.write("build.config.0", "settings.intellinia32",
"default;debug");
propertyWriter.write("build.config.0", "settings.mswin32",
"default;debug");
propertyWriter.write("build.config.0", "type", "Toolset");
propertyWriter.write("build.config.0", "win32.builddir",
"windows/Debug_Build");
propertyWriter.write("build.node", "name", projectDef.getName());
final String buildType = getBuildType(task);
propertyWriter.write("build.node", "type", buildType);
propertyWriter.write("build.platform", "active",
getActivePlatform(task));
propertyWriter.write("build.platform", "linux.Debug_Build.toolset",
"gnuc++");
propertyWriter.write("build.platform", "linux.Release_Build.toolset",
"gnuc++");
propertyWriter.write("build.platform", "linux.default", "gnuc++");
propertyWriter.write("build.platform", "linux.gnuc++.enabled", "1");
propertyWriter.write("build.platform", "linux.mswin32.enabled", "1");
propertyWriter.write("build.platform", "linux.win32b.enabled", "1");
propertyWriter.write("build.platform", "solaris.default", "gnuc++");
propertyWriter.write("build.platform", "solaris.enabled", "1");
String toolset = getWin32Toolset(compilerConfig);
propertyWriter.write("build.platform", "win32.default", toolset);
propertyWriter.write("build.platform", "win32." + toolset + ".enabled", "1");
propertyWriter.write("cbproject", "version", "X.1.0");
if ("dllproject".equals(buildType)) {
propertyWriter.write("gnuc++.g++compile",
"option.fpic_using_GOT.enabled", "1");
propertyWriter.write("gnuc++.g++link", "option.shared.enabled", "1");
propertyWriter.write("intellinia32.icc", "option.minus_Kpic.enabled",
"1");
propertyWriter.write("intellinia32.icclink",
"option.minus_shared.enabled", "1");
}
//
// assume the first target is representative of all compilation tasks
//
writeCompileOptions(basePath, propertyWriter, compilerConfig);
writeLinkOptions(basePath, propertyWriter, linkTarget);
propertyWriter.write("linux.gnuc++.Debug_Build", "saved", "1");
if ("dllproject".equals(buildType)) {
propertyWriter.write("runtime", "ExcludeDefaultForZero", "1");
//propertyWriter.write("unique", "id", "852");
} else if ("exeproject".equals(buildType)) {
propertyWriter.write("runtime.0", "BuildTargetOnRun",
"com.borland.cbuilder.build."
+ "CBProjectBuilder$ProjectBuildAction;make");
propertyWriter.write("runtime.0", "ConfigurationName",
projectDef.getName());
propertyWriter.write("runtime.0", "RunnableType",
"com.borland.cbuilder.runtime.ExecutableRunner");
}
AttributesImpl fileAttributes = new AttributesImpl();
fileAttributes.addAttribute(null, "path", "path", "#PCDATA", "");
AttributesImpl gccAttributes = null;
if (!"g++".equals(compilerConfig.getCommand())) {
gccAttributes = new AttributesImpl();
gccAttributes.addAttribute(null, "category", "category", "#PCDATA",
"build.basecmd");
gccAttributes.addAttribute(null, "name", "name", "#PCDATA",
"linux.gnuc++.Debug_Build.g++_key");
gccAttributes.addAttribute(null, "value", "value", "#PCDATA",
compilerConfig.getCommand());
}
Iterator targetIter = targets.values().iterator();
while (targetIter.hasNext()) {
TargetInfo info = (TargetInfo) targetIter.next();