示例#1
0
        ProcessLibraryDependency(
            C.CModule executable,
            C.CModule library)
        {
            var fullLibraryPath = this.GetLibraryPath(library);

            if (null == fullLibraryPath)
            {
                return;
            }
            var linker      = executable.Settings as C.ICommonLinkerSettings;
            var libFilename = library.CreateTokenizedString("@filename($(0))", fullLibraryPath);

            lock (libFilename)
            {
                if (!libFilename.IsParsed)
                {
                    libFilename.Parse();
                }
            }
            linker.Libraries.AddUnique(libFilename.ToString());
            var libDir = library.CreateTokenizedString("@dir($(0))", fullLibraryPath);

            lock (libDir)
            {
                if (!libDir.IsParsed)
                {
                    libDir.Parse();
                }
            }
            linker.LibraryPaths.AddUnique(libDir);
        }
示例#2
0
        ProcessLibraryDependency(
            C.CModule executable,
            C.CModule library)
        {
            var fullLibraryPath = GetLibraryPath(library);

            if (null == fullLibraryPath)
            {
                return;
            }
            // TODO: use @filenamenoext
            var libFilename = GetLPrefixLibraryName(fullLibraryPath.Parse());
            var linker      = executable.Settings as C.ICommonLinkerSettings;

            linker.Libraries.AddUnique(libFilename);
            linker.LibraryPaths.AddUnique(library.CreateTokenizedString("@dir($(0))", fullLibraryPath));
        }
示例#3
0
        ProcessLibraryDependency(
            C.CModule executable,
            C.CModule library)
        {
            var linker = executable.Settings as C.ICommonLinkerSettings;

            if (library is C.StaticLibrary)
            {
                // TODO: @filenamenoext
                var libraryPath = library.GeneratedPaths[C.StaticLibrary.Key].Parse();
                // order matters on libraries - the last occurrence is always the one that matters to resolve all symbols
                var libraryName = GetLPrefixLibraryName(libraryPath);
                if (linker.Libraries.Contains(libraryName))
                {
                    linker.Libraries.Remove(libraryName);
                }
                linker.Libraries.Add(libraryName);

                linker.LibraryPaths.AddUnique(library.CreateTokenizedString("@dir($(0))", library.GeneratedPaths[C.StaticLibrary.Key]));
            }
            else if (library is C.IDynamicLibrary)
            {
                // TODO: @filenamenoext
                var libraryPath = library.GeneratedPaths[C.DynamicLibrary.Key].Parse();
                var libraryName = library.Macros.Contains("LinkerName") ?
                                  GetLPrefixLibraryName(library.Macros["LinkerName"].Parse()) :
                                  GetLPrefixLibraryName(libraryPath);
                // order matters on libraries - the last occurrence is always the one that matters to resolve all symbols
                if (linker.Libraries.Contains(libraryName))
                {
                    linker.Libraries.Remove(libraryName);
                }
                linker.Libraries.Add(libraryName);

                linker.LibraryPaths.AddUnique(library.CreateTokenizedString("@dir($(0))", library.GeneratedPaths[C.DynamicLibrary.Key]));

                var gccLinker            = executable.Settings as GccCommon.ICommonLinkerSettings;
                var allDynamicDependents = FindAllDynamicDependents(library as C.IDynamicLibrary);
                foreach (var dep in allDynamicDependents)
                {
                    gccLinker.RPathLink.AddUnique(dep.CreateTokenizedString("@dir($(0))", dep.GeneratedPaths[C.DynamicLibrary.Key]));
                }
            }
        }
示例#4
0
 GetLibraryPath(
     C.CModule library)
 {
     if (library is C.StaticLibrary)
     {
         return(library.GeneratedPaths[C.StaticLibrary.Key]);
     }
     else if (library is C.IDynamicLibrary)
     {
         return(library.GeneratedPaths[C.DynamicLibrary.ImportLibraryKey]);
     }
     else if ((library is C.CSDKModule) ||
              (library is C.HeaderLibrary) ||
              (library is C.OSXFramework))
     {
         return(null);
     }
     throw new Bam.Core.Exception("Unsupported library type, {0}", library.GetType().ToString());
 }
示例#5
0
        ProcessLibraryDependency(
            C.CModule executable,
            C.CModule library)
        {
            var linker = executable.Settings as C.ICommonLinkerSettings;

            if (library is C.StaticLibrary)
            {
                // TODO: @filenamenoext
                var libraryPath = library.GeneratedPaths[C.StaticLibrary.Key].ToString();
                linker.Libraries.AddUnique(GetLPrefixLibraryName(libraryPath));

                var libDir = library.CreateTokenizedString("@dir($(0))", library.GeneratedPaths[C.StaticLibrary.Key]);
                lock (libDir)
                {
                    if (!libDir.IsParsed)
                    {
                        libDir.Parse();
                    }
                }

                linker.LibraryPaths.AddUnique(libDir);
            }
            else if (library is C.IDynamicLibrary)
            {
                // TODO: @filenamenoext
                var libraryPath = library.GeneratedPaths[C.DynamicLibrary.Key].ToString();
                linker.Libraries.AddUnique(GetLPrefixLibraryName(libraryPath));

                var libDir = library.CreateTokenizedString("@dir($(0))", library.GeneratedPaths[C.DynamicLibrary.Key]);
                lock (libDir)
                {
                    if (!libDir.IsParsed)
                    {
                        libDir.Parse();
                    }
                }

                linker.LibraryPaths.AddUnique(libDir);
            }
        }
示例#6
0
        ProcessLibraryDependency(
            C.CModule executable,
            C.CModule library)
        {
            var linker = executable.Settings as C.ICommonLinkerSettings;

            if (library is C.StaticLibrary)
            {
                // TODO: @filenamenoext
                var libraryPath = library.GeneratedPaths[C.StaticLibrary.Key].ToString();
                // order matters on libraries - the last occurrence is always the one that matters to resolve all symbols
                var libraryName = GetLPrefixLibraryName(libraryPath);
                if (linker.Libraries.Contains(libraryName))
                {
                    linker.Libraries.Remove(libraryName);
                }
                linker.Libraries.Add(libraryName);

                var libDir = library.CreateTokenizedString("@dir($(0))", library.GeneratedPaths[C.StaticLibrary.Key]);
                lock (libDir)
                {
                    if (!libDir.IsParsed)
                    {
                        libDir.Parse();
                    }
                }
                linker.LibraryPaths.AddUnique(libDir);
            }
            else if (library is C.IDynamicLibrary)
            {
                // TODO: @filenamenoext
                var libraryPath       = library.GeneratedPaths[C.DynamicLibrary.Key].ToString();
                var linkerNameSymLink = (library as C.IDynamicLibrary).LinkerNameSymbolicLink;
                // TODO: I think there's a problem when there's no linkerName symlink - i.e. taking the full shared object path
                var libraryName = (linkerNameSymLink != null) ?
                                  GetLPrefixLibraryName(linkerNameSymLink.GeneratedPaths[C.SharedObjectSymbolicLink.Key].ToString()) :
                                  GetLPrefixLibraryName(libraryPath);
                // order matters on libraries - the last occurrence is always the one that matters to resolve all symbols
                if (linker.Libraries.Contains(libraryName))
                {
                    linker.Libraries.Remove(libraryName);
                }
                linker.Libraries.Add(libraryName);

                var libDir = library.CreateTokenizedString("@dir($(0))", library.GeneratedPaths[C.DynamicLibrary.Key]);
                lock (libDir)
                {
                    if (!libDir.IsParsed)
                    {
                        libDir.Parse();
                    }
                }
                linker.LibraryPaths.AddUnique(libDir);
                var gccLinker = executable.Settings as GccCommon.ICommonLinkerSettings;

                // if an explicit link occurs in this executable/shared object, the library path
                // does not need to be on the rpath-link
                if (gccLinker.RPathLink.Contains(libDir))
                {
                    gccLinker.RPathLink.Remove(libDir);
                }

                var allDynamicDependents = FindAllDynamicDependents(library as C.IDynamicLibrary);
                foreach (var dep in allDynamicDependents)
                {
                    var rpathLinkDir = dep.CreateTokenizedString("@dir($(0))", dep.GeneratedPaths[C.DynamicLibrary.Key]);
                    // only need to add to rpath-link, if there's been no explicit link to the library already
                    if (!linker.LibraryPaths.Contains(rpathLinkDir))
                    {
                        lock (rpathLinkDir)
                        {
                            if (!rpathLinkDir.IsParsed)
                            {
                                rpathLinkDir.Parse();
                            }
                        }
                        gccLinker.RPathLink.AddUnique(rpathLinkDir);
                    }
                }
            }
        }