示例#1
0
 public override bool VisitMethodDecl(Method method)
 {
     if (method.Namespace is ClassTemplateSpecialization)
     {
         var exporting = string.Empty;
         if (Context.ParserOptions.IsMicrosoftAbi)
         {
             exporting = "__declspec(dllexport) ";
         }
         else if (TargetTriple.IsMacOS(Context.ParserOptions.TargetTriple))
         {
             exporting = "__attribute__((visibility(\"default\"))) ";
         }
         WriteLine($"template {exporting}{method.Visit(cppTypePrinter)};");
         return(true);
     }
     if (method.IsConstructor)
     {
         WrapConstructor(method);
         return(true);
     }
     if (method.IsDestructor)
     {
         WrapDestructor(method);
         return(true);
     }
     return(this.VisitFunctionDecl(method));
 }
        public TargetTriple GetTargetTriple()
        {
            TargetTriple confTriple = TryGetTripleFromConfiguration();

            if (confTriple != null)
            {
                return(confTriple);
            }
            return(TryGetTripleFromRustc());
        }
        TargetTriple TryGetTripleFromRustc()
        {
            string defaultInstallPath = Shared.Environment.FindInstallPath("default");

            if (defaultInstallPath == null)
            {
                return(null);
            }
            string rustcPath = Path.Combine(defaultInstallPath, "rustc.exe");
            string rustcHost = GetRustcHost(rustcPath);

            return(TargetTriple.Create(rustcHost));
        }
示例#4
0
        private string GetExporting()
        {
            var exporting = string.Empty;

            if (Context.ParserOptions.IsMicrosoftAbi)
            {
                exporting = "__declspec(dllexport) ";
            }
            else if (TargetTriple.IsMacOS(Context.ParserOptions.TargetTriple))
            {
                exporting = "__attribute__((visibility(\"default\"))) ";
            }
            return(exporting);
        }
示例#5
0
 // We need to run the right gdb depending on the architecture of the debuggee
 private string GetArchitectureName(TargetTriple triple)
 {
     if (triple != null)
     {
         if (triple.Arch == "i686" || triple.Arch == "x86_64")
         {
             return(triple.Arch);
         }
     }
     if (System.Environment.Is64BitOperatingSystem)
     {
         return("x86_64");
     }
     return("i686");
 }
示例#6
0
        private IRustProjectLauncher ChooseLauncher(bool debug)
        {
            if (!debug)
            {
                return(new ReleaseLauncher(environment));
            }
            TargetTriple triple = environment.GetTargetTriple();

            if (triple != null && triple.Abi == "msvc")
            {
                return(new MsvcDebugLauncher(environment));
            }
            else
            {
                return(new GnuDebugLauncher(environment, triple));
            }
        }
示例#7
0
 // We need to run the right gdb depending on the architecture of the debuggee
 private string GetMingwName(TargetTriple triple)
 {
     if (triple != null)
     {
         if (triple.Arch == "i686")
         {
             return("mingw32");
         }
         if (triple.Arch == "x86_64")
         {
             return("mingw64");
         }
     }
     if (System.Environment.Is64BitOperatingSystem)
     {
         return("mingw64");
     }
     return("mingw32");
 }
示例#8
0
        string GetGdbPath(EnvDTE.DTE dte, TargetTriple triple)
        {
            string gdbPath = null;
            //bool useCustomPath = false;
            //bool.TryParse(GetDebuggingConfigProperty<bool>(dte, ""));
            bool useCustomPath = GetDebuggingConfigProperty <bool>(dte, nameof(DebuggingOptionsPage.UseCustomGdb));

            if (useCustomPath)
            {
                gdbPath = GetDebuggingConfigProperty <string>(dte, nameof(DebuggingOptionsPage.CustomGdbPath));
            }

            if (gdbPath != null)
            {
                return(gdbPath);
            }

            return(Path.Combine(
                       Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                       GetMingwName(triple),
                       @"bin\gdb"));
        }
        public Task <DebugLaunchSettings> GetLaunchSettingsAsync(string executable, string arguments, string workingDirectory,
                                                                 DebugLaunchOptions options, Cargo cargo, TargetTriple triple)
        {
            var target = new DebugLaunchSettings(options)
            {
                LaunchOperation       = DebugLaunchOperation.CreateProcess,
                LaunchDebugEngineGuid = DebuggerEngines.NativeOnlyEngine,
                Executable            = executable,
                Arguments             = arguments,
                CurrentDirectory      = workingDirectory
            };

            return(Task.FromResult(target));
        }
示例#10
0
        private async Task <PipeLaunchOptions> BuildLaunchOptionsAsync(string path, string args, string workingDir,
                                                                       EnvDTE.DTE dte, Cargo cargo, TargetTriple triple)
        {
            // We could go through LocalLaunchOptions, but this way we can pass additional args
            PipeLaunchOptions options = new PipeLaunchOptions();

            options.PipePath      = GetGdbPath(dte, triple);
            options.PipeArguments = String.Format("-q -interpreter=mi {0}", GetDebuggingConfigProperty <string>(dte, nameof(DebuggingOptionsPage.GdbExtraArguments)));
            options.ExePath       = EscapePath(path);
            options.ExeArguments  = args;
            options.SetupCommands = GetSetupCommands();
            // this affects the number of bytes the engine reads when disassembling commands,
            // x64 has the largest maximum command size, so it should be safe to use for x86 as well
            options.TargetArchitecture = TargetArchitecture.x64;
            await SetWorkingDirectoryAsync(options, path, workingDir, cargo);

            return(options);
        }
示例#11
0
        public async Task <DebugLaunchSettings> GetLaunchSettingsAsync(string executable, string arguments, string workingDirectory,
                                                                       DebugLaunchOptions options, Cargo cargo, TargetTriple triple)
        {
            EnvDTE.DTE env    = (EnvDTE.DTE)VisualRustPackage.GetGlobalService(typeof(EnvDTE.DTE));
            var        target = new DebugLaunchSettings(options)
            {
                LaunchOperation       = DebugLaunchOperation.CreateProcess,
                LaunchDebugEngineGuid = MIDebugEngineGuid,
                Executable            = executable,
                Arguments             = arguments,
                CurrentDirectory      = workingDirectory,
                Options = ToXmlString(await BuildLaunchOptionsAsync(executable, arguments, workingDirectory, env, cargo, triple))
            };

            return(target);
        }
示例#12
0
        TargetTriple TryGetTripleFromConfiguration()
        {
            string triple = Configuration.Build.LoadFrom(new ProjectConfig[] { projectConfig }).PlatformTarget;

            return(TargetTriple.Create(triple));
        }
示例#13
0
 public GnuDebugLauncher(LauncherEnvironment env, TargetTriple triple)
 {
     this.env    = env;
     this.triple = triple;
 }