Esempio n. 1
0
        protected void SetTargetConfiguration(StreamWriter writer)
        {
            writer.WriteLine("  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />");

            string projectType;

            switch (outputType)
            {
            case OutputAssemblyType.Console:
            case OutputAssemblyType.Executable: projectType = "Application"; break;

            case OutputAssemblyType.Library: projectType = "DynamicLibrary"; break;

            case OutputAssemblyType.Static:
            default: projectType = "StaticLibrary"; break;
            }
            string extension;

            switch (outputType)
            {
            case OutputAssemblyType.Console:
            case OutputAssemblyType.Executable: extension = ".exe"; break;

            case OutputAssemblyType.Library: extension = ".dll"; break;

            case OutputAssemblyType.Static:
            default: extension = ".lib"; break;
            }
            foreach (BuildTarget target in buildTargets)
            {
                writer.WriteLine("  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='{0}|{1}'\" Label=\"Configuration\">", target.Mode.Name, target.Architecture);
                writer.WriteLine("    <ConfigurationType>{0}</ConfigurationType>", projectType);
                writer.WriteLine("    <UseDebugLibraries>{0}</UseDebugLibraries>", (target.Mode.Optimized) ? "false" : "true");
                writer.WriteLine("    <PlatformToolset>{0}</PlatformToolset>", VisualStudioUtils.GetToolsetVersion(version));
                writer.WriteLine("  </PropertyGroup>");

                writer.WriteLine("  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='{0}|{1}'\">", target.Mode.Name, target.Architecture);
                writer.WriteLine("    <OutDir>{0}</OutDir>", outputPath.GetRelativePath(location));
                writer.WriteLine("    <IntDir>{0}$(ProjectName)\\</IntDir>", Application.BuildDirectory.GetRelativePath(location));
                writer.WriteLine("    <TargetName>{0}</TargetName>", assemblyName);
                writer.WriteLine("    <TargetExt>{0}</TargetExt>", extension);
                writer.WriteLine("  </PropertyGroup>");

                writer.WriteLine("  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='{0}|{1}'\">", target.Mode.Name, target.Architecture);
                writer.WriteLine("    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />");
                writer.WriteLine("  </ImportGroup>");

                writer.WriteLine("  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='{0}|{1}'\">", target.Mode.Name, target.Architecture);
                writer.WriteLine("    <ClCompile>");

                writer.Write("      <AdditionalIncludeDirectories>");
                writer.Write("$(ProjectDir);");
                foreach (VisualStudioProject reference in DependencyProjects)
                {
                    writer.Write("$(ProjectDir)");
                    writer.Write(reference.Location.GetRelativePath(location));
                    writer.Write(";");
                }
                writer.WriteLine("</AdditionalIncludeDirectories>");

                writer.Write("      <PreprocessorDefinitions>");
                foreach (KeyValuePair <string, object> definitions in target.Mode.Definitions)
                {
                    writer.Write(definitions.Key);
                    writer.Write(";");
                }
                writer.WriteLine("</PreprocessorDefinitions>");
                writer.WriteLine("      <WarningLevel>Level4</WarningLevel>");
                writer.WriteLine("      <TreatWarningAsError>{0}</TreatWarningAsError>", (target.Mode.WarningAsError) ? "true" : "false");
                writer.WriteLine("      <ExceptionHandling>false</ExceptionHandling>");

                if (target.Mode.Optimized)
                {
                    writer.WriteLine("      <Optimization>MaxSpeed</Optimization>");
                }

                writer.WriteLine("    </ClCompile>");
                writer.WriteLine("    <Link>");

                HashSet <UInt32> directories = new HashSet <UInt32>();
                writer.Write("      <AdditionalLibraryDirectories>");
                foreach (VisualStudioProject reference in DependencyProjects)
                {
                    UInt32 id = reference.OutputPath.GetAbsolutePath().Fnv32();
                    if (!directories.Contains(id))
                    {
                        writer.Write("$(ProjectDir)\\");
                        writer.Write(reference.OutputPath.GetRelativePath(location));
                        writer.Write(";");
                        directories.Add(id);
                    }
                }
                writer.WriteLine("</AdditionalLibraryDirectories>");
                writer.Write("      <AdditionalDependencies>");
                foreach (VisualStudioProject reference in DependencyProjects)
                {
                    string depExtension;
                    switch (reference.OutputType)
                    {
                    case OutputAssemblyType.Console:
                    case OutputAssemblyType.Executable: depExtension = ".exe"; break;

                    case OutputAssemblyType.Library: depExtension = ".dll"; break;

                    case OutputAssemblyType.Static:
                    default: depExtension = ".lib"; break;
                    }

                    writer.Write("{0}{1}", reference.AssemblyName, depExtension);
                    writer.Write(";");
                }
                foreach (FileDescriptor external in dependencies)
                {
                    writer.Write(external.FullName);
                    writer.Write(";");
                }
                writer.WriteLine("</AdditionalDependencies>");

                writer.WriteLine("      <GenerateDebugInformation>{0}</GenerateDebugInformation>", target.Mode.SymbolExport);
                writer.WriteLine("    </Link>");

                writer.WriteLine("  </ItemDefinitionGroup>");
            }

            writer.WriteLine("  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />");
            writer.WriteLine("  <ImportGroup Label=\"ExtensionSettings\">");
            writer.WriteLine("    <Import Project=\"$(VCTargetsPath)\\BuildCustomizations\\masm.props\" />");
            writer.WriteLine("  </ImportGroup>");
        }