Example #1
0
 string GetSDKPath()
 {
     if (sdkPath == null)
     {
         sdkPath = ExecAndCollect.Run("/usr/bin/xcrun", "--show-sdk-path --sdk " + CompilerInfo.SDKPath, workingDirectory: string.Empty).Trim();
     }
     return(sdkPath);
 }
        // returns the path to the output XML file
        public static string PathToXmlFromModules(string executablePath, List <string> searchDirectories, List <string> modules,
                                                  string outfilePath)
        {
            var args = BuildArgs(searchDirectories, modules, outfilePath);

            ExecAndCollect.Run(executablePath, args);
            return(outfilePath);
        }
Example #3
0
        void Lipo(List <string> sourcePaths, string outputPath, string libraryName)
        {
            var sb = new StringBuilder();

            foreach (string s in sourcePaths)
            {
                sb.Append($" {Path.Combine (s, libraryName)}");
            }
            ExecAndCollect.Run("/usr/bin/lipo", $"-create {sb.ToString ()} -output {Path.Combine (outputPath, libraryName)}", verbose: verbose);
        }
Example #4
0
        public static string CompileToCSharp(DisposableTempDirectory provider, string outputDirectory = null, string moduleName = "Xython", string target = "x86_64-apple-macosx10.9", IEnumerable <string> additionalTypeDatabases = null, bool separateProcess = false, UnicodeMapper unicodeMapper = null, int expectedErrorCount = -1)
        {
            NewClassCompiler ncc = DefaultCSharpCompiler(unicodeMapper);

            List <string> typeDatabases = Compiler.kTypeDatabases;

            if (additionalTypeDatabases != null)
            {
                typeDatabases.AddRange(additionalTypeDatabases);
            }

            ClassCompilerLocations classCompilerLocations = new ClassCompilerLocations(new List <string> {
                provider.DirectoryPath, Compiler.kSwiftRuntimeGlueDirectory
            },
                                                                                       new List <string> {
                provider.DirectoryPath, Compiler.kSwiftRuntimeGlueDirectory
            },
                                                                                       typeDatabases);
            ClassCompilerNames compilerNames = new ClassCompilerNames(moduleName, null);

            if (separateProcess)
            {
                var args = new StringBuilder();
                args.Append($"--debug ");
                args.Append($"{Path.Combine (Path.GetDirectoryName (ncc.GetType ().Assembly.Location), "tom-swifty.exe")} ");
                args.Append($"--swift-bin-path={StringUtils.Quote (Compiler.CompilerLocation.SwiftCompilerBin)} ");
                args.Append($"--swift-lib-path={StringUtils.Quote (Path.GetDirectoryName (Compiler.CompilerLocation.SwiftCompilerLib))} ");
                args.Append($"--retain-xml-reflection ");
                foreach (var db in typeDatabases)
                {
                    args.Append($"--type-database-path={StringUtils.Quote (db)} ");
                }
                args.Append($"--retain-swift-wrappers ");
                args.Append($"--wrapping-module-name={StringUtils.Quote (moduleName)}Wrapping ");
                foreach (var l in classCompilerLocations.LibraryDirectories)
                {
                    args.Append($"-L {StringUtils.Quote (l)} ");
                }
                foreach (var m in classCompilerLocations.ModuleDirectories)
                {
                    args.Append($"-M {StringUtils.Quote (m)} ");
                }
                args.Append($"-o {StringUtils.Quote (outputDirectory ?? provider.DirectoryPath)} ");
                args.Append($"--module-name={StringUtils.Quote (moduleName)} ");
                return(ExecAndCollect.Run("mono", args.ToString()));
            }
            else
            {
                ErrorHandling errors = ncc.CompileToCSharp(classCompilerLocations, compilerNames, new List <string> {
                    target
                }, outputDirectory ?? provider.DirectoryPath);
                CheckErrors(errors, expectedErrorCount);
                return(null);
            }
        }
        void YouCantBtouchThis(string csOutputFileName, bool needsSwiftRuntimeLibrary)
        {
            var btoucher = BtouchPath();

            if (!File.Exists(btoucher))
            {
                errors.Add(new FileNotFoundException($"Unable to find bgen at {kBgenPath}"));
                return;
            }

            var args = new StringBuilder();

            BuildBtouchArgs(csOutputFileName, args, needsSwiftRuntimeLibrary);

            try {
                ExecAndCollect.Run(btoucher, args.ToString(), workingDirectory: outputDirectory, verbose: false);
            } catch (Exception e) {
                errors.Add(e);
            }
        }
Example #6
0
 string Launch(string executable, string args)
 {
     return(ExecAndCollect.Run(executable, args, workingDirectory: DirectoryPath, verbose: Verbose));
 }