コード例 #1
0
    private TargetParseResult ParseIntoTarget(
        State state, TargetParseResult tpr,
        string sourcesFileName, string exclusionsFileName,
        TargetParseResult fallbackTarget
        )
    {
        if (!File.Exists(sourcesFileName))
        {
            if (state.ExclusionsFileName == null && File.Exists(exclusionsFileName))
            {
                Console.Error.WriteLine($"// Exclusion file {exclusionsFileName} exists, but not {sourcesFileName} - {fallbackTarget != null} {fallbackTarget?.Exclusions}!");
                state.ExclusionsFileName = exclusionsFileName;
            }
            if (fallbackTarget != null)
            {
                if (TraceLevel >= 2)
                {
                    Console.Error.WriteLine($"// Not found: {sourcesFileName}, falling back to {fallbackTarget}");
                }
                tpr.Sources    = fallbackTarget.Sources;
                tpr.Exclusions = fallbackTarget.Exclusions;
                tpr.IsFallback = true;
                state.Result.TargetDictionary.Add(tpr.Key, tpr);
                return(tpr);
            }
            else
            {
                if (TraceLevel >= 1)
                {
                    Console.Error.WriteLine($"// Not found: {sourcesFileName}");
                }
                return(null);
            }
        }

        if (state.ExclusionsFileName != null)
        {
            exclusionsFileName = state.ExclusionsFileName;
        }

        tpr.Sources = ParseSingleFile(state, sourcesFileName, false);

        if (File.Exists(exclusionsFileName))
        {
            tpr.Exclusions = ParseSingleFile(state, exclusionsFileName, true);
        }

        state.Result.TargetDictionary.Add(tpr.Key, tpr);
        return(tpr);
    }
コード例 #2
0
    private TargetParseResult ParseTarget(State state, string prefix, TargetParseResult fallbackTarget)
    {
        // FIXME: We determine the prefix for the pair of sources and exclusions,
        //  which may not match intended behavior:
        // if linux_net_4_x_foo.sources is present, but linux_net_4_x_foo.exclude.sources is not present,
        //  should net_4_x_foo.exclude.sources be used as a fallback? Maybe it should.
        // This won't do that though.

        var tpr = new TargetParseResult {
            Key = (hostPlatform : state.HostPlatform, profile : state.ProfileName)
        };

        var sourcesFileName    = prefix + ".sources";
        var exclusionsFileName = prefix + ".exclude.sources";

        if (!File.Exists(sourcesFileName))
        {
            if (fallbackTarget != null)
            {
                if (TraceLevel >= 2)
                {
                    Console.Error.WriteLine($"// Not found: {sourcesFileName}, falling back to {fallbackTarget}");
                }
                tpr.Sources    = fallbackTarget.Sources;
                tpr.Exclusions = fallbackTarget.Exclusions;
                tpr.IsFallback = true;
                state.Result.TargetDictionary.Add(tpr.Key, tpr);
                return(tpr);
            }
            else
            {
                if (TraceLevel >= 2)
                {
                    Console.Error.WriteLine($"// Not found: {sourcesFileName}");
                }
                return(null);
            }
        }

        tpr.Sources = ParseSingleFile(state, sourcesFileName, false);

        if (File.Exists(exclusionsFileName))
        {
            tpr.Exclusions = ParseSingleFile(state, exclusionsFileName, true);
        }

        state.Result.TargetDictionary.Add(tpr.Key, tpr);
        return(tpr);
    }
コード例 #3
0
    private TargetParseResult ParseTarget(State state, string prefix, TargetParseResult fallbackTarget)
    {
        // FIXME: We determine the prefix for the pair of sources and exclusions,
        //  which may not match intended behavior:
        // if linux_net_4_x_foo.sources is present, but linux_net_4_x_foo.exclude.sources is not present,
        //  should net_4_x_foo.exclude.sources be used as a fallback? Maybe it should.
        // This won't do that though.

        var tpr = new TargetParseResult {
            Key = (hostPlatform : state.HostPlatform, profile : state.ProfileName)
        };

        var sourcesFileName    = prefix + ".sources";
        var exclusionsFileName = prefix + ".exclude.sources";

        return(ParseIntoTarget(state, tpr, sourcesFileName, exclusionsFileName, fallbackTarget));
    }
コード例 #4
0
 private void StripFallbackTargetsOrDefaultTarget(
     State state, TargetParseResult defaultTarget, List <TargetParseResult> fallbackTargets, int maximumCount
     )
 {
     if (fallbackTargets.Count == maximumCount)
     {
         // If we didn't find any platform specific targets, remove them and just leave one single
         //  platform-specific target entry
         foreach (var target in fallbackTargets)
         {
             state.Result.TargetDictionary.Remove(target.Key);
         }
     }
     else if (defaultTarget != null)
     {
         // Otherwise, strip the non-platform-specific target
         state.Result.TargetDictionary.Remove(defaultTarget.Key);
     }
 }
コード例 #5
0
    private TargetParseResult ParseIntoTarget(
        State state, TargetParseResult tpr,
        string sourcesFileName, string exclusionsFileName,
        TargetParseResult fallbackTarget, string overrideDirectory = null
        )
    {
        if (!File.Exists(sourcesFileName))
        {
            if (fallbackTarget != null)
            {
                if (TraceLevel >= 2)
                {
                    Console.Error.WriteLine($"// Not found: {sourcesFileName}, falling back to {fallbackTarget}");
                }
                tpr.Sources    = fallbackTarget.Sources;
                tpr.Exclusions = fallbackTarget.Exclusions;
                tpr.IsFallback = true;
                state.Result.TargetDictionary.Add(tpr.Key, tpr);
                return(tpr);
            }
            else
            {
                if (TraceLevel >= 1)
                {
                    Console.Error.WriteLine($"// Not found: {sourcesFileName}");
                }
                return(null);
            }
        }

        tpr.Sources = ParseSingleFile(state, sourcesFileName, false, overrideDirectory: overrideDirectory);

        if (File.Exists(exclusionsFileName))
        {
            tpr.Exclusions = ParseSingleFile(state, exclusionsFileName, true, overrideDirectory: overrideDirectory);
        }

        state.Result.TargetDictionary.Add(tpr.Key, tpr);
        return(tpr);
    }