public void WriteConfig(AS3Project project, string[] extraClasspaths, bool debugMode) { this.project = project; try { InternalWriteConfig(extraClasspaths, debugMode); } finally { Close(); } }
public string ImportProject() { OpenFileDialog dialog = new OpenFileDialog(); dialog.Title = TextHelper.GetString("Title.ImportProject"); dialog.Filter = TextHelper.GetString("Info.ImportProjectFilter"); if (dialog.ShowDialog() == DialogResult.OK && File.Exists(dialog.FileName)) { if (FileInspector.IsFlexBuilderProject(dialog.FileName)) { try { Project imported = AS3Project.Load(dialog.FileName); string path = Path.GetDirectoryName(imported.ProjectPath); string name = Path.GetFileName(path); string newPath = Path.Combine(path, name + ".as3proj"); imported.SaveAs(newPath); return(newPath); } catch (Exception exception) { string msg = TextHelper.GetString("Info.CouldNotOpenProject"); ErrorManager.ShowInfo(msg + " " + exception.Message); } } } return(null); }
public MxmlcArgumentBuilder(AS3Project project, double sdkVersion, bool asc2Mode) { this.project = project; flex45 = sdkVersion >= 4.5; flex410 = Math.Truncate(sdkVersion) >= 4 && (sdkVersion % 1) * 100 > 9; asc2 = asc2Mode; }
public AS3ProjectBuilder(AS3Project project, string compilerPath, string ipcName) : base(project, compilerPath) { this.project = project; DetectFlexSdk(compilerPath); bool mxmlcExists = File.Exists(mxmlcPath); bool fcshExists = File.Exists(fcshPath); bool ascshExists = File.Exists(ascshPath); bool asc2Exixts = File.Exists(asc2Path); asc2Mode = !fcshExists && (ascshExists || asc2Exixts); bool hostedInFD = (fcshExists || ascshExists) && ipcName != null && ipcName != ""; if (hostedInFD) { fcsh = Activator.GetObject(typeof(FlexCompilerShell), "ipc://" + ipcName + "/FlexCompilerShell") as FlexCompilerShell; } if (project.OutputType == OutputType.Application || project.OutputType == OutputType.Library) { if (fcsh != null && !fcshExists && !ascshExists) { throw new Exception("Could not locate lib\\fcsh.jar or lib\\ascsh.jar in Flex SDK."); } if (fcsh == null && !mxmlcExists && !asc2Mode) { throw new Exception("Could not locate lib\\mxmlc.jar or lib\\mxmlc-cli.jar in Flex SDK."); } } }
internal string ImportProject(string importFrom) { using (OpenFileDialog dialog = new OpenFileDialog()) { dialog.Title = TextHelper.GetString("Title.ImportProject"); dialog.Filter = TextHelper.GetString("Info.ImportProjectFilter"); if (importFrom == "hxml") { dialog.FilterIndex = 3; } if (dialog.ShowDialog() == DialogResult.OK && File.Exists(dialog.FileName)) { string fileName = dialog.FileName; string currentDirectory = Directory.GetCurrentDirectory(); try { if (FileInspector.IsHxml(Path.GetExtension(fileName).ToLower())) { var project = HaxeProject.Load(fileName); var path = Path.GetDirectoryName(project.ProjectPath); var name = Path.GetFileNameWithoutExtension(project.OutputPath); var newPath = Path.Combine(path, $"{name}.hxproj"); PatchProject(project); PatchHxmlProject(project); project.SaveAs(newPath); return(newPath); } if (FileInspector.IsFlexBuilderPackagedProject(fileName)) { fileName = ExtractPackagedProject(fileName); } if (FileInspector.IsFlexBuilderProject(fileName)) { AS3Project imported = AS3Project.Load(fileName); string path = Path.GetDirectoryName(imported.ProjectPath); string name = Path.GetFileNameWithoutExtension(imported.OutputPath); string newPath = Path.Combine(path, name + ".as3proj"); PatchProject(imported); PatchFbProject(imported); imported.SaveAs(newPath); return(newPath); } ErrorManager.ShowInfo(TextHelper.GetString("Info.NotValidFlashBuilderProject")); } catch (Exception exception) { Directory.SetCurrentDirectory(currentDirectory); string msg = TextHelper.GetString("Info.CouldNotOpenProject"); ErrorManager.ShowInfo(msg + " " + exception.Message); } } } return(null); }
public void WriteConfig(AS3Project project, double sdkVersion, string[] extraClasspaths, bool debugMode, bool asc2Mode) { this.project = project; project.UpdateVars(true); flex4 = sdkVersion >= 4; asc2 = asc2Mode; try { InternalWriteConfig(extraClasspaths, debugMode); } finally { Close(); } }
public string[] GetCompilerConstants() { IProject project = PluginBase.CurrentProject; if (project == null) { //Output.Text += "No project loaded"; return(null); } AS3Project as3_project = project as AS3Project; return(as3_project.CompilerOptions.CompilerConstants); }
// each project needs to have its own temporary build target that is consistent // between builds. This is necessary because the arguments to the FlexCompilerShell // (if you're using it) have to be identical between builds to enable incremental compiling. //private string GetTempProjectFile(AS3Project project) internal static string GetTempProjectFile(AS3Project project) { // this serves two purposes - randomize the filename, so two identically-named // projects don't get the same temp build target, and also provide an extra // method of forcing a recompile after a project modification. string projectName = project.Name.Replace(" ", ""); long modified = File.GetLastWriteTime(project.ProjectPath).Ticks; string tempFileName = projectName + modified; string tempPath = "obj"; string tempFile = Path.Combine(tempPath, tempFileName); File.Create(tempFile).Close(); return(tempFile); }
/// <summary> /// Look in current project configuration for user-defined namespaces /// </summary> static public void AddProjectManifests() { AS3Project project = PluginBase.CurrentProject as AS3Project; if (project != null) { //-compiler.namespaces.namespace http://e4xu.googlecode.com run\manifest.xml if (project.CompilerOptions.Additional != null) { foreach (string line in project.CompilerOptions.Additional) { string temp = line.Trim(); if (temp.StartsWith("-compiler.namespaces.namespace") || temp.StartsWith("-namespace")) { int p = temp.IndexOf(' '); if (p < 0) { p = temp.IndexOf('='); } if (p < 0) { continue; } temp = temp.Substring(p + 1).Trim(); p = temp.IndexOf(' '); if (p < 0) { p = temp.IndexOf(','); } if (p < 0) { continue; } string uri = temp.Substring(0, p); string path = temp.Substring(p + 1).Trim(); if (path.StartsWith("\"")) { path = path.Substring(1, path.Length - 2); } AddManifest(uri, PathHelper.ResolvePath(path, project.Directory)); } } } } }
public FlexJSProjectBuilder(AS3Project project, string compilerPath) : base(project, compilerPath) { this.project = project; mxmlcPath = Path.Combine(compilerPath, "js", "lib", "mxmlc.jar"); if (!File.Exists(mxmlcPath)) { throw new Exception("Could not locate js\\lib\\mxmlc.jar in FlexJS SDK."); } jvmConfig = JvmConfigHelper.ReadConfig(compilerPath); if (jvmConfig.ContainsKey("java.args")) { var args = jvmConfig["java.args"]; if (args.Trim().Length > 0) { jvmArgs = args; } } }
public string ImportProject() { OpenFileDialog dialog = new OpenFileDialog(); dialog.Title = TextHelper.GetString("Title.ImportProject"); dialog.Filter = TextHelper.GetString("Info.ImportProjectFilter"); if (dialog.ShowDialog() == DialogResult.OK && File.Exists(dialog.FileName)) { string fbProject = dialog.FileName; string currentDirectory = Directory.GetCurrentDirectory(); try { if (FileInspector.IsFlexBuilderPackagedProject(fbProject)) { fbProject = ExtractPackagedProject(fbProject); } if (FileInspector.IsFlexBuilderProject(fbProject)) { AS3Project imported = AS3Project.Load(fbProject); string path = Path.GetDirectoryName(imported.ProjectPath); string name = Path.GetFileNameWithoutExtension(imported.OutputPath); string newPath = Path.Combine(path, name + ".as3proj"); PatchProject(imported); PatchFbProject(imported); imported.SaveAs(newPath); return(newPath); } else { ErrorManager.ShowInfo(TextHelper.GetString("Info.NotValidFlashBuilderProject")); } } catch (Exception exception) { Directory.SetCurrentDirectory(currentDirectory); string msg = TextHelper.GetString("Info.CouldNotOpenProject"); ErrorManager.ShowInfo(msg + " " + exception.Message); } } return(null); }
private void config_constants_ItemCheck(object sender, ItemCheckEventArgs e) { System.Windows.Forms.CheckedListBox obj = sender as CheckedListBox; //Output.Text += "Clicked " + obj.Text; // +" newvalue " + e.NewValue + "\n"; IProject project = PluginBase.CurrentProject; if (project == null) { //Output.Text += "No project loaded"; return; } AS3Project as3_project = project as AS3Project; string[] constants = GetCompilerConstants(); for (int i = 0; i < constants.GetLength(0); i++) { //Output.Text += " " + constants[i]; if (IsConstantCONFIG(constants[i])) { string key; string value; string conf_namespace; ExtractCONFIGKeyValue(constants[i], out key, out value, out conf_namespace); if (key == obj.Text) // is this the clicked one { constants[i] = conf_namespace + "::" + key + "," + (e.NewValue == CheckState.Checked ? "true" : "false"); //Output.Text += "toggled " + constants[i] + "\n"; as3_project.Save(); return; } } } }
public AS3ProjectBuilder(AS3Project project, string compilerPath, string ipcName) : base(project, compilerPath) { this.project = project; DetectFlexSdk(compilerPath); bool hostedInFD = (ipcName != null && ipcName != ""); bool mxmlcExists = File.Exists(mxmlcPath); bool fcshExists = File.Exists(fcshPath); if (!mxmlcExists && !project.NoOutput) { throw new Exception("Could not locate lib\\mxmlc.jar in Flex SDK. Please set the correct path to the Flex SDK in AS3Context plugin settings."); } if (hostedInFD && fcshExists) { Console.WriteLine("Using the Flex Compiler Shell."); fcsh = Activator.GetObject(typeof(FlexCompilerShell), "ipc://" + ipcName + "/FlexCompilerShell") as FlexCompilerShell; } }
private void AddTargetPlayer(MxmlcOptions options) { int majorVersion = project.MovieOptions.MajorVersion; int minorVersion = project.MovieOptions.MinorVersion; if (project.MovieOptions.Platform == AS3MovieOptions.AIR_PLATFORM || project.MovieOptions.Platform == AS3MovieOptions.AIR_MOBILE_PLATFORM) { AS3Project.GuessFlashPlayerForAIR(ref majorVersion, ref minorVersion); } string version; if (options.MinorVersion.Length > 0) { version = majorVersion + "." + options.MinorVersion; } else { version = majorVersion + "." + minorVersion; } WriteElementString("target-player", version); }
public MxmlcArgumentBuilder(AS3Project project, double sdkVersion) { this.project = project; flex45 = sdkVersion >= 4.5; asc2 = sdkVersion < 3; }
public MxmlcArgumentBuilder(AS3Project project, double sdkVersion, bool asc2Mode) { this.project = project; flex45 = sdkVersion >= 4.5; asc2 = asc2Mode; }
public string[] BuildHXML(string[] paths, string outfile, bool release) { List <String> pr = new List <String>(); if (rawHXML != null) { pr.AddRange(rawHXML); } else { // libraries foreach (string lib in CompilerOptions.Libraries) { if (lib.Length > 0) { if (lib.Trim().StartsWith("-lib")) { pr.Add(lib); } else { pr.Add("-lib " + lib); } } } // class paths List <String> classPaths = new List <String>(); foreach (string cp in paths) { classPaths.Add(cp); } foreach (string cp in this.Classpaths) { classPaths.Add(cp); } foreach (string cp in classPaths) { String ccp = String.Join("/", cp.Split('\\')); pr.Add("-cp " + Quote(ccp)); } // compilation mode string mode = null; if (IsFlashOutput) { mode = "swf"; } else if (IsJavacriptOutput) { mode = "js"; } else if (IsNekoOutput) { mode = "neko"; } else if (IsPhpOutput) { mode = "php"; } else if (IsCppOutput) { mode = "cpp"; } else if (IsCSharpOutput) { mode = "cs"; } else if (IsJavaOutput) { mode = "java"; } //else throw new SystemException("Unknown mode"); if (mode != null) { outfile = String.Join("/", outfile.Split('\\')); pr.Add("-" + mode + " " + Quote(outfile)); } // nme options /*if (IsNmeOutput) * { * pr.Add("--remap flash:nme"); * }*/ // flash options if (IsFlashOutput) { string htmlColor = this.MovieOptions.Background.Substring(1); if (htmlColor.Length > 0) { htmlColor = ":" + htmlColor; } pr.Add("-swf-header " + string.Format("{0}:{1}:{2}{3}", MovieOptions.Width, MovieOptions.Height, MovieOptions.Fps, htmlColor)); if (!UsesInjection && LibraryAssets.Count > 0) { pr.Add("-swf-lib " + Quote(LibrarySWFPath)); } if (CompilerOptions.FlashStrict) { pr.Add("--flash-strict"); } // convert Flash version to haxe supported parameter string param = null; int majorVersion = MovieOptions.MajorVersion; int minorVersion = MovieOptions.MinorVersion; if (MovieOptions.Platform == HaxeMovieOptions.AIR_PLATFORM || MovieOptions.Platform == HaxeMovieOptions.AIR_MOBILE_PLATFORM) { AS3Project.GuessFlashPlayerForAIR(ref majorVersion, ref minorVersion); } if (movieOptions.Platform == HaxeMovieOptions.NME_PLATFORM) { HaxeProject.GuessFlashPlayerForNME(ref majorVersion, ref minorVersion); } if (majorVersion >= 10) { if (minorVersion > 0) { param = majorVersion + "." + minorVersion; } else { param = "" + majorVersion; } } else { param = "" + majorVersion; } if (param != null) { pr.Add("-swf-version " + param); } } // defines foreach (string def in CompilerOptions.Directives) { pr.Add("-D " + Quote(def)); } // add project files marked as "always compile" foreach (string relTarget in CompileTargets) { string absTarget = GetAbsolutePath(relTarget); // guess the class name from the file name foreach (string cp in classPaths) { if (absTarget.StartsWith(cp, StringComparison.OrdinalIgnoreCase)) { string className = GetClassName(absTarget, cp); if (CompilerOptions.MainClass != className) { pr.Add(className); } } } } // add main class if (CompilerOptions.MainClass != null && CompilerOptions.MainClass.Length > 0) { pr.Add("-main " + CompilerOptions.MainClass); } // extra options foreach (string opt in CompilerOptions.Additional) { String p = opt.Trim(); if (p == "" || p[0] == '#') { continue; } char[] space = { ' ' }; string[] parts = p.Split(space, 2); if (parts.Length == 1) { pr.Add(p); } else { pr.Add(parts[0] + ' ' + Quote(parts[1])); } } } // debug if (!release) { pr.Add("-debug"); if (IsFlashOutput && MovieOptions.DebuggerSupported && CompilerOptions.EnableDebug) { pr.Add("--no-inline"); pr.Add("-D fdb"); } } return(pr.ToArray()); }
/// <summary> /// Exports FD project setting to COLTRemoteProject instance. /// </summary> /// <returns></returns> private COLTRemoteProject ExportCOLTProject() { // our options: parse project.ProjectPath (xml file) or use api AS3Project project = (AS3Project)PluginBase.CurrentProject; String configCopy = ""; if (settingObject.FullConfig) { // Construct flex config file name (see AS3ProjectBuilder, line 140) String projectName = project.Name.Replace(" ", ""); String configFile = Path.Combine("obj", projectName + "Config.xml"); if (!File.Exists(project.GetAbsolutePath(configFile))) { TraceManager.Add("Required file (" + projectName + "Config.xml) does not exist, project must be built first...", -1); try { allowBuildInterception = false; EventManager.DispatchEvent(this, new DataEvent(EventType.Command, "ProjectManager.BuildProject", null)); } finally { allowBuildInterception = true; } return(null); } // Create config copy with <file-specs>...</file-specs> commented out configCopy = Path.Combine("obj", projectName + "ConfigCopy.xml"); File.WriteAllText(project.GetAbsolutePath(configCopy), File.ReadAllText(project.GetAbsolutePath(configFile)) .Replace("<file-specs", "<!-- file-specs") .Replace("/file-specs>", "/file-specs -->")); } // Export COLT project COLTRemoteProject result = new COLTRemoteProject(); result.path = project.GetAbsolutePath(Path.Combine(settingObject.WorkingFolder, System.Guid.NewGuid() + ".colt")); result.name = project.Name; List <String> libraryPathsList = new List <String>(project.CompilerOptions.LibraryPaths); for (int i = 0; i < libraryPathsList.Count; i++) { if (libraryPathsList[i].ToLower().EndsWith(".swc")) { libraryPathsList[i] = @"..\" + libraryPathsList[i]; } else { // workaround (FD saves empty paths for missing libs) libraryPathsList.RemoveAt(i); i--; } } result.libraries = libraryPathsList.ToArray(); result.targetPlayerVersion = project.MovieOptions.Version + ".0"; result.mainClass = project.GetAbsolutePath(project.CompileTargets[0]); result.flexSDKPath = project.CurrentSDK; if (settingObject.FullConfig) { result.customConfigPath = project.GetAbsolutePath(configCopy); } String outputPath = project.OutputPath; int lastSlash = outputPath.LastIndexOf(@"\"); if (lastSlash > -1) { result.outputPath = project.GetAbsolutePath(outputPath.Substring(0, lastSlash)); result.outputFileName = outputPath.Substring(lastSlash + 1); } else { result.outputPath = project.GetAbsolutePath(""); result.outputFileName = outputPath; } String[] sourcePaths = project.SourcePaths.Clone() as String[]; for (int i = 0; i < sourcePaths.Length; i++) { sourcePaths[i] = @"..\" + sourcePaths[i]; } result.sources = sourcePaths; result.assets = AssetFolders; for (int i = 0; i < result.assets.Length; i++) { result.assets[i] = @"..\" + project.GetRelativePath(result.assets[i]); } // size, frame rate and background color String[] coltAdditionalOptionsKeys = { "-default-size", "-default-frame-rate", "-default-background-color" }; String[] coltAdditionalOptions = { coltAdditionalOptionsKeys[0] + " " + project.MovieOptions.Width + " " + project.MovieOptions.Height, coltAdditionalOptionsKeys[1] + " " + project.MovieOptions.Fps, coltAdditionalOptionsKeys[2] + " " + project.MovieOptions.BackgroundColorInt }; String additionalOptions = ""; foreach (String option in project.CompilerOptions.Additional) { for (int i = 0; i < coltAdditionalOptionsKeys.Length; i++) { if (option.Contains(coltAdditionalOptionsKeys[i])) { coltAdditionalOptions[i] = ""; } } additionalOptions += option + " "; } foreach (String option in coltAdditionalOptions) { additionalOptions += option + " "; } // compiler constants // see AddCompilerConstants in FDBuild's Building.AS3.FlexConfigWriter Boolean debugMode = project.TraceEnabled; Boolean isMobile = (project.MovieOptions.Platform == AS3MovieOptions.AIR_MOBILE_PLATFORM); Boolean isDesktop = (project.MovieOptions.Platform == AS3MovieOptions.AIR_PLATFORM); additionalOptions += "-define+=CONFIG::debug," + (debugMode ? "true" : "false") + " "; additionalOptions += "-define+=CONFIG::release," + (debugMode ? "false" : "true") + " "; additionalOptions += "-define+=CONFIG::timeStamp,\"'" + DateTime.Now.ToString("d") + "'\" "; additionalOptions += "-define+=CONFIG::air," + (isMobile || isDesktop ? "true" : "false") + " "; additionalOptions += "-define+=CONFIG::mobile," + (isMobile ? "true" : "false") + " "; additionalOptions += "-define+=CONFIG::desktop," + (isDesktop ? "true" : "false") + " "; if (project.CompilerOptions.CompilerConstants != null) { foreach (string define in project.CompilerOptions.CompilerConstants) { if (define.IndexOf(',') >= 0) { additionalOptions += "-define+=" + define + " "; } } } result.compilerOptions = additionalOptions.Trim() + (debugMode ? " -debug" : ""); return(result); }
public MxmlcArgumentBuilder(AS3Project project) { this.project = project; }
private void values_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) { if (e.CancelEdit) { return; } /*if (e.Node.Parent == null) * Output.Text += "Parent is null / " + e.Node.Text + "\n"; * else * Output.Text += e.Node.Parent.Text + " / " + e.Node.Text + "\n"; * * return;*/ IProject project = PluginBase.CurrentProject; if (project == null) { //Output.Text += "No project loaded"; return; } AS3Project as3_project = project as AS3Project; string[] constants = GetCompilerConstants(); string old_key = ""; string new_key = ""; string new_value = null; if (e.Node.Parent == null) // edited the CONFIG::name part, so change the key { old_key = e.Node.Text; new_key = e.Label; //new_value shall be taken from if (old_key == new_key) { return; } } else // edited the value { old_key = e.Node.Parent.Text; new_key = old_key; new_value = e.Label; //Output.Text += e.Node.Parent.Text + " / " + e.Node.Text; } for (int i = 0; i < constants.GetLength(0); i++) { //Output.Text += " " + constants[i]; if (!IsConstantCONFIG(constants[i]) && IsConstantVALUE(constants[i])) { string key; string value; ExtractVALUEKeyValue(constants[i], out key, out value); if (key == new_key) // is this the clicked one { if (new_value == null) { new_value = value; } constants[i] = new_key + "," + new_value; Output.Text += "edited to " + constants[i] + "\n"; as3_project.Save(); return; } } } }
private void PatchFbProject(AS3Project project) { if (project == null || !project.MovieOptions.Platform.StartsWithOrdinal("AIR")) { return; } // We do this because the batch files cannot automatically detect the path changes caused by debug/release differences bool trace = project.TraceEnabled; project.TraceEnabled = false; project.OutputPath = project.FixDebugReleasePath(project.OutputPath); project.TraceEnabled = trace; string path = Path.GetDirectoryName(project.ProjectPath); string descriptor = "src\\" + Path.GetFileNameWithoutExtension(project.OutputPath) + "-app.xml"; project.TestMovieBehavior = TestMovieBehavior.Custom; project.TestMovieCommand = "bat\\RunApp.bat"; // CrossOver template related mod if (PlatformHelper.isRunningOnWine()) { project.TestMovieCommand += " $(TargetBuild)"; } if (!File.Exists(Path.Combine(path, descriptor))) { // Either it's some library project (we'll deal with these later) // or it's placed in some folder different to the default one (same as above) return; } // We copy the needed project template files bool isFlex = project.CompileTargets.Count > 0 && Path.GetExtension(project.CompileTargets[0]).ToLower() == ".mxml"; string projectPath; var excludedFiles = new List <string>(); // This could be a setting, in any case, decided to do this in case someone added custom files to the project templates... if (project.MovieOptions.Platform == "AIR Mobile") { projectPath = isFlex ? project.MovieOptions.PlatformSupport.GetProjectTemplate("flex") : project.MovieOptions.PlatformSupport.GetProjectTemplate("as3"); excludedFiles.AddRange(new[] { "application.xml.template", "Project.as3proj", "Project.png", "Project.txt", "bin", "cert", "icons", "src" }); } else { // The files are the same for Flex 3 and 4, so no need to discern them projectPath = isFlex ? project.MovieOptions.PlatformSupport.GetProjectTemplate("flex4") : project.MovieOptions.PlatformSupport.GetProjectTemplate("as3"); excludedFiles.AddRange(new[] { "application.xml.template", "Project.as3proj", "Project.png", "Project.txt", "bin", "src" }); } if (projectPath == null || !Directory.Exists(projectPath = Path.Combine(PathHelper.ProjectsDir, projectPath))) { string info = TextHelper.GetString("Info.TemplateDirNotFound"); ErrorManager.ShowWarning(info, null); return; } var creator = new ProjectCreator(); creator.SetContext(Path.GetFileNameWithoutExtension(project.OutputPath), string.Empty); foreach (var file in Directory.GetFiles(projectPath, "*.*", SearchOption.AllDirectories)) { bool excluded = false; foreach (var excludedFile in excludedFiles) { if (file.StartsWithOrdinal(Path.Combine(projectPath, excludedFile))) { excluded = true; break; } } if (excluded) { continue; } var fileDirectory = Path.GetDirectoryName(file).Replace(projectPath, string.Empty); if (fileDirectory.StartsWith('\\')) { fileDirectory = fileDirectory.Substring(1); } var folder = Path.Combine(path, fileDirectory); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } string newFile = Path.Combine(folder, Path.GetFileName(file)); if (Path.GetExtension(file).ToLower() == ".template") { creator.CopyFile(file, newFile); } else { File.Copy(file, newFile, true); } } // We configure the batch files var configurator = new AirConfigurator { ApplicationSetupBatch = Path.Combine(path, "bat\\SetupApp.bat") }; configurator.ApplicationSetupParams[AirConfigurator.DescriptorPath] = descriptor; configurator.ApplicationSetupParams[AirConfigurator.PackageDir] = Path.GetFileName(Path.GetDirectoryName(project.OutputPath)); configurator.SetUp(); // We change the descriptor file so it targets our output file. FB does this dynamically. descriptor = Path.Combine(path, descriptor); var fileInfo = FileHelper.GetEncodingFileInfo(descriptor); string contents = Regex.Replace(fileInfo.Contents, "<content>\\[This value will be overwritten by (Flex|Flash) Builder in the output app.xml]</content>", "<content>" + Path.GetFileName(project.OutputPath) + "</content>"); FileHelper.WriteFile(descriptor, contents, Encoding.GetEncoding(fileInfo.CodePage), fileInfo.ContainsBOM); }
public void UpdateASCompletion(IMainForm mainForm, Project project) { List <string> classPaths = new List <string>(); List <string> hiddenPaths = new List <string>(); int majorVersion = 0; int minorVersion = 0; string platform = ""; if (project != null) { BuildActions.GetCompilerPath(project); // refresh project's SDK project.UpdateVars(true); // platform/version platform = project.MovieOptions.Platform; majorVersion = project.MovieOptions.MajorVersion; minorVersion = project.MovieOptions.MinorVersion; if (project.MovieOptions.Platform == AS3MovieOptions.AIR_PLATFORM || project.MovieOptions.Platform == AS3MovieOptions.AIR_MOBILE_PLATFORM) { AS3Project.GuessFlashPlayerForAIR(ref majorVersion, ref minorVersion); } // add project classpaths foreach (string cp in project.AbsoluteClasspaths) { if (Directory.Exists(cp)) { classPaths.Add(cp); } } // add AS3 libraries string absPath; if (project is AS3Project) { MxmlcOptions options = (project as AS3Project).CompilerOptions; foreach (string relPath in options.IntrinsicPaths) { absPath = PathHelper.ResolvePath(relPath); if (absPath == null) { absPath = project.GetAbsolutePath(relPath); } if (absPath == null) { continue; } if (Directory.Exists(absPath)) { classPaths.Add(absPath); } } foreach (string relPath in options.LibraryPaths) { absPath = project.GetAbsolutePath(relPath); if (absPath == null) { continue; } if (File.Exists(absPath)) { classPaths.Add(absPath); } else if (Directory.Exists(absPath)) { string[] libs = Directory.GetFiles(absPath, "*.swc"); foreach (string lib in libs) { classPaths.Add(lib); } } } foreach (string relPath in options.IncludeLibraries) { absPath = project.GetAbsolutePath(relPath); if (absPath == null) { continue; } if (Directory.Exists(absPath) || File.Exists(absPath)) { classPaths.Add(absPath); } } foreach (string relPath in options.ExternalLibraryPaths) { absPath = project.GetAbsolutePath(relPath); if (absPath == null) { continue; } if (Directory.Exists(absPath) || File.Exists(absPath)) { classPaths.Add(absPath); } } foreach (string relPath in options.RSLPaths) { string[] parts = relPath.Split(','); if (parts.Length < 2) { continue; } absPath = project.GetAbsolutePath(relPath); if (absPath == null) { continue; } if (File.Exists(absPath)) { classPaths.Add(absPath); } } } string dir = project.Directory; foreach (string hidPath in project.HiddenPaths) { absPath = Path.Combine(dir, hidPath); foreach (string cp in classPaths) { if (absPath.StartsWith(cp)) { hiddenPaths.Add(absPath); break; } } } } DataEvent de; Hashtable info = new Hashtable(); // release old classpath if (currentLang != null && project == null) { info["lang"] = currentLang; info["platform"] = ""; info["targetBuild"] = ""; info["version"] = "0.0"; info["classpath"] = null; info["hidden"] = null; de = new DataEvent(EventType.Command, "ASCompletion.ClassPath", info); EventManager.DispatchEvent(this, de); } // set new classpath if (project != null) { currentLang = project.Language; info["platform"] = platform; info["version"] = majorVersion + "." + minorVersion; info["targetBuild"] = project.TargetBuild; info["lang"] = currentLang; info["classpath"] = classPaths.ToArray(); info["hidden"] = hiddenPaths.ToArray(); de = new DataEvent(EventType.Command, "ASCompletion.ClassPath", info); EventManager.DispatchEvent(this, de); project.AdditionalPaths = info.ContainsKey("additional") ? info["additional"] as string[] : null; } else { currentLang = null; } }
public void AddOptions(bool releaseMode, bool incremental) { if (!releaseMode) { AddEq("-debug", true); } if (!asc2 && incremental) { AddEq("-incremental", true); } MxmlcOptions options = project.CompilerOptions; if (asc2 && options.AdvancedTelemetry) { AddEq("-advanced-telemetry", true); if (!string.IsNullOrEmpty(options.AdvancedTelemetryPassword)) { AddEq("-advanced-telemetry-password", options.AdvancedTelemetryPassword); } } if (asc2 && options.InlineFunctions) { AddEq("-inline", true); } if (options.LinkReport.Length > 0) { Add("-link-report", options.LinkReport); } if (options.LoadExterns.Length > 0) { Add("-load-externs", options.LoadExterns); } bool hasConfig = false; bool hasVersion = false; if (options.Additional != null) { string all = String.Join(" ", options.Additional); if (all.IndexOf("configname") > 0) { hasConfig = true; } if (all.IndexOf("swf-version") > 0) { hasVersion = true; } } bool isAIR = false; if (!hasConfig) { if (project.MovieOptions.Platform == "AIR") { isAIR = true; AddEq("+configname", "air"); } else if (project.MovieOptions.Platform == "AIR Mobile") { isAIR = true; AddEq("+configname", "airmobile"); } } if ((asc2 || flex45) && !hasVersion) { string version = project.MovieOptions.Version; if (isAIR) { version = AS3Project.GuessFlashPlayerForAIR(version); } string swfVersion = (project.MovieOptions as AS3MovieOptions).GetSWFVersion(version); if (swfVersion != null) { AddEq("-swf-version", swfVersion); } } if (options.Additional != null) { Add(options.Additional, releaseMode); } }