Exemple #1
0
        void SetEntryPoint(FunctionDefinition entry)
        {
            Debug.Assert(entry.GetAttribute("COMPILE.ENTRY") == "TRUE");
            var d = entry;

            var output = d.GetAttribute("COMPILE.OUTPUT", false);

            if (output != null)
            {
                CompilerOptionsBuild._i.output = output;
            }

            var asm = d.GetAttribute("COMPILE.ASM");

            if (asm == "TRUE")
            {
                CompilerOptionsBuild._i.asm = true;
            }
            else if (asm == "FALSE")
            {
                CompilerOptionsBuild._i.asm = false;
            }
            var ll = d.GetAttribute("COMPILE.LL");

            if (ll == "TRUE")
            {
                CompilerOptionsBuild._i.ll = true;
            }
            else if (ll == "FALSE")
            {
                CompilerOptionsBuild._i.ll = false;
            }
            var bc = d.GetAttribute("COMPILE.BC");

            if (bc == "TRUE")
            {
                CompilerOptionsBuild._i.bc = true;
            }
            else if (bc == "FALSE")
            {
                CompilerOptionsBuild._i.bc = false;
            }

            var opt = d.GetAttribute("COMPILE.OPT");

            if (int.TryParse(opt, out int opt_level))
            {
                CompilerOptionsBuild._i.optimizationLevel = opt_level;
            }

            var debugInfo = d.GetAttribute("COMPILE.DEBUGINFO");

            if (debugInfo == "TRUE")
            {
                CompilerOptionsBuild._i.debugInfo = true;
            }
            else if (debugInfo == "FALSE")
            {
                CompilerOptionsBuild._i.debugInfo = false;
            }

            var cpu = d.GetAttribute("COMPILE.CPU");

            if (!string.IsNullOrWhiteSpace(cpu))
            {
                CompilerOptionsBuild._i.cpu = cpu;
            }

            var run = d.GetAttribute("COMPILE.RUN");

            if (run == "TRUE")
            {
                CompilerOptionsBuild._i.runAfterCompile = true;
            }
            else if (run == "FALSE")
            {
                CompilerOptionsBuild._i.runAfterCompile = false;
            }

            var dll = d.GetAttribute("COMPILE.DLL");

            if (dll == "TRUE")
            {
                CompilerOptionsBuild._i.dll = true;
            }
            else if (dll == "FALSE")
            {
                CompilerOptionsBuild._i.dll = false;
            }


            var libs = d.GetAttribute("COMPILE.LIBS", upperCase: false);

            if (libs != null)
            {
                var ls = libs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var lib in ls)
                {
                    var tlib = lib.Trim();
                    CompilerOptionsBuild._i.libs.Add(tlib);
                }
            }

            {
                var fullPath = Path.GetFullPath(@"..\lib", Path.GetDirectoryName(entry.token.filename));
                CompilerOptionsBuild._i.lib_path.Add(fullPath);
            }
            var lib_path = d.GetAttribute("COMPILE.PATH", upperCase: false);

            if (lib_path != null)
            {
                var lp = lib_path.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var p in lp)
                {
                    var tp       = p.Trim();
                    var fullPath = Path.GetFullPath(tp, Path.GetDirectoryName(entry.token.filename));
                    CompilerOptionsBuild._i.lib_path.Add(fullPath);
                }
            }
        }