func cmd(name, args)
{
    var filename = Env.GetRealExecutablePath(name).ToString();
    Console.Write($"Running command, {filename}");
    each(var arg : args)
        Console.Write($" {arg}");
    Console.WriteLine();
    var p= Process.Start({
        FileName = filename,
        Arguments = args
    });
    p.Join();
}
func main(args)
{
    
    var args2=["c","-o","./Tesses.CrossLang.BuildEssentials/bin-tmp","-r","./Tesses.CrossLang.BuildEssentials/res","-n","Tesses.CrossLang.BuildEssentials","-v","1.0.0.0-dev","Tesses.CrossLang.BuildEssentials/main.tcross"];
    each(var f : FS.Local.EnumeratePaths("./Tesses.CrossLang.BuildEssentials/src"))
    {
        if(f.GetExtension() == ".tcross")
        {
            args2.Add(f.ToString());
        }
    }
    


    cmd("crosslang", args2);
    cmd("crosslang",["vm","./Tesses.CrossLang.BuildEssentials/bin-tmp/Tesses.CrossLang.BuildEssentials-1.0.0.0-dev.crvm","Tesses.CrossLang.Shell"]);
    cmd("crosslang",["vm","./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-dev.crvm","build","Tesses.CrossLang.PackageServer"]);
    cmd("crosslang",["vm","./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-dev.crvm","build","Tesses.CrossLang.Std"]);
    cmd("crosslang",["vm","./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-dev.crvm","build","Templates/console"]);
    cmd("crosslang",["vm","./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-dev.crvm","build","Templates/emptyweb"]);
    cmd("crosslang",["vm","./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-dev.crvm","build","Templates/web"]);
    cmd("crosslang",["vm","./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-dev.crvm","build","Templates/template"]);
    cmd("crosslang",["vm","./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-dev.crvm","build","Templates/lib"]);
    cmd("crosslang",["vm","./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-dev.crvm","build","Templates/compiletool"]);
    cmd("crosslang",["vm","./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-dev.crvm","build","Templates/tool"]);
    cmd("crosslang",["vm","./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-dev.crvm","build","Templates/webapp"]);
    cmd("crosslang",["vm","./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-dev.crvm","build","Templates/npmweb"]);
    cmd("crosslang",["vm","./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-dev.crvm","build","Templates/npmwebapp"]);
    
    /*
    cmd("crossvm",["./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-dev.crvm","build","Tesses.CrossLang.PackageServer"]);
    cmd("crossvm",["./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-dev.crvm","build","Tesses.CrossLang.PackageServer"]);
    cmd("crossvm",["./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-dev.crvm","build","Tesses.CrossLang.PackageServer"]);
    */
    cmd("crosslang",["vm","./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-dev.crvm","build","crosslang_shell_archive_maker"]);
    
    if(args.Length > 1)
    {
        if(args[1] == "install")
        {
            cmd("crosslang",["vm","crosslang_shell_archive_maker/bin/crosslang_shell_archive_maker-1.0.0.0-dev.crvm", "install"]);
        }
        else if(args[1] == "pack")
        {
            cmd("crosslang",["vm","crosslang_shell_archive_maker/bin/crosslang_shell_archive_maker-1.0.0.0-dev.crvm"]);
        }
    }
}
