using System.Diagnostics;

namespace Nerfed.Builder;

public class ShaderImporter : IImporter
{
    public void Import(string inFile, string outFile)
    {
        using (Process proc = new Process())
        {
            string glslc;
            if (OperatingSystem.IsWindows())
            {
                glslc = "Win64/glslc.exe";
            }
            else if (OperatingSystem.IsLinux())
            {
                glslc = "Linux/glslc";
            }
            else
            {
                throw new PlatformNotSupportedException("No shader compiler found for current platform");
            }

            proc.StartInfo.FileName = glslc;
            proc.StartInfo.Arguments = @$"""{inFile}"" -o ""{outFile}"" -c";
            proc.StartInfo.CreateNoWindow = true;
            proc.StartInfo.UseShellExecute = false;
            proc.Start();
            proc.WaitForExit();
        }
    }
}
