So the other day i was trying to build the AsWing library with the Flex SDK. Sadly, i failed miserably. I didn’t even know where to start. How do you feed all the files into the compiler? What command line switches to use? So after reading basically every piece of documentation that Adobe has to offer, i finally pieced it together.
And now i can proudly say, that wasn’t so hard after all, was it?
Alright, enough with the prologue. If you’re interested in the topic of build an SWC with the SDK you most likely know that you have to feed all the libraries classes into it using a manifest file. But in the case of AsWing, there are like a million files to add (give or take). So i wrote myself a handy script real quick:
var fso = new ActiveXObject( "Scripting.FileSystemObject" ); var manifest = fso.createTextFile( "src\\manifest.xml", true ); manifest.writeLine( "<?xml version=\"1.0\"?>" ); manifest.writeLine( "<componentPackage>" ); var src = fso.getFolder( "src" ); listFolder( src, manifest, "" ); manifest.writeLine( "</componentPackage>" ); manifest.close(); function listFolder( source, target, package ) { for( var items = new Enumerator( source.SubFolders ); !items.atEnd(); items.moveNext() ) { var currentFolder = items.item(); listFolder( currentFolder, target, package + currentFolder.name + "." ); } for( var files = new Enumerator( source.files ); !files.atEnd(); files.moveNext() ) { var currentFile = files.item(); if( String( currentFile.name ).match( "\.as$" ) ) { var component = String( currentFile.name ).replace( "\.as", "" ); target.writeLine( "\t<component id=\"" + component + "\" class=\"" + package + component + "\"/>" ); } } }
So, that bad boy will build you the manifest for the given folder. I named this guy configure.js and placed it in the AsWing folder.
Now for slightly easier calling i added a small .bat to go with that. There’s only one line that matters and it is: wscript.exe configure.js
So far so good. Now we’re only missing the actual building (i’m hiliting this as JavaScript, but it’s only a .bat ;P):
@echo off set flex_sdk_dir=path_to_flex_sdk if (%flex_sdk_dir%) == (path_to_flex_sdk) goto sdk_missing if (%flex_sdk_dir%) == () goto sdk_missing if not exist %flex_sdk_dir% goto sdk_missing if not exist src\manifest.xml goto manifest_missing goto make :manifest_missing echo You have to run configure.bat first. goto end :sdk_missing echo You have to set the path to the Flex SDK inside "%0.bat". goto end :make echo Making... if not exist bin md bin set compc=%flex_sdk_dir%\bin\compc.exe %compc% -source-path src -output bin\AsWing.swc -namespace http://aswing.org src\manifest.xml -include-namespaces http://aswing.org :end echo Done.
That should be it ;) I also added these scripts to the AsWing repository.