
FB project import patches
Here is the list of changes:
1.
Output pathIn the original FB project we have these attributes under 'compiler' node:
Code:
outputFolderLocation="X:/project"
outputFolderPath="bin-debug"
FD sets the output path to "bin-debug\project.swf", while it has to set it to "x:\project\project.swf".
Fixed by using 'outputFolderLocation' instead of 'outputFolderPath'. If this breaks your projects, please let me know.
2.
LibrariesLibraries are defined in FB like this:
Code:
<libraryPathEntry kind="3" linkType="2" path="${env_dir}/as/loader/loader.swc" sourcepath="${env_dir}/as/loader/shared" useDefaultLinkType="false"/>
In FD libraries are imported in External Libraries or SWC Libraries. Absolute paths are resolved to relative (if possible).
3. Fixed a bug with empty compiler options, that made libraries inaccessible for import.
4. Added "Flex Builder Workspace Paths" parameter to Project Manager options (Tools -> Program Settings... -> Project Manager). This paths will be resolved while importing libraries. Example:
FB project file:
Code:
<libraryPathEntry kind="3" linkType="2" path="${env_dir}/as/loader/loader.swc" sourcepath="${env_dir}/as/loader/shared" useDefaultLinkType="false"/>
FD Project Manager options:
Code:
games=c:\games
projects=c:\dev\projects
env_dir=d:\environment
Library will be imported with path "d:\environment\as\loader\loader.swc", which will then be reduced if the project is on the same disk (if project is in the "d:\environment\as\game\", this will resolve to "..\loader\loader.swc").
Workspace Paths are name-value pairs, separated with '=' (just plain strings, like "name=value").
This patch mostly hacks together the needed functionality and may be unstable. For example, I don't know how it will work with long unicode paths. Anyway, it works for me, so I decided to share it.
Code:
Index: External/Plugins/ProjectManager/Projects/AS3/FlexProjectReader.cs
===================================================================
--- External/Plugins/ProjectManager/Projects/AS3/FlexProjectReader.cs (revision 1469)
+++ External/Plugins/ProjectManager/Projects/AS3/FlexProjectReader.cs (working copy)
@@ -37,7 +37,7 @@
private void ReadCompilerOptions()
{
- outputPath = GetAttribute("outputFolderPath") ?? "";
+ outputPath = GetAttribute("outputFolderLocation") ?? "";
mainApp = (GetAttribute("sourceFolderPath") ?? "") + "/" + mainApp;
if (mainApp.StartsWith("/")) mainApp = mainApp.Substring(1);
project.CompileTargets.Add(OSPath(mainApp.Replace('/', '\\')));
@@ -75,8 +75,11 @@
private void ReadCompilerSourcePaths()
{
- ReadStartElement("compilerSourcePath");
- ReadPaths("compilerSourcePathEntry", project.Classpaths);
+ if (!IsEmptyElement)
+ {
+ ReadStartElement("compilerSourcePath");
+ ReadPaths("compilerSourcePathEntry", project.Classpaths);
+ }
}
private void ReadLibraryPaths()
@@ -96,11 +99,16 @@
case "libraryPathEntry":
string path = GetAttribute("path") ?? "";
+ if (path.StartsWith("$"))
+ path = normalizeFBPath(path);
if (path.Length > 0 && !path.StartsWith("$"))
{
+ path = getRelativePath(path, project.ProjectPath);
asset = new LibraryAsset(project, path.Replace('/', '\\'));
- if (exclude) asset.SwfMode = SwfAssetMode.ExternalLibrary;
- else asset.SwfMode = SwfAssetMode.Library;
+ if (exclude || (GetAttribute("linkType").ToString() == "2"))
+ asset.SwfMode = SwfAssetMode.ExternalLibrary;
+ else
+ asset.SwfMode = SwfAssetMode.Library;
project.SwcLibraries.Add(asset);
}
break;
@@ -109,6 +117,27 @@
}
project.RebuildCompilerOptions();
}
+ private string normalizeFBPath(string path)
+ {
+ string env_path_name = path.Substring(2, path.IndexOf('}') - 2);
+ string[] paths = PluginMain.Settings.FBWorkspacePaths;
+ for (int i = 0; i < paths.Length; i++)
+ {
+ if (paths[i].StartsWith(env_path_name + "="))
+ {
+ string env_path = paths[i].Substring(env_path_name.Length + 1);
+ return (path.Replace("${" + env_path_name + "}", env_path));
+ }
+ }
+ return path;
+ }
+ private string getRelativePath(string path1, string path2)
+ {
+ System.Uri uri1 = new Uri(path1);
+ System.Uri uri2 = new Uri(path2);
+ Uri relativeUri = uri2.MakeRelativeUri(uri1);
+ return relativeUri.ToString();
+ }
public void ReadApplications()
{
Index: External/Plugins/ProjectManager/Settings.cs
===================================================================
--- External/Plugins/ProjectManager/Settings.cs (revision 1469)
+++ External/Plugins/ProjectManager/Settings.cs (working copy)
@@ -49,6 +49,7 @@
string[] excludedDirectories = new string[] { "obj", ".svn", "_svn", ".cvs", "_cvs", "cvs", "_sgbak", ".git" };
string[] executableFileTypes = new string[] { ".exe", ".lnk", ".fla", ".doc", ".pps", ".psd", ".png", ".jpg", ".gif", ".xls", ".docproj", ".ttf", ".otf", ".wav", ".mp3", ".ppt", ".pptx", ".docx", ".xlsx", ".ai", ".pdf", ".zip", ".rar" };
string[] filteredDirectoryNames = new string[] { "src", "source", "sources", "as", "as2", "as3", "actionscript", "flash", "classes", "trunk", "svn" };
+ string[] fbWorkspacePaths = new string[] { };
#region Properties
[Browsable(false)]
@@ -169,6 +170,15 @@
get { return filteredDirectoryNames; }
set { filteredDirectoryNames = value; FireChanged("FilteredDirectoryNames"); }
}
+
+ [DisplayName("Flex Builder Workspace Paths")]
+ [LocalizedDescription("ProjectManager.Description.FBWorkspacePaths")]
+ [LocalizedCategory("ProjectManager.Category.Exclusions")]
+ public string[] FBWorkspacePaths
+ {
+ get { return fbWorkspacePaths; }
+ set { fbWorkspacePaths = value; FireChanged("FBWorkspacePaths"); }
+ }
[DisplayName("Show Project Classpaths")]
[LocalizedDescription("ProjectManager.Description.ShowProjectClasspaths")]