示例#1
0
        CreateGroupHierarchy(
            Bam.Core.TokenizedString path)
        {
            Group group = null;

            lock (this.Project)
            {
                var found = this.Project.GroupMap.Where(item => item.Key == path.Parse()).FirstOrDefault();
                if (!found.Equals(default(System.Collections.Generic.KeyValuePair <string, Group>)))
                {
                    return(found.Value);
                }
                var basename = this.Module.CreateTokenizedString("@basename($(0))", path).Parse();
                group = new Group(basename);
                this.Project.Groups.Add(group);
                this.Project.GroupMap.Add(path.Parse(), group);
                if (path.Parse().Contains(System.IO.Path.DirectorySeparatorChar))
                {
                    var parent      = this.Module.CreateTokenizedString("@dir($(0))", path);
                    var parentGroup = this.CreateGroupHierarchy(parent);
                    parentGroup.AddChild(group);
                }
            }
            return(group);
        }
示例#2
0
        IStripToolPolicy.Strip(
            StripModule sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.TokenizedString originalPath,
            Bam.Core.TokenizedString copiedPath)
        {
            var meta = new MakeFileBuilder.MakeFileMeta(sender);
            var rule = meta.AddRule();

            var sourceFilename = System.IO.Path.GetFileName(originalPath.Parse());

            meta.CommonMetaData.Directories.AddUnique(sender.CreateTokenizedString("@dir($(0))", copiedPath).Parse());
            rule.AddTarget(copiedPath, variableName: "strip_" + sourceFilename);

            var commandLine = new Bam.Core.StringArray();

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

            rule.AddShellCommand(System.String.Format("{0} {1} {2} -o {3} {4}",
                                                      CommandLineProcessor.Processor.StringifyTool(sender.Tool as Bam.Core.ICommandLineTool),
                                                      commandLine.ToString(' '),
                                                      originalPath.Parse(),
                                                      copiedPath.Parse(),
                                                      CommandLineProcessor.Processor.TerminatingArgs(sender.Tool as Bam.Core.ICommandLineTool)));
        }
示例#3
0
        IInstallNameToolPolicy.InstallName(
            InstallNameModule sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.TokenizedString oldName,
            Bam.Core.TokenizedString newName)
        {
            var originalModule = sender.Source.SourceModule;

            if (originalModule == null)
            {
                return;
            }

            var commandLine = new Bam.Core.StringArray();

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

            var commands = new Bam.Core.StringArray();

            if (sender.Source.SourceModule != null && sender.Source.SourceModule.MetaData != null)
            {
                commands.Add(System.String.Format("{0} {1} {2} {3} {4} {5}",
                                                  CommandLineProcessor.Processor.StringifyTool(sender.Tool as Bam.Core.ICommandLineTool),
                                                  commandLine.ToString(' '),
                                                  oldName.Parse(),
                                                  newName.Parse(),
                                                  sender.Source.GeneratedPaths[CollatedObject.Key].Parse(),
                                                  CommandLineProcessor.Processor.TerminatingArgs(sender.Tool as Bam.Core.ICommandLineTool)));

                var target        = sender.Source.SourceModule.MetaData as XcodeBuilder.Target;
                var configuration = target.GetConfiguration(sender.Source.SourceModule);
                target.AddPostBuildCommands(commands, configuration);
            }
            else
            {
                var destinationFolder = "$CONFIGURATION_BUILD_DIR";
                if (sender.Source.Reference != null)
                {
                    destinationFolder = "$CONFIGURATION_BUILD_DIR/$EXECUTABLE_FOLDER_PATH";
                }

                commands.Add(System.String.Format("{0} {1} {2} {3} {4}/{5} {6}",
                                                  CommandLineProcessor.Processor.StringifyTool(sender.Tool as Bam.Core.ICommandLineTool),
                                                  commandLine.ToString(' '),
                                                  oldName.Parse(),
                                                  newName.Parse(),
                                                  destinationFolder,
                                                  sender.Source.CreateTokenizedString("$(0)/@filename($(1))", sender.Source.SubDirectory, sender.Source.SourcePath).Parse(),
                                                  CommandLineProcessor.Processor.TerminatingArgs(sender.Tool as Bam.Core.ICommandLineTool)));

                var target        = sender.Source.Reference.SourceModule.MetaData as XcodeBuilder.Target;
                var configuration = target.GetConfiguration(sender.Source.Reference.SourceModule);
                target.AddPostBuildCommands(commands, configuration);
            }
        }
示例#4
0
        IObjCopyToolPolicy.ObjCopy(
            ObjCopyModule sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.TokenizedString originalPath,
            Bam.Core.TokenizedString copiedPath)
        {
            var mode = (sender.Settings as IObjCopyToolSettings).Mode;

            // if linking debug data, add to the strip
            var meta = (EObjCopyToolMode.AddGNUDebugLink == mode) ? sender.SourceModule.MetaData as MakeFileBuilder.MakeFileMeta : new MakeFileBuilder.MakeFileMeta(sender);
            var rule = (EObjCopyToolMode.AddGNUDebugLink == mode) ? meta.Rules[0] :meta.AddRule();

            if (EObjCopyToolMode.AddGNUDebugLink == mode)
            {
                rule.AddOrderOnlyDependency(copiedPath.Parse());
            }
            else
            {
                meta.CommonMetaData.AddDirectory(sender.CreateTokenizedString("@dir($(0))", copiedPath).Parse());

                var sourceFilename = System.IO.Path.GetFileName(originalPath.Parse());
                rule.AddTarget(copiedPath, variableName: "objcopy_" + sourceFilename);
                rule.AddPrerequisite(originalPath);
            }

            var commandLine = new Bam.Core.StringArray();

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

            rule.AddShellCommand(System.String.Format("{0} {1} {2}",
                                                      CommandLineProcessor.Processor.StringifyTool(sender.Tool as Bam.Core.ICommandLineTool),
                                                      commandLine.ToString(' '),
                                                      CommandLineProcessor.Processor.TerminatingArgs(sender.Tool as Bam.Core.ICommandLineTool)));
        }
        SetOutputPath(
            Bam.Core.TokenizedString path)
        {
            var macros = new Bam.Core.MacroList();

            // TODO: ideally, $(ProjectDir) should replace the following directory separator as well,
            // but it does not seem to be a show stopper if it doesn't
            macros.Add("packagebuilddir", Bam.Core.TokenizedString.CreateVerbatim("$(ProjectDir)"));
            macros.Add("modulename", Bam.Core.TokenizedString.CreateVerbatim("$(ProjectName)"));
            var outDir = path.Parse(macros);

            outDir  = System.IO.Path.GetDirectoryName(outDir);
            outDir += "\\";
            this.OutputDirectory = outDir;

            var targetName = this.Module.CreateTokenizedString("@basename($(0))", path).Parse();

            if (!string.IsNullOrEmpty(targetName))
            {
                var filename = this.Module.CreateTokenizedString("@filename($(0))", path).Parse();
                var ext      = filename.Replace(targetName, string.Empty);
                this.TargetName = targetName;
                this.TargetExt  = ext;
            }
        }
示例#6
0
        ITarPolicy.CreateTarBall(
            TarBall sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.ICommandLineTool compiler,
            Bam.Core.TokenizedString scriptPath,
            Bam.Core.TokenizedString outputPath)
        {
            var tarPath = outputPath.ToString();
            var tarDir  = System.IO.Path.GetDirectoryName(tarPath);

            if (!System.IO.Directory.Exists(tarDir))
            {
                System.IO.Directory.CreateDirectory(tarDir);
            }

            var commandLine = new Bam.Core.StringArray();

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

            commandLine.Add("-c");
            commandLine.Add("-v");
            commandLine.Add("-T");
            commandLine.Add(scriptPath.Parse());
            commandLine.Add("-f");
            commandLine.Add(tarPath);
            CommandLineProcessor.Processor.Execute(context, compiler, commandLine);
        }
        IAssemblerPolicy.Assemble(
            AssembledObjectFile sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.TokenizedString objectFilePath,
            Bam.Core.Module source)
        {
            var encapsulating = sender.GetEncapsulatingReferencedModule();

            var solution = Bam.Core.Graph.Instance.MetaData as VSSolutionBuilder.VSSolution;
            var project  = solution.EnsureProjectExists(encapsulating);
            var config   = project.GetConfiguration(encapsulating);

            var output = objectFilePath.Parse();

            var args = new Bam.Core.StringArray();

            args.Add(CommandLineProcessor.Processor.StringifyTool(sender.Tool as Bam.Core.ICommandLineTool));
            (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(args);
            args.Add("%(FullPath)");

            var customBuild = config.GetSettingsGroup(VSSolutionBuilder.VSSettingsGroup.ESettingsGroup.CustomBuild, include: sender.InputPath, uniqueToProject: true);

            customBuild.AddSetting("Command", args.ToString(' '), condition: config.ConditionText);
            customBuild.AddSetting("Message", System.String.Format("Assembling {0}", System.IO.Path.GetFileName(sender.InputPath.Parse())), condition: config.ConditionText);
            customBuild.AddSetting("Outputs", output, condition: config.ConditionText);
            sender.MetaData = customBuild;
        }
示例#8
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);
            }
        }
        IAssemblerPolicy.Assemble(
            AssembledObjectFile sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.TokenizedString objectFilePath,
            Bam.Core.Module source)
        {
            if (!sender.PerformCompilation)
            {
                return;
            }

            var meta = new MakeFileBuilder.MakeFileMeta(sender);
            var rule = meta.AddRule();
            rule.AddTarget(objectFilePath);
            rule.AddPrerequisite(source, C.SourceFile.Key);

            var outputPath = objectFilePath.Parse();

            var args = new Bam.Core.StringArray();
            args.Add(CommandLineProcessor.Processor.StringifyTool(sender.Tool as Bam.Core.ICommandLineTool));
            (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(args);
            args.Add("$<");
            rule.AddShellCommand(args.ToString(' '));

            meta.CommonMetaData.AddDirectory(System.IO.Path.GetDirectoryName(outputPath));
        }
示例#10
0
        IStripToolPolicy.Strip(
            StripModule sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.TokenizedString originalPath,
            Bam.Core.TokenizedString strippedPath)
        {
            var strippedDir = System.IO.Path.GetDirectoryName(strippedPath.Parse());

            Bam.Core.IOWrapper.CreateDirectoryIfNotExists(strippedDir);

            var commandLine = new Bam.Core.StringArray();

            (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(commandLine);
            commandLine.Add(originalPath.Parse());
            commandLine.Add(System.String.Format("-o {0}", strippedPath.Parse()));
            CommandLineProcessor.Processor.Execute(context, sender.Tool as Bam.Core.ICommandLineTool, commandLine);
        }
示例#11
0
 public Group(
     Target target,
     string name,
     Bam.Core.TokenizedString fullPath)
     :
     base(target.Project, name, "PBXGroup", fullPath.Parse())
 {
     this.SourceTree = "<group>";
     this.Children   = new System.Collections.Generic.List <Object>();
 }
示例#12
0
        INSISPolicy.CreateInstaller(
            NSISInstaller sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.ICommandLineTool compiler,
            Bam.Core.TokenizedString scriptPath)
        {
            var args = new Bam.Core.StringArray();

            args.Add(scriptPath.Parse());
            CommandLineProcessor.Processor.Execute(context, compiler, args);
        }
示例#13
0
        IDSymUtilToolPolicy.CreateBundle(
            DSymUtilModule sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.TokenizedString originalPath,
            Bam.Core.TokenizedString copiedPath)
        {
            var copiedDir = System.IO.Path.GetDirectoryName(copiedPath.Parse());

            if (!System.IO.Directory.Exists(copiedDir))
            {
                System.IO.Directory.CreateDirectory(copiedDir);
            }

            var commandLine = new Bam.Core.StringArray();

            (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(commandLine);
            commandLine.Add(System.String.Format("-o {0}", copiedPath.Parse()));
            commandLine.Add(originalPath.Parse());
            CommandLineProcessor.Processor.Execute(context, sender.Tool as Bam.Core.ICommandLineTool, commandLine);
        }
示例#14
0
        GetRelativePathToProject(
            Bam.Core.TokenizedString inputPath)
        {
            var relPath = Bam.Core.RelativePathUtilities.GetPath(inputPath.Parse(), this.ProjectDir.Parse());

            if (Bam.Core.RelativePathUtilities.IsPathAbsolute(relPath))
            {
                return(null);
            }
            return(relPath);
        }
示例#15
0
        IInstallNameToolPolicy.InstallName(
            InstallNameModule sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.TokenizedString oldName,
            Bam.Core.TokenizedString newName)
        {
            var commandLine = new Bam.Core.StringArray();

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

            commandLine.Add(newName.Parse());
            commandLine.Add(sender.Source.GeneratedPaths[CollatedObject.Key].Parse());
            CommandLineProcessor.Processor.Execute(context, sender.Tool as Bam.Core.ICommandLineTool, commandLine);
        }
示例#16
0
        IObjCopyToolPolicy.ObjCopy(
            ObjCopyModule sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.TokenizedString originalPath,
            Bam.Core.TokenizedString copiedPath)
        {
            var copiedDir = System.IO.Path.GetDirectoryName(copiedPath.Parse());

            Bam.Core.IOWrapper.CreateDirectoryIfNotExists(copiedDir);

            var commandLine = new Bam.Core.StringArray();

            (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(commandLine);
            CommandLineProcessor.Processor.Execute(context, sender.Tool as Bam.Core.ICommandLineTool, commandLine);
        }
        Add(
            string name,
            Bam.Core.TokenizedString value)
        {
            var parsedValue = value.Parse();

            if (this.Defines.ContainsKey(name))
            {
                if (this.Defines[name] != parsedValue)
                {
                    throw new Bam.Core.Exception("Preprocessor define {0} already exists with value {1}. Cannot change it to {2}", name, this.Defines[name], parsedValue);
                }
                return;
            }
            this.Defines.Add(name, parsedValue);
        }
示例#18
0
 public FileReference(
     Bam.Core.TokenizedString path,
     EFileType type,
     Project project,
     bool explicitType      = false,
     ESourceTree sourceTree = ESourceTree.NA,
     string relativePath    = null)
     :
     base(project, path.Parse(), "PBXFileReference", type.ToString(), project.GUID, explicitType.ToString(), sourceTree.ToString(), relativePath)
 {
     this.Path         = path;
     this.Type         = type;
     this.SourceTree   = sourceTree;
     this.ExplicitType = explicitType;
     this.RelativePath = relativePath;
 }
示例#19
0
        AddSetting(
            string name,
            Bam.Core.TokenizedString path,
            string condition     = null,
            bool inheritExisting = false)
        {
            lock (this.Settings)
            {
                var stringValue = path.Parse();
                if (this.Settings.Any(item => item.Name == name && item.Condition == condition && item.Value != stringValue))
                {
                    throw new Bam.Core.Exception("Cannot change the value of existing tokenized path option {0} to {1}", name, stringValue);
                }

                this.Settings.AddUnique(new VSSetting(name, stringValue, condition));
            }
        }
示例#20
0
        AddFilters(
            Bam.Core.Module module,
            Bam.Core.TokenizedString filterPath)
        {
            var path = filterPath.Parse();

            if (!this.Filters.ContainsKey(path))
            {
                this.Filters.Add(path, new Bam.Core.Array <VSSettingsGroup>());
            }
            if (!path.Contains(System.IO.Path.DirectorySeparatorChar))
            {
                return;
            }
            // the entire hierarchy needs to be added, even if they are empty
            var parent = module.CreateTokenizedString("@dir($(0))", filterPath);

            this.AddFilters(module, parent);
        }
示例#21
0
        IInstallNameToolPolicy.InstallName(
            InstallNameModule sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.TokenizedString oldName,
            Bam.Core.TokenizedString newName)
        {
            // add another shell command to the rule for copying the file
            var meta = sender.Source.MetaData as MakeFileBuilder.MakeFileMeta;
            var rule = meta.Rules[0];

            var commandLine = new Bam.Core.StringArray();

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

            rule.AddShellCommand(System.String.Format(@"{0} {1} {2} $@ {3}",
                                                      CommandLineProcessor.Processor.StringifyTool(sender.Tool as Bam.Core.ICommandLineTool),
                                                      commandLine.ToString(' '),
                                                      newName.Parse(),
                                                      CommandLineProcessor.Processor.TerminatingArgs(sender.Tool as Bam.Core.ICommandLineTool)));
        }
示例#22
0
        toRelativePath(
            Bam.Core.TokenizedString path)
        {
            var programFiles    = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles);
            var programFilesX86 = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFilesX86);

            var pathString = path.Parse();

            if (pathString.StartsWith(programFiles) || pathString.StartsWith(programFilesX86))
            {
                return(pathString);
            }

            var contatenated = new System.Text.StringBuilder();
            var relative     = Bam.Core.RelativePathUtilities.GetPath(pathString, this.Project.ProjectPath);

            if (!Bam.Core.RelativePathUtilities.IsPathAbsolute(relative))
            {
                contatenated.Append("$(ProjectDir)");
            }
            contatenated.AppendFormat("{0}", relative);
            return(contatenated.ToString());
        }
示例#23
0
        public ReferenceProxy(
            Project project,
            FileReference.EFileType fileType,
            Bam.Core.TokenizedString path,
            Object remoteRef,
            FileReference.ESourceTree sourceTree)
            :
            base(project, null, "PBXReferenceProxy", project.GUID, fileType.ToString(), path.Parse(), remoteRef.GUID, sourceTree.ToString())
        {
            this.FileType   = fileType;
            this.Path       = path;
            this.RemoteRef  = remoteRef;
            this.SourceTree = sourceTree;

            project.ReferenceProxies.AddUnique(this);
        }
示例#24
0
 SetProductName(
     Bam.Core.TokenizedString productName)
 {
     this["PRODUCT_NAME"] = new UniqueConfigurationValue(productName.Parse());
 }