Exemple #1
0
        public override void Init(Context context)
        {
            if (MinGW)
            {
                NativeLibraryExtension = Configurables.Defaults.MonoHostMingwRuntimeNativeLibraryExtension;
                NativeLibraryDirPrefix = Configurables.Paths.MonoRuntimeHostMingwNativeLibraryPrefix;
            }
            else
            {
                NativeLibraryExtension = Configurables.Defaults.NativeLibraryExtension;
            }

            if (Context.IsNativeHostAbi(Name))
            {
                OutputAotProfilerFilename = Configurables.Defaults.MonoRuntimeOutputAotProfilerFilename;
                OutputProfilerFilename    = Configurables.Defaults.MonoRuntimeOutputProfilerFilename;
            }
            else
            {
                OutputAotProfilerFilename = String.Empty;
                OutputProfilerFilename    = String.Empty;
            }
            OutputMonoBtlsFilename        = String.Empty;
            OutputMonoPosixHelperFilename = Configurables.Defaults.MonoRuntimeOutputMonoPosixHelperFilename;

            if (Context.IsMingwHostAbi(Name))
            {
                string prefix;
                if (Context.Is32BitMingwHostAbi(Name))
                {
                    prefix = Context.Properties.GetRequiredValue(KnownProperties.MingwCommandPrefix32);
                }
                else if (Context.Is64BitMingwHostAbi(Name))
                {
                    prefix = Context.Properties.GetRequiredValue(KnownProperties.MingwCommandPrefix64);
                }
                else
                {
                    throw new InvalidOperationException($"MinGW host ABI {Name} is neither 32 nor 64-bit (?!)");
                }
                Strip = Path.Combine(Configurables.Paths.MingwBinDir, $"{prefix}-strip");
            }
            else
            {
                Strip      = "strip";
                StripFlags = "-S";
            }

            InitOS();
        }
Exemple #2
0
        async Task <(bool disabled, bool success)> ConfigureBuildAndInstall(Context context, string abiName)
        {
            if (!context.IsHostJitAbiEnabled(abiName))
            {
                Log.DebugLine($"Windows target {abiName} disabled, not building libzip");
                return(true, true);
            }

            bool   sixtyFourBit = context.Is64BitMingwHostAbi(abiName);
            string sourceDir    = context.Properties.GetRequiredValue(KnownProperties.LibZipSourceFullPath);
            string buildDir     = Path.Combine(Configurables.Paths.BuildBinDir, $"libzip-windows-{abiName}");
            string stampFile    = Path.Combine(buildDir, $".build-{context.BuildInfo.FullLibZipHash}");
            string outputPath;

            if (sixtyFourBit)
            {
                outputPath = Path.Combine("x64", LibZipName);
            }
            else
            {
                outputPath = LibZipName;
            }

            string sourceFile = Path.Combine(buildDir, "lib", LibZipName);
            string destFile   = Path.Combine(Configurables.Paths.LibZipOutputPath, outputPath);
            bool   needBuild;

            if (Utilities.FileExists(stampFile) && Utilities.FileExists(sourceFile))
            {
                Log.DebugLine($"LibZip-Windows build stamp file exists: {stampFile}");
                Log.StatusLine($"LibZip for {abiName} already built, skipping compilation");
                needBuild = false;
            }
            else
            {
                needBuild = true;
            }

            if (needBuild)
            {
                Utilities.DeleteDirectorySilent(buildDir);
                Utilities.CreateDirectory(buildDir);
                List <string> arguments = GetCmakeArguments(context, buildDir, sixtyFourBit);

                string logTag = $"libzip-windows-{abiName}";
                var    cmake  = new CMakeRunner(context);
                bool   result = await cmake.Run(
                    logTag : logTag,
                    sourceDirectory : sourceDir,
                    workingDirectory : buildDir,
                    arguments : arguments
                    );

                if (!result)
                {
                    return(false, false);
                }

                var ninja = new NinjaRunner(context);
                result = await ninja.Run(
                    logTag : logTag,
                    workingDirectory : buildDir
                    );

                if (!result)
                {
                    return(false, false);
                }
            }

            Utilities.CopyFile(sourceFile, destFile);

            if (!File.Exists(destFile))
            {
                Log.ErrorLine($"Failed to copy {sourceFile} to {destFile}");
                return(false, false);
            }

            TouchStampFile(stampFile);
            return(false, true);
        }