예제 #1
0
 getTargetDependency(
     string name,
     ContainerItemProxy proxy)
 {
     return(this.TargetDependencies.FirstOrDefault(item => item.Dependency == null && item.Name == name && item.Proxy == proxy));
 }
예제 #2
0
        Requires(
            Target other)
        {
            lock (this)
            {
                var existingTargetDep = this.TargetDependencies.Where(item => item.Dependency == other).FirstOrDefault();
                if (null != existingTargetDep)
                {
                    return;
                }
                if (this.Project == other.Project)
                {
                    var itemProxy = this.Project.ContainerItemProxies.Where(item => (item.ContainerPortal == this.Project) && (item.Remote == other)).FirstOrDefault();
                    if (null == itemProxy)
                    {
                        itemProxy = new ContainerItemProxy(this.Project, this.Project, other, false);
                    }

                    var dependency = this.TargetDependencies.Where(item => (item.Dependency == other) && (item.Proxy == itemProxy)).FirstOrDefault();
                    if (null == dependency)
                    {
                        dependency = new TargetDependency(this.Project, other, itemProxy);
                        this.TargetDependencies.AddUnique(dependency);
                    }
                }
                else
                {
                    var fileRef = this.Project.EnsureFileReferenceExists(
                        other.Project.ProjectDir,
                        FileReference.EFileType.Project,
                        explicitType: false,
                        sourceTree: FileReference.ESourceTree.Absolute);
                    this.Project.MainGroup.AddChild(fileRef);

                    var itemProxy = this.Project.ContainerItemProxies.Where(item => (item.ContainerPortal == fileRef) && (item.Remote == other)).FirstOrDefault();
                    if (null == itemProxy)
                    {
                        itemProxy = new ContainerItemProxy(this.Project, fileRef, other, false);
                    }

                    var refProxy = this.Project.ReferenceProxies.Where(item => item.RemoteRef == itemProxy).FirstOrDefault();
                    if (null == refProxy)
                    {
                        refProxy = new ReferenceProxy(
                            this.Project,
                            other.FileReference.Type,
                            other.FileReference.Path,
                            itemProxy,
                            other.FileReference.SourceTree);
                    }

                    var productRefGroup = this.Project.Groups.Where(item => item.Children.Contains(refProxy)).FirstOrDefault();
                    if (null == productRefGroup)
                    {
                        productRefGroup = new Group("Products");
                        productRefGroup.AddChild(refProxy);
                        this.Project.Groups.Add(productRefGroup);
                    }

                    var productRef = this.Project.ProjectReferences.Where(item => item.Key == productRefGroup).FirstOrDefault();
                    if (productRef.Equals(default(System.Collections.Generic.Dictionary <Group, FileReference>)))
                    {
                        this.Project.ProjectReferences.Add(productRefGroup, fileRef);
                    }

                    var dependency = this.TargetDependencies.Where(item => (item.Dependency == null) && (item.Proxy == itemProxy)).FirstOrDefault();
                    if (null == dependency)
                    {
                        dependency = new TargetDependency(this.Project, null, itemProxy);
                        this.TargetDependencies.AddUnique(dependency);
                    }
                }
            }
        }
예제 #3
0
 getTargetDependency(
     Target target,
     ContainerItemProxy proxy)
 {
     return(this.TargetDependencies.FirstOrDefault(item => item.Dependency == target && item.Proxy == proxy));
 }
예제 #4
0
 getReferenceProxyForRemoteRef(
     ContainerItemProxy remoteRef)
 {
     return(this.ReferenceProxies.FirstOrDefault(item => item.RemoteRef == remoteRef));
 }
예제 #5
0
 appendContainerItemProxy(
     ContainerItemProxy proxy)
 {
     // these are only added in a single thread
     this.ContainerItemProxies.AddUnique(proxy);
 }
예제 #6
0
        public void Requires(
            Target other)
        {
            lock (this)
            {
                var existingTargetDep = this.TargetDependencies.Where(item => item.Dependency == other).FirstOrDefault();
                if (null != existingTargetDep)
                {
                    return;
                }
                if (this.Project == other.Project)
                {
                    var itemProxy = this.Project.ContainerItemProxies.Where(item => (item.ContainerPortal == this.Project) && (item.Remote == other)).FirstOrDefault();
                    if (null == itemProxy)
                    {
                        itemProxy = new ContainerItemProxy(this.Project, this.Project, other, false);
                    }

                    var dependency = this.TargetDependencies.Where(item => (item.Dependency == other) && (item.Proxy == itemProxy)).FirstOrDefault();
                    if (null == dependency)
                    {
                        dependency = new TargetDependency(this.Project, other, itemProxy);
                        this.TargetDependencies.AddUnique(dependency);
                    }
                }
                else
                {
                    var fileRef = this.Project.EnsureFileReferenceExists(
                        other.Project.ProjectDir,
                        FileReference.EFileType.Project,
                        explicitType: false,
                        sourceTree: FileReference.ESourceTree.Absolute);
                    this.Project.MainGroup.AddChild(fileRef);

                    var itemProxy = this.Project.ContainerItemProxies.Where(item => (item.ContainerPortal == fileRef) && (item.Remote == other)).FirstOrDefault();
                    if (null == itemProxy)
                    {
                        itemProxy = new ContainerItemProxy(this.Project, fileRef, other, false);
                    }

                    var refProxy = this.Project.ReferenceProxies.Where(item => item.RemoteRef == itemProxy).FirstOrDefault();
                    if (null == refProxy)
                    {
                        refProxy = new ReferenceProxy(
                            this.Project,
                            other.FileReference.Type,
                            other.FileReference.Path,
                            itemProxy,
                            other.FileReference.SourceTree);
                    }

                    var productRefGroup = this.Project.Groups.Where(item => item.Children.Contains(refProxy)).FirstOrDefault();
                    if (null == productRefGroup)
                    {
                        productRefGroup = new Group("Products");
                        productRefGroup.AddChild(refProxy);
                        this.Project.Groups.Add(productRefGroup);
                    }

                    var productRef = this.Project.ProjectReferences.Where(item => item.Key == productRefGroup).FirstOrDefault();
                    if (productRef.Equals(default(System.Collections.Generic.Dictionary<Group, FileReference>)))
                    {
                        this.Project.ProjectReferences.Add(productRefGroup, fileRef);
                    }

                    var dependency = this.TargetDependencies.Where(item => (item.Dependency == null) && (item.Proxy == itemProxy)).FirstOrDefault();
                    if (null == dependency)
                    {
                        dependency = new TargetDependency(this.Project, null, itemProxy);
                        this.TargetDependencies.AddUnique(dependency);
                    }
                }
            }
        }
예제 #7
0
        ResolveTargetDependencies()
        {
            foreach (var depTarget in this.ProposedTargetDependencies)
            {
                if (this.Project == depTarget.Project)
                {
                    var nativeTargetItemProxy = this.Project.getContainerItemProxy(depTarget, depTarget.Project);
                    if (null == nativeTargetItemProxy)
                    {
                        nativeTargetItemProxy = new ContainerItemProxy(this.Project, depTarget);
                    }

                    // note that target dependencies can be shared in a project by many Targets
                    // but each Target needs a reference to it
                    var dependency = this.Project.getTargetDependency(depTarget, nativeTargetItemProxy);
                    if (null == dependency)
                    {
                        dependency = new TargetDependency(this.Project, depTarget, nativeTargetItemProxy);
                    }
                    this.TargetDependencies.AddUnique(dependency);
                }
                else
                {
                    if (null == depTarget.FileReference)
                    {
                        // expect header libraries not to have a build output
                        if (!(depTarget.Module is C.HeaderLibrary))
                        {
                            Bam.Core.Log.ErrorMessage("Project {0} cannot be a target dependency as it has no output FileReference", depTarget.Name);
                        }
                        continue;
                    }

                    var relativePath = this.Project.GetRelativePathToProject(depTarget.Project.ProjectDir);
                    var sourceTree   = FileReference.ESourceTree.NA;
                    if (null == relativePath)
                    {
                        sourceTree = FileReference.ESourceTree.Absolute;
                    }
                    else
                    {
                        sourceTree = FileReference.ESourceTree.Group; // note: not relative to SOURCE
                    }

                    var dependentProjectFileRef = this.Project.EnsureFileReferenceExists(
                        depTarget.Project.ProjectDir,
                        relativePath,
                        FileReference.EFileType.Project,
                        explicitType: false,
                        sourceTree: sourceTree);
                    this.Project.MainGroup.AddChild(dependentProjectFileRef);

                    // need a ContainerItemProxy for the dependent NativeTarget
                    // which is associated with a local PBXTargetDependency
                    var nativeTargetItemProxy = this.Project.getContainerItemProxy(depTarget, dependentProjectFileRef);
                    if (null == nativeTargetItemProxy)
                    {
                        nativeTargetItemProxy = new ContainerItemProxy(this.Project, dependentProjectFileRef, depTarget);
                    }

                    // note that target dependencies can be shared in a project by many Targets
                    // but each Target needs a reference to it
                    var targetDependency = this.Project.getTargetDependency(depTarget.Name, nativeTargetItemProxy);
                    if (null == targetDependency)
                    {
                        // no 'target', but does have the name of the dependent
                        targetDependency = new TargetDependency(this.Project, depTarget.Name, nativeTargetItemProxy);
                    }
                    this.TargetDependencies.AddUnique(targetDependency);

                    // need a ContainerItemProxy for the filereference of the dependent NativeTarget
                    // which is associated with a local PBXReferenceProxy
                    var dependentFileRefItemProxy = this.Project.getContainerItemProxy(depTarget.FileReference, dependentProjectFileRef);
                    if (null == dependentFileRefItemProxy)
                    {
                        // note, uses the name of the Target, not the FileReference
                        dependentFileRefItemProxy = new ContainerItemProxy(this.Project, dependentProjectFileRef, depTarget.FileReference, depTarget.Name);
                    }

                    var refProxy = this.Project.getReferenceProxyForRemoteRef(dependentFileRefItemProxy);
                    if (null == refProxy)
                    {
                        refProxy = new ReferenceProxy(
                            this.Project,
                            depTarget.FileReference.Type,
                            depTarget.FileReference.Path,
                            dependentFileRefItemProxy,
                            depTarget.FileReference.SourceTree);
                    }

                    // TODO: all PBXReferenceProxies could go into the same group
                    // but at the moment, a group is made for each
                    var productRefGroup = this.Project.groupWithChild(refProxy);
                    if (null == productRefGroup)
                    {
                        productRefGroup = new Group(this.Project, "Products", refProxy);
                        this.Project.appendGroup(productRefGroup);
                    }

                    this.Project.EnsureProjectReferenceExists(productRefGroup, dependentProjectFileRef);
                }
            }
        }