You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2021/09/20 21:25:00 UTC

[royale-compiler] 05/05: build: add formatter

This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 9195440be0eed53f208d5b6ca8952c00b3b81774
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Mon Sep 20 14:09:59 2021 -0700

    build: add formatter
---
 build.xml                                  | 29 +++++++++++++-
 compiler/src/assembly/scripts/asformat     | 62 ++++++++++++++++++++++++++++++
 compiler/src/assembly/scripts/asformat.bat | 26 +++++++++++++
 pom.xml                                    |  1 +
 releasesteps.xml                           |  6 +++
 5 files changed, 123 insertions(+), 1 deletion(-)

diff --git a/build.xml b/build.xml
index 4f9086f..82af803 100644
--- a/build.xml
+++ b/build.xml
@@ -71,7 +71,7 @@
 
     <target name="swf" depends="sdk, javadoc, tests" description="Builds SWF compiler, builds Royale Javadoc, and runs SWF compiler tests."/>
 
-    <target name="main" depends="swf, jx, oem, debugger, anttasks, royaleunit.anttasks" description="Builds Royale SWF compiler, then Royale JS Transpiler"/>
+    <target name="main" depends="swf, jx, oem, debugger, formatter, anttasks, royaleunit.anttasks" description="Builds Royale SWF compiler, then Royale JS Transpiler"/>
 
     <target name="jx" depends="compiler.jx, compiler.jx.tests" description="Builds Royale JS Transpiler" />
     
@@ -100,6 +100,10 @@
     <target name="debugger" depends="swfutils" description="Builds FDB JAR">
         <ant dir="debugger" target="jar"/>
     </target>
+
+    <target name="formatter" description="Builds formatter JAR">
+        <ant dir="formatter" target="main"/>
+    </target>
     
     <target name="compiler.jx" description="Builds Royale JS Transpiler.">
         <ant dir="compiler-jx" target="main"/>
@@ -142,6 +146,7 @@
         <ant dir="royale-ant-tasks" target="clean"/>
         <ant dir="royaleunit-ant-tasks" target="clean"/>
         <ant dir="debugger" target="clean"/>
+        <ant dir="formatter" target="clean"/>
     </target>
 
     <target name="wipe" description="Wipes out everything that didn't come from Git.">
@@ -171,6 +176,7 @@
         <ant dir="royale-ant-tasks" target="wipe"/>
         <ant dir="royaleunit-ant-tasks" target="wipe"/>
         <ant dir="debugger" target="clean"/>
+        <ant dir="formatter" target="clean"/>
         <delete dir="${basedir}/out" failonerror="false" includeEmptyDirs="true"/>
         <delete dir="${basedir}/temp" failonerror="false" includeEmptyDirs="true"/>
         <!-- remove legacy folders if they exist -->
@@ -288,6 +294,9 @@
         <!-- compiler -->
         <antcall target="stage-compiler"/>
         
+        <!-- formatter -->
+        <antcall target="stage-formatter"/>
+        
         <!-- flex-compiler-oem and fdb -->
         <antcall target="stage-fb-integration"/>
         
@@ -443,6 +452,24 @@
         <!--<antcall target="version-update"/>-->
     </target>
 
+    <target name="stage-formatter">
+        <copy todir="${staging-dir}/formatter" includeEmptyDirs="false">
+            <fileset dir="${basedir}/formatter">
+                <include name="**"/>
+                <exclude name=".classpath" />
+                <exclude name=".project" />
+                <exclude name=".settings/**" />
+                <exclude name="in/**"/>
+                <exclude name="lib/**"/>
+                <exclude name="target/classes/**"/>
+                <exclude name="target/test-classes/**"/>
+                <exclude name="target/junit-temp/**"/>
+                <exclude name="target/junit-reports/**"/>
+                <exclude name="**/unittest.properties" />
+            </fileset>
+        </copy>
+    </target>
+
     <target name="stage-fb-integration">
         <copy todir="${staging-dir}/debugger" includeEmptyDirs="false">
             <fileset dir="${basedir}/debugger">
diff --git a/compiler/src/assembly/scripts/asformat b/compiler/src/assembly/scripts/asformat
new file mode 100644
index 0000000..8020357
--- /dev/null
+++ b/compiler/src/assembly/scripts/asformat
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+################################################################################
+##
+##  Licensed to the Apache Software Foundation (ASF) under one or more
+##  contributor license agreements.  See the NOTICE file distributed with
+##  this work for additional information regarding copyright ownership.
+##  The ASF licenses this file to You under the Apache License, Version 2.0
+##  (the "License"); you may not use this file except in compliance with
+##  the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing, software
+##  distributed under the License is distributed on an "AS IS" BASIS,
+##  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+##  See the License for the specific language governing permissions and
+##  limitations under the License.
+##
+################################################################################
+
+#
+# fasc shell script to launch compiler-asc.jar on OSX, Unix, or Cygwin.
+# In Windows Command Prompt, use fasc.bat instead.
+#
+
+if [ "x${ROYALE_COMPILER_HOME}" = "x" ]
+then
+    SCRIPT_HOME=`dirname "$0"`
+    ROYALE_COMPILER_HOME=${SCRIPT_HOME}/..
+else
+    echo Using Royale codebase: $ROYALE_COMPILER_HOME
+fi
+
+case `uname` in
+		CYGWIN*)
+			OS="Windows"
+		;;
+		*)
+			OS=Unix
+esac
+
+D32=''
+
+if [ $OS = "Windows" ]; then
+
+	ROYALE_COMPILER_HOME=`cygpath -m $ROYALE_COMPILER_HOME`
+
+elif [ $OS = "Unix" ]; then
+
+    check64="`java -version 2>&1 | grep -i 64-Bit`"
+    isOSX="`uname | grep -i Darwin`"
+    javaVersion="`java -version 2>&1 | awk -F '[ ".]+' 'NR==1 {print $3 "." $4}'`"
+    
+    if [ "$isOSX" != "" -a "$HOSTTYPE" = "x86_64" -a "$check64" != "" -a "$javaVersion" = "1.6" ]; then
+        D32='-d32'
+    fi
+fi
+
+VMARGS="-Xmx384m -Dsun.io.useCanonCaches=false "
+
+java $VMARGS $D32 $SETUP_SH_VMARGS -jar "${ROYALE_COMPILER_HOME}/lib/formatter.jar" "$@"
diff --git a/compiler/src/assembly/scripts/asformat.bat b/compiler/src/assembly/scripts/asformat.bat
new file mode 100644
index 0000000..7c1f5c9
--- /dev/null
+++ b/compiler/src/assembly/scripts/asformat.bat
@@ -0,0 +1,26 @@
+@echo off
+
+rem
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements.  See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License.  You may obtain a copy of the License at
+rem
+rem     http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+rem
+
+rem
+rem fasc.bat script to launch compiler-asc.jar in Windows Command Prompt.
+rem On OSX, Unix, or Cygwin, use the fasc shell script instead.
+rem
+
+@java -Dsun.io.useCanonCaches=false -Dapplication.home="%~dp0.." -Xms32m -Xmx512m -jar "%~dp0..\lib\formatter.jar" %*
+
diff --git a/pom.xml b/pom.xml
index 0d79b14..e62d398 100644
--- a/pom.xml
+++ b/pom.xml
@@ -106,6 +106,7 @@
     <module>compiler-test-utils</module>
     <module>swfutils</module>
     <module>debugger</module>
+    <module>formatter</module>
     <module>flex-compiler-oem</module>
     <module>royale-ant-tasks</module>
     <module>royaleunit-ant-tasks</module>
diff --git a/releasesteps.xml b/releasesteps.xml
index b4752ba..f45f8cb 100644
--- a/releasesteps.xml
+++ b/releasesteps.xml
@@ -323,6 +323,12 @@
             <param name="jarname" value="debugger" />
         </antcall>
         <antcall target="sign-jar-artifacts" >
+            <param name="jarname" value="formatter" />
+        </antcall>
+        <antcall target="sign-file" >
+            <param name="file" value="${artifactfolder}/artifacts/archive/target/local-release-dir/org/apache/royale/compiler/formatter/${release.version}/formatter-${release.version}-tests.jar" />
+        </antcall>
+        <antcall target="sign-jar-artifacts" >
             <param name="jarname" value="flex-compiler-oem" />
         </antcall>
         <antcall target="sign-jar-artifacts" >