/// <summary> /// Preprocess your code with the specified mode. /// This method will be automatically called when constructor calls. /// </summary> /// <param name="mode">The specified compile mode.</param> private void Preprocess(CompileMode mode) { XDocument xml; if (mode == CompileMode.FILE_PASS) { xml = XDocument.Load(filePath); } else { xml = XDocument.Parse(source); } // 버전 확인 var versionCheckQuery = from c in xml.Root.Descendants("mocca") select c.Attribute("version"); var version = 0; foreach (int i in versionCheckQuery) { version = i; break; } if (version > COMPILER_MINIMUM_VERSION) { Console.WriteLine("[-] File Version is not acceptable."); return; } // 파일 정보 추출 var fileInfoCheckQuery = from c in xml.Root.Descendants("meta") select c.Attribute("name").Value + "|" + c.Attribute("field").Value; foreach (string i in fileInfoCheckQuery) { string[] a = i.Split('|'); fileInfo.Add(a[0], a[1]); } // 외부 모듈 정보 추출 var extModuleCheckQuery = from c in xml.Root.Descendants("mod") select c.Attribute("name").Value; foreach (string i in extModuleCheckQuery) { extModules.Add(i); } // 원본 소스 추출 var sourceQuery = from c in xml.Root.Descendants("code") select c.Value; foreach (string i in sourceQuery) { source = i; break; } }
private void SetupCompileMode(CompileMode mode, ReadOnlyTargetRules Target) { LoadAirSimDependency(Target, "MavLinkCom", "MavLinkCom"); switch (mode) { case CompileMode.HeaderOnlyNoRpc: Definitions.Add("AIRLIB_HEADER_ONLY=1"); Definitions.Add("AIRLIB_NO_RPC=1"); AddLibDependency("AirLib", Path.Combine(AirLibPath, "lib"), "AirLib", Target, false); break; case CompileMode.HeaderOnlyWithRpc: Definitions.Add("AIRLIB_HEADER_ONLY=1"); AddLibDependency("AirLib", Path.Combine(AirLibPath, "lib"), "AirLib", Target, false); LoadAirSimDependency(Target, "rpclib", "rpc"); break; case CompileMode.CppCompileNoRpc: LoadAirSimDependency(Target, "MavLinkCom", "MavLinkCom"); Definitions.Add("AIRLIB_NO_RPC=1"); break; case CompileMode.CppCompileWithRpc: LoadAirSimDependency(Target, "rpclib", "rpc"); break; default: throw new System.Exception("CompileMode specified in plugin's Build.cs file is not recognized"); } }
private YieldFinishedCompile(GlobalPath scriptPath, int lineNumber, string fileContent, string contextIdentifier, CompilerOptions compilerOptions) { compileMode = CompileMode.RUN; path = scriptPath; startLineNum = lineNumber; content = fileContent; contextId = contextIdentifier; options = compilerOptions; }
public static T SetCompileMode <T>(this T registration, CompileMode compileMode) where T : IExpressionRegistration { if (registration == null) { throw new ArgumentNullException("registration"); } registration.CompileMode = compileMode; return(registration); }
public Compile(Gothic gothic, CompileMode compileMode) : base(gothic) { Mode = compileMode; compilingAssetsWatcher.OnFileCompile = (compilingFile) => { if (compilingFile.Contains("MENU.DAT")) { gothic.EndProcess(); } }; }
private void ExistingFile(CompileMode mode) { var directoryNode = CurrentNode as DirectoryNode; if (directoryNode == null) { return; } if (AddExistingFile != null) { AddExistingFile(null, directoryNode.DirectoryInfo.FullName, mode); } }
internal static string ToSerializedValue(this CompileMode value) { switch (value) { case CompileMode.Semantic: return("Semantic"); case CompileMode.Full: return("Full"); case CompileMode.SingleBox: return("SingleBox"); } return(null); }
public ExpressionRegistration(IResolver resolver, Expression <Func <IResolver, T> > expression, ILifetime lifetime, CompileMode compileMode = CompileMode.Delegate, object key = null) : base(lifetime: lifetime, key: key) { if (resolver == null) { throw new ArgumentNullException("resolver"); } if (expression == null) { throw new ArgumentNullException("expression"); } _resolver = resolver; CompileMode = compileMode; Expression = expression.Convert(); }
public ExpressionRegistration(Type type, Expression<Func<IResolver, object>> expression, ILifetime lifetime, object key = null, CompileMode compileMode = CompileMode.Dynamic) { if (type == null) throw new ArgumentNullException("type"); if (expression == null) throw new ArgumentNullException("expression"); _type = type; _expression = expression; SetFactory(expression); SetLifetime(lifetime); _key = key; _compileMode = compileMode; }
public static string GetAltCompileArg(CompileMode comp) { string cmode = ""; switch (comp) { case CompileMode.Debug: cmode = ""; break; case CompileMode.Release: cmode = " -r"; break; } return cmode; }
public static string GetAltCompileArg(CompileMode comp) { string cmode = ""; switch (comp) { case CompileMode.Debug: cmode = ""; break; case CompileMode.Release: cmode = " -r"; break; } return(cmode); }
public static string GetOutputFolderName(CompileMode comp) { string cmode = ""; switch (comp) { case CompileMode.Debug: cmode = "Debug"; break; case CompileMode.Release: cmode = "Release"; break; } return(cmode); }
public static string GetMsBuildCompileArg(CompileMode comp) { string cmode = ""; switch (comp) { case CompileMode.Debug: cmode = ""; break; case CompileMode.Release: cmode = " /p:Configuration=Release"; break; } return(cmode); }
/// <summary> /// Initializes a new instance of the <see cref="T:Mocca.Compiler"/> class. /// </summary> /// <param name="source">The source depends on your CompileMode.</param> /// <param name="mode">The Compile session mode.</param> public MoccaParser(String source, CompileMode mode) { switch (mode) { case CompileMode.FILE_PASS: this.filePath = source; Preprocess(CompileMode.FILE_PASS); break; case CompileMode.PURE_SOURCE_PASS: this.source = source; break; case CompileMode.XML_SOURCE_PASS: this.source = source; Preprocess(CompileMode.XML_SOURCE_PASS); break; } }
public IocContainer(Func <ILifetime> defaultLifetimeFactory = null, CompileMode defaultCompileMode = CompileMode.Delegate, IIndex index = null) { if (defaultLifetimeFactory != null) { _defaultLifetimeFactory = defaultLifetimeFactory; // Test if the lifetime factory returns valid ILifetime? } else { _defaultLifetimeFactory = () => new TransientLifetime(); } if (!Enum.IsDefined(typeof(CompileMode), defaultCompileMode)) { throw new ArgumentException("Invalid CompileMode value"); } _defaultCompileMode = defaultCompileMode; _index = index ?? new DirectIndex(); }
static void Main(string[] args) { ServiceProvider serviceProvider = RegisterServices(args); IConfiguration configuration = serviceProvider.GetService <IConfiguration>(); IAppSettings appSettings = serviceProvider.GetService <IAppSettings>(); ICompiler compiler = serviceProvider.GetService <ICompiler>(); ILogger logger = serviceProvider.GetService <ILogger <Program> >(); var exit = Parser.Default.ParseArguments <CompileOptions, Options>(args) .MapResult( (CompileOptions o) => { logger.LogInformation("{o}", JsonConvert.SerializeObject(o)); CompileMode m = o.CompileMode; //compiler return(0); }, (Options o) => { logger.LogInformation("{o}", JsonConvert.SerializeObject(o)); return(0); }, errs => 1); }
/// <summary> /// Processes a battle animation from a txt file, reading all referenced image files /// </summary> public BattleAnimMaker(string folder, string[] file) { FormLoading loading = new FormLoading(); loading.SetMessage("Processing animation..."); loading.Show(); AnimCode = new List <string> [12]; Graphics = new List <TileSheet>(); for (int i = 0; i < AnimCode.Length; i++) { AnimCode[i] = new List <string>(); } AddTileSheet(); Palettes = Palette.Split(GetPaletteFromFile(folder), 4); Frames = new List <OAM_Array>(); FrameData = new List <Tuple <uint, uint> >(); List <string> filenames = new List <string>(); List <Tuple <string, Point, Size> > affines = new List <Tuple <string, Point, Size> >(); CompileMode compile = CompileMode.Usual; bool new_frame = true; int mode = 0; // the current animation mode being processed int frame = 0; // the current frame number int affine = 0; // the current affine sprite number int duration = 0; // the current frame's duration decimal[] arguments; for (int line = 0; line < file.Length; line++) { loading.SetPercent(100 * ((float)line / (float)file.Length)); loading.SetMessage("Processing Anim Mode" + ((mode == 0 || mode == 2 || mode == 8) ? "s " + (mode + 1) + " and " + (mode + 2) : " " + (mode + 1)) + "..."); if (file[line] == null) { continue; } else if (file[line] == "") { continue; } else //try { for (int i = 0; i < file[line].Length; i++) { // Comments if (file[line][i] == '#') { break; } if (file[line][i] == '/' && file[line][i + 1] == '/') { break; } // Syntax switch (file[line][i]) { case ' ': continue; case '\t': continue; case 'c': case 'C': if (compile == CompileMode.Extra) { compile = CompileMode.Usual; } if (compile == CompileMode.Usual) { AnimCode[mode].Add("c" + file[line].Substring(i + 1, 2)); if (mode == 0 || mode == 2) { AnimCode[mode + 1].Add("c" + file[line].Substring(i + 1, 2)); } i += 2; continue; } else { throw new Exception("Unexpected 'c' command read."); } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (compile == CompileMode.Extra) { compile = CompileMode.Usual; } if (compile == CompileMode.Usual) { int length = 0; while (i + length < file[line].Length) { if (file[line][i + length] == ' ' || file[line][i + length] == '\t') { break; } else { length++; } } try { duration = int.Parse(file[line].Substring(i, length)); } catch { throw new Exception("Invalid duration number read:" + file[line].Substring(i, length)); } compile = CompileMode.Frame; i += (length - 1); continue; } else { throw new Exception("Unexpected frame duration number read."); } case 'f': case 'F': case 'b': case 'B': bool bg = (file[line][i] == 'b' || file[line][i] == 'B'); if ((bg && compile == CompileMode.Extra) || compile == CompileMode.Frame) { i++; string filename = ReadArgument_FileName(ref file, ref line, ref i); frame = -1; new_frame = true; for (int f = 0; f < filenames.Count; f++) { if (filename.Equals(filenames[f])) { frame = f; new_frame = false; break; } } if (frame == -1) { frame = filenames.Count; filenames.Add(filename); AddFrame(bg, new GBA.Image(folder + filename, Palettes[0]), filename); } // add the new frame's OAM if it hasn't yet been used if (bg) { if (mode == 0 || mode == 2 || mode == 8) { AnimCode[mode + 1][AnimCode[mode + 1].Count - 1] = duration + " f" + Util.ByteToHex((byte)frame); } else { throw new Exception("'b' background layer frame commands can only be used in animation modes 1, 3 and 9."); } } else { AnimCode[mode].Add(duration + " f" + Util.ByteToHex((byte)frame)); if (mode == 0 || mode == 2 || mode == 8) { AnimCode[mode + 1].Add(duration + " fFF"); } } compile = CompileMode.Extra; continue; } else { throw new Exception("Unexpected '" + (bg ? 'b' : 'f') + "' frame command read."); } case 'a': case 'A': case 'd': case 'D': bool big = (file[line][i] == 'd' || file[line][i] == 'D'); if (compile == CompileMode.Extra) { i++; string affinefile = ReadArgument_FileName(ref file, ref line, ref i); i++; arguments = ReadArgument_Numbers(ref file, ref line, ref i); if (arguments.Length != 2) { throw new Exception( "Expected affine sprite X and Y screen coordinates."); } Point coords = new Point((int)arguments[0], (int)arguments[1]); arguments = ReadArgument_Numbers(ref file, ref line, ref i); if (arguments.Length != 1 && arguments.Length != 4) { throw new Exception( "Expected affine sprite (angle) argument, or (Ux, Vx, Uy, and Vy) vector arguments."); } float[] vectors; if (arguments.Length == 1) // convert angle into (Ux Vx Uy Vy) { float cos = (float)Math.Cos((double)arguments[0]); float sin = (float)Math.Sin((double)arguments[1]); vectors = new float[4] { cos, sin, -sin, cos }; } else { vectors = new float[4] { (float)arguments[0], (float)arguments[1], (float)arguments[2], (float)arguments[3] } }; if (new_frame == false) { // if there's an affine on a preexisting frame, duplicate the OAM data if (AddDuplicateFrameWithAffines(mode, ref frame, ref filenames, coords, vectors)) { // if it returned true, that means an identical frame with identical affine exists continue; } } affine = -1; for (int a = 0; a < affines.Count; a++) { if (affinefile.Equals(affines[a].Item1)) { affine = a; break; } } if (affine == -1) { affine = affines.Count; Tuple <Point, Size> sheet = AddAffineToTilesheet( frame, new GBA.Image(folder + affinefile, Palettes[0])); affines.Add(Tuple.Create(affinefile, sheet.Item1, sheet.Item2)); } AddAffine(big, frame, coords, vectors, affines[affine].Item2, affines[affine].Item3); continue; } else { throw new Exception("Unexpected '" + (big ? 'd' : 'a') + "' affine command read."); } case 'e': case 'E': if (compile == CompileMode.Extra) { compile = CompileMode.Usual; } if (compile == CompileMode.Usual) { if ((file[line][i + 1] == 'n' || file[line][i + 1] == 'N') && (file[line][i + 2] == 'd' || file[line][i + 2] == 'D')) { AnimCode[mode].Add("end"); if (mode == 0 || mode == 2 || mode == 8) { AnimCode[mode + 1].Add("end"); mode += 2; } else { mode++; } i += 2; continue; } else { throw new Exception("Invalid terminator read:" + file[line].Substring(i, 3)); } } else { throw new Exception("Unexpected terminator read."); } default: throw new Exception("Unexpected character: " + file[line][i]); } } }/* * catch (Exception ex) * { * throw new Exception("At line " + line + ":\r\n'" + file[line] + "'\r\n" + ex.Message); * }*/ } uint emptyFrame = (uint)(Frames[0].Sprites.Count * OAM.LENGTH); // this uint is just the offset to the 1st terminator, so it produces an empty frame while (FrameData.Count < 256) { FrameData.Add(Tuple.Create((uint)0x00000000, emptyFrame)); } // fill framedata with empty frames so 'fFF' commands or such are proeperly compiled int oam_total = 0; for (int i = 0; i < Frames.Count; i++) { oam_total += Frames[i].Affines.Count * OAM.LENGTH + Frames[i].Sprites.Count * OAM.LENGTH + OAM.LENGTH; } if (oam_total > BattleAnimation.MAXIMUM_OAM_LENGTH) { Program.ShowWarning("The final OAM block is too large: " + oam_total + "\nIt should weigh " + BattleAnimation.MAXIMUM_OAM_LENGTH + " bytes or less."); } }
void StartCompile(CompileMode mode) { // a compile is running already if (IsCompiling()) { //TODO: should halt compiling really return; //CurrentThread.Stop(); } if (mode.bIntercepted) { Options options = OptionsManager.GetGlobalOptions().GetGlobalConfiguration().Options; bool bExtendCommands = options.ExtendCommands.Value; if (!bExtendCommands) { return; } } if (IsVSCompiling()) { //cancel it App().ExecuteCommand("Build.Cancel", ""); } // activate the output pane... GetOutputPane().Clear(); ActivateOutputPane(); // ok, lets attempt to start compiling now. CurrentThread = null; PostEvent = ""; // no solution loaded DTE2 app = App(); Solution solution = app.Solution; if (solution == null) { return; } // first save all the open files - this is a global setting SaveOpenFiles(); List <Project> Projects; // find the selections we need (projects) if (mode.Selection == SelectionTypes.Solution) { Projects = ProjectUtility.GetSolutionProjects(); } else if (mode.Selection == SelectionTypes.Project) { Projects = ProjectUtility.GetActiveProjects(); } else // if (mode.Selection == SelectionTypes.ProjectOnly) { Projects = ProjectUtility.GetActiveProjectOnly(); } // // Mode Arguments // // clean : send it -clean // rebuild : send it -force // build : none... string ModeArguments = ""; if (mode.Action == CompileTypes.Rebuild) { ModeArguments += "-force"; } else if (mode.Action == CompileTypes.Clean) { ModeArguments += "-clean"; } //else if Debug || NoDebug || Build ... no additional needed //TODO: need the global options path string GlobalArguments = "-dependencies \"" + Paths.GetGlobalOptionsFilename() + "\""; //no projects to compile if (Projects.Count == 0) { return; } List <CommandSetting> CommandSettings = new List <CommandSetting>(); int numprojects = Projects.Count; for (int ip = 0; ip < numprojects; ip++) { Project project = Projects[ip]; string ActiveConfiguration = ProjectUtility.ProjectActiveConfiguration(project); List <VCFile> ohfiles = ProjectUtility.GetOhFiles(project); // does it contain active oh files? if not skip it. ProjectUtility.FilterActiveFiles(ref ohfiles, ActiveConfiguration); if (ohfiles.Count == 0) { continue; } // are the project settings set to enable opcpp? bool bProjectEnabled = true; if (!bProjectEnabled) { continue; } //3. do we have .doh files in the project? List <VCFile> dohfiles = ProjectUtility.GetDohFiles(project); ProjectUtility.FilterActiveFiles(ref dohfiles, ActiveConfiguration); // if (dohfiles.Count == 0) // continue; //fetch the project doh files from the global/project doh settings List <string> ProjectDohFiles = new List <string>(); // if(ProjectDohFiles.Count + dohfiles.Count == 0) // { // //print a message "Project has oh files but no dialect was found or specified" // continue; // } //now build the settings CommandSetting setting = new CommandSetting(); setting.Project = project; setting.WorkingDir = StringUtility.RLeft(project.FileName, "\\"); //build the oh files list from the arguments //build the doh files list from the arguments string ohfilestring = ""; for (int i = 0; i < ohfiles.Count; i++) { VCFile file = ohfiles[i]; ohfilestring += '"'; ohfilestring += file.FullPath; ohfilestring += '"'; if (i + 1 < ohfiles.Count) { ohfilestring += ','; } } string dohfilestring = ""; for (int i = 0; i < dohfiles.Count; i++) { VCFile file = dohfiles[i]; dohfilestring += '"'; dohfilestring += file.FullPath; dohfilestring += '"'; if (i + 1 < dohfiles.Count) { dohfilestring += ','; } } for (int i = 0; i < ProjectDohFiles.Count; i++) { dohfilestring += '"'; dohfilestring += ProjectDohFiles[i]; dohfilestring += '"'; if (i + 1 < ProjectDohFiles.Count) { dohfilestring += ','; } } string FileArguments = ""; if (ohfilestring.Length > 0) { FileArguments += " -oh " + ohfilestring; } if (dohfilestring.Length > 0) { FileArguments += " -doh " + dohfilestring; } // fetch the global + overloaded project arguments CommandLineInfo info = OptionsManager.GetCommandLineInfo(project); setting.ExePath = info.ExecutablePath; FileArguments += " -dependencies \"" + Paths.GetProjectOptionsFilename(project) + "\""; if (setting.ExePath == "") { LogCompile("Error: opCpp exe path is undefined, please define in global and/or project settings"); return; } string ProjectArguments = info.Arguments; string MacroArguments = FileArguments + " " + ProjectArguments + " " + ModeArguments + " " + GlobalArguments; if (opBeta.IsBeta) { MacroArguments += " -beta"; } setting.Arguments = Paths.ResolveVisualStudioMacros(project, MacroArguments); //verify the macros worked... Regex findmacros = new Regex("$\\(*.\\)"); Match result = findmacros.Match(setting.Arguments); if (result.Success) { string foundstring = setting.Arguments.Substring(result.Index, result.Length); LogCompile("Error: bad macro found in settings - " + foundstring); return; } CommandSettings.Add(setting); } //no commands to execute if (CommandSettings.Count == 0) { // CurrentMode = null; // FinishedCompile(false); return; } //execute commands CurrentMode = mode; CurrentThread = new opCppThread(CommandSettings); CurrentThread.OnReadLine = LogCompile; CurrentThread.OnEnd = FinishedCompile; CurrentThread.Start(); }
public static string GetMsBuildCompileArg(CompileMode comp) { string cmode = ""; switch (comp) { case CompileMode.Debug: cmode = ""; break; case CompileMode.Release: cmode = " /p:Configuration=Release"; break; } return cmode; }
public static string GetOutputFolderName(CompileMode comp) { string cmode = ""; switch (comp) { case CompileMode.Debug: cmode = "Debug"; break; case CompileMode.Release: cmode = "Release"; break; } return cmode; }