Example #1
0
        public (bool success, string output) RunWithConfig(Config.ConfigFile config, string appType = "true", [CallerMemberName] string configName = "", bool failTestOnError = true)
        {
            config.Id = configName;

            var xUnitLogger = new XUnitLogger(outputHelper, failTestOnError);
            var logger      = new Logger(xUnitLogger, null);

            var vcInstallDir = Environment.ExpandEnvironmentVariables("VCINSTALLDIR");

            if (!Directory.Exists(vcInstallDir))
            {
                vcInstallDir = @"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\";
            }

            var msvcToolsetVer = File.ReadAllText(vcInstallDir + Path.Combine(@"\Auxiliary\Build", "Microsoft.VCToolsVersion.default.txt")).Trim();

            var codeGenApp = new CodeGenApp(logger)
            {
                GlobalNamespace       = new GlobalNamespaceProvider("SharpGen.Runtime"),
                CastXmlExecutablePath = "../../../../CastXML/bin/castxml.exe",
                VcToolsPath           = Path.Combine(vcInstallDir, $@"Tools\MSVC\{msvcToolsetVer}\"),
                AppType                = appType,
                Config                 = config,
                OutputDirectory        = testDirectory.FullName,
                IntermediateOutputPath = testDirectory.FullName
            };

            codeGenApp.Init();
            codeGenApp.Run();
            return(xUnitLogger.Success, xUnitLogger.ExitReason);
        }
Example #2
0
        private void RunCodeGen(ConfigFile config, string appType)
        {
            var codeGenApp = new CodeGenApp(new global::SharpGen.Logging.Logger(new MsBuildSharpGenLogger(Log), null))
            {
                CastXmlExecutablePath = CastXmlPath,
                AppType                     = appType,
                Config                      = config,
                GlobalNamespace             = new GlobalNamespaceProvider(GlobalNamespace),
                IsGeneratingDoc             = GenerateDocs,
                VcToolsPath                 = VcToolsPath,
                IntermediateOutputPath      = IntermediateOutputPath,
                OutputDirectory             = OutputDirectory,
                IncludeAssemblyNameFolder   = IncludeAssemblyNameFolder,
                GeneratedCodeFolder         = GeneratedCodeFolder,
                ConsumerBindMappingConfigId = ConsumerBindMappingConfigId
            };

            if (!codeGenApp.Init())
            {
            }
            codeGenApp.Run();
        }