royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erikdebr...@apache.org
Subject [royale-asjs] 08/08: Fix playerglobal paths
Date Fri, 17 Nov 2017 13:48:59 GMT
This is an automated email from the ASF dual-hosted git repository.

erikdebruin pushed a commit to branch feature/as2wasm
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit 78d1603210f1985b90570d9d70f4c7ec0a4aae32
Author: Erik de Bruin <erik@ixsoftware.nl>
AuthorDate: Fri Nov 17 14:48:43 2017 +0100

    Fix playerglobal paths
    
    Signed-off-by: Erik de Bruin <erik@ixsoftware.nl>
---
 as2wasm/create.js          | 81 ++++++++++++++++++++--------------------------
 as2wasm/download.js        |  2 +-
 as2wasm/resources/build.js |  2 +-
 3 files changed, 37 insertions(+), 48 deletions(-)

diff --git a/as2wasm/create.js b/as2wasm/create.js
index f5a3898..69d2656 100644
--- a/as2wasm/create.js
+++ b/as2wasm/create.js
@@ -19,7 +19,7 @@
 
 'use strict';
 
-let args, copyFile, createFile, dir, fs, playerGlobalVersion, projectName,
+let args, copyFile, createDirectory, createFile, dir, fs, projectName,
     projectPath, projectSrcPath, royaleHome, tgtDir;
 
 
@@ -32,6 +32,12 @@ copyFile = function (file, srcDir, tgtDir) {
   fs.createReadStream(srcDir + file).pipe(fs.createWriteStream(tgtDir + file));
 };
 
+createDirectory = function (path) {
+  if (!fs.existsSync(path)) {
+    fs.mkdirSync(path);
+  }
+};
+
 createFile = function (file, content) {
   fs.writeFile(file, content, function(error) {
     if (error) {
@@ -64,7 +70,7 @@ process.argv.slice(2).forEach(function (value) {
 royaleHome = process.argv[1].split('/');
 royaleHome.pop(); // remove 'create.js'
 royaleHome.pop(); // remove 'as2wasm'
-royaleHome = royaleHome.join('/');
+royaleHome = royaleHome.join('/') + '/';
 
 dir = args['dir'];
 if (!fs.existsSync(dir)) {
@@ -74,75 +80,58 @@ if (!fs.existsSync(dir)) {
 }
 
 projectName = args['name'];
-projectPath = dir + '/' + projectName;
-if (!fs.existsSync(projectPath)) {
-  fs.mkdirSync(projectPath);
-}
-
-playerGlobalVersion = args['playerglobal-version'];
-if (!playerGlobalVersion || '' === playerGlobalVersion) {
-  playerGlobalVersion = process.env.PLAYERGLOBAL_VERSION;
-}
-if (!playerGlobalVersion || '' === playerGlobalVersion) {
-  playerGlobalVersion = '25';
-
-  console.log(`PLAYERGLOBAL_VERSION was undefined. It is now set to '${playerGlobalVersion}'.
To override this default, create an environment variable (PLAYERGLOBAL_VERSION) and set it
to required version, or use 'npm run build -- -player-version=[version]'.`);
-} else {
-  console.log('PLAYERGLOBAL_VERSION is ' + playerGlobalVersion + '.');
-}
+projectPath = dir + '/' + projectName + '/';
+createDirectory(projectPath);
 
-
-fs.mkdirSync(projectPath + '/lib/');
+createDirectory(projectPath + 'lib/');
 
 tgtDir = projectPath + 'lib/compiler/';
-fs.mkdirSync(tgtDir);
-copyFile('wastc.jar', royaleHome + '/as2wasm/lib/', tgtDir);
-copyFile('compiler.jar', royaleHome + '/as2wasm/lib/', tgtDir);
+createDirectory(tgtDir);
+copyFile('wastc.jar', royaleHome + 'as2wasm/lib/', tgtDir);
+copyFile('compiler.jar', royaleHome + 'as2wasm/lib/', tgtDir);
 
 tgtDir = projectPath + 'lib/compiler/external/';
-fs.mkdirSync(tgtDir);
-copyFile('antlr-LICENSE.html', royaleHome + '/as2wasm/lib/external/', tgtDir);
-copyFile('antlr.jar', royaleHome + '/as2wasm/lib/external/', tgtDir);
-copyFile('commons-cli.jar', royaleHome + '/as2wasm/lib/external/', tgtDir);
-copyFile('commons-io.jar', royaleHome + '/as2wasm/lib/external/', tgtDir);
-copyFile('flex-tool-api-LICENSE.html', royaleHome + '/as2wasm/lib/external/', tgtDir);
-copyFile('flex-tool-api.jar', royaleHome + '/as2wasm/lib/external/', tgtDir);
-copyFile('guava-LICENSE.html', royaleHome + '/as2wasm/lib/external/', tgtDir);
-copyFile('guava.jar', royaleHome + '/as2wasm/lib/external/', tgtDir);
-copyFile('lzma-sdk-LICENSE.html', royaleHome + '/as2wasm/lib/external/', tgtDir);
-copyFile('lzma-sdk.jar', royaleHome + '/as2wasm/lib/external/', tgtDir);
+createDirectory(tgtDir);
+copyFile('antlr-LICENSE.html', royaleHome + 'as2wasm/lib/external/', tgtDir);
+copyFile('antlr.jar', royaleHome + 'as2wasm/lib/external/', tgtDir);
+copyFile('commons-cli.jar', royaleHome + 'as2wasm/lib/external/', tgtDir);
+copyFile('commons-io.jar', royaleHome + 'as2wasm/lib/external/', tgtDir);
+copyFile('flex-tool-api-LICENSE.html', royaleHome + 'as2wasm/lib/external/', tgtDir);
+copyFile('flex-tool-api.jar', royaleHome + 'as2wasm/lib/external/', tgtDir);
+copyFile('guava-LICENSE.html', royaleHome + 'as2wasm/lib/external/', tgtDir);
+copyFile('guava.jar', royaleHome + 'as2wasm/lib/external/', tgtDir);
+copyFile('lzma-sdk-LICENSE.html', royaleHome + 'as2wasm/lib/external/', tgtDir);
+copyFile('lzma-sdk.jar', royaleHome + 'as2wasm/lib/external/', tgtDir);
 
 tgtDir = projectPath + 'lib/player/';
-fs.mkdirSync(tgtDir);
-copyFile('playerglobal.swc', royaleHome + '/as2wasm/lib/player/25.0/', tgtDir);
+createDirectory(tgtDir);
+copyFile('playerglobal.swc', royaleHome + 'as2wasm/lib/player/', tgtDir);
 
-copyFile('build.js', royaleHome + '/as2wasm/resources/', projectPath);
-copyFile('install.js', royaleHome + '/as2wasm/resources/', projectPath);
+copyFile('build.js', royaleHome + 'as2wasm/resources/', projectPath);
+copyFile('install.js', royaleHome + 'as2wasm/resources/', projectPath);
 
-createFile(projectPath + '/README', `To build and run this project, use:
+createFile(projectPath + 'README', `To build and run this project, use:
 
 cd [project dir]
 npm run build
 `);
 
-createFile(projectPath + '/package.json', `{
+createFile(projectPath + 'package.json', `{
 
   "dependencies": { 
     "http-server" : "0.10.0"
   },
   
   "scripts": {
-    "build": "node install.js; node build.js -playerglobal-version=${playerGlobalVersion}
-src=src/${projectName}.as; http-server ./bin -o -a localhost -p 1337 -c-1"
+    "build": "node install.js; node build.js -src=src/${projectName}.as; http-server ./bin
-o -a localhost -p 1337 -c-1"
   }
 
 }
 `);
 
-projectSrcPath = projectPath + '/src';
-if (!fs.existsSync(projectSrcPath)) {
-  fs.mkdirSync(projectSrcPath);
-}
-createFile(projectSrcPath + '/' + projectName + '.as', `package {
+projectSrcPath = projectPath + 'src/';
+createDirectory(projectSrcPath);
+createFile(projectSrcPath + projectName + '.as', `package {
 
   public class ${projectName} {
 
diff --git a/as2wasm/download.js b/as2wasm/download.js
index bc0157b..d07255c 100644
--- a/as2wasm/download.js
+++ b/as2wasm/download.js
@@ -85,7 +85,7 @@ prompt.get(schema, function (err, result) {
       if(200 !== response.statusCode) {
         console.log(`Download failed with status code: ${response.statusCode}`);
       } else {
-        let destination = `lib/player/${fileData.version}.0/`;
+        let destination = 'lib/player/';
 
         if (!fs.existsSync('lib')) {
           fs.mkdirSync('lib');
diff --git a/as2wasm/resources/build.js b/as2wasm/resources/build.js
index 7dd4065..c8e8eae 100644
--- a/as2wasm/resources/build.js
+++ b/as2wasm/resources/build.js
@@ -44,7 +44,7 @@ process.argv.slice(2).forEach(function (value) {
   }
 });
 
-cmd = `/usr/bin/java -Xmx384m -Dsun.io.useCanonCaches=false -jar "lib/compiler/wastc.jar"
-external-library-path="lib/player/${args['playerglobal-version']}.0/playerglobal.swc" ${args['src']}`;
+cmd = `/usr/bin/java -Xmx384m -Dsun.io.useCanonCaches=false -jar "lib/compiler/wastc.jar"
-external-library-path="lib/player/playerglobal.swc" ${args['src']}`;
 exec(cmd, function (error, stdout, stderr) {
   console.log(stdout);
 

-- 
To stop receiving notification emails like this one, please contact
"commits@royale.apache.org" <commits@royale.apache.org>.

Mime
View raw message