Пример #1
0
        public void ExtractTo(string path)
        {
            // FIXME: This assumes packages are being extracted underneath the current
            // working directory (i.e. the module root).
            if (GitUtils.IsGitRepository())
            {
                GitUtils.UnmarkIgnored(path);
            }

            GitUtils.RunGit(null, "clone " + this.SourcePath + " " + path);
            GitUtils.RunGit(path, "checkout -f " + this.GitRef);
            this.InitializeSubmodulesFromCache(path);

            if (GitUtils.IsGitRepository())
            {
                GitUtils.MarkIgnored(path);
            }
        }
Пример #2
0
        private void ExtractGitSourceTo(string workingDirectory, string sourcePath, string gitRef, string path)
        {
            // FIXME: This assumes packages are being extracted underneath the current
            // working directory (i.e. the module root).
            if (GitUtils.IsGitRepository())
            {
                GitUtils.UnmarkIgnored(path);
            }

            GitUtils.RunGit(workingDirectory, null, "clone --progress " + sourcePath + " \"" + path + "\"");
            GitUtils.RunGit(workingDirectory, path, "checkout -f " + gitRef);
            this.InitializeSubmodulesFromCache(workingDirectory, path);

            if (GitUtils.IsGitRepository())
            {
                GitUtils.MarkIgnored(path);
            }
        }
Пример #3
0
        private void ResolveLibraryBinary(string workingDirectory, ICachableBinaryPackageMetadata protobuildMetadata, string folder, bool forceUpgrade, Func <byte[]> getBinaryPackage)
        {
            var platformFolder = Path.Combine(folder, protobuildMetadata.Platform);

            if (File.Exists(Path.Combine(platformFolder, ".pkg")))
            {
                if (!forceUpgrade)
                {
                    RedirectableConsole.WriteLine("Protobuild binary package already present at " + platformFolder);
                    return;
                }
            }

            RedirectableConsole.WriteLine("Creating and emptying " + platformFolder);

            if (File.Exists(Path.Combine(folder, ".pkg")))
            {
                if (Directory.Exists(platformFolder))
                {
                    // Only clear out the target's folder if the reference folder
                    // already contains binary packages (for other platforms)
                    PathUtils.AggressiveDirectoryDelete(platformFolder);
                }
            }
            else
            {
                // The reference folder is holding source code, so clear it
                // out entirely.
                PathUtils.AggressiveDirectoryDelete(folder);
            }

            Directory.CreateDirectory(platformFolder);

            RedirectableConsole.WriteLine("Marking " + folder + " as ignored for Git");
            GitUtils.MarkIgnored(folder);

            var package = getBinaryPackage();

            if (package == null)
            {
                return;
            }

            ExtractTo(workingDirectory, protobuildMetadata.PackageName, protobuildMetadata.BinaryFormat, package, platformFolder, protobuildMetadata.Platform);

            // Only copy ourselves to the binary folder if both "Build/Module.xml" and
            // "Build/Projects" exist in the binary package's folder.  This prevents us
            // from triggering the "create new module?" logic if the package hasn't been
            // setup correctly.
            if (Directory.Exists(Path.Combine(platformFolder, "Build", "Projects")) &&
                File.Exists(Path.Combine(platformFolder, "Build", "Module.xml")))
            {
                var sourceProtobuild = Assembly.GetEntryAssembly().Location;
                File.Copy(sourceProtobuild, Path.Combine(platformFolder, "Protobuild.exe"), true);
                PathUtils.MakePathExecutable(Path.Combine(platformFolder, "Protobuild.exe"), true);
            }

            var file = File.Create(Path.Combine(platformFolder, ".pkg"));

            file.Close();

            file = File.Create(Path.Combine(folder, ".pkg"));
            file.Close();

            RedirectableConsole.WriteLine("Binary resolution complete");
        }
Пример #4
0
        private void ResolveLibraryBinary(PackageRef reference, string platform, string source, bool forceUpgrade)
        {
            if (File.Exists(Path.Combine(reference.Folder, platform, ".pkg")))
            {
                if (!forceUpgrade)
                {
                    Console.WriteLine("Protobuild binary package already present at " + Path.Combine(reference.Folder, platform));
                    return;
                }
            }

            var folder = Path.Combine(reference.Folder, platform);

            Console.WriteLine("Creating and emptying " + folder);

            if (File.Exists(Path.Combine(reference.Folder, ".pkg")))
            {
                if (Directory.Exists(folder))
                {
                    // Only clear out the target's folder if the reference folder
                    // already contains binary packages (for other platforms)
                    this.EmptyReferenceFolder(folder);
                }
            }
            else
            {
                // The reference folder is holding source code, so clear it
                // out entirely.
                this.EmptyReferenceFolder(reference.Folder);
            }

            Directory.CreateDirectory(folder);

            Console.WriteLine("Marking " + reference.Folder + " as ignored for Git");
            GitUtils.MarkIgnored(reference.Folder);

            var package = m_PackageCache.GetBinaryPackage(reference.Uri, reference.GitRef, platform);

            if (package == null)
            {
                this.ResolveLibrarySource(reference, source, forceUpgrade);
                return;
            }

            package.ExtractTo(folder);

            // Only copy ourselves to the binary folder if both "Build/Module.xml" and
            // "Build/Projects" exist in the binary package's folder.  This prevents us
            // from triggering the "create new module?" logic if the package hasn't been
            // setup correctly.
            if (Directory.Exists(Path.Combine(folder, "Build", "Projects")) &&
                File.Exists(Path.Combine(folder, "Build", "Module.xml")))
            {
                var sourceProtobuild = Assembly.GetEntryAssembly().Location;
                File.Copy(sourceProtobuild, Path.Combine(folder, "Protobuild.exe"), true);

                try
                {
                    var chmodStartInfo = new ProcessStartInfo
                    {
                        FileName         = "chmod",
                        Arguments        = "a+x Protobuild.exe",
                        WorkingDirectory = folder,
                        CreateNoWindow   = true,
                        UseShellExecute  = false
                    };
                    Process.Start(chmodStartInfo);
                }
                catch (ExecEnvironment.SelfInvokeExitException)
                {
                    throw;
                }
                catch
                {
                }
            }

            var file = File.Create(Path.Combine(folder, ".pkg"));

            file.Close();

            file = File.Create(Path.Combine(reference.Folder, ".pkg"));
            file.Close();

            Console.WriteLine("Binary resolution complete");
        }