Example #1
0
 public bool GetLib(string name, out LibRef Output, LibBuildConfig CFG, bool IsDLL = false)
 {
     name   = Path.GetFileNameWithoutExtension(name);
     Output = null;
     if (IsDLL)
     {
         foreach (LibRef r in FoundDLLs)
         {
             if (r.Name == name)
             {
                 Output = r;
                 return(true);
             }
         }
     }
     else
     {
         foreach (LibRef r in FoundLibs)
         {
             if (r.Name == name && r.BuildCFg == CFG)
             {
                 Output = r;
                 return(true);
             }
         }
     }
     return(false);
 }
Example #2
0
        public void PostInit(TargetRules r)
        {
            PreProcessorDefines.Add(ModuleName.ToUpper() + "_EXPORT");
            if (ModuleOutputType == ModuleType.LIB)
            {
                PreProcessorDefines.Add("STATIC_MODULE");
            }
            foreach (string t in r.GlobalDefines)
            {
                PreProcessorDefines.Add(t);
            }
            string path = "//Intermediate//Generated//" + ModuleName + "//";

            IncludeDirectories.Add(path);
            IncludeDirectories.Add("//Source//" + ModuleName + "//");
            IncludeDirectories.Add("//Source//" + SourceFileSearchDir + "//");
            foreach (ExternalModuleDef EMD in ExternalModules)
            {
                EMD.Build();

                IncludeDirectories.Add(ModuleDefManager.GetThirdPartyDirRelative() + EMD.IncludeDir);
                DLLs.AddRange(EMD.DynamaicLibs);
                LibNameRefs.AddRange(EMD.StaticLibs);
                AdditonalLibSearchPaths.AddRange(EMD.LibrarySearchPaths);
                SystemLibNames.AddRange(EMD.SystemLibNames);
            }
            foreach (string s in SystemLibNames)
            {
                LibRef L = new LibRef();
                L.Path      = s;
                L.BuildCFg  = LibBuildConfig.General;
                L.BuildType = Library.BCToString(LibBuildConfig.General);
                ModuleLibs.Add(L);
            }
            foreach (LibDependency l in StaticLibraries)
            {
                if (l.NeedsDll)
                {
                    LibNameRef lref;
                    lref.Config  = LibBuildConfig.General;
                    lref.IsDLL   = true;
                    lref.LibName = l.LibName.Replace(".lib", ".dll");
                    DLLs.Add(lref);
                }
            }
        }
Example #3
0
        public void CopyDllsToConfig(List <PlatformDefinition> Platforms, List <BuildConfig> configs, List <ModuleDef> ALLModules)
        {
            foreach (PlatformDefinition PD in Platforms)
            {
                foreach (BuildConfig bc in configs)
                {
                    Console.WriteLine("Copying Files for: '" + bc.Name + "' Of type " + bc.CurrentType.ToString());
                    List <string> DLLsForConfig = new List <string>();
                    foreach (ModuleDef M in ALLModules)
                    {
                        foreach (LibNameRef LNR in M.DLLs)
                        {
                            LibRef DLLref = null;
                            GetLib(LNR.LibName, out DLLref, LibBuildConfig.General, true);
                            if (DLLref == null)
                            {
                                Console.WriteLine("Error Failed to find DLL " + LNR.LibName);
                                continue;
                            }
                            if (!IsValidConfig(DLLref.BuildCFg, bc.GetLibType()))
                            {
                                continue;
                            }
                            string filepath = ModuleDefManager.GetBinPath() + "\\" + PD.Name + "\\" + bc.Name + "\\" + Path.GetFileName(LNR.LibName);

                            if (File.Exists(filepath))
                            {
                                if (File.GetLastWriteTime(filepath) >= File.GetLastWriteTime(DLLref.Path))
                                {
                                    continue;
                                }
                            }
                            Directory.CreateDirectory(Path.GetDirectoryName(filepath));
                            File.Copy(DLLref.Path, filepath, true);
                            if (ModuleDefManager.IsDebug())
                            {
                                Console.WriteLine("Copied " + Path.GetFileName(LNR.LibName) + " to output dir");
                            }
                        }
                    }
                }
            }
        }
Example #4
0
 public void AddLibsForModule(ModuleDef m, bool All = false)
 {
     if (m.LibNameRefs.Count > 0)
     {
         foreach (LibNameRef LibName in m.LibNameRefs)
         {
             LibRef outputlib    = null;
             string CleanLibName = Path.GetFileNameWithoutExtension(LibName.LibName);
             if (GetLib(CleanLibName, out outputlib, LibName.Config))
             {
                 m.ModuleLibs.Add(outputlib);
             }
             else
             {
                 Console.WriteLine("Error: failed to find lib " + LibName.LibName);
             }
         }
     }
 }
Example #5
0
 void AddModulePaths(List <string> paths, LibBuildConfig buildconfig, bool DLL)
 {
     foreach (string s in paths)
     {
         LibRef Newref = new LibRef();
         Newref.BuildType = BCToString(buildconfig);
         Newref.Path      = StringUtils.SanitizePath(s);
         Newref.Name      = Path.GetFileNameWithoutExtension(s);
         Newref.BuildCFg  = buildconfig;
         if (DLL)
         {
             FoundDLLs.Add(Newref);
         }
         else
         {
             FoundLibs.Add(Newref);
         }
     }
 }
Example #6
0
        string CreateLibs(ModuleDef m, BuildConfig BC, PlatformDefinition PD)
        {
            string linkout = "";

            if (m.UnsupportedPlatforms.Contains(PD.Name))
            {
                return("");
            }
            string DllOut = "";

            if (m != ModuleDefManager.CoreModule)
            {
                DllOut += "\"" + ModuleDefManager.CoreModule.ModuleName + "\", ";
            }
            List <LibRef> AllLibs = new List <LibRef>();

            AllLibs.AddRange(m.ModuleLibs);
            if (m != ModuleDefManager.CoreModule)
            {
                LibRef r = new LibRef();
                r.TargetPlatform = PlatformID.Invalid;
                string OutputDir = StringUtils.SanitizePath(ModuleDefManager.GetBinPath()) + "/" + PD.Name + "/" + BC.Name;
                r.Path = OutputDir + "/Core.lib";
                AllLibs.Add(r);
                AllLibs.AddRange(ModuleDefManager.CoreModule.ModuleLibs);
            }
            //new core
            List <LibDependency> StaticLibs = new List <LibDependency>();

            StaticLibs.AddRange(m.StaticLibraries);

            foreach (ExternalModuleDef ExtraMods in m.ExternalModules)
            {
                // if (!ExtraMods.UnsupportedPlatformsTypes.Contains(""))
                {
                    StaticLibs.AddRange(ExtraMods.StaticLibraries);
                }
            }
            foreach (LibDependency dep in StaticLibs)
            {
                if (dep.Platforms.Contains(PD.TypeId))
                {
                    DllOut += "\"" + dep.LibName + "\", ";
                }
            }
            foreach (LibRef r in AllLibs)
            {
                if (r.TargetPlatform != PlatformID.Invalid && r.TargetPlatform != PD.TypeId)
                {
                    continue;
                }
                if (r.BuildCFg == BC.GetLibType() || r.BuildCFg == LibBuildConfig.General)
                {
                    DllOut += "\"" + r.Path + "\", ";
                }
            }

            if (m.LaunguageType == ModuleDef.ProjectType.CSharp || m.LaunguageType == ModuleDef.ProjectType.ManagedCPP)
            {
                foreach (string s in m.NetReferences)
                {
                    DllOut += "\"" + s + "\", ";
                }
            }
            ModuleDefManager.Instance.OnPreMakeAddLibs(m, BC, PD, ref DllOut);
            return(linkout + DllOut);
        }