Skip to content

Commit

Permalink
AutomaticExporter: pass "--unmodified" to force-export all files, not…
Browse files Browse the repository at this point in the history
… just those that have been modified
  • Loading branch information
tconkling committed Aug 26, 2016
1 parent 2781de2 commit 29cdf70
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 8 deletions.
8 changes: 6 additions & 2 deletions exporter/rsrc/flump-export
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ print_help() {
echo " button were pressed in the UI";
}

if [[ $# -ne 1 ]]; then
if [[ $# -lt 1 ]]; then
print_help
exit 0
fi
Expand Down Expand Up @@ -35,7 +35,11 @@ echo -n "" > exporter.log
tail -F exporter.log &
TAIL_PID=$!

$FLUMP_HOME/Contents/MacOS/Flump --export $project
# eat the $1 relative filename argument
shift

# execute flump, passing any remaining arguments to it
$FLUMP_HOME/Contents/MacOS/Flump --export $project "$@"

# give it a second to make sure we caught all the output
sleep 1
Expand Down
21 changes: 17 additions & 4 deletions exporter/src/main/as/flump/export/AutomaticExporter.as
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@ import react.BoolView;
*/
public class AutomaticExporter extends ExportController
{
public function AutomaticExporter (project :File) {
/**
* Constructs a new AutomaticExporter
*
* @param project the project to export
*
* @param exportUnmodified if false, files that are unmodified (their SWFs MD5 hashes
* haven't changed since the previous export) will be skipped. If true, all files
* in the project will be exported regardless of whether they've been modified.
*/
public function AutomaticExporter (project :File, exportUnmodified :Boolean) {
_exportIfUnmodified = exportUnmodified;

_complete.connect(function (complete :Boolean) :void {
if (!complete) return;
if (OUT != null) {
Expand All @@ -41,7 +52,8 @@ public class AutomaticExporter extends ExportController
OUT.open(outFile, FileMode.WRITE);

_confFile = project;
println("Exporting project: '" + _confFile.nativePath + "'");
println("Exporting project: '" + _confFile.nativePath + "'" +
(_exportIfUnmodified ? " (exportUnmodified=true)" : ""));
println();

if (readProjectConfig()) {
Expand Down Expand Up @@ -100,7 +112,7 @@ public class AutomaticExporter extends ExportController
var libs :Vector.<XflLibrary> = getLibs();
// if we have one or more combined export format, publish them
if (hasCombined) {
if (publisher.modified(libs)) {
if (_exportIfUnmodified || publisher.modified(libs)) {
println("Exporting combined formats...");
var numPublished :int = publisher.publishCombined(libs);
if (numPublished == 0) {
Expand All @@ -116,7 +128,7 @@ public class AutomaticExporter extends ExportController
// now publish any appropriate single formats
if (hasSingle) {
for each (var status :DocStatus in _statuses) {
if (publisher.modified(new <XflLibrary>[status.lib], 0)) {
if (_exportIfUnmodified || publisher.modified(new <XflLibrary>[status.lib], 0)) {
println("Exporting '" + status.path + "'...");
numPublished = publisher.publishSingle(status.lib);
if (numPublished == 0) {
Expand Down Expand Up @@ -194,6 +206,7 @@ public class AutomaticExporter extends ExportController
}

protected const _complete :BoolValue = new BoolValue(false);
protected var _exportIfUnmodified :Boolean;

protected var OUT :FileStream;

Expand Down
44 changes: 42 additions & 2 deletions exporter/src/main/as/flump/export/FlumpApp.as
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ public class FlumpApp

var launched :Boolean = false;
NA.addEventListener(InvokeEvent.INVOKE, function (event :InvokeEvent) :void {
if (event.arguments.length > 1 && event.arguments[0] == "--export") {
var headless :AutomaticExporter = new AutomaticExporter(new File(event.arguments[1]));
if (hasValueArgument(event.arguments, "--export")) {
var projectName :String = popValueArgument(event.arguments, "--export");
var exportUnmodified :Boolean = popFlagArgument(event.arguments, "--unmodified");
var headless :AutomaticExporter = new AutomaticExporter(new File(projectName), exportUnmodified);
headless.complete.connectNotify(function (complete :Boolean) :void {
if (!complete) return;

Expand Down Expand Up @@ -205,6 +207,44 @@ public class FlumpApp
});
}

/**
* If the given flag argument (e.g. "--unmodified") is set in the args list, it is removed
* from the list and 'true' is returned.
*/
protected static function popFlagArgument (args :Array, argName :String) :Boolean {
var idx :int = args.indexOf(argName);
if (idx >= 0) {
args.removeAt(idx);
return true;
} else {
return false;
}
}

/**
* If the given value argument pair (e.g. "--export myproject.flump") is set in the args list,
* it is removed from the list and its value is returned.
*/
protected static function popValueArgument (args :Array, argName :String) :String {
var idx :int = args.indexOf(argName);
if (idx >= 0 && idx <= args.length - 2) {
var value :String = args[idx + 1];
args.splice(idx, 2);
return value;
} else {
return null;
}
}

protected static function hasFlagArgument (args :Array, argName :String) :Boolean {
return (args.indexOf(argName) >= 0);
}

protected static function hasValueArgument (args :Array, argName :String) :Boolean {
var idx :int = args.indexOf(argName);
return (idx >= 0 && idx <= args.length - 2);
}

protected var _loaderInfo :LoaderInfo;
protected var _projects :Array = [];
protected var _previewController :PreviewController;
Expand Down

0 comments on commit 29cdf70

Please sign in to comment.