Пример #1
0
 void WriteMSBuildConfigureHostRuntimeCommands(StreamWriter sw, string indent, CmakeBuilds.RuntimeCommand command, Dictionary <string, string> replacements)
 {
     WriteMSBuildConfigureRuntimeCommands(
         sw,
         indent,
         $"$(IntermediateOutputPath)%(_HostRuntime.OutputDirectory)-{command.Suffix}",
         "$(OutputPath)/%(_HostRuntime.OutputDirectory)",
         "@(_HostRuntime)",
         CmakeBuilds.ConfigureHostRuntimeCommandsCommonFlags,
         command,
         replacements,
         false
         );
 }
Пример #2
0
        void WriteMSBuildConfigureRuntimeCommands(StreamWriter sw, string indent, string workingDirectory, string outputDirectory, string itemName, List <string> commonFlags, CmakeBuilds.RuntimeCommand command, Dictionary <string, string> replacements, bool needsApiLevel)
        {
            replacements["@CONFIGURATION@"]    = EnsureRequired("Configuration", command.Configuration);
            replacements["@BUILD_TYPE@"]       = EnsureRequired("BuildType", command.BuildType);
            replacements["@NATIVE_API_LEVEL@"] = needsApiLevel ? EnsureRequired("MSBuildApiLevel", command.MSBuildApiLevel) : String.Empty;
            replacements["@OUTPUT_DIRECTORY@"] = outputDirectory;

            var flags = new StringBuilder();

            flags.Append(String.Join(" ", commonFlags));

            if (command.ExtraOptions != null && command.ExtraOptions.Count > 0)
            {
                flags.Append(" ");
                flags.Append(String.Join(" ", command.ExtraOptions));
            }

            sw.WriteLine($"{indent}<MakeDir Directories=\"{workingDirectory}\" />");
            sw.WriteLine($"{indent}<ItemGroup>");
            sw.WriteLine($"{indent}  <_ConfigureRuntimeCommands Include=\"{itemName}\">");
            sw.WriteLine($"{indent}    <Command>$(CmakePath)</Command>");
            WriteProperty(sw, $"{indent}    ", "Arguments", flags, replacements);
            sw.WriteLine($"{indent}    <WorkingDirectory>{workingDirectory}</WorkingDirectory>");
            sw.WriteLine($"{indent}  </_ConfigureRuntimeCommands>");
            sw.WriteLine($"{indent}</ItemGroup>");
            sw.WriteLine();

            string EnsureRequired(string name, string v)
            {
                if (v.Length > 0)
                {
                    return(v);
                }

                throw new InvalidOperationException($"RuntimeCommand.{name} must not be an empty string");
            }
        }
Пример #3
0
        void WriteMSBuildConfigureAndroidRuntimeCommands(StreamWriter sw, string indent, CmakeBuilds.RuntimeCommand command, Dictionary <string, string> replacements)
        {
            const string LegacyOutputDirectory = "$(OutputPath)%(AndroidSupportedTargetJitAbi.Identity)";
            const string Net6OutputDirectory   = LegacyOutputDirectory + "-net6";

            WriteMSBuildConfigureRuntimeCommands(
                sw,
                indent,
                $"$(IntermediateOutputPath)%(AndroidSupportedTargetJitAbi.Identity)-{command.Suffix}",
                command.IsNet6 ? Net6OutputDirectory : LegacyOutputDirectory,
                "@(AndroidSupportedTargetJitAbi)",
                CmakeBuilds.ConfigureAndroidRuntimeCommandsCommonFlags,
                command,
                replacements,
                true
                );
        }
Пример #4
0
        void WriteShellRuntimeCommand(StreamWriter sw, Dictionary <string, string> abis, CmakeBuilds.RuntimeCommand command, Dictionary <string, string> replacements)
        {
            var    funcName = new StringBuilder();
            string indent   = "\t";

            foreach (var kvp in abis)
            {
                string abi             = kvp.Key;
                string apiLevelVarName = command.IsNet6 ? kvp.Value : kvp.Key;
                string outputDirName   = command.IsNet6 ? $"{abi}-net6" : abi;
                string isMxe           = "no";
                string mxeBitness      = String.Empty;
                bool   forMxe          = false;

                if (command.IsHost)
                {
                    if (String.Compare(abi, AbiNames.HostJit.Win32, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        mxeBitness = "32";
                    }
                    else if (String.Compare(abi, AbiNames.HostJit.Win64, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        mxeBitness = "64";
                    }

                    if (mxeBitness.Length > 0)
                    {
                        isMxe  = "yes";
                        forMxe = true;
                    }
                }

                if (command.IsHost)
                {
                    outputDirName = $"host-{outputDirName}";
                    abi           = $"host-{abi}";
                }

                funcName.Clear();
                funcName.Append(abi.ToLowerInvariant());
                funcName.Append('_');
                funcName.Append(command.Suffix.ToLowerInvariant());
                funcName.Replace('-', '_');

                sw.WriteLine();
                sw.WriteLine($"function _configure_{funcName}()");
                sw.WriteLine("{");
                sw.WriteLine($"{indent}local build_directory=\"$1\"");
                sw.WriteLine($"{indent}local rebuild=\"$2\"");
                sw.WriteLine($"{indent}local force=\"$3\"");
                sw.WriteLine();
                sw.WriteLine($"{indent}if [ -z \"${{build_directory}}\" ]; then");
                sw.WriteLine($"{indent}\tbuild_directory=\"${{MONODROID_OBJ_DIR}}\"");
                sw.WriteLine($"{indent}fi");
                sw.WriteLine($"{indent}__BUILD_DIR=\"${{build_directory}}/{abi}-{command.Suffix}\"");
                sw.WriteLine($"{indent}__OUTPUT_DIR=\"${{XA_INSTALL_DIR}}/{outputDirName}\"");
                sw.WriteLine($"{indent}__CONFIGURATION={command.Configuration}");
                sw.WriteLine($"{indent}__BUILD_TYPE={command.BuildType}");
                sw.WriteLine($"{indent}__REBUILD=\"${{rebuild}}\"");
                sw.WriteLine($"{indent}__FORCE=\"${{force}}\"");
                if (!command.IsHost)
                {
                    sw.WriteLine($"{indent}__NATIVE_ABI={abi}");
                    sw.WriteLine($"{indent}__NATIVE_API_LEVEL=${{{ApiLevelVariableNames[apiLevelVarName]}}}");
                }
                sw.WriteLine();
                if (!command.IsHost)
                {
                    sw.Write($"{indent}__xa_configure_android_runtime");
                }
                else
                {
                    sw.Write($"{indent}__xa_configure_host_runtime {isMxe}");
                }

                StringBuilder?flags = null;
                if (forMxe)
                {
                    flags = new StringBuilder(String.Join(" ", CmakeBuilds.MonodroidMxeCommonFlagsBitness));
                    replacements["@BITNESS@"] = mxeBitness;
                }

                if (command.ExtraOptions != null && command.ExtraOptions.Count > 0)
                {
                    if (flags == null)
                    {
                        flags = new StringBuilder();
                    }
                    else
                    {
                        flags.Append(" ");
                    }
                    flags.Append(String.Join(" ", command.ExtraOptions));
                }

                if (flags != null && flags.Length > 0)
                {
                    sw.Write(" ");
                    sw.Write(ApplyReplacements(flags, replacements));
                }

                sw.WriteLine();
                sw.WriteLine();
                sw.WriteLine("}");

                indent = "\t";
                sw.WriteLine();
                sw.WriteLine($"function _build_{funcName}()");
                sw.WriteLine("{");
                sw.WriteLine($"{indent}local build_directory=\"$1\"");
                sw.WriteLine();
                sw.WriteLine($"{indent}shift");
                sw.WriteLine($"{indent}if [ -z \"${{build_directory}}\" ]; then");
                sw.WriteLine($"{indent}\tbuild_directory=\"${{MONODROID_OBJ_DIR}}\"");
                sw.WriteLine($"{indent}fi");
                sw.WriteLine($"{indent}__BUILD_DIR=\"${{build_directory}}/{abi}-{command.Suffix}\"");
                sw.WriteLine();
                sw.WriteLine($"{indent}__xa_build \"$@\"");
                sw.WriteLine("}");
            }
            ;
        }