Exemplo n.º 1
0
        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 asc2Exixts = File.Exists(asc2Path);
            asc2Mode = asc2Exixts && !fcshExists;
 
            bool hostedInFD = !asc2Mode && 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) throw new Exception("Could not locate lib\\fcsh.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.");
            }
        }
 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;
 }
Exemplo n.º 3
0
        public void WriteConfig(AS3Project project, string[] extraClasspaths, bool debugMode)
        {
            this.project = project;

            try { InternalWriteConfig(extraClasspaths, debugMode); }
            finally { Close(); }
        }
        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 override Project ReadProject()
        {
            AS3Project project = base.ReadProject() as AS3Project;

            // re-import FlashDevelop 4 AIR projects
            if (project.MovieOptions.Version <= 2)
            {
                project.MovieOptions.Version = project.MovieOptions.Version < 2 ? 9 : 10;
                List <String> add = new List <string>();
                add.Add("+configname=air");
                if (project.CompilerOptions.Additional != null)
                {
                    add.AddRange(project.CompilerOptions.Additional);
                }
                project.CompilerOptions.Additional = add.ToArray();

                project.TestMovieBehavior = TestMovieBehavior.Custom;
                project.TestMovieCommand  = @"$(FlexSDK)\bin\adl.exe;application.xml bin";
            }
            return(project);
        }
Exemplo n.º 6
0
        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;
            }
        }
Exemplo n.º 7
0
 public AS3ProjectReader(string filename)
     : base(filename, new AS3Project(filename))
 {
     this.project = base.Project as AS3Project;
 }
Exemplo n.º 8
0
 public FlexProjectReader(string filename)
     : base(filename, new AS3Project(filename))
 {
     this.project = base.Project as AS3Project;
 }
Exemplo n.º 9
0
 public MxmlcArgumentBuilder(AS3Project project, double sdkVersion, bool asc2Mode)
 {
     this.project = project;
     flex45 = sdkVersion >= 4.5;
     asc2 = asc2Mode;
 }
Exemplo n.º 10
0
 public MxmlcArgumentBuilder(AS3Project project, double sdkVersion)
 {
     this.project = project;
     flex45 = sdkVersion >= 4.5;
     asc2 = sdkVersion < 3;
 }
Exemplo n.º 11
0
 public FlexProjectReader(string filename)
     : base(filename, new AS3Project(filename))
 {
     this.project = base.Project as AS3Project;
     Directory.SetCurrentDirectory(project.Directory);
 }
Exemplo n.º 12
0
 public AS3ProjectWriter(AS3Project project, string filename)
     : base(project, filename)
 {
     this.project = base.Project as AS3Project;
 }
 public FlexProjectReader(string filename)
     : base(filename, new AS3Project(filename))
 {
     this.project = base.Project as AS3Project;
     Directory.SetCurrentDirectory(project.Directory);
 }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
 public MxmlcArgumentBuilder(AS3Project project)
 {
     this.project = project;
 }
Exemplo n.º 16
0
 public AS3ProjectWriter(AS3Project project, string filename)
     : base(project, filename)
 {
     this.project = base.Project as AS3Project;
 }
Exemplo n.º 17
0
 // 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)
 private 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;
 }