Ejemplo n.º 1
0
    public static void clean(Taskman tm, string[] args)
    {
        tm.Rm($"{BHL_ROOT}/src/autogen.cs");

        foreach (var dll in tm.Glob($"{BHL_ROOT}/*.dll"))
        {
            if (!dll.StartsWith("bhl_"))
            {
                continue;
            }
            tm.Rm(dll);
            tm.Rm($"{dll}.mdb");
        }

        foreach (var exe in tm.Glob($"{BHL_ROOT}/*.exe"))
        {
            //NOTE: when removing itself under Windows we can get an exception, so let's force its staleness
            if (exe.EndsWith("bhlb.exe"))
            {
                tm.Touch(exe, new DateTime(1970, 3, 1, 7, 0, 0) /*some random date in the past*/);
                continue;
            }

            tm.Rm(exe);
            tm.Rm($"{exe}.mdb");
        }
    }
Ejemplo n.º 2
0
    public static void MCSBuild(Taskman tm, string[] srcs, string result, string opts = "", string binary = "mcs")
    {
        var files = new List <string>();

        foreach (var s in srcs)
        {
            files.AddRange(tm.Glob(s));
        }

        foreach (var f in files)
        {
            if (!File.Exists(f))
            {
                throw new Exception($"Bad file {f}");
            }
        }

        var refs = new List <string>();

        for (int i = files.Count; i-- > 0;)
        {
            if (files[i].EndsWith(".dll"))
            {
                refs.Add(files[i]);
                files.RemoveAt(i);
            }
        }

        if (files.Count == 0)
        {
            throw new Exception("No files");
        }

        string args = (refs.Count > 0 ? " -r:" + String.Join(" -r:", refs.Select(r => tm.CLIPath(r))) : "") + $" {opts} -out:{tm.CLIPath(result)} " + String.Join(" ", files.Select(f => tm.CLIPath(f)));
        string cmd  = binary + " " + args;

        uint   cmd_hash      = Hash.CRC32(cmd);
        string cmd_hash_file = $"{BHL_ROOT}/build/" + Hash.CRC32(result) + ".mhash";

        if (!File.Exists(cmd_hash_file) || File.ReadAllText(cmd_hash_file) != cmd_hash.ToString())
        {
            tm.Write(cmd_hash_file, cmd_hash.ToString());
        }

        files.Add(cmd_hash_file);

        if (tm.NeedToRegen(result, files) || tm.NeedToRegen(result, refs))
        {
            tm.Shell(binary, args);
        }
    }