Ejemplo n.º 1
0
        private static DirectoryPath GetFrameworkPath(ICakeEnvironment environment, PlatformTarget target, string version)
        {
            // Get the Microsoft .NET folder.
            var windowsFolder = environment.GetSpecialPath(SpecialPath.Windows);
            var netFolder     = windowsFolder.Combine("Microsoft.NET");

            if (target == PlatformTarget.MSIL)
            {
                // Get the framework folder.
                var is64Bit         = environment.Is64BitOperativeSystem();
                var frameWorkFolder = is64Bit ? netFolder.Combine("Framework64") : netFolder.Combine("Framework");
                return(frameWorkFolder.Combine(version));
            }

            if (target == PlatformTarget.x86)
            {
                return(netFolder.Combine("Framework").Combine(version));
            }

            if (target == PlatformTarget.x64)
            {
                return(netFolder.Combine("Framework64").Combine(version));
            }

            throw new NotSupportedException();
        }
Ejemplo n.º 2
0
 ParsedProject(ExtProjectParserResult parsedProject, FilePath p, string configuration, PlatformTarget platform)
 {
     Configuration = configuration;
     Platform      = platform;
     ProjectFile   = p;
     Project       = parsedProject;
 }
Ejemplo n.º 3
0
    static FilePath PreProcessProject(ICakeContext context, PlatformTarget target, FilePath input)
    {
        var targetDirName = string.Format("{0}/build-analysis/{1}/{2}",
                                          BuildConfig.TargetDirectory,
                                          target,
                                          BuildConfig.Configuration);
        var directory = context.Directory(targetDirName);

        context.CreateDirectory(directory);
        var targetFile = directory.Path.CombineWithFilePath(input.GetFilename().ChangeExtension("tmp.xml"))
                         .MakeAbsolute(context.Environment);

        if (XBuildHelper.DotNetExists)
        {
            var buildSettings = CreatePreProcessingMSBuildSettings(target, targetFile);

            var tool = new DotNetGeneralTool(context.FileSystem,
                                             context.Environment,
                                             context.ProcessRunner,
                                             context.Tools);
            tool.DotNetMSBuild(input, buildSettings);
            return(targetFile);
        }
        if (context.Environment.Platform.Family == PlatformFamily.Windows)
        {
            var buildSettings = CreatePreProcessingMSBuildSettings(target, targetFile);
            context.MSBuild(input, buildSettings);
            return(targetFile);
        }
        return(input);
    }
Ejemplo n.º 4
0
        protected async override Task SetTargetAsync(ISelfDisposingBitmapDrawable image, bool animated)
        {
            ThrowIfCancellationRequested();

            var ffDrawable = image as FFBitmapDrawable;

            if (ffDrawable != null)
            {
                if (ffDrawable.IsAnimationRunning)
                {
                    await Task.Delay(ffDrawable.FadeDuration + 25);
                }

                if (animated)
                {
                    ISelfDisposingBitmapDrawable placeholderDrawable = null;
                    if (_loadingPlaceholderWeakReference != null && _loadingPlaceholderWeakReference.TryGetTarget(out placeholderDrawable) && placeholderDrawable != null)
                    {
                        int fadeDuration = Parameters.FadeAnimationDuration.HasValue ?
                                           Parameters.FadeAnimationDuration.Value : Configuration.FadeAnimationDuration;

                        placeholderDrawable?.SetIsRetained(true);
                        ffDrawable?.SetPlaceholder(placeholderDrawable as BitmapDrawable, fadeDuration);
                        placeholderDrawable?.SetIsRetained(false);
                    }
                }
            }

            await MainThreadDispatcher.PostAsync(() =>
            {
                ThrowIfCancellationRequested();

                PlatformTarget.Set(this, image, animated);
            }).ConfigureAwait(false);
        }
Ejemplo n.º 5
0
        private static string GetPlatformName(PlatformTarget platform, bool isSolution)
        {
            switch (platform)
            {
            case PlatformTarget.MSIL:
                // Solutions expect "Any CPU", but projects expect "AnyCPU"
                return(isSolution ? "\"Any CPU\"" : "AnyCPU");

            case PlatformTarget.x86:
                return("x86");

            case PlatformTarget.x64:
                return("x64");

            case PlatformTarget.ARM:
                return("arm");

            case PlatformTarget.ARM64:
                return("arm64");

            case PlatformTarget.Win32:
                return("Win32");

            default:
                throw new ArgumentOutOfRangeException(nameof(platform), platform, "Invalid platform");
            }
        }
Ejemplo n.º 6
0
 static string PlatformAsString(PlatformTarget t)
 {
     if (t == PlatformTarget.MSIL)
     {
         return("AnyCPU");
     }
     return(t.ToString());
 }
Ejemplo n.º 7
0
 public static string ConvertPlatformTargetToString(PlatformTarget target)
 {
     if (PlatformTarget.MSIL == target)
     {
         return("AnyCPU");
     }
     return(target.ToString());
 }
 protected override Task SetTargetAsync(UIImage image, bool animated)
 {
     return(MainThreadDispatcher.PostAsync(() =>
     {
         ThrowIfCancellationRequested();
         PlatformTarget.Set(this, image, animated);
     }));
 }
Ejemplo n.º 9
0
        protected async override Task SetTargetAsync(SelfDisposingBitmapDrawable image, bool animated)
        {
            if (Target == null)
            {
                return;
            }

            ThrowIfCancellationRequested();

            var ffDrawable = image as FFBitmapDrawable;

            if (ffDrawable != null)
            {
                if (ffDrawable.IsAnimationRunning)
                {
                    var mut = new FFBitmapDrawable(Context.Resources, ffDrawable.Bitmap, ffDrawable);
                    ffDrawable = mut as FFBitmapDrawable;
                    image      = ffDrawable;

                    // old hacky workaround
                    //await Task.Delay(ffDrawable.FadeDuration + 50).ConfigureAwait(false);
                }

                if (animated)
                {
                    SelfDisposingBitmapDrawable placeholderDrawable = null;
                    PlaceholderWeakReference?.TryGetTarget(out placeholderDrawable);

                    if (placeholderDrawable == null)
                    {
                        // Enable fade animation when no placeholder is set and the previous image is not null
                        var imageView = PlatformTarget.Control as ImageViewAsync;
                        placeholderDrawable = imageView?.Drawable as SelfDisposingBitmapDrawable;
                    }

                    if (placeholderDrawable.IsValidAndHasValidBitmap())
                    {
                        int fadeDuration = Parameters.FadeAnimationDuration.HasValue ?
                                           Parameters.FadeAnimationDuration.Value : Configuration.FadeAnimationDuration;

                        placeholderDrawable?.SetIsRetained(true);
                        ffDrawable?.SetPlaceholder(placeholderDrawable, fadeDuration);
                        placeholderDrawable?.SetIsRetained(false);
                    }
                }
                else
                {
                    ffDrawable?.SetPlaceholder(null, 0);
                }
            }

            await MainThreadDispatcher.PostAsync(() =>
            {
                ThrowIfCancellationRequested();

                PlatformTarget.Set(this, image, animated);
            }).ConfigureAwait(false);
        }
 public ProjectBuildConfiguration(
     string configurationName,
     string platformName,
     PlatformTarget platformTarget,
     string outputPath)
 {
     ConfigurationName = configurationName;
     PlatformName      = platformName;
     PlatformTarget    = platformTarget;
     OutputPath        = outputPath;
 }
        protected override async Task SetTargetAsync(SharedEvasImage image, bool animated)
        {
            if (Target == null)
            {
                return;
            }

            await MainThreadDispatcher.PostAsync(() =>
            {
                ThrowIfCancellationRequested();
                PlatformTarget.Set(this, image, animated);
            }).ConfigureAwait(false);
        }
Ejemplo n.º 12
0
        protected override Task SetTargetAsync(PImage image, bool animated)
        {
            if (Target == null)
            {
                return(Task.FromResult(true));
            }

            return(MainThreadDispatcher.PostAsync(() =>
            {
                ThrowIfCancellationRequested();
                PlatformTarget.Set(this, image, animated);
            }));
        }
Ejemplo n.º 13
0
        public static string GetCompilerArgument(PlatformTarget target)
        {
            switch (target)
            {
                case PlatformTarget.AnyCPU:
                    return "/platform:anycpu";
                case PlatformTarget.Itanium:
                    return "/platform:Itanium";
                case PlatformTarget.x64:
                    return "/platform:x64";
                case PlatformTarget.x86:
                    return "/platform:x86";
            }

            throw new NotSupportedException("Unknown platform target specified");
        }
Ejemplo n.º 14
0
        public static string ToSolutionFileToken(this PlatformTarget platformTarget)
        {
            switch (platformTarget)
            {
            case PlatformTarget.AnyCPU:
                return(SolutionFileUtilities.AnyCpuSolutionFileReleasePlatformToken);

            case PlatformTarget.x32:
                return(SolutionFileUtilities.x86SolutionFileReleasePlatformToken);    // x32 is x86.

            case PlatformTarget.x64:
                return(SolutionFileUtilities.x64SolutionFileReleasePlatformToken);

            default:
                throw new Exception(EnumHelper.UnexpectedEnumerationValueMessage(platformTarget));
            }
        }
Ejemplo n.º 15
0
        private static string GetPlatformName(PlatformTarget platform)
        {
            switch (platform)
            {
            case PlatformTarget.MSIL:
                return("\"Any CPU\"");

            case PlatformTarget.x86:
                return("x86");

            case PlatformTarget.x64:
                return("x64");

            default:
                throw new InvalidEnumArgumentException("platform", (int)platform, typeof(PlatformTarget));
            }
        }
        protected async override Task SetTargetAsync(SelfDisposingBitmapDrawable image, bool animated)
        {
            ThrowIfCancellationRequested();

            var ffDrawable = image as FFBitmapDrawable;

            if (ffDrawable != null)
            {
                if (ffDrawable.IsAnimationRunning)
                {
                    var mut = new FFBitmapDrawable(Context.Resources, ffDrawable.Bitmap, ffDrawable);
                    ffDrawable = mut as FFBitmapDrawable;
                    image      = ffDrawable;

                    // old hacky workaround
                    //await Task.Delay(ffDrawable.FadeDuration + 50).ConfigureAwait(false);
                }

                if (animated)
                {
                    SelfDisposingBitmapDrawable placeholderDrawable = null;
                    if (PlaceholderWeakReference != null && PlaceholderWeakReference.TryGetTarget(out placeholderDrawable) && placeholderDrawable != null)
                    {
                        int fadeDuration = Parameters.FadeAnimationDuration.HasValue ?
                                           Parameters.FadeAnimationDuration.Value : Configuration.FadeAnimationDuration;

                        placeholderDrawable?.SetIsRetained(true);
                        ffDrawable?.SetPlaceholder(placeholderDrawable, fadeDuration);
                        placeholderDrawable?.SetIsRetained(false);
                    }
                }
                else
                {
                    ffDrawable?.SetPlaceholder(null, 0);
                }
            }

            await MainThreadDispatcher.PostAsync(() =>
            {
                ThrowIfCancellationRequested();

                PlatformTarget.Set(this, image, animated);
            }).ConfigureAwait(false);
        }
Ejemplo n.º 17
0
    static MSBuildSettings CreatePreProcessingMSBuildSettings(PlatformTarget target, FilePath targetFile)
    {
        var settings = new AnyBuildSettings(BuildConfig.BuildSettings);

        settings.PlatformTarget = target;
        var buildSettings  = XBuildHelper.CreateMSBuildSettings(settings);
        var argsCustomizer = buildSettings.ArgumentCustomization;

        buildSettings.ArgumentCustomization = args =>
        {
            if (argsCustomizer != null)
            {
                args = argsCustomizer.Invoke(args);
            }
            args.AppendQuoted("/preprocess:" + targetFile.FullPath);
            return(args);
        };
        return(buildSettings);
    }
Ejemplo n.º 18
0
        public static string GetCompilerArgument(PlatformTarget target)
        {
            switch (target)
            {
            case PlatformTarget.AnyCPU:
                return("/platform:anycpu");

            case PlatformTarget.Itanium:
                return("/platform:Itanium");

            case PlatformTarget.x64:
                return("/platform:x64");

            case PlatformTarget.x86:
                return("/platform:x86");
            }

            throw new NotSupportedException("Unknown platform target specified");
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Gets the cpu target for the application.
        /// </summary>
        /// <param name="appInfo">The application info structure.</param>
        /// <returns>CPU target</returns>
        private CpuTarget GetCpuTarget(ApplicationInfo appInfo)
        {
            this.startupLogger.Info(Strings.DetectingCpuTarget);

            string[] allAssemblies = Directory.GetFiles(appInfo.Path, "*.dll", SearchOption.AllDirectories);

            CpuTarget target = CpuTarget.X64;

            foreach (string assembly in allAssemblies)
            {
                target = PlatformTarget.DetectPlatform(assembly);
                if (target == CpuTarget.X86)
                {
                    break;
                }
            }

            this.startupLogger.Info(Strings.DetectedCpuTarget, target.ToString());

            return(target);
        }
Ejemplo n.º 20
0
        private static string GetPlatformName(PlatformTarget platform)
        {
            switch (platform)
            {
            case PlatformTarget.MSIL:
                return("\"Any CPU\"");

            case PlatformTarget.x86:
                return("x86");

            case PlatformTarget.x64:
                return("x64");

            case PlatformTarget.ARM:
                return("arm");

            case PlatformTarget.Win32:
                return("Win32");

            default:
                throw new ArgumentOutOfRangeException("platform", platform, "Invalid platform");
            }
        }
Ejemplo n.º 21
0
    public static void InvokeXBuild(FilePath path, AnyBuildSettings settings, PlatformTarget platformTarget)
    {
        settings = new AnyBuildSettings(settings);
        settings.PlatformTarget = platformTarget;

        if (settings == null)
        {
            throw new ArgumentNullException("settings");
        }

        var targets = new List <string>();

        targets.AddRange(settings.Targets);
        if (targets.Count == 0)
        {
            targets.Add("Build");
        }

        var relativeProjectFile = Context.Environment.WorkingDirectory.GetRelativePath(path);

        Context.Log.Verbose(string.Format("Starting build for {0} with platform {1}", relativeProjectFile,
                                          platformTarget));

        foreach (var target in targets)
        {
            if (Context.Environment.Platform.Family == PlatformFamily.Windows && !BuildConfig.UseXBuildOnWindows)
            {
                Context.MSBuild(path, XBuildHelper.CreateMSBuildSettings(settings, target));
            }
            else
            {
                Context.XBuild(path, XBuildHelper.CreateXBuildSettings(settings, path, target));
            }
        }
        Context.Log.Verbose(string.Format("Finished build for {0} with platform {1}", relativeProjectFile,
                                          platformTarget));
    }
        /// <summary>
        /// Compiles a scene graph into a windows platform .NET executable.
        /// </summary>
        /// <param name="graph">
        /// The specified scene graph to compile source from.
        /// </param>
        /// <returns>
        /// A Stream comprising the compilation output
        /// </returns>
        public static Stream Compile(SceneGraph graph, PlatformTarget platform = PlatformTarget.Windows)
        {
            Stream        s;
            MemoryStream  ms;
            ILRepack      repack;
            RepackOptions options;
            string        source;
            bool          compiled;
            string        tmpExeFile;
            string        tmpExeFileRepacked;

            byte[] data;

            source = CompileAsObjects(graph);

            compiled = CompileCSharp(source, out tmpExeFile);

            tmpExeFileRepacked = Path.GetTempFileName() + ".exe";

            options = new RepackOptions()
            {
                TargetKind      = ILRepack.Kind.Exe,
                Parallel        = true,
                Internalize     = true,
                InputAssemblies = new string[] { tmpExeFile },
                OutputFile      = tmpExeFileRepacked
            };
            repack = new ILRepack(options);

            data = File.ReadAllBytes(tmpExeFileRepacked);
            ms   = new MemoryStream(data);

            s = ms;

            return(s);
        }
Ejemplo n.º 23
0
            public void Should_Get_Correct_Path_To_MSBuild_Version_35(MSBuildToolVersion version, PlatformTarget target, bool is64BitOperativeSystem, string expected)
            {
                // Given
                var fixture = new MSBuildRunnerFixture(is64BitOperativeSystem, true);

                fixture.Settings.ToolVersion    = version;
                fixture.Settings.PlatformTarget = target;

                // When
                fixture.Run();

                // Then
                fixture.AssertReceivedFilePath(expected);
            }
Ejemplo n.º 24
0
            public void Should_Get_Correct_Path_To_MSBuild_Version_35(MSBuildToolVersion version, PlatformTarget target, bool is64BitOperativeSystem, string expected)
            {
                // Given
                var fixture = new MSBuildRunnerFixture(is64BitOperativeSystem);
                var runner  = fixture.CreateRunner();

                // When
                runner.Run(new MSBuildSettings("./src/Solution.sln")
                {
                    ToolVersion    = version,
                    PlatformTarget = target
                });

                // Then
                fixture.ProcessRunner.Received(1).Start(Arg.Is <ProcessStartInfo>(
                                                            p => p.FileName == expected));
            }
Ejemplo n.º 25
0
        public static FilePath GetMSBuildPath(ICakeEnvironment environment, MSBuildToolVersion version, PlatformTarget target)
        {
            // Get the bin path for MSBuild.
            var binPath = GetMSBuildPath(environment, (MSBuildVersion)version, target);

            if (binPath == null)
            {
                throw new CakeException("Could not resolve MSBuild.");
            }

            // Get the MSBuild path.
            return(binPath.CombineWithFilePath("MSBuild.exe"));
        }
Ejemplo n.º 26
0
        private static DirectoryPath GetHighestAvailableMSBuildVersion(IFileSystem fileSystem, ICakeEnvironment environment, PlatformTarget target)
        {
            var versions = new[]
            {
                MSBuildVersion.MSBuild14,
                MSBuildVersion.MSBuild12,
                MSBuildVersion.MSBuild4,
                MSBuildVersion.MSBuild35,
                MSBuildVersion.MSBuild20
            };

            foreach (var version in versions)
            {
                var path = GetMSBuildPath(environment, version, target);
                if (fileSystem.Exist(path))
                {
                    return(path);
                }
            }
            return(null);
        }
Ejemplo n.º 27
0
        private static DirectoryPath GetMSBuildPath(ICakeEnvironment environment, MSBuildVersion version, PlatformTarget target)
        {
            switch (version)
            {
            case MSBuildVersion.MSBuild14:
                return(GetVisualStudioPath(environment, target, "14.0"));

            case MSBuildVersion.MSBuild12:
                return(GetVisualStudioPath(environment, target, "12.0"));

            case MSBuildVersion.MSBuild4:
                return(GetFrameworkPath(environment, target, "v4.0.30319"));

            case MSBuildVersion.MSBuild35:
                return(GetFrameworkPath(environment, target, "v3.5"));

            case MSBuildVersion.MSBuild20:
                return(GetFrameworkPath(environment, target, "v2.0.50727"));

            default:
                return(null);
            }
        }
 /// <summary>
 /// Sets the platform target.
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <param name="target">The target.</param>
 /// <returns>The same <see cref="MSBuildSettings"/> instance so that multiple calls can be chained.</returns>
 public static MSBuildSettings SetPlatformTarget(this MSBuildSettings settings, PlatformTarget target)
 {
     if (settings == null)
     {
         throw new ArgumentNullException(nameof(settings));
     }
     settings.PlatformTarget = target;
     return(settings);
 }
Ejemplo n.º 29
0
        private static DirectoryPath GetVisualStudioPath(ICakeEnvironment environment, PlatformTarget target, string version)
        {
            // Get the bin path.
            var programFilesPath = environment.GetSpecialPath(SpecialPath.ProgramFilesX86);
            var binPath          = programFilesPath.Combine(string.Concat("MSBuild/", version, "/Bin"));

            if (target == PlatformTarget.MSIL)
            {
                if (environment.Is64BitOperativeSystem())
                {
                    binPath = binPath.Combine("amd64");
                }
            }
            if (target == PlatformTarget.x64)
            {
                binPath = binPath.Combine("amd64");
            }
            return(binPath);
        }
Ejemplo n.º 30
0
        public static FilePath GetMSBuildPath(IFileSystem fileSystem, ICakeEnvironment environment, MSBuildToolVersion version, PlatformTarget target)
        {
            var binPath = (version == MSBuildToolVersion.Default)
                ? GetHighestAvailableMSBuildVersion(fileSystem, environment, target)
                : GetMSBuildPath(environment, (MSBuildVersion)version, target);

            if (binPath == null)
            {
                throw new CakeException("Could not resolve MSBuild.");
            }

            // Get the MSBuild path.
            return(binPath.CombineWithFilePath("MSBuild.exe"));
        }
        protected async override Task SetTargetAsync(SelfDisposingBitmapDrawable image, bool animated)
        {
            if (Target == null)
            {
                return;
            }

            ThrowIfCancellationRequested();

            if (image is FFBitmapDrawable ffDrawable)
            {
                if (ffDrawable.IsAnimationRunning)
                {
                    var mut = new FFBitmapDrawable(Context.Resources, ffDrawable.Bitmap, ffDrawable);
                    ffDrawable = mut as FFBitmapDrawable;
                    image      = ffDrawable;

                    // old hacky workaround
                    //await Task.Delay(ffDrawable.FadeDuration + 50).ConfigureAwait(false);
                }

                if (animated)
                {
                    SelfDisposingBitmapDrawable placeholderDrawable = null;
                    PlaceholderWeakReference?.TryGetTarget(out placeholderDrawable);

                    if (placeholderDrawable == null)
                    {
                        // Enable fade animation when no placeholder is set and the previous image is not null
                        var imageView = PlatformTarget.Control as ImageViewAsync;
                        placeholderDrawable = imageView?.Drawable as SelfDisposingBitmapDrawable;
                    }

                    var fadeDuration = Parameters.FadeAnimationDuration ?? Configuration.FadeAnimationDuration;

                    if (placeholderDrawable.IsValidAndHasValidBitmap())
                    {
                        placeholderDrawable?.SetIsRetained(true);
                        ffDrawable?.SetPlaceholder(placeholderDrawable, fadeDuration);
                        placeholderDrawable?.SetIsRetained(false);
                    }
                    else if (ffDrawable.IsValidAndHasValidBitmap())
                    {
                        var width  = ffDrawable.Bitmap.Width;
                        var height = ffDrawable.Bitmap.Height;
                        var bitmap = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888);

                        using (var canvas = new Canvas(bitmap))
                            using (var paint = new Paint()
                            {
                                Color = _placeholderHelperColor
                            })
                            {
                                canvas.DrawRect(0, 0, width, height, paint);
                            }

                        ffDrawable?.SetPlaceholder(new SelfDisposingBitmapDrawable(Context.Resources, bitmap), fadeDuration);
                    }
                }
                else
                {
                    ffDrawable?.SetPlaceholder(null, 0);
                }
            }

            await MainThreadDispatcher.PostAsync(() =>
            {
                ThrowIfCancellationRequested();

                PlatformTarget.Set(this, image, animated);
            }).ConfigureAwait(false);
        }