Exemple #1
0
        public override void ParseParameter(string[] parameters, FileInfo sourceFilePath, int lineNumber, IAssemblerContext context)
        {
            string      includeFilename = parameters[0];
            IncludeType matchType       = IncludeType.Relative;

            if (parameters.Length > 1)
            {
                string incType = parameters[1].Replace("Sharpmake.", "");
                incType = incType.Replace("IncludeType.", "");
                if (!Enum.TryParse <IncludeType>(incType, out matchType))
                {
                    throw new Error("\t" + sourceFilePath.FullName + "(" + lineNumber + "): error: Sharpmake.Include invalid include type used ({0})", parameters[1]);
                }
            }
            string includeAbsolutePath = Path.IsPathRooted(includeFilename) ? includeFilename : null;

            if (Util.IsPathWithWildcards(includeFilename))
            {
                if (matchType != IncludeType.Relative)
                {
                    throw new Error("\t" + sourceFilePath.FullName + "(" + lineNumber + "): error: Sharpmake.Include with non-relative match types, wildcards are not supported ({0})", includeFilename);
                }
                includeAbsolutePath = includeAbsolutePath ?? Path.Combine(sourceFilePath.DirectoryName, includeFilename);
                context.AddSourceFiles(Util.DirectoryGetFilesWithWildcards(includeAbsolutePath));
            }
            else
            {
                includeAbsolutePath = includeAbsolutePath ?? Util.PathGetAbsolute(sourceFilePath.DirectoryName, includeFilename);

                if (matchType == IncludeType.Relative)
                {
                    if (!Util.FileExists(includeAbsolutePath))
                    {
                        includeAbsolutePath = Util.GetCapitalizedPath(includeAbsolutePath);
                    }
                }
                else
                {
                    includeAbsolutePath = Util.GetCapitalizedPath(MatchIncludeInParentPath(includeFilename, sourceFilePath.DirectoryName, matchType));
                }

                if (!Util.FileExists(includeAbsolutePath))
                {
                    throw new Error("\t" + sourceFilePath.FullName + "(" + lineNumber + "): error: Sharpmake.Include file not found {0}", includeFilename);
                }

                context.AddSourceFile(includeAbsolutePath);
            }
        }
Exemple #2
0
        public override void ParseParameter(string[] parameters, FileInfo sourceFilePath, int lineNumber, IAssemblerContext context)
        {
            string reference = parameters[0];

            if (Util.IsPathWithWildcards(reference))
            {
                string referenceAbsolutePath = Path.IsPathRooted(reference) ? reference : null;
                referenceAbsolutePath = referenceAbsolutePath ?? Path.Combine(sourceFilePath.DirectoryName, reference);
                context.AddReferences(Util.DirectoryGetFilesWithWildcards(referenceAbsolutePath));
            }
            else
            {
                bool foundReference = false;
                foundReference = Assembler.DefaultReferences.Any(
                    defaultReference => FileSystemStringComparer.StaticCompare(defaultReference, reference) == 0
                    );

                if (!foundReference)
                {
                    foreach (string candidateReferenceLocation in EnumerateReferencePathCandidates(sourceFilePath, reference))
                    {
                        if (Util.FileExists(candidateReferenceLocation))
                        {
                            context.AddReference(candidateReferenceLocation);
                            foundReference = true;
                            break;
                        }
                    }
                }
                else if (Builder.Instance.Diagnostics)
                {
                    Util.LogWrite("{0}({1}): Warning: Reference '{2}' is redundant and can be removed since it is in the default reference list.", sourceFilePath.FullName, lineNumber, reference);
                }

                if (!foundReference)
                {
                    throw new Error(
                              "\t{0}({1}): error: Sharpmake.Reference file not found: {2}{3}Those paths were evaluated as candidates:{3}  - {4}",
                              sourceFilePath.FullName,
                              lineNumber,
                              reference,
                              Environment.NewLine,
                              string.Join(Environment.NewLine + "  - ", EnumerateReferencePathCandidates(sourceFilePath, reference))
                              );
                }
            }
        }
Exemple #3
0
        public override void ParseParameter(string[] parameters, FileInfo sourceFilePath, int lineNumber, IAssemblerContext context)
        {
            string reference = parameters[0];

            if (Util.IsPathWithWildcards(reference))
            {
                string referenceAbsolutePath = Path.IsPathRooted(reference) ? reference : null;
                referenceAbsolutePath = referenceAbsolutePath ?? Path.Combine(sourceFilePath.DirectoryName, reference);
                context.AddReferences(Util.DirectoryGetFilesWithWildcards(referenceAbsolutePath));
            }
            else
            {
                bool foundReference = false;
                foreach (string candidateReferenceLocation in EnumerateReferencePathCandidates(sourceFilePath, reference))
                {
                    if (Util.FileExists(candidateReferenceLocation))
                    {
                        context.AddReference(candidateReferenceLocation);
                        foundReference = true;
                        break;
                    }
                }

                if (!foundReference)
                {
                    throw new Error(
                              "\t{0}({1}): error: Sharpmake.Reference file not found: {2}{3}Those paths were evaluated as candidates:{3}  - {4}",
                              sourceFilePath.FullName,
                              lineNumber,
                              reference,
                              Environment.NewLine,
                              string.Join(Environment.NewLine + "  - ", EnumerateReferencePathCandidates(sourceFilePath, reference))
                              );
                }
            }
        }