Exemple #1
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            var bamVersion = Bam.Core.Graph.Instance.ProcessState.Version;

            this.Macros["MajorVersion"] = Bam.Core.TokenizedString.CreateVerbatim(bamVersion.Major.ToString());
            this.Macros["MinorVersion"] = Bam.Core.TokenizedString.CreateVerbatim(bamVersion.Minor.ToString());
            this.Macros["PatchVersion"] = Bam.Core.TokenizedString.CreateVerbatim(bamVersion.Build.ToString());
            this.Macros["Description"]  = Bam.Core.TokenizedString.CreateVerbatim("Test9: Example C++ dynamic library");

            this.CreateHeaderContainer("$(packagedir)/include/library_cpp.h");

            var source = this.CreateCxxSourceContainer("$(packagedir)/source/library_cpp.c");

            source.PrivatePatch(settings =>
            {
                var compiler = settings as C.ICommonCompilerSettings;
                compiler.IncludePaths.Add(this.CreateTokenizedString("$(packagedir)/include"));

                var cxxCompiler = settings as C.ICxxOnlyCompilerSettings;
                cxxCompiler.ExceptionHandler = C.Cxx.EExceptionHandler.Synchronous;
            });

            if (this.BuildEnvironment.Platform.Includes(Bam.Core.EPlatform.Windows) &&
                this.Linker is VisualCCommon.LinkerBase)
            {
                this.LinkAgainst <WindowsSDK.WindowsSDK>();
            }
        }
Exemple #2
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            var source = this.CreateCSourceContainer("$(packagedir)/source/main.c");

            if (this.BuildEnvironment.Platform.Includes(Bam.Core.EPlatform.Windows))
            {
                source.AddFile("$(packagedir)/source/win/win.c");
            }
            else if (this.BuildEnvironment.Platform.Includes(Bam.Core.EPlatform.Linux))
            {
                source.AddFile("$(packagedir)/source/unix/unix.c");
            }
            else if (this.BuildEnvironment.Platform.Includes(Bam.Core.EPlatform.OSX))
            {
                source.AddFile("$(packagedir)/source/osx/osx.c");
            }

            if (this.BuildEnvironment.Platform.Includes(Bam.Core.EPlatform.Windows) &&
                this.Linker is VisualCCommon.LinkerBase)
            {
                this.LinkAgainst <WindowsSDK.WindowsSDK>();
            }
        }
Exemple #3
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.CreateCSourceContainer("$(packagedir)/source/dlldependentapp.c");

            this.PrivatePatch(settings =>
            {
                var gccLinker = settings as GccCommon.ICommonLinkerSettings;
                if (gccLinker != null)
                {
                    gccLinker.CanUseOrigin = true;
                    gccLinker.RPath.AddUnique("$ORIGIN");
                }
            });

            this.LinkAgainst <MyDynamicLibrary>();

            if (this.BuildEnvironment.Platform.Includes(Bam.Core.EPlatform.Windows) &&
                this.Linker is VisualCCommon.LinkerBase)
            {
                this.LinkAgainst <WindowsSDK.WindowsSDK>();
            }
        }
Exemple #4
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.Tool = Bam.Core.Graph.Instance.FindReferencedModule <ObjCopyTool>();
        }
Exemple #5
0
 GenerateFileCopyDestination(
     Bam.Core.Module module,
     Bam.Core.TokenizedString referenceFilePath,
     Bam.Core.TokenizedString subDirectory,
     Bam.Core.TokenizedString unReferencedRoot)
 {
     if (referenceFilePath != null)
     {
         if (null != subDirectory)
         {
             return(module.CreateTokenizedString("@normalize(@dir($(0))/$(1)/)",
                                                 referenceFilePath,
                                                 subDirectory));
         }
         else
         {
             return(module.CreateTokenizedString("@normalize(@dir($(0))/)",
                                                 referenceFilePath));
         }
     }
     else
     {
         if (null != subDirectory)
         {
             return(module.CreateTokenizedString("@normalize($(0)/$(1)/)",
                                                 unReferencedRoot,
                                                 subDirectory));
         }
         else
         {
             return(module.CreateTokenizedString("@normalize($(0)/)",
                                                 unReferencedRoot));
         }
     }
 }
Exemple #6
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.CreateSymbolsFrom <Runtime>();
        }
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.CreateHeaderContainer("$(packagedir)/include/configurablelibrary/*.h");
            var source = this.CreateCSourceContainer("$(packagedir)/source/library.c");

            this.PublicPatch((settings, appliedTo) =>
                {
                    var compiler = settings as C.ICommonCompilerSettings;
                    if (null != compiler)
                    {
                        compiler.IncludePaths.AddUnique(this.CreateTokenizedString("$(packagedir)/include/configurablelibrary"));
                    }
                });

#if BAM_FEATURE_MODULE_CONFIGURATION
            var config = this.Configuration as IConfigureLibrary;
            if (null != config)
            {
                if (config.UseFunkyNewFeature)
                {
                    source.PrivatePatch(settings =>
                        {
                            var compiler = settings as C.ICommonCompilerSettings;
                            compiler.PreprocessorDefines.Add("D_ENABLE_FUNKY_NEW_FEATURE");
                        });
                    this.CompileAgainst<FunkyFeatureLibrary>(source);
                }
            }
        }
Exemple #8
0
        CreateCollatedFile(
            Bam.Core.Module sourceModule,
            Bam.Core.TokenizedString sourcePath,
            CollatedFile reference,
            Bam.Core.TokenizedString subDirectory)
        {
            var copyFileModule = Bam.Core.Module.Create <CollatedFile>(preInitCallback: module =>
            {
                Bam.Core.TokenizedString referenceFilePath = null;
                if (null != reference)
                {
                    referenceFilePath = reference.GeneratedPaths[CollatedObject.Key];
                }
                else
                {
                    if (!this.GeneratedPaths.ContainsKey(Key))
                    {
                        this.RegisterGeneratedFile(Key, module.CreateTokenizedString("@dir($(0))", sourcePath));
                    }
                }
                module.Macros["CopyDir"] = GenerateFileCopyDestination(
                    module,
                    referenceFilePath,
                    subDirectory,
                    this.GeneratedPaths[Key]);
            });

            this.Requires(copyFileModule);

            copyFileModule.SourceModule = sourceModule;
            copyFileModule.SourcePath   = sourcePath;
            copyFileModule.Reference    = reference;
            copyFileModule.SubDirectory = subDirectory;
            return(copyFileModule);
        }
Exemple #9
0
        CreateCollatedSymbolicLink(
            Bam.Core.Module sourceModule,
            Bam.Core.TokenizedString sourcePath,
            CollatedFile reference,
            Bam.Core.TokenizedString subDirectory)
        {
            if (null == reference)
            {
                throw new Bam.Core.Exception("Collating a symbolic link requires a collated file as reference");
            }

            var copySymlinkModule = Bam.Core.Module.Create <CollatedSymbolicLink>(preInitCallback: module =>
            {
                module.Macros["CopyDir"] = GenerateSymbolicLinkCopyDestination(
                    module,
                    reference.GeneratedPaths[CollatedObject.Key],
                    subDirectory);
            });

            this.Requires(copySymlinkModule);

            copySymlinkModule.SourceModule = sourceModule;
            copySymlinkModule.SourcePath   = sourcePath;
            copySymlinkModule.Reference    = reference;
            copySymlinkModule.SubDirectory = subDirectory;
            return(copySymlinkModule);
        }
Exemple #10
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.AddFile("$(packagedir)/source/main_c.c");
        }
Exemple #11
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.CreateHeaderContainer("$(packagedir)/include/*.h");

            var cSource = this.CreateCSourceContainer("$(packagedir)/source/library_c.c");

            cSource.PrivatePatch(settings =>
            {
                var compiler = settings as C.ICommonCompilerSettings;
                compiler.IncludePaths.Add(this.CreateTokenizedString("$(packagedir)/include"));
            });

            var cxxSource = this.CreateCxxSourceContainer();

            cxxSource.AddFile("$(packagedir)/source/library_cpp.c");
            cxxSource.AddFile("$(packagedir)/source/appmain_cpp.c");
            cxxSource.PrivatePatch(settings =>
            {
                var compiler = settings as C.ICommonCompilerSettings;
                compiler.IncludePaths.Add(this.CreateTokenizedString("$(packagedir)/include"));
                var cxxCompiler = settings as C.ICxxOnlyCompilerSettings;
                cxxCompiler.ExceptionHandler = C.Cxx.EExceptionHandler.Synchronous;
            });

            if (this.BuildEnvironment.Platform.Includes(Bam.Core.EPlatform.Windows) &&
                this.Linker is VisualCCommon.LinkerBase)
            {
                this.LinkAgainst <WindowsSDK.WindowsSDK>();
            }
        }
Exemple #12
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.InputPath = this.CreateTokenizedString("$(packagedir)/source/main_c.c");
        }
Exemple #13
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.PrivatePatch(settings =>
            {
                var gccCommon = settings as GccCommon.ICommonLinkerSettings;
                if (null != gccCommon)
                {
                    gccCommon.CanUseOrigin = true;
                    gccCommon.RPath.AddUnique("$ORIGIN");
                }
            });

            var source = this.CreateCSourceContainer("$(packagedir)/source/dynamicmain.c");

            this.LinkAgainst <Test4.MyStaticLib>();
            this.CompileAndLinkAgainst <Test4.MyDynamicLib>(source);

            if (this.BuildEnvironment.Platform.Includes(Bam.Core.EPlatform.Windows) &&
                this.Linker is VisualCCommon.LinkerBase)
            {
                this.LinkAgainst <WindowsSDK.WindowsSDK>();
            }
        }
Exemple #14
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.CreateHeaderContainer("$(packagedir)/include/*.h");

            var cSource = this.CreateCSourceContainer("$(packagedir)/source/library_c.c");

            cSource.PrivatePatch(settings =>
            {
                var compiler = settings as C.ICommonCompilerSettings;
                compiler.IncludePaths.Add(this.CreateTokenizedString("$(packagedir)/include"));
            });

            var cxxSource = this.CreateCxxSourceContainer();

            cxxSource.AddFile("$(packagedir)/source/library_cpp.c");
            cxxSource.AddFile("$(packagedir)/source/appmain_cpp.c");
            cxxSource.PrivatePatch(settings =>
            {
                var compiler = settings as C.ICommonCompilerSettings;
                compiler.IncludePaths.Add(this.CreateTokenizedString("$(packagedir)/include"));
                var cxxCompiler = settings as C.ICxxOnlyCompilerSettings;
                cxxCompiler.ExceptionHandler = C.Cxx.EExceptionHandler.Synchronous;
            });
        }
Exemple #15
0
 AddFile(
     Bam.Core.Module module,
     Bam.Core.PathKey key)
 {
     this.DependsOn(module);
     this.Files.Add(module, key);
 }
Exemple #16
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.SetSemanticVersion(Bam.Core.Graph.Instance.ProcessState as Bam.Core.ISemanticVersion);
            this.Macros["Description"] = Bam.Core.TokenizedString.CreateVerbatim("EmbedStaticIntoDynamicLibrary: Example C++ dynamic library");

            var source = this.CreateCxxSourceContainer("$(packagedir)/source/dynamic/*.c");

            source.PrivatePatch(settings =>
            {
                var compiler = settings as C.ICommonCompilerSettings;
                compiler.PreprocessorDefines.Add("DYNAMICLIB_SOURCE");
            });

            // publicly because the app requires the include path from the dependent
            this.ExtendSourcePublicly <CxxProxyForStaticLibrary>(source);

            this.PublicPatch((settings, appliedTo) =>
            {
                var compiler = settings as C.ICommonCompilerSettings;
                if (null != compiler)
                {
                    compiler.IncludePaths.AddUnique(this.CreateTokenizedString("$(packagedir)/include/dynamic"));
                }
            });
        }
Exemple #17
0
 AddPath(
     Bam.Core.Module module,
     Bam.Core.PathKey key)
 {
     this.DependsOn(module);
     this.Paths.Add(module, key);
 }
Exemple #18
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.AddFiles("$(packagedir)/source/static/*.c");

            this.PublicPatch((settings, appliedTo) =>
            {
                var compiler = settings as C.ICommonCompilerSettings;
                if (null != compiler)
                {
                    compiler.IncludePaths.AddUnique(this.CreateTokenizedString("$(packagedir)/include/static"));
                }
            });

            this.PrivatePatch(settings =>
            {
                var compiler = settings as C.ICommonCompilerSettings;
                compiler.PreprocessorDefines.Add("STATICLIB_SOURCE");

                // the source files are shared for both C and C++ compilation
                // but this option will only be set when compiled as C++ - the preprocessor checks this
                compiler.PreprocessorDefines.Add("COMPILE_AS_CXX");
            });
        }
Exemple #19
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.StripBinariesFrom <Runtime, DebugSymbols>();
        }
Exemple #20
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.LinkAgainst <MyStaticLib>();

            this.CreateHeaderContainer("$(packagedir)/include/dynamiclibrary.h");
            var source = this.CreateCSourceContainer("$(packagedir)/source/dynamiclibrary.c");

            this.PublicPatch((settings, appliedTo) =>
            {
                var compiler = settings as C.ICommonCompilerSettings;
                if (null != compiler)
                {
                    compiler.IncludePaths.AddUnique(this.CreateTokenizedString("$(packagedir)/include"));
                }
            });

            if (this.BuildEnvironment.Platform.Includes(Bam.Core.EPlatform.Windows) &&
                this.Linker is VisualCCommon.LinkerBase)
            {
                this.CompilePubliclyAndLinkAgainst <WindowsSDK.WindowsSDK>(source);
            }
        }
Exemple #21
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.CreateCSourceContainer("$(packagedir)/source/generateheadertool/main.c");
        }
Exemple #22
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);
            this.GeneratedPaths[Key] = this.CreateTokenizedString("$(packagebuilddir)/$(moduleoutputdir)/$(dynamicprefix)$(OutputName)$(dynamicext)");
            this.Macros.Add("LinkOutput", this.GeneratedPaths[Key]);

            if (this.BuildEnvironment.Platform.Includes(Bam.Core.EPlatform.Windows))
            {
                this.RegisterGeneratedFile(ImportLibraryKey, this.CreateTokenizedString("$(packagebuilddir)/$(moduleoutputdir)/$(libprefix)$(OutputName)$(libext)"));
            }
            else if (this.BuildEnvironment.Platform.Includes(Bam.Core.EPlatform.Linux))
            {
                if (!(this is Plugin))
                {
                    this.Macros.Add("SOName", this.CreateTokenizedString("$(dynamicprefix)$(OutputName)$(sonameext)"));
                    this.Macros.Add("LinkerName", this.CreateTokenizedString("$(dynamicprefix)$(OutputName)$(linkernameext)"));
                }
            }

            this.PrivatePatch(settings =>
            {
                var linker = settings as C.ICommonLinkerSettings;
                if (null != linker)
                {
                    linker.OutputType = ELinkerOutput.DynamicLibrary;
                }

                var osxLinker = settings as C.ICommonLinkerSettingsOSX;
                if (null != osxLinker)
                {
                    osxLinker.InstallName = this.CreateTokenizedString("@executable_path/@filename($(LinkOutput))");
                }
            });
        }
Exemple #23
0
        CreateCollatedSymbolicLink(
            Bam.Core.Module sourceModule,
            Bam.Core.TokenizedString sourcePath,
            CollatedFile reference,
            Bam.Core.TokenizedString subDirectory)
        {
            if (null == reference)
            {
                throw new Bam.Core.Exception("Collating a symbolic link requires a collated file as reference");
            }

            var copySymlinkModule = Bam.Core.Module.Create <CollatedSymbolicLink>(preInitCallback: module =>
            {
                module.Macros["CopyDir"] = GenerateSymbolicLinkCopyDestination(
                    module,
                    reference.GeneratedPaths[CollatedObject.Key],
                    subDirectory);
            });

            this.Requires(copySymlinkModule);
            if (null != reference.SourceModule &&
                null != sourceModule &&
                reference.SourceModule != sourceModule) // in case a different key from the same module is published
            {
                // ensuring that non-Native builders set up order-only dependencies for additional published only modules
                reference.SourceModule.Requires(sourceModule);
            }

            copySymlinkModule.SourceModule = sourceModule;
            copySymlinkModule.SourcePath   = sourcePath;
            copySymlinkModule.Reference    = reference;
            copySymlinkModule.SubDirectory = subDirectory;
            return(copySymlinkModule);
        }
Exemple #24
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.Macros["OutputName"] = Bam.Core.TokenizedString.CreateVerbatim("ExplicitDynamicLibrary");

            this.CreateHeaderContainer("$(packagedir)/include/dynamiclibrary.h");
            this.CreateCSourceContainer("$(packagedir)/source/dynamiclibrary.c");
            this.PublicPatch((settings, appliedTo) =>
            {
                var compiler = settings as C.ICommonCompilerSettings;
                if (null == compiler)
                {
                    return;
                }
                compiler.IncludePaths.AddUnique(this.CreateTokenizedString("$(packagedir)/include"));
            });

            if (this.BuildEnvironment.Platform.Includes(Bam.Core.EPlatform.Windows) &&
                this.Linker is VisualCCommon.LinkerBase)
            {
                this.LinkAgainst <WindowsSDK.WindowsSDK>();
            }
        }
Exemple #25
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            var source = this.CreateCSourceContainer("$(packagedir)/source/*.c");

            this.CompileAndLinkAgainst <TestLib>(source);

            this.PrivatePatch(settings =>
            {
                var linker = settings as C.ICommonLinkerSettings;
                if (this.BuildEnvironment.Platform.Includes(Bam.Core.EPlatform.OSX))
                {
                    linker.Libraries.AddUnique("-lcurses");
                }
                else if (this.BuildEnvironment.Platform.Includes(Bam.Core.EPlatform.Linux))
                {
                    linker.Libraries.AddUnique("-ldl");
                }
                else
                {
                    if (this.Linker is VisualCCommon.LinkerBase)
                    {
                        linker.Libraries.AddUnique("Ws2_32.lib");
                    }
                    else
                    {
                        linker.Libraries.AddUnique("-lws2_32");
                    }
                }
            });
        }
Exemple #26
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            throw new Bam.Core.UnableToBuildModuleException("this is testing failure to build");
        }
Exemple #27
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.CreateCSourceContainer("$(packagedir)/source/stlib.c");
        }
Exemple #28
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.LinkAgainst <MyStaticLib>();

            var bamVersion = Bam.Core.Graph.Instance.ProcessState.Version;

            this.Macros["MajorVersion"] = Bam.Core.TokenizedString.CreateVerbatim(bamVersion.Major.ToString());
            this.Macros["MinorVersion"] = Bam.Core.TokenizedString.CreateVerbatim(bamVersion.Minor.ToString());
            this.Macros["PatchVersion"] = Bam.Core.TokenizedString.CreateVerbatim(bamVersion.Build.ToString());
            this.Macros["Description"]  = Bam.Core.TokenizedString.CreateVerbatim("Test4: Example dynamic library");

            this.CreateHeaderContainer("$(packagedir)/include/dynamiclibrary.h");
            this.CreateCSourceContainer("$(packagedir)/source/dynamiclibrary.c");
            this.PublicPatch((settings, appliedTo) =>
            {
                var compiler = settings as C.ICommonCompilerSettings;
                if (null != compiler)
                {
                    compiler.IncludePaths.AddUnique(this.CreateTokenizedString("$(packagedir)/include"));
                }
            });

            if (this.Linker is VisualCCommon.LinkerBase)
            {
                this.LinkAgainst <WindowsSDK.WindowsSDK>();
            }
        }
Exemple #29
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.StripBinariesFrom <CxxExecutableRuntime, CxxExecutableDebugSymbols>();
        }
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.Tool = Bam.Core.Graph.Instance.FindReferencedModule <ObjCopyTool>();

            var trueSourceModule = this.sourceModule;

            // stripping works on the initial collated file
            while (trueSourceModule is ICollatedObject)
            {
                // necessary on Linux, as the real source module needs checking against
                // C.IDynamicLibrary to identify paths as lib<name>.so.X.Y
                trueSourceModule = (trueSourceModule as ICollatedObject).SourceModule;
            }
            if (this.BuildEnvironment.Platform.Includes(Bam.Core.EPlatform.Linux) &&
                trueSourceModule is C.IDynamicLibrary)
            {
                this.RegisterGeneratedFile(Key,
                                           this.CreateTokenizedString("$(0)/@filename($(1)).debug",
                                                                      new[] { this.Macros["publishingdir"], this.sourceModule.GeneratedPaths[this.sourcePathKey] }));
            }
            else
            {
                this.RegisterGeneratedFile(Key,
                                           this.CreateTokenizedString("$(0)/@basename($(1)).debug",
                                                                      new[] { this.Macros["publishingdir"], this.sourceModule.GeneratedPaths[this.sourcePathKey] }));
            }

            this.Requires(this.sourceModule);
        }