Skip to content

Commit cdad6b6

Browse files
committed
asconfigc: implemented unpackage-anes command line option
1 parent 953aa13 commit cdad6b6

File tree

5 files changed

+106
-1
lines changed

5 files changed

+106
-1
lines changed

externs/adm-zip/asconfig.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"type": "lib",
3+
"config": "node",
4+
"compilerOptions": {
5+
"targets": [
6+
"SWF",
7+
"JSNode"
8+
],
9+
"keep-as3-metadata": [
10+
"JSModule"
11+
],
12+
"source-path": [
13+
"src"
14+
],
15+
"include-sources": [
16+
"src"
17+
],
18+
"output": "../../typedefs/adm-zip.swc"
19+
}
20+
}

externs/adm-zip/src/admZip.as

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package
2+
{
3+
[JSModule(name="adm-zip")]
4+
/**
5+
* @externs
6+
*/
7+
public class admZip
8+
{
9+
public function admZip(filePath:String)
10+
{
11+
}
12+
13+
public function extractAllTo(targetPath:String, overwrite:Boolean):void
14+
{
15+
16+
}
17+
}
18+
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"node": ">=6.0.0"
3131
},
3232
"dependencies": {
33+
"adm-zip": "^0.4.13",
3334
"del": "^3.0.0",
3435
"jsen": "^0.6.6",
3536
"json5": "^1.0.1",

src/ASConfigC.as

+67-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ package
4949
public class ASConfigC
5050
{
5151
private static const ASCONFIG_JSON:String = "asconfig.json";
52+
private static const FILE_EXTENSION_ANE:String = ".ane";
53+
private static const FILE_NAME_UNPACKAGED_ANES:String = ".as3mxml-unpackaged-anes";
5254

5355
private static const MXMLC_JARS:Vector.<String> = new <String>
5456
[
@@ -1060,7 +1062,71 @@ package
10601062
//the compilerOptions field is not defined, so there's nothing to copy
10611063
return;
10621064
}
1063-
console.warn("Skipping native extension unpackaging step. This option is currently unsupported by asconfigc. To debug with native extensions, you must unpackage them manually.");
1065+
1066+
if(CompilerOptions.LIBRARY_PATH in this._compilerOptionsJSON)
1067+
{
1068+
var libraryPathJSON:Array = this._compilerOptionsJSON[CompilerOptions.LIBRARY_PATH] as Array;
1069+
this.unpackANEs(libraryPathJSON);
1070+
}
1071+
if(CompilerOptions.EXTERNAL_LIBRARY_PATH in this._compilerOptionsJSON)
1072+
{
1073+
var externalLibraryPathJSON:Array = this._compilerOptionsJSON[CompilerOptions.EXTERNAL_LIBRARY_PATH] as Array;
1074+
this.unpackANEs(externalLibraryPathJSON);
1075+
}
1076+
}
1077+
1078+
private function unpackANEs(libraryPathJSON:Array):void
1079+
{
1080+
var pathCount:int = libraryPathJSON.length;
1081+
for(var i:int = 0; i < pathCount; i++)
1082+
{
1083+
var libraryPath:String = libraryPathJSON[i] as String;
1084+
libraryPath = path.resolve(libraryPath);
1085+
if(libraryPath.endsWith(FILE_EXTENSION_ANE))
1086+
{
1087+
this.unpackANE(libraryPath);
1088+
}
1089+
else if(fs.statSync(libraryPath).isDirectory())
1090+
{
1091+
var files:Array = fs.readdirSync(libraryPath);
1092+
var fileCount:int = files.length;
1093+
for(var j:int = 0; j < fileCount; j++)
1094+
{
1095+
var file:String = files[j];
1096+
var fullPath:String = path.resolve(libraryPath, file);
1097+
if(fullPath.endsWith(FILE_EXTENSION_ANE))
1098+
{
1099+
this.unpackANE(fullPath);
1100+
}
1101+
}
1102+
}
1103+
}
1104+
}
1105+
1106+
private function unpackANE(aneFilePath:String):void
1107+
{
1108+
if(fs.statSync(aneFilePath).isDirectory())
1109+
{
1110+
//this is either an ANE that's already unpacked
1111+
//...or something else entirely
1112+
return;
1113+
}
1114+
1115+
var outputDir:String = findOutputDirectory(this._mainFile, this._outputPath, !this._outputIsJS);
1116+
var unpackedAneDir:String = path.resolve(outputDir, FILE_NAME_UNPACKAGED_ANES);
1117+
var currentAneDir:String = path.resolve(unpackedAneDir, path.basename(aneFilePath));
1118+
mkdirp["sync"](currentAneDir);
1119+
1120+
try
1121+
{
1122+
var zipFile:admZip = new admZip(aneFilePath);
1123+
zipFile.extractAllTo(currentAneDir, true);
1124+
}
1125+
catch(error:Error)
1126+
{
1127+
console.error("Failed to copy Adobe AIR native extension from path: " + aneFilePath + ".");
1128+
process.exit(1);
1129+
}
10641130
}
10651131

10661132
private function copyAIRFiles():void

typedefs/adm-zip.swc

2.34 KB
Binary file not shown.

0 commit comments

Comments
 (0)