<commit_before>// <copyright file="CopyFile.cs" company="<NAME>">
//  Opus package
// </copyright>
// <summary>FileUtilities package</summary>
// <author><NAME></author>
namespace XcodeBuilder
{
    public sealed partial class XcodeBuilder
    {
        public object Build(FileUtilities.CopyFile moduleToBuild, out bool success)
        {
            var besideModuleType = moduleToBuild.BesideModuleType;
            if (null == besideModuleType)
            {
                success = false;
                return null;
            }

            var copyOptions = moduleToBuild.Options as FileUtilities.ICopyFileOptions;
            if (null == copyOptions.SourceModuleType)
            {
                Opus.Core.Log.MessageAll("QMake support for copying to arbitrary locations is unavailable");
                success = true;
                return null;
            }

            var node = moduleToBuild.OwningNode;
            var target = node.Target;

            var copySourceNode = Opus.Core.ModuleUtilities.GetNode(copyOptions.SourceModuleType, (Opus.Core.BaseTarget)target);
            var copySourceData = copySourceNode.Data as PBXNativeTarget;

            var besideModuleNode = Opus.Core.ModuleUtilities.GetNode(besideModuleType, (Opus.Core.BaseTarget)target);
            var besideModuleData = besideModuleNode.Data as PBXNativeTarget;

            var project = besideModuleData.Project;
            var moduleName = besideModuleNode.ModuleName;

            var copyFilesBuildPhase = project.CopyFilesBuildPhases.Get("CopyFiles", moduleName);
            besideModuleData.BuildPhases.AddUnique(copyFilesBuildPhase);

            // need a different copy of the build file, to live in the CopyFiles build phase
            // but still referencing the same PBXFileReference
            var type = copySourceData.ProductReference.Type;
            if (type == PBXFileReference.EType.DynamicLibrary)
            {
                type = PBXFileReference.EType.ReferencedDynamicLibrary;
            }
            var relativePath = Opus.Core.RelativePathUtilities.GetPath(copySourceData.ProductReference.FullPath, project.RootUri);
            var dependentFileRef = project.FileReferences.Get(copySourceNode.UniqueModuleName, type, relativePath, project.RootUri);
            var buildFile = project.BuildFiles.Get(copySourceNode.UniqueModuleName, dependentFileRef, copyFilesBuildPhase);
            if (null == buildFile)
            {
                throw new Opus.Core.Exception("Build file not available");
            }

            project.MainGroup.Children.AddUnique(dependentFileRef);

            success = true;
            return null;
        }
    }
}<commit_msg>[trunk] Allow copying files in Xcode to an absolute folder<commit_after>// <copyright file="CopyFile.cs" company="<NAME>">
//  Opus package
// </copyright>
// <summary>FileUtilities package</summary>
// <author><NAME></author>
namespace XcodeBuilder
{
    public sealed partial class XcodeBuilder
    {
        public object Build(FileUtilities.CopyFile moduleToBuild, out bool success)
        {
            var copyOptions = moduleToBuild.Options as FileUtilities.ICopyFileOptions;
            if (null == copyOptions.SourceModuleType)
            {
                throw new Opus.Core.Exception("Xcode support for copying from arbitrary locations is unavailable");
            }

            var node = moduleToBuild.OwningNode;
            var target = node.Target;

            var copySourceNode = Opus.Core.ModuleUtilities.GetNode(copyOptions.SourceModuleType, (Opus.Core.BaseTarget)target);
            var copySourceData = copySourceNode.Data as PBXNativeTarget;

            var besideModuleType = moduleToBuild.BesideModuleType;
            if (null == besideModuleType)
            {
                var project = copySourceData.Project;
                var moduleName = copySourceNode.ModuleName;

                var copyFilesBuildPhase = project.CopyFilesBuildPhases.Get("CopyFiles", moduleName);
                copyFilesBuildPhase.DestinationPath = copyOptions.DestinationDirectory;
                copyFilesBuildPhase.SubFolder = PBXCopyFilesBuildPhase.ESubFolder.AbsolutePath;
                copySourceData.BuildPhases.AddUnique(copyFilesBuildPhase);

                // need a different copy of the build file, to live in the CopyFiles build phase
                // but still referencing the same PBXFileReference
                var type = copySourceData.ProductReference.Type;
                if (type == PBXFileReference.EType.DynamicLibrary)
                {
                    type = PBXFileReference.EType.ReferencedDynamicLibrary;
                }
                var relativePath = Opus.Core.RelativePathUtilities.GetPath(copySourceData.ProductReference.FullPath, project.RootUri);
                var dependentFileRef = project.FileReferences.Get(copySourceNode.UniqueModuleName, type, relativePath, project.RootUri);
                var buildFile = project.BuildFiles.Get(copySourceNode.UniqueModuleName, dependentFileRef, copyFilesBuildPhase);
                if (null == buildFile)
                {
                    throw new Opus.Core.Exception("Build file not available");
                }

                project.MainGroup.Children.AddUnique(dependentFileRef);
            }
            else
            {
                var besideModuleNode = Opus.Core.ModuleUtilities.GetNode(besideModuleType, (Opus.Core.BaseTarget)target);
                var besideModuleData = besideModuleNode.Data as PBXNativeTarget;

                var project = besideModuleData.Project;
                var moduleName = besideModuleNode.ModuleName;

                var copyFilesBuildPhase = project.CopyFilesBuildPhases.Get("CopyFiles", moduleName);
                besideModuleData.BuildPhases.AddUnique(copyFilesBuildPhase);

                // need a different copy of the build file, to live in the CopyFiles build phase
                // but still referencing the same PBXFileReference
                var type = copySourceData.ProductReference.Type;
                if (type == PBXFileReference.EType.DynamicLibrary)
                {
                    type = PBXFileReference.EType.ReferencedDynamicLibrary;
                }
                var relativePath = Opus.Core.RelativePathUtilities.GetPath(copySourceData.ProductReference.FullPath, project.RootUri);
                var dependentFileRef = project.FileReferences.Get(copySourceNode.UniqueModuleName, type, relativePath, project.RootUri);
                var buildFile = project.BuildFiles.Get(copySourceNode.UniqueModuleName, dependentFileRef, copyFilesBuildPhase);
                if (null == buildFile)
                {
                    throw new Opus.Core.Exception("Build file not available");
                }

                project.MainGroup.Children.AddUnique(dependentFileRef);
            }

            success = true;
            return null;
        }
    }
}
{'fraction_non_alphanumeric': 0.07521489971346705, 'fraction_numerical': 0.0, 'mean_word_length': 2.22895467160037, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5930863', 'n_tokens_mistral': 1740, 'n_tokens_neox': 1642, 'n_words': 369}