Defaults(
     this C.ICommonCompilerSettingsOSX settings,
     Bam.Core.Module module)
 {
     // N.B. this default is set in the specific Clang version
     // as it's set on both compiler and linker
 }
Example #2
0
 Init(
     Bam.Core.Module parent)
 {
     base.Init(parent);
     this.InputPath = this.OutputPath;
     this.GeneratedPaths.Add(HashFileKey, this.CreateTokenizedString("$(packagebuilddir)/$(moduleoutputdir)/@filename($(0)).hash", this.OutputPath));
 }
Example #3
0
 VisualStudioProcessor.IConvertToProject.Convert(
     Bam.Core.Module module,
     VSSolutionBuilder.VSSettingsGroup vsSettingsGroup,
     string condition)
 {
     VisualStudioProcessor.Conversion.Convert(typeof(VisualCCommon.VSSolutionImplementation), this, module, vsSettingsGroup, condition);
 }
Example #4
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.AddFile("$(packagedir)/main.c");
        }
 Defaults(
     this C.ICommonWinResourceCompilerSettings settings,
     Bam.Core.Module module)
 {
     settings.Verbose      = false;
     settings.IncludePaths = new Bam.Core.TokenizedStringArray();
 }
Example #6
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);
            this.InputPath = this.OutputPath;
            this.GeneratedPaths.Add(HashFileKey, this.CreateTokenizedString("$(packagebuilddir)/$(moduleoutputdir)/@filename($(0)).hash", this.OutputPath));

            this.PublicPatch((settings, appliedTo) =>
            {
                var compiler = settings as C.ICommonCompilerSettings;
                if (null != compiler)
                {
                    compiler.IncludePaths.AddUnique(this.IncludeDirectory);
                }

                var assembler = settings as C.ICommonAssemblerSettings;
                if (null != assembler)
                {
                    assembler.IncludePaths.AddUnique(this.IncludeDirectory);
                }

                var rcCompiler = settings as C.ICommonWinResourceCompilerSettings;
                if (null != rcCompiler)
                {
                    rcCompiler.IncludePaths.AddUnique(this.IncludeDirectory);
                }
            });
        }
Example #7
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("Test15: Example dynamic library");

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

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

            // because DynamicLibrary1 pokes out of the public API of DynamicLibrary2 (see D_PUBLIC_FORWARDING),
            // the dependency has to be marked as 'public' so that forwarding occurs
            this.CompilePubliclyAndLinkAgainst <Test14.DynamicLibrary1>(source);
        }
 Convert(
     this C.ICOnlyCompilerSettings settings,
     Bam.Core.Module module,
     VSSolutionBuilder.VSSettingsGroup vsSettingsGroup,
     string condition)
 {
 }
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

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

            source.PrivatePatch(settings =>
            {
                // make everything visible
                var gccCompiler        = settings as GccCommon.ICommonCompilerSettings;
                gccCompiler.Visibility = GccCommon.EVisibility.Default;
            });

            // limit exports with version script
            var versionScript = Bam.Core.Graph.Instance.FindReferencedModule <VersionScript>();

            this.DependsOn(versionScript);
            this.PrivatePatch(settings =>
            {
                var gccLinker           = settings as GccCommon.ICommonLinkerSettings;
                gccLinker.VersionScript = versionScript.InputPath;
            });

            this.PublicPatch((settings, appliedTo) =>
            {
                var compiler = settings as C.ICommonCompilerSettings;
                if (null != compiler)
                {
                    compiler.IncludePaths.AddUnique(this.CreateTokenizedString("$(packagedir)/source/library"));
                }
            });
        }
Example #10
0
 Init(
     Bam.Core.Module parent)
 {
     base.Init(parent);
     this.Librarian = DefaultToolchain.Librarian(this.BitDepth);
     this.RegisterGeneratedFile(Key, this.CreateTokenizedString("$(packagebuilddir)/$(moduleoutputdir)/$(libprefix)$(OutputName)$(libext)"));
 }
Example #11
0
        Convert(
            this C.ICommonAssemblerSettings settings,
            Bam.Core.Module module,
            VSSolutionBuilder.VSSettingsGroup vsSettingsGroup,
            string condition)
        {
            vsSettingsGroup.AddSetting("GenerateDebugInformation", settings.DebugSymbols, condition);
            switch (settings.OutputType)
            {
            case C.ECompilerOutput.CompileOnly:
                vsSettingsGroup.AddSetting("GeneratePreprocessedSourceListing", false, condition);
                break;

            case C.ECompilerOutput.Preprocess:
                vsSettingsGroup.AddSetting("GeneratePreprocessedSourceListing", true, condition);
                break;
            }
            vsSettingsGroup.AddSetting("TreatWarningsAsErrors", settings.WarningsAsErrors, condition);
            if (settings.IncludePaths.Any())
            {
                vsSettingsGroup.AddSetting("IncludePaths", settings.IncludePaths, condition, inheritExisting: true, arePaths: true);
            }
            if (settings.PreprocessorDefines.Any())
            {
                vsSettingsGroup.AddSetting("PreprocessorDefinitions", settings.PreprocessorDefines, condition, inheritExisting: true);
            }
        }
Example #12
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.AddFile("$(proxypkgroot)/main.c");
        }
Example #13
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.InputPath = this.CreateTokenizedString("$(proxypkgroot)/main.c");
        }
Example #14
0
        AddFile(
            string path,
            Bam.Core.Module macroModuleOverride = null,
            bool verbatim = false)
        {
            // TODO: how can I distinguish between creating a child module that inherits it's parents settings
            // and from a standalone object of type ChildModuleType which should have it's own copy of the settings?
            var child = Bam.Core.Module.Create <ChildModuleType>(this);

            if (child is IRequiresSourceModule)
            {
                var source = this.CreateSourceFile <SourceFile>(path, macroModuleOverride, verbatim);
                (child as IRequiresSourceModule).Source = source;
            }
            else
            {
                if (verbatim)
                {
                    child.InputPath = Bam.Core.TokenizedString.CreateVerbatim(path);
                }
                else
                {
                    var macroModule = (macroModuleOverride == null) ? this : macroModuleOverride;
                    child.InputPath = macroModule.CreateTokenizedString(path);
                }
            }

            (child as Bam.Core.IChildModule).Parent = this;
            this.children.Add(child);
            this.DependsOn(child);
            return(child);
        }
Example #15
0
        Convert(
            this C.ICOnlyCompilerSettings settings,
            Bam.Core.Module module,
            XcodeBuilder.Configuration configuration)
        {
            if (settings.LanguageStandard.HasValue)
            {
                switch (settings.LanguageStandard.Value)
                {
                case C.ELanguageStandard.C89:
                    configuration["GCC_C_LANGUAGE_STANDARD"] = new XcodeBuilder.UniqueConfigurationValue("c89");
                    break;

                case C.ELanguageStandard.GNU89:
                    configuration["GCC_C_LANGUAGE_STANDARD"] = new XcodeBuilder.UniqueConfigurationValue("gnu89");
                    break;

                case C.ELanguageStandard.C99:
                    configuration["GCC_C_LANGUAGE_STANDARD"] = new XcodeBuilder.UniqueConfigurationValue("c99");
                    break;

                case C.ELanguageStandard.GNU99:
                    configuration["GCC_C_LANGUAGE_STANDARD"] = new XcodeBuilder.UniqueConfigurationValue("gnu99");
                    break;

                default:
                    throw new Bam.Core.Exception("Invalid C language standard, {0}", settings.LanguageStandard.Value.ToString());
                }
            }
        }
Example #16
0
        Convert(
            System.Type conversionClass,
            Bam.Core.Settings toolSettings,
            Bam.Core.Module module,
            XcodeBuilder.Configuration configuration)
        {
            var moduleType             = typeof(Bam.Core.Module);
            var xcodeConfigurationType = typeof(XcodeBuilder.Configuration);

            foreach (var i in toolSettings.Interfaces())
            {
                var method = conversionClass.GetMethod("Convert", new[] { i, moduleType, xcodeConfigurationType });
                if (null == method)
                {
                    throw new Bam.Core.Exception("Unable to locate method {0}.Convert({1}, {2}, {3})",
                                                 conversionClass.ToString(),
                                                 i.ToString(),
                                                 moduleType,
                                                 xcodeConfigurationType);
                }
                try
                {
                    method.Invoke(null, new object[] { toolSettings, module, configuration });
                }
                catch (System.Reflection.TargetInvocationException exception)
                {
                    throw new Bam.Core.Exception(exception.InnerException, "Xcode conversion error:");
                }
            }
        }
Example #17
0
        EnsureTargetExists(
            Bam.Core.Module module)
        {
            var moduleType = module.GetType();

            lock (this.TargetMap)
            {
                if (!this.TargetMap.ContainsKey(moduleType))
                {
                    Project project = null;
                    // TODO: remember projects, both by a Module or by a Package
                    if (this.ProjectPerModule)
                    {
                        throw new System.NotSupportedException();
                    }
                    else
                    {
                        project = this.EnsureProjectExists(module, module.PackageDefinition.FullName);
                    }

                    var target = new Target(module, project);
                    this.TargetMap.Add(moduleType, target);

                    project.Targets.Add(moduleType, target);
                }
            }
            if (null == module.MetaData)
            {
                module.MetaData = this.TargetMap[moduleType];
            }
            return(module.MetaData as Target);
        }
Example #18
0
        GetUniqueSettingsGroup(
            Bam.Core.Module module,
            VSSettingsGroup.ESettingsGroup group,
            Bam.Core.TokenizedString include = null)
        {
            lock (this.ProjectSettings)
            {
                foreach (var settings in this.ProjectSettings)
                {
                    if (null == include)
                    {
                        if ((null == settings.Include) && (settings.Group == group))
                        {
                            return(settings);
                        }
                    }
                    else
                    {
                        // ignore group, as files can mutate between them during the buildprocess (e.g. headers into custom builds)
                        if (settings.Include.Parse() == include.Parse())
                        {
                            return(settings);
                        }
                    }
                }

                var newGroup = new VSSettingsGroup(module, group, include);
                this.ProjectSettings.Add(newGroup);
                return(newGroup);
            }
        }
Example #19
0
        ICompilationPolicy.Compile(
            ObjectFile sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.TokenizedString objectFilePath,
            Bam.Core.Module source)
        {
            var commandLineArgs = new Bam.Core.StringArray();

            (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(commandLineArgs);

            var meta = new MakeFileBuilder.MakeFileMeta(sender);
            var rule = meta.AddRule();

            rule.AddTarget(objectFilePath);
            rule.AddPrerequisite(source, C.SourceFile.Key);

            var tool    = sender.Tool as Bam.Core.ICommandLineTool;
            var command = new System.Text.StringBuilder();

            command.AppendFormat("{0} {1} $< {2}",
                                 CommandLineProcessor.Processor.StringifyTool(tool),
                                 commandLineArgs.ToString(' '),
                                 CommandLineProcessor.Processor.TerminatingArgs(tool));
            rule.AddShellCommand(command.ToString());

            var objectFileDir = System.IO.Path.GetDirectoryName(objectFilePath.ToString());

            meta.CommonMetaData.Directories.AddUnique(objectFileDir);
            meta.CommonMetaData.ExtendEnvironmentVariables(tool.EnvironmentVariables);
        }
Example #20
0
        GetConfiguration(
            Bam.Core.Module module)
        {
            lock (this.Configurations)
            {
                var moduleConfig = module.BuildEnvironment.Configuration;
                if (this.Configurations.ContainsKey(moduleConfig))
                {
                    return(this.Configurations[moduleConfig]);
                }

                var platform = Bam.Core.EPlatform.Invalid;
                var bitDepth = GetModuleBitDepth(module);
                switch (bitDepth)
                {
                case C.EBit.ThirtyTwo:
                    platform = Bam.Core.EPlatform.Win32;
                    break;

                case C.EBit.SixtyFour:
                    platform = Bam.Core.EPlatform.Win64;
                    break;
                }
                if (Bam.Core.EPlatform.Invalid == platform)
                {
                    throw new Bam.Core.Exception("Platform cannot be extracted from the tool {0} for project {1}", module.Tool.ToString(), this.ProjectPath);
                }
                var configuration = new VSProjectConfiguration(this, module, platform);
                this.Configurations.Add(moduleConfig, configuration);
                return(configuration);
            }
        }
Example #21
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.InputPath = this.CreateTokenizedString("$(packagedir)/main.c");
        }
 Defaults(
     this IDiskImageSettings settings,
     Bam.Core.Module module)
 {
     settings.Verbosity = EDiskImageVerbosity.Default;
     settings.ImageSize = "32m";
 }
Example #23
0
 GetLibraryPath(
     Bam.Core.Module module)
 {
     if (module is C.StaticLibrary)
     {
         return(module.GeneratedPaths[C.StaticLibrary.Key]);
     }
     else if (module is C.IDynamicLibrary)
     {
         return(module.GeneratedPaths[C.DynamicLibrary.ImportLibraryKey]);
     }
     else if (module is C.CSDKModule)
     {
         // collection of libraries, none in particular
         return(null);
     }
     else if (module is C.HeaderLibrary)
     {
         // no library
         return(null);
     }
     else if (module is C.OSXFramework)
     {
         // dealt with elsewhere
         return(null);
     }
     else
     {
         throw new Bam.Core.Exception("Unknown module library type: {0}", module.GetType());
     }
 }
Example #24
0
        InternalCreateContainer <T>(
            bool requires,
            string wildcardPath = null,
            Bam.Core.Module macroModuleOverride               = null,
            System.Text.RegularExpressions.Regex filter       = null,
            Bam.Core.Module.PrivatePatchDelegate privatePatch = null)
            where T : CModule, IAddFiles, new()
        {
            var source = Bam.Core.Module.Create <T>(this);

            if (null != privatePatch)
            {
                source.PrivatePatch(privatePatch);
            }

            if (requires)
            {
                this.Requires(source);
            }
            else
            {
                this.DependsOn(source);
            }

            if (null != wildcardPath)
            {
                (source as IAddFiles).AddFiles(wildcardPath, macroModuleOverride: macroModuleOverride, filter: filter);
            }

            return(source);
        }
Example #25
0
 Defaults(
     this C.ICommonLinkerSettingsWin settings,
     Bam.Core.Module module)
 {
     settings.SubSystem            = ESubsystem.Console;
     settings.ExportDefinitionFile = null;
 }
Example #26
0
        Convert(
            System.Type conversionClass,
            Bam.Core.Settings settings,
            Bam.Core.Module module,
            VSSolutionBuilder.VSSettingsGroup vsSettingsGroup,
            string condition)
        {
            var moduleType          = typeof(Bam.Core.Module);
            var vsSettingsGroupType = typeof(VSSolutionBuilder.VSSettingsGroup);
            var stringType          = typeof(string);

            foreach (var i in settings.Interfaces())
            {
                var method = conversionClass.GetMethod("Convert", new[] { i, moduleType, vsSettingsGroupType, stringType });
                if (null == method)
                {
                    throw new Bam.Core.Exception("Unable to locate method {0}.Convert({1}, {2}, {3})",
                                                 conversionClass.ToString(),
                                                 i.ToString(),
                                                 moduleType,
                                                 vsSettingsGroupType,
                                                 stringType);
                }
                try
                {
                    method.Invoke(null, new object[] { settings, module, vsSettingsGroup, condition });
                }
                catch (System.Reflection.TargetInvocationException exception)
                {
                    throw new Bam.Core.Exception(exception.InnerException, "VisualStudio conversion error:");
                }
            }
        }
Example #27
0
        Init(
            Bam.Core.Module parent)
        {
            base.Init(parent);

            this.CreateCSourceContainer("$(packagedir)/source/library.c");
        }
Example #28
0
        public VSProjectConfiguration(
            VSProject project,
            Bam.Core.Module module,
            Bam.Core.EPlatform platform)
        {
            this.Project       = project;
            this.Module        = module;
            this.Configuration = module.BuildEnvironment.Configuration;
            this.Platform      = platform;
            this.FullName      = this.CombinedName;

            this.Type = EType.NA;

            var visualCMeta = Bam.Core.Graph.Instance.PackageMetaData <VisualC.MetaData>("VisualC");

            this.PlatformToolset          = visualCMeta.PlatformToolset;
            this.UseDebugLibraries        = false;
            this.CharacterSet             = C.ECharacterSet.NotSet;
            this.WholeProgramOptimization = false;// TODO: false is consistent with Native builds (module.BuildEnvironment.Configuration != Bam.Core.EConfiguration.Debug);

            this.SettingGroups = new Bam.Core.Array <VSSettingsGroup>();
            this.Sources       = new Bam.Core.Array <VSSettingsGroup>();

            this.PreBuildCommands  = new Bam.Core.StringArray();
            this.PostBuildCommands = new Bam.Core.StringArray();
        }
Example #29
0
 Init(
     Bam.Core.Module parent)
 {
     base.Init(parent);
     // TODO: shouldn't attempt to find the default C compiler if only C++ is of interest
     this.Compiler = C.DefaultToolchain.Cxx_Compiler(this.BitDepth);
 }
Example #30
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("Test14: Example dynamic library");

            this.CreateHeaderContainer("$(packagedir)/include/dynamiclibrary1.h");
            this.CreateCSourceContainer("$(packagedir)/source/dynamiclibrary1.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>();
            }
        }