Esempio n. 1
0
        public static void Create(List <BuildTask> tasks, Abi abi, Target target, string ifile)
        {
            var app   = target.App;
            var arch  = abi.AsArchString();
            var ofile = Path.Combine(app.Cache.Location, Path.GetFileNameWithoutExtension(ifile) + "." + arch + ".o");

            if (!Application.IsUptodate(ifile, ofile))
            {
                tasks.Add(new RegistrarTask()
                {
                    Target        = target,
                    Abi           = abi,
                    InputFile     = ifile,
                    OutputFile    = ofile,
                    SharedLibrary = false,
                    Language      = "objective-c++",
                });
            }
            else
            {
                Driver.Log(3, "Target '{0}' is up-to-date.", ofile);
            }

            target.LinkWith(ofile);
        }
Esempio n. 2
0
        public static void Create(List <BuildTask> tasks, Abi abi, Target target, string ifile)
        {
            var arch  = abi.AsArchString();
            var ext   = target.App.FastDev ? ".dylib" : ".o";
            var ofile = Path.Combine(target.App.Cache.Location, "lib" + Path.GetFileNameWithoutExtension(ifile) + "." + arch + ext);

            if (!Application.IsUptodate(ifile, ofile))
            {
                var task = new PinvokesTask()
                {
                    Target        = target,
                    Abi           = abi,
                    InputFile     = ifile,
                    OutputFile    = ofile,
                    SharedLibrary = target.App.FastDev,
                    Language      = "objective-c++",
                };
                if (target.App.FastDev)
                {
                    task.InstallName = "lib" + Path.GetFileNameWithoutExtension(ifile) + ext;
                    task.CompilerFlags.AddFramework("Foundation");
                    task.CompilerFlags.LinkWithXamarin();
                }
                tasks.Add(task);
            }
            else
            {
                Driver.Log(3, "Target '{0}' is up-to-date.", ofile);
            }

            target.LinkWith(ofile);
            target.LinkWithAndShip(ofile);
        }
Esempio n. 3
0
        public static void Create(List <BuildTask> tasks, Target target, Abi abi, IEnumerable <Assembly> assemblies, string assemblyName, IList <string> registration_methods)
        {
            var app   = target.App;
            var arch  = abi.AsArchString();
            var ofile = Path.Combine(app.Cache.Location, "main." + arch + ".o");
            var ifile = Path.Combine(app.Cache.Location, "main." + arch + ".m");

            var files = assemblies.Select(v => v.FullPath);

            if (!Application.IsUptodate(files, new string [] { ifile }))
            {
                Driver.GenerateMain(target.App, assemblies, assemblyName, abi, ifile, registration_methods);
            }
            else
            {
                Driver.Log(3, "Target '{0}' is up-to-date.", ifile);
            }

            if (!Application.IsUptodate(ifile, ofile))
            {
                var main = new MainTask()
                {
                    Target        = target,
                    Abi           = abi,
                    AssemblyName  = assemblyName,
                    InputFile     = ifile,
                    OutputFile    = ofile,
                    SharedLibrary = false,
                    Language      = "objective-c++",
                };
                main.CompilerFlags.AddDefine("MONOTOUCH");
                tasks.Add(main);
            }
            else
            {
                Driver.Log(3, "Target '{0}' is up-to-date.", ofile);
            }

            target.LinkWith(ofile);
        }
Esempio n. 4
0
        // The input file is either a .s or a .bc file
        BuildTask CreateCompileTask(string assembly_name, string infile_path, Abi abi)
        {
            var ext          = App.FastDev ? "dylib" : "o";
            var ofile        = Path.ChangeExtension(infile_path, ext);
            var install_name = string.Empty;

            if (App.FastDev)
            {
                if (dylibs == null)
                {
                    dylibs = new List <string> ();
                }
                dylibs.Add(ofile);
                install_name = "lib" + Path.GetFileName(assembly_name) + ".dylib";
            }
            else
            {
                Target.LinkWith(ofile);
            }

            if (Application.IsUptodate(new string [] { infile_path, Driver.CompilerPath }, new string [] { ofile }))
            {
                Driver.Log(3, "Target {0} is up-to-date.", ofile);
                return(null);
            }
            else
            {
                Application.TryDelete(ofile);                  // otherwise the next task might not detect that it will have to rebuild.
                Driver.Log(3, "Target {0} needs to be rebuilt.", ofile);
            }

            var compiler_flags = new CompilerFlags()
            {
                Target = Target
            };

            BuildTask bitcode_task = null;
            BuildTask link_task = null;
            string    link_task_input, link_language = "";

            if (App.EnableAsmOnlyBitCode)
            {
                link_task_input = infile_path + ".ll";
                link_language   = "";
                // linker_flags.Add (" -fembed-bitcode");

                bitcode_task = new BitCodeify()
                {
                    Input            = infile_path,
                    OutputFile       = link_task_input,
                    Platform         = App.Platform,
                    Abi              = abi,
                    DeploymentTarget = App.DeploymentTarget,
                };
            }
            else
            {
                link_task_input = infile_path;
                if (infile_path.EndsWith(".s"))
                {
                    link_language = "assembler";
                }
            }

            if (App.FastDev)
            {
                compiler_flags.AddFrameworks(Frameworks, WeakFrameworks);
                compiler_flags.AddLinkWith(LinkWith, ForceLoad);
                compiler_flags.LinkWithMono();
                compiler_flags.LinkWithXamarin();
                compiler_flags.AddOtherFlags(LinkerFlags);
                if (Target.GetEntryPoints().ContainsKey("UIApplicationMain"))
                {
                    compiler_flags.AddFramework("UIKit");
                }
            }

            link_task = new LinkTask()
            {
                Target        = Target,
                AssemblyName  = assembly_name,
                Abi           = abi,
                InputFile     = link_task_input,
                OutputFile    = ofile,
                InstallName   = install_name,
                CompilerFlags = compiler_flags,
                SharedLibrary = App.FastDev,
                Language      = link_language,
            };

            if (bitcode_task != null)
            {
                bitcode_task.NextTasks = new BuildTask[] { link_task };
                return(bitcode_task);
            }
            return(link_task);
        }
Esempio n. 5
0
        IEnumerable <BuildTask> CreateManagedToAssemblyTasks(string s, Abi abi, string build_dir)
        {
            var    arch = abi.AsArchString();
            var    asm_dir = Cache.Location;
            var    asm = Path.Combine(asm_dir, Path.GetFileName(s)) + "." + arch + ".s";
            var    llvm_asm = Path.Combine(asm_dir, Path.GetFileName(s)) + "." + arch + "-llvm.s";
            var    data = Path.Combine(asm_dir, Path.GetFileNameWithoutExtension(s)) + "." + arch + ".aotdata";
            string llvm_ofile, llvm_aot_ofile = "";
            var    is_llvm       = (abi & Abi.LLVM) == Abi.LLVM;
            bool   assemble_llvm = is_llvm && Driver.LLVMAsmWriter;

            if (!File.Exists(s))
            {
                throw new MonoTouchException(3004, true, "Could not AOT the assembly '{0}' because it doesn't exist.", s);
            }

            HashSet <string> dependencies = null;
            List <string>    deps         = null;
            List <string>    outputs      = new List <string> ();
            var warnings = new List <Exception> ();

            dependencies = ComputeDependencies(warnings);

            if (warnings.Count > 0)
            {
                ErrorHelper.Show(warnings);
                ErrorHelper.Warning(3006, "Could not compute a complete dependency map for the project. This will result in slower build times because Xamarin.iOS can't properly detect what needs to be rebuilt (and what does not need to be rebuilt). Please review previous warnings for more details.");
            }
            else
            {
                deps = new List <string> (dependencies.ToArray());
                deps.Add(s);
                deps.Add(Driver.GetAotCompiler(Target.Is64Build));
            }

            if (App.EnableLLVMOnlyBitCode)
            {
                //
                // In llvm-only mode, the AOT compiler emits a .bc file and no .s file for JITted code
                //
                llvm_ofile = Path.Combine(asm_dir, Path.GetFileName(s)) + "." + arch + ".bc";
                outputs.Add(llvm_ofile);
                llvm_aot_ofile = llvm_ofile;
            }
            else
            {
                llvm_ofile = Path.Combine(asm_dir, Path.GetFileName(s)) + "." + arch + "-llvm.o";
                outputs.Add(asm);

                if (is_llvm)
                {
                    if (assemble_llvm)
                    {
                        llvm_aot_ofile = llvm_asm;
                    }
                    else
                    {
                        llvm_aot_ofile = llvm_ofile;
                        Target.LinkWith(llvm_ofile);
                    }
                    outputs.Add(llvm_aot_ofile);
                }
            }

            if (deps != null && Application.IsUptodate(deps, outputs))
            {
                Driver.Log(3, "Target {0} is up-to-date.", asm);
                if (App.EnableLLVMOnlyBitCode)
                {
                    return(CreateCompileTasks(s, null, llvm_ofile, abi));
                }
                else
                {
                    return(CreateCompileTasks(s, asm, assemble_llvm ? llvm_asm : null, abi));
                }
            }
            else
            {
                Application.TryDelete(asm);                  // otherwise the next task might not detect that it will have to rebuild.
                Application.TryDelete(llvm_asm);
                Application.TryDelete(llvm_ofile);
                Driver.Log(3, "Target {0} needs to be rebuilt.", asm);
            }

            var aotCompiler = Driver.GetAotCompiler(Target.Is64Build);
            var aotArgs     = Driver.GetAotArguments(s, abi, build_dir, asm, llvm_aot_ofile, data);

            Driver.Log(3, "Aot compiler: {0} {1}", aotCompiler, aotArgs);

            AotDataFiles.Add(data);

            IEnumerable <BuildTask> nextTasks;

            if (App.EnableLLVMOnlyBitCode)
            {
                nextTasks = CreateCompileTasks(s, null, llvm_ofile, abi);
            }
            else
            {
                nextTasks = CreateCompileTasks(s, asm, assemble_llvm ? llvm_asm : null, abi);
            }

            return(new BuildTask [] { new AOTTask()
                                      {
                                          AssemblyName = s,
                                          ProcessStartInfo = Driver.CreateStartInfo(aotCompiler, aotArgs, Path.GetDirectoryName(s)),
                                          NextTasks = nextTasks
                                      } });
        }
Esempio n. 6
0
        public static void Create(List<BuildTask> tasks, Abi abi, Target target, string ifile)
        {
            var arch = abi.AsArchString ();
            var ofile = Path.Combine (Cache.Location, "registrar." + arch + ".o");

            if (!Application.IsUptodate (ifile, ofile)) {
                tasks.Add (new RegistrarTask ()
                {
                    Target = target,
                    Abi = abi,
                    InputFile = ifile,
                    OutputFile = ofile,
                    SharedLibrary = false,
                    Language = "objective-c++",
                });
            } else {
                Driver.Log (3, "Target '{0}' is up-to-date.", ofile);
            }

            target.LinkWith (ofile);
        }
Esempio n. 7
0
        public static void Create(List<BuildTask> tasks, Target target, Abi abi, IEnumerable<Assembly> assemblies, string assemblyName, IList<string> registration_methods)
        {
            var arch = abi.AsArchString ();
            var ofile = Path.Combine (Cache.Location, "main." + arch + ".o");
            var ifile = Path.Combine (Cache.Location, "main." + arch + ".m");

            var files = assemblies.Select (v => v.FullPath);

            if (!Application.IsUptodate (files, new string [] { ifile })) {
                Driver.GenerateMain (assemblies, assemblyName, abi, ifile, registration_methods);
            } else {
                Driver.Log (3, "Target '{0}' is up-to-date.", ifile);
            }

            if (!Application.IsUptodate (ifile, ofile)) {
                var main = new MainTask ()
                {
                    Target = target,
                    Abi = abi,
                    AssemblyName = assemblyName,
                    InputFile = ifile,
                    OutputFile = ofile,
                    SharedLibrary = false,
                    Language = "objective-c++",
                };
                main.CompilerFlags.AddDefine ("MONOTOUCH");
                tasks.Add (main);
            } else {
                Driver.Log (3, "Target '{0}' is up-to-date.", ofile);
            }

            target.LinkWith (ofile);
        }