Beispiel #1
0
        public override Cci.CompilerOptions GetCompilerOptions(Microsoft.VisualStudio.Package.ProjectOptions projectOptions)
        {
            Cci.CompilerOptions     options;
            SpecSharpProjectOptions specSharpOptions = projectOptions as SpecSharpProjectOptions;

            if (specSharpOptions != null)
            {
                options = specSharpOptions.GetCompilerOptions();
            }
            else
            {
                options = base.GetCompilerOptions(projectOptions);
            }
            if (this.BuildSite != null)
            {
                options.Site = new Microsoft.VisualStudio.IntegrationHelper.BuildSiteAdaptor(this.BuildSite);
            }
            return(options);
        }
        public virtual ProjectOptions GetProjectOptions(ConfigCanonicalName configCanonicalName)
        {
            if (this.options != null)
                return this.options;

            ProjectOptions options = this.options = CreateProjectOptions();


            options.GenerateExecutable = true;

            this.SetConfiguration(configCanonicalName);

            string outputPath = this.GetOutputPath();
            if (!String.IsNullOrEmpty(outputPath))
            {
                // absolutize relative to project folder location
                outputPath = Path.Combine(this.ProjectFolder, outputPath);
            }

            // Set some default values
            options.OutputAssembly = outputPath + this.Caption + ".exe";
            options.ModuleKind = ModuleKindFlags.ConsoleApplication;

            options.RootNamespace = GetProjectProperty(ProjectFileConstants.RootNamespace, false);
            options.OutputAssembly = outputPath + this.GetAssemblyName(configCanonicalName);

            string outputtype = GetProjectProperty(ProjectFileConstants.OutputType, false);
            if (!String.IsNullOrEmpty(outputtype))
            {
                outputtype = outputtype.ToLower(CultureInfo.InvariantCulture);
            }

            if (outputtype == "library")
            {
                options.ModuleKind = ModuleKindFlags.DynamicallyLinkedLibrary;
                options.GenerateExecutable = false; // DLL's have no entry point.
            }
            else if (outputtype == "winexe")
                options.ModuleKind = ModuleKindFlags.WindowsApplication;
            else
                options.ModuleKind = ModuleKindFlags.ConsoleApplication;

            options.Win32Icon = GetProjectProperty("ApplicationIcon", false);
            options.MainClass = GetProjectProperty("StartupObject", false);

            string targetPlatform = GetProjectProperty("TargetPlatform", false);

            if (targetPlatform != null && targetPlatform.Length > 0)
            {
                try
                {
                    options.TargetPlatform = (PlatformType)Enum.Parse(typeof(PlatformType), targetPlatform);
                }
                catch (ArgumentException e)
                {
                    Trace.WriteLine("Exception : " + e.Message);
                }
                options.TargetPlatformLocation = GetProjectProperty("TargetPlatformLocation", false);
                this.SetTargetPlatform(options);
            }

            //    other settings from CSharp we may want to adopt at some point...
            //    AssemblyKeyContainerName = ""  //This is the key file used to sign the interop assembly generated when importing a com object via add reference
            //    AssemblyOriginatorKeyFile = ""
            //    DelaySign = "false"
            //    DefaultClientScript = "JScript"
            //    DefaultHTMLPageLayout = "Grid"
            //    DefaultTargetSchema = "IE50"
            //    PreBuildEvent = ""
            //    PostBuildEvent = ""
            //    RunPostBuildEvent = "OnBuildSuccess"

            // transfer all config build options...
            if (GetBoolAttr("AllowUnsafeBlocks"))
            {
                options.AllowUnsafeCode = true;
            }

            if (GetProjectProperty("BaseAddress", false) != null)
            {
                try
                {
                    options.BaseAddress = Int64.Parse(GetProjectProperty("BaseAddress", false), CultureInfo.InvariantCulture);
                }
                catch (ArgumentNullException e)
                {
                    Trace.WriteLine("Exception : " + e.Message);
                }
                catch (ArgumentException e)
                {
                    Trace.WriteLine("Exception : " + e.Message);
                }
                catch (FormatException e)
                {
                    Trace.WriteLine("Exception : " + e.Message);
                }
                catch (OverflowException e)
                {
                    Trace.WriteLine("Exception : " + e.Message);
                }
            }

            if (GetBoolAttr("CheckForOverflowUnderflow"))
            {
                options.CheckedArithmetic = true;
            }

            if (GetProjectProperty("DefineConstants", false) != null)
            {
                options.DefinedPreProcessorSymbols = new StringCollection();
                foreach (string s in GetProjectProperty("DefineConstants", false).Replace(" \t\r\n", "").Split(';'))
                {
                    options.DefinedPreProcessorSymbols.Add(s);
                }
            }

            string docFile = GetProjectProperty("DocumentationFile", false);
            if (!String.IsNullOrEmpty(docFile))
            {
                options.XMLDocFileName = Path.Combine(this.ProjectFolder, docFile);
            }

            if (GetBoolAttr("DebugSymbols"))
            {
                options.IncludeDebugInformation = true;
            }

            if (GetProjectProperty("FileAlignment", false) != null)
            {
                try
                {
                    options.FileAlignment = Int32.Parse(GetProjectProperty("FileAlignment", false), CultureInfo.InvariantCulture);
                }
                catch (ArgumentNullException e)
                {
                    Trace.WriteLine("Exception : " + e.Message);
                }
                catch (ArgumentException e)
                {
                    Trace.WriteLine("Exception : " + e.Message);
                }
                catch (FormatException e)
                {
                    Trace.WriteLine("Exception : " + e.Message);
                }
                catch (OverflowException e)
                {
                    Trace.WriteLine("Exception : " + e.Message);
                }
            }

            if (GetBoolAttr("IncrementalBuild"))
            {
                options.IncrementalCompile = true;
            }

            if (GetBoolAttr("Optimize"))
            {
                options.Optimize = true;
            }

            if (GetBoolAttr("RegisterForComInterop"))
            {
            }

            if (GetBoolAttr("RemoveIntegerChecks"))
            {
            }

            if (GetBoolAttr("TreatWarningsAsErrors"))
            {
                options.TreatWarningsAsErrors = true;
            }

            if (GetProjectProperty("WarningLevel", false) != null)
            {
                try
                {
                    options.WarningLevel = Int32.Parse(GetProjectProperty("WarningLevel", false), CultureInfo.InvariantCulture);
                }
                catch (ArgumentNullException e)
                {
                    Trace.WriteLine("Exception : " + e.Message);
                }
                catch (ArgumentException e)
                {
                    Trace.WriteLine("Exception : " + e.Message);
                }
                catch (FormatException e)
                {
                    Trace.WriteLine("Exception : " + e.Message);
                }
                catch (OverflowException e)
                {
                    Trace.WriteLine("Exception : " + e.Message);
                }
            }

            return options;
        }
Beispiel #3
0
        /// <summary>
        /// Set configuration properties for a specific configuration
        /// </summary>
        /// <param name="config">configuration name</param>
        protected virtual void SetBuildConfigurationProperties(string config)
        {
            ProjectOptions options = null;

            if (!String.IsNullOrEmpty(config))
            {
                options = this.GetProjectOptions(config);
            }

            if (options != null && this.buildProject != null)
            {
                // Make sure the project configuration is set properly
                this.SetConfiguration(config);
            }
        }
Beispiel #4
0
 public virtual void UpdateRuntimeAssemblyLocations(ProjectOptions options){
 }
Beispiel #5
0
    /// <include file='doc\Project.uex' path='docs/doc[@for="Project.GetProjectOptions"]/*' />
    public virtual ProjectOptions GetProjectOptions(XmlElement config){
      if (this.options != null && this.lastConfig == config) return this.options;

      ProjectOptions options = this.options = this.CreateProjectOptions();
      this.lastConfig = config;

      if (config == null) return options;

      options.GenerateExecutable = true;

      string outputPath = this.GetOutputPath(config);
      // absolutize relative to project folder location
      outputPath = Path.Combine(this.ProjectFolder, outputPath);
      EnsureOutputPath(outputPath);
      // transfer configuration independent settings.
      XmlElement settings = (XmlElement)config.ParentNode;

      if (settings.Name == "Settings"){
        options.RootNamespace = settings.GetAttribute("RootNamespace");
        options.OutputAssembly = outputPath + this.GetAssemblyName(config);

        string outputtype = settings.GetAttribute("OutputType").ToLower();

        if (outputtype == "library"){
          options.ModuleKind = ModuleKindFlags.DynamicallyLinkedLibrary;
          options.GenerateExecutable = false; // DLL's have no entry point.
        } else if (outputtype == "winexe")
          options.ModuleKind = ModuleKindFlags.WindowsApplication;
        else
          options.ModuleKind = ModuleKindFlags.ConsoleApplication;

        options.Win32Icon = settings.GetAttribute("ApplicationIcon");
        options.MainClass = settings.GetAttribute("StartupObject");

        options.ShadowedAssembly = settings.GetAttribute("ShadowedAssembly");
        if (options.ShadowedAssembly != null && options.ShadowedAssembly.Length > 0) {
          options.ShadowedAssembly = Environment.ExpandEnvironmentVariables(options.ShadowedAssembly);
          options.ShadowedAssembly = Path.Combine(this.ProjectFolder, options.ShadowedAssembly);
        }

        options.StandardLibraryLocation = settings.GetAttribute("StandardLibraryLocation");
        if (options.StandardLibraryLocation != null && options.StandardLibraryLocation.Length > 0)
          options.StandardLibraryLocation = Path.Combine(this.ProjectFolder, options.StandardLibraryLocation);        

        string targetPlatform = settings.GetAttribute("TargetPlatform");

        if (targetPlatform != null && targetPlatform.Length > 0){
          try{ options.TargetPlatform = (PlatformType)Enum.Parse(typeof(PlatformType), targetPlatform); } catch{ }
          options.TargetPlatformLocation = settings.GetAttribute("TargetPlatformLocation");
          if (options.TargetPlatformLocation != null && options.TargetPlatformLocation.Length > 0)
            options.TargetPlatformLocation = Path.Combine(this.ProjectFolder, options.TargetPlatformLocation);
          this.SetTargetPlatform(options);
        }

        /*
         * other settings from CSharp we may want to adopt at some point...
        AssemblyKeyContainerName = ""  //This is the key file used to sign the interop assembly generated when importing a com object via add reference
        AssemblyOriginatorKeyFile = ""
        DelaySign = "false"
        DefaultClientScript = "JScript"
        DefaultHTMLPageLayout = "Grid"
        DefaultTargetSchema = "IE50"
        PreBuildEvent = ""
        PostBuildEvent = ""
        RunPostBuildEvent = "OnBuildSuccess"
        */
      } else{
        options.OutputAssembly = outputPath + this.Caption + ".exe";
        options.ModuleKind = ModuleKindFlags.ConsoleApplication;
      }
      // transfer all config build options...
      if (GetBoolAttr(config, "AllowUnsafeBlocks")){
        options.AllowUnsafeCode = true;
      }

      if (config.GetAttribute("BaseAddress") != null){
        try{ options.BaseAddress = Int64.Parse(config.GetAttribute("BaseAddress")); } catch{ }
      }

      if (GetBoolAttr(config, "CheckForOverflowUnderflow")){
        options.CheckedArithmetic = true;
      }

      if (config.GetAttribute("DefineConstants") != null){
        options.DefinedPreProcessorSymbols = new StringCollection();
        foreach (string s in config.GetAttribute("DefineConstants").Replace(" \t\r\n", "").Split(';')){
          options.DefinedPreProcessorSymbols.Add(s);
        }
      }

      if (config.GetAttribute("DocumentationFile") != null && config.GetAttribute("DocumentationFile") != ""){
        options.XMLDocFileName = Path.Combine(this.ProjectFolder, config.GetAttribute("DocumentationFile"));
      }

      if (GetBoolAttr(config, "DebugSymbols")){
        options.IncludeDebugInformation = true;
      }

      if (config.GetAttribute("FileAlignment") != null){
        try{ options.FileAlignment = Int32.Parse(config.GetAttribute("FileAlignment")); } catch{ }
      }

      if (GetBoolAttr(config, "IncrementalBuild")){
        options.IncrementalCompile = true;
      }
      
      if (GetBoolAttr(config, "Optimize")){
        options.Optimize = true;
      }

      if (GetBoolAttr(config, "RegisterForComInterop")){
      }

      if (GetBoolAttr(config, "RemoveIntegerChecks")){
        options.CheckedArithmetic = false;
      }

      if (GetBoolAttr(config, "TreatWarningsAsErrors")){
        options.TreatWarningsAsErrors = true;
      }

      if (config.GetAttribute("WarningLevel") != null){
        try{ options.WarningLevel = Int32.Parse(config.GetAttribute("WarningLevel")); } catch{ }
      }

      if (GetBoolAttr(config, "DisableAssumeChecks"))
        options.DisableAssumeChecks = true;
      if (GetBoolAttr(config, "DisableDefensiveChecks"))
        options.DisableDefensiveChecks = true;
      if (GetBoolAttr(config, "DisableGuardedClassesChecks"))
        options.DisableGuardedClassesChecks = true;
      if (GetBoolAttr(config, "DisableInternalChecks"))
        options.DisableInternalChecks = true;
      if (GetBoolAttr(config, "DisableInternalContractsMetadata"))
        options.DisableInternalContractsMetadata = true;
      if (GetBoolAttr(config, "DisablePublicContractsMetadata"))
        options.DisablePublicContractsMetadata = true;
      // Add the References
      XmlDocument doc = config.OwnerDocument;

      foreach (XmlElement e in doc.SelectNodes("//Reference")){
        string projectGuid = e.GetAttribute("Project");
        if (projectGuid != null && projectGuid.Length > 0){
          if (projectGuid[0] == '{') projectGuid = projectGuid.Trim('{','}');
          string file = this.GetOutputPathFromReferencedProject(projectGuid);
          if (file != null && !options.ReferencedAssemblies.Contains(file)){
            string localPath = Path.Combine(outputPath, Path.GetFileName(file));
            if (File.Exists(file)){
              try{
                File.Copy(file, localPath, true);
                if (options.IncludeDebugInformation){
                  string pdb = Path.ChangeExtension(file, "pdb");
                  if (File.Exists(pdb))
                    File.Copy(pdb, Path.ChangeExtension(localPath, "pdb"), true);
                }
              }catch{
                //TODOO: log the error
              }
            }
            options.ReferencedAssemblies.Add(file);
          }else
            this.options = null;
          continue;
        }else{
          string file = e.GetAttribute("AssemblyName") + ".dll";
          string hint = e.GetAttribute("HintPath");

          if (hint != null && hint != ""){// probably relative to the current file...
            hint = hint.Replace(Path.DirectorySeparatorChar, '/');
            hint = hint.Replace("#", "%23");
            string s = doc.BaseURI;
            s = s.Replace("#", "%23");
#if WHIDBEY
            Uri baseUri = new Uri(s);
            Uri uri = new Uri(baseUri, hint);
#else
            Uri baseUri = new Uri(s, true);
            Uri uri = new Uri(baseUri, hint, true);
#endif
            if (File.Exists(uri.LocalPath)){
              file = uri.LocalPath;
            }
          }

          if (!options.ReferencedAssemblies.Contains(file))
            options.ReferencedAssemblies.Add(file);
        }
      }
      if (GetBoolAttr(settings, "NoStandardLibraries"))
        options.NoStandardLibrary = true;
      if (options.NoStandardLibrary || (options.StandardLibraryLocation != null && options.StandardLibraryLocation.Length > 0))
        this.UpdateRuntimeAssemblyLocations(options);

      //Deal with Embedded Resources
      foreach (XmlElement e in doc.SelectNodes("//Files/Include/File")){
        if (e == null) continue;
        string buildAction = e.GetAttribute("BuildAction");
        if (string.Compare(buildAction, "EmbeddedResource", true, System.Globalization.CultureInfo.InvariantCulture) == 0){
          string relpath = e.GetAttribute("RelPath");
          string ext = Path.GetExtension(relpath);
          if (string.Compare(ext, ".resx", true, System.Globalization.CultureInfo.InvariantCulture) == 0 ||
            string.Compare(ext, ".txt", true, System.Globalization.CultureInfo.InvariantCulture) == 0){
            relpath = outputPath + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(relpath)+".resources";
          }
          options.EmbeddedResources.Add(relpath);
        }
      }
      return options;
    }
 public override void SetTargetPlatform(ProjectOptions options){
   if (this.LastModifiedTime == this.lastModifiedTimeOfPlatform) return;
   //TODO: what about referenced projects with different target platforms? This should probably be a mistake and should generate an error.
   this.lastModifiedTimeOfPlatform = this.LastModifiedTime;
   //TODO: handle errors caused by bad path names and/or missing platform assemblies
   switch (options.TargetPlatform){
     case PlatformType.v1: Microsoft.SpecSharp.TargetPlatform.SetToV1(options.TargetPlatformLocation); break;
     case PlatformType.v11: Microsoft.SpecSharp.TargetPlatform.SetToV1_1(options.TargetPlatformLocation); break;
     case PlatformType.v2: Microsoft.SpecSharp.TargetPlatform.SetToV2(options.TargetPlatformLocation); break;
     case PlatformType.cli1: Microsoft.SpecSharp.TargetPlatform.SetToPostV1_1(options.TargetPlatformLocation); break;
   }
 }
Beispiel #7
0
 /// <include file='doc\Project.uex' path='docs/doc[@for="Project.SetTargetPlatform"]/*' />
 public virtual void SetTargetPlatform(ProjectOptions options)
 {
 }
Beispiel #8
0
        /// <include file='doc\Project.uex' path='docs/doc[@for="Project.GetFullyQualifiedNameForReferencedLibrary"]/*' />
        public virtual string GetFullyQualifiedNameForReferencedLibrary(ProjectOptions options, string rLibraryName)
        {
            if (File.Exists(rLibraryName)) return rLibraryName;

            string rtfName = Path.Combine(GetSystemAssemblyPath(), rLibraryName);

            if (File.Exists(rtfName)) return rtfName;

            StringCollection searchPaths = null;

            if (options != null && (searchPaths = options.AdditionalSearchPaths) != null)
            {
                for (int i = 0, n = searchPaths.Count; i < n; i++)
                {
                    string path = searchPaths[i];
                    string fname = path + Path.DirectorySeparatorChar + rLibraryName;
                    if (File.Exists(fname)) return fname;
                }
            }

            return null;
        }
Beispiel #9
0
 /// <include file='doc\Project.uex' path='docs/doc[@for="Project.SetProjectFileDirty"]/*' />
 public void SetProjectFileDirty(bool value){
   this.options = null;
   if (this.dirty = value){
     this.LastModifiedTime = DateTime.Now;
   }
 }
Beispiel #10
0
 public override string GetFullyQualifiedNameForReferencedLibrary(Microsoft.VisualStudio.Package.ProjectOptions options, string rLibraryName)
 {
     return(this.compiler.GetFullyQualifiedNameForReferencedLibrary(
                new Microsoft.VisualStudio.IntegrationHelper.CompilerOptions(options), rLibraryName));
 }
Beispiel #11
0
 public virtual Project GetCompilerProject(XmlElement config, Cci.ErrorNodeList errors)
 {
     if (config == null)
     {
         return(null);
     }
     lock (ProjectManager.BuildLock){
         Project project = this.scProject;
         if (project == null)
         {
             Debug.Assert(false); return(null);
         }
         bool refresh = this.LastModifiedTime != project.LastModifiedTime || this.lastConfig != config;
         if (!refresh)
         {
             Debug.Assert(project.CompilerParameters != null);
             this.RefreshPerBuildCompilerParameters();
             return(project);
         }
         Cci.Compilation compilation = project.Compilation = this.compiler.CreateCompilation(null, null, null, null);
         this.compiler.CurrentCompilation = compilation;
         project.LastModifiedTime         = this.LastModifiedTime;
         Microsoft.VisualStudio.Package.ProjectOptions vscOptions = this.GetProjectOptions(config);
         Cci.CompilerOptions options = this.GetCompilerOptions(vscOptions);
         if (options == null)
         {
             Debug.Assert(false); return(null);
         }
         project.CompilerParameters = options;
         string         dir       = this.ProjectFolder;
         XmlDocument    doc       = this.projFile;
         Cci.StringList fileNames = new Cci.StringList();
         Cci.CompilationUnitSnippetList cuSnippets = new Cci.CompilationUnitSnippetList();
         Cci.CompilationUnitList        cUnits     = new Cci.CompilationUnitList();
         foreach (XmlElement e in doc.SelectNodes("//Files/Include/File"))
         {
             if (e == null)
             {
                 continue;
             }
             string relpath = e.GetAttribute("RelPath");
             string file    = Path.Combine(dir, relpath);
             Cci.CompilationUnitSnippet snippet = null;
             int key = Cci.Identifier.For(file).UniqueIdKey;
             if (!File.Exists(file))
             {
                 errors.Add(this.compiler.CreateErrorNode(Cci.Error.NoSuchFile, file));
                 continue;
             }
             snippet = this.GetCompilationUnitSnippetFor(file, e.GetAttribute("BuildAction"));
             if (snippet == null)
             {
                 continue;
             }
             fileNames.Add(file);
             cuSnippets.Add(snippet);
             cUnits.Add(snippet);
             snippet.Compilation = compilation;
         }
         project.CompilationUnitSnippets    = cuSnippets;
         project.FullPathsToSources         = fileNames;
         compilation.CompilationUnits       = cUnits;
         compilation.CompilerParameters     = options;
         compilation.ReferencedCompilations = this.GetReferencedCompilations(config, errors);
         this.compiler.ConstructSymbolTable(compilation, errors);
         this.compiler.CurrentCompilation = null;
         return(project);
     }
 }
Beispiel #12
0
 public virtual Cci.CompilerOptions GetCompilerOptions(Microsoft.VisualStudio.Package.ProjectOptions projectOptions)
 {
     return(new CompilerOptions(projectOptions));
 }
Beispiel #13
0
 public CompilerOptions(Microsoft.VisualStudio.Package.ProjectOptions compilerOptions)
 {
     this.AdditionalSearchPaths = new Cci.StringList(compilerOptions.AdditionalSearchPaths);
     this.AllowUnsafeCode       = compilerOptions.AllowUnsafeCode;
     this.BaseAddress           = compilerOptions.BaseAddress;
     this.BugReportFileName     = compilerOptions.BugReportFileName;
     this.CheckedArithmetic     = compilerOptions.CheckedArithmetic;
     this.CodePage                         = compilerOptions.CodePage;
     this.CompileAndExecute                = compilerOptions.CompileAndExecute;
     this.DefinedPreProcessorSymbols       = new Cci.StringList(compilerOptions.DefinedPreProcessorSymbols);
     this.DisplayCommandLineHelp           = compilerOptions.DisplayCommandLineHelp;
     this.DisableAssumeChecks              = compilerOptions.DisableAssumeChecks;
     this.DisableDefensiveChecks           = compilerOptions.DisableDefensiveChecks;
     this.DisableGuardedClassesChecks      = compilerOptions.DisableGuardedClassesChecks;
     this.DisableInternalChecks            = compilerOptions.DisableInternalChecks;
     this.DisableInternalContractsMetadata = compilerOptions.DisableInternalContractsMetadata;
     this.DisablePublicContractsMetadata   = compilerOptions.DisablePublicContractsMetadata;
     foreach (string eresource in compilerOptions.EmbeddedResources)
     {
         this.EmbeddedResources.Add(eresource);
     }
     this.EmitManifest                 = compilerOptions.EmitManifest;
     this.EncodeOutputInUTF8           = compilerOptions.EncodeOutputInUTF8;
     this.Evidence                     = compilerOptions.Evidence;
     this.FileAlignment                = compilerOptions.FileAlignment;
     this.GenerateExecutable           = compilerOptions.GenerateExecutable;
     this.GenerateInMemory             = compilerOptions.GenerateInMemory;
     this.HeuristicReferenceResolution = compilerOptions.HeuristicReferenceResolution;
     this.IncludeDebugInformation      = compilerOptions.IncludeDebugInformation;
     this.IncrementalCompile           = compilerOptions.IncrementalCompile;
     this.IsContractAssembly           = compilerOptions.ShadowedAssembly != null && compilerOptions.ShadowedAssembly.Length > 0;
     foreach (string lresource in compilerOptions.LinkedResources)
     {
         this.LinkedResources.Add(lresource);
     }
     this.MainClass         = compilerOptions.MainClass;
     this.ModuleKind        = (Cci.ModuleKindFlags)compilerOptions.ModuleKind;
     this.NoStandardLibrary = compilerOptions.NoStandardLibrary;
     this.Optimize          = compilerOptions.Optimize;
     this.OutputAssembly    = Path.GetFileNameWithoutExtension(compilerOptions.OutputAssembly);
     this.OutputPath        = Path.GetDirectoryName(compilerOptions.OutputAssembly); //TODO: look at project code
     this.PDBOnly           = compilerOptions.PDBOnly;
     this.RecursiveWildcard = compilerOptions.RecursiveWildcard;
     foreach (string refAssem in compilerOptions.ReferencedAssemblies)
     {
         this.ReferencedAssemblies.Add(refAssem);
     }
     this.ReferencedModules       = new Cci.StringList(compilerOptions.ReferencedModules);
     this.RootNamespace           = compilerOptions.RootNamespace;
     this.ShadowedAssembly        = compilerOptions.ShadowedAssembly;
     this.StandardLibraryLocation = compilerOptions.StandardLibraryLocation;
     this.SuppressedWarnings      = new Cci.Int32List(compilerOptions.SuppressedWarnings);
     this.SuppressLogo            = compilerOptions.SuppressLogo;
     this.TargetPlatform          = (Cci.PlatformType)compilerOptions.TargetPlatform;
     this.TargetPlatformLocation  = compilerOptions.TargetPlatformLocation;
     this.TempFiles             = compilerOptions.TempFiles;
     this.TreatWarningsAsErrors = compilerOptions.TreatWarningsAsErrors;
     this.UserLocaleId          = compilerOptions.UserLocaleId;
     this.UserToken             = compilerOptions.UserToken;
     this.WarningLevel          = compilerOptions.WarningLevel;
     this.Win32Icon             = compilerOptions.Win32Icon;
     this.Win32Resource         = compilerOptions.Win32Resource;
     this.XMLDocFileName        = compilerOptions.XMLDocFileName;
 }
    public override void UpdateRuntimeAssemblyLocations(ProjectOptions options){
      this.compiler.UpdateRuntimeAssemblyLocations(this.GetCompilerOptions(options));
      //TODO: if the runtime assemblies have already been loaded, they need to get re-initialized.
      //However, this means that all projects must be marked dirty
//      Cci.SystemTypes.Initialize(true, false);
//      Cci.Runtime.Initialize();
//      Runtime.Initialize();
    }
        /// <summary>
        /// Set configuration properties for a specific configuration
        /// </summary>
        /// <param name="config">configuration name</param>
        /// <param name="platformName">platform name</param>
        protected virtual void SetBuildConfigurationProperties(ConfigCanonicalName config)
        {
            ProjectOptions options = null;

            options = this.GetProjectOptions(config);


            if (options != null && this.buildProject != null)
            {
                // Make sure the project configuration is set properly
                this.SetConfiguration(config);
            }
        }
Beispiel #16
0
 /// <include file='doc\Project.uex' path='docs/doc[@for="Project.SetProjectFileDirty"]/*' />
 public void SetProjectFileDirty(bool value)
 {
     this.options = null;
     if (this.dirty = value)
     {
         this.LastModifiedTime = DateTime.Now;
         this.buildIsPrepared = false;
     }
 }
Beispiel #17
0
 /// <include file='doc\Project.uex' path='docs/doc[@for="Project.GetFullyQualifiedNameForReferencedLibrary"]/*' />
 public abstract string GetFullyQualifiedNameForReferencedLibrary(ProjectOptions options, string rLibraryName);
Beispiel #18
0
        /// <include file='doc\Project.uex' path='docs/doc[@for="Project.GetProjectOptions"]/*' />
        public virtual ProjectOptions GetProjectOptions(string config)
        {
            if (this.options != null)
                return this.options;

            ProjectOptions options = this.options = CreateProjectOptions();

            if (config == null)
                return options;

            options.GenerateExecutable = true;

            // Set the active configuration
            this.projFile.GlobalProperties.SetProperty("Configuration", config);
            this.currentConfig = this.projFile.EvaluatedProperties;

            string outputPath = this.GetOutputPath(this.currentConfig);
            // absolutize relative to project folder location
            outputPath = Path.Combine(this.ProjectFolder, outputPath);

            // Set some default values
            options.OutputAssembly = outputPath + this.Caption + ".exe";
            options.ModuleKind = ModuleKindFlags.ConsoleApplication;

            options.RootNamespace = GetProjectProperty("RootNamespace", false);
            options.OutputAssembly = outputPath + this.GetAssemblyName(config);

            string outputtype = GetProjectProperty("OutputType", false).ToLower();

            if (outputtype == "library")
            {
                options.ModuleKind = ModuleKindFlags.DynamicallyLinkedLibrary;
                options.GenerateExecutable = false; // DLL's have no entry point.
            }
            else if (outputtype == "winexe")
                options.ModuleKind = ModuleKindFlags.WindowsApplication;
            else
                options.ModuleKind = ModuleKindFlags.ConsoleApplication;

            options.Win32Icon = GetProjectProperty("ApplicationIcon", false);
            options.MainClass = GetProjectProperty("StartupObject", false);

            string targetPlatform = GetProjectProperty("TargetPlatform", false);

            if (targetPlatform != null && targetPlatform.Length > 0)
            {
                try { options.TargetPlatform = (PlatformType)Enum.Parse(typeof(PlatformType), targetPlatform); } catch { }
                options.TargetPlatformLocation = GetProjectProperty("TargetPlatformLocation", false);
                this.SetTargetPlatform(options);
            }
                /*
         * other settings from CSharp we may want to adopt at some point...
        AssemblyKeyContainerName = ""  //This is the key file used to sign the interop assembly generated when importing a com object via add reference
        AssemblyOriginatorKeyFile = ""
        DelaySign = "false"
        DefaultClientScript = "JScript"
        DefaultHTMLPageLayout = "Grid"
        DefaultTargetSchema = "IE50"
        PreBuildEvent = ""
        PostBuildEvent = ""
        RunPostBuildEvent = "OnBuildSuccess"
        */

            // transfer all config build options...
            if (GetBoolAttr(this.currentConfig, "AllowUnsafeBlocks"))
            {
                options.AllowUnsafeCode = true;
            }

            if (GetProjectProperty("BaseAddress", false) != null)
            {
                try { options.BaseAddress = Int64.Parse(GetProjectProperty("BaseAddress", false)); } catch { }
            }

            if (GetBoolAttr(this.currentConfig, "CheckForOverflowUnderflow"))
            {
                options.CheckedArithmetic = true;
            }

            if (GetProjectProperty("DefineConstants", false) != null)
            {
                options.DefinedPreProcessorSymbols = new StringCollection();
                foreach (string s in GetProjectProperty("DefineConstants", false).Replace(" \t\r\n", "").Split(';'))
                {
                    options.DefinedPreProcessorSymbols.Add(s);
                }
            }

            string docFile = GetProjectProperty("DocumentationFile", false);
            if (docFile != null && docFile != "")
            {
                options.XMLDocFileName = Path.Combine(this.ProjectFolder, docFile);
            }

            if (GetBoolAttr(this.currentConfig, "DebugSymbols"))
            {
                options.IncludeDebugInformation = true;
            }

            if (GetProjectProperty("FileAlignment", false) != null)
            {
                try { options.FileAlignment = Int32.Parse(GetProjectProperty("FileAlignment", false)); } catch { }
            }

            if (GetBoolAttr(this.currentConfig, "IncrementalBuild"))
            {
                options.IncrementalCompile = true;
            }

            if (GetBoolAttr(this.currentConfig, "Optimize"))
            {
                options.Optimize = true;
            }

            if (GetBoolAttr(this.currentConfig, "RegisterForComInterop"))
            {
            }

            if (GetBoolAttr(this.currentConfig, "RemoveIntegerChecks"))
            {
            }

            if (GetBoolAttr(this.currentConfig, "TreatWarningsAsErrors"))
            {
                options.TreatWarningsAsErrors = true;
            }

            if (GetProjectProperty("WarningLevel", false) != null)
            {
                try { options.WarningLevel = Int32.Parse(GetProjectProperty("WarningLevel", false)); } catch { }
            }

            foreach (MSBuild.Item reference in this.projFile.GetEvaluatedItemsByType("Reference"))
            {
                string file = reference.GetAttribute("AssemblyName") + ".dll";
                string hint = reference.GetAttribute("HintPath");

                if (hint != null && hint != "")
                {
                    // probably relative to the current file...
                    hint = hint.Replace(Path.DirectorySeparatorChar, '/');
                    Url url = new Url(this.BaseURI, hint);
                    string path = url.AbsoluteUrl;
                    file = path;
                }

                if (!options.ReferencedAssemblies.Contains(file))
                    options.ReferencedAssemblies.Add(file);
            }

            return options;
        }
Beispiel #19
0
 public abstract CompilerResults CompileAssemblyFromFile(ProjectOptions options, string filename);
Beispiel #20
0
 public abstract CompilerResults CompileAssemblyFromFileBatch(ProjectOptions options, string[] fileNames);
 public override string GetFullyQualifiedNameForReferencedLibrary(ProjectOptions options, string rLibraryName){
   return this.compiler.GetFullyQualifiedNameForReferencedLibrary(
     new Microsoft.VisualStudio.IntegrationHelper.CompilerOptions(options), rLibraryName);
 }