]> source.dussan.org Git - aspectj.git/commitdiff
Fixed Bugzilla Bug 113554: support ajsym file generation for command line builds
authormkersten <mkersten>
Tue, 8 Nov 2005 02:33:59 +0000 (02:33 +0000)
committermkersten <mkersten>
Tue, 8 Nov 2005 02:33:59 +0000 (02:33 +0000)
ajde/testsrc/org/aspectj/ajde/AjdeTests.java
ajde/testsrc/org/aspectj/ajde/SymbolFileGenerationTest.java [new file with mode: 0644]
docs/devGuideDB/ajc.xml
org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java

index 461dfc52f3c345ccec10b6deeaf3cba996eaf354..bf95d0e37dc087d2748c470fd5e49880568ee3d4 100644 (file)
@@ -40,7 +40,8 @@ public class AjdeTests extends TestCase {
     public static Test suite() { 
         TestSuite suite = new TestSuite(AjdeTests.class.getName());
         //$JUnit-BEGIN$
-               suite.addTestSuite(ShowWeaveMessagesTestCase.class);
+        suite.addTestSuite(SymbolFileGenerationTest.class);
+        suite.addTestSuite(ShowWeaveMessagesTestCase.class);
                suite.addTestSuite(DuplicateManifestTest.class);
                suite.addTestSuite(BuildOptionsTest.class); 
         suite.addTestSuite(BuildConfigurationTests.class);
diff --git a/ajde/testsrc/org/aspectj/ajde/SymbolFileGenerationTest.java b/ajde/testsrc/org/aspectj/ajde/SymbolFileGenerationTest.java
new file mode 100644 (file)
index 0000000..100ed2f
--- /dev/null
@@ -0,0 +1,65 @@
+/* *******************************************************************
+ * Copyright (c) 1999-2001 Xerox Corporation, 
+ *               2002 Palo Alto Research Center, Incorporated (PARC).
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Common Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://www.eclipse.org/legal/cpl-v10.html 
+ *  
+ * Contributors: 
+ *     Xerox/PARC     initial implementation 
+ * ******************************************************************/
+
+package org.aspectj.ajde;
+
+import java.io.File;
+
+import org.aspectj.tools.ajc.AjcTestCase;
+
+/**
+ * @author Mik Kersten
+ */
+public class SymbolFileGenerationTest extends AjcTestCase {
+       private static final String DIR = "../ajde/testdata/examples/coverage";
+
+       protected File dir = new File(DIR);
+       protected File configFile = new File(DIR + "/coverage.lst");
+       protected File esymFile = new File(DIR + "/ModelCoverage.ajesym");
+       protected File outDir = new File(DIR + "/bin"); 
+       protected File crossRefsFile = new File(outDir.getAbsolutePath() + "/build.ajsym");
+       
+       protected void setUp() throws Exception {
+               super.setUp();
+       }
+       
+       public void testCrossRefsFileGeneration() {
+               if (crossRefsFile.exists()) assertTrue(crossRefsFile.delete());
+               if (esymFile.exists()) assertTrue(esymFile.delete());
+               String[] args = new String[] {
+                               "-d",
+                               outDir.getAbsolutePath(),
+                               "-crossrefs",
+                               "@" + configFile.getAbsolutePath()
+               };
+               ajc(dir, args);
+               
+               assertFalse(esymFile.exists());
+               assertTrue(crossRefsFile.exists());
+       }
+
+       public void testEmacssymGeneration() {
+               if (crossRefsFile.exists()) assertTrue(crossRefsFile.delete());
+               if (esymFile.exists()) assertTrue(esymFile.delete());
+               String[] args = new String[] {
+                               "-d",
+                               outDir.getAbsolutePath(),
+                               "-emacssym",
+                               "@" + configFile.getAbsolutePath()
+               };
+               ajc(dir, args);
+               
+               assertTrue(esymFile.exists());
+               assertFalse(crossRefsFile.exists());
+       }
+}
index ef3438987329987ff03c4504f319b0a280d432b9..04393eaa5f1faea1a6ec94c30a1fd78f3af2decb 100644 (file)
         </para></listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term>-crossrefs</term>
+        <listitem><para>
+          Generate a build .ajsym file into the output directory.  Used for
+          viewing crosscutting references by tools like the AspectJ
+          Browser.
+        </para></listitem>
+      </varlistentry>
+
+
       <varlistentry>
         <term>-emacssym</term>
         <listitem><para>
index 74135e9b659945a6f64059903c7c3e9140cbf2f1..9db08913dc7165a18f241ad87ac28316529a2b2a 100644 (file)
@@ -117,7 +117,6 @@ public class BuildArgParser extends Main {
                        
                        AjcConfigParser parser = new AjcConfigParser(buildConfig, handler);
                        parser.parseCommandLine(args);
-                       
                        boolean swi = buildConfig.getShowWeavingInformation();
                        // Now jump through firey hoops to turn them on/off
                        if (handler instanceof CountingMessageHandler) {
@@ -519,6 +518,9 @@ public class BuildArgParser extends Main {
                 } else {
                     showError("-XincrementalFile requires file argument");
                 }
+                       } else if (arg.equals("-crossrefs")) {
+                               buildConfig.setGenerateCrossRefsMode(true);
+                               buildConfig.setGenerateModelMode(true);
                        } else if (arg.equals("-emacssym")) {
                                buildConfig.setEmacsSymMode(true);
                                buildConfig.setGenerateModelMode(true);
index 9a9029e97cc27e0910e5235488b8b0adf1d1db92..a297978eca10f2209053d58fb8e8c92bd67d5621 100644 (file)
@@ -31,6 +31,7 @@ AspectJ-specific options:\n\
 \t                    (reads stdin: enter to recompile and ''q'' to quit)\n\
 \t-sourceroots <dirs> compile all .aj and .java files in <dirs>\n\
 \t                    (<dirs> uses classpath delimiter)\n\
+\t-crossrefs          generate .ajsym file into the output directory\n\
 \t-emacssym           generate .ajesym symbol files for emacs support\n\
 \t-Xlint              same as ''-Xlint:warning''\n\
 \t-Xlint:<level>      set default level for crosscutting messages\n\
index 8b5cf2132b65a56c0b82006017832fe528b560d4..505b80844e8545fd3bab67ab8e3f05ec81c8b60a 100644 (file)
@@ -515,6 +515,14 @@ public class AjBuildConfig {
                        boolean generateJavadocsInModelMode) {
                options.generateJavaDocsInModel = generateJavadocsInModelMode;
        }
+
+       public boolean isGenerateCrossRefsMode() {
+               return options.generateCrossRefs;
+       }
+
+       public void setGenerateCrossRefsMode(boolean on) {
+               options.generateCrossRefs = on;
+       }
        
        public boolean isEmacsSymMode() {
                return options.generateEmacsSymFiles;
index 9cb561ea295181c7a3de3483d83bc81c769f5748..004ab65343cefb384badf2f40bf446d7506b0694 100644 (file)
@@ -89,6 +89,7 @@ import org.eclipse.core.runtime.OperationCanceledException;
 //import org.aspectj.org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
 
 public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourceProvider,ICompilerAdapterFactory {
+       private static final String CROSSREFS_FILE_NAME = "build.lst";
        private static final String CANT_WRITE_RESULT = "unable to write compilation result";
        private static final String MANIFEST_NAME = "META-INF/MANIFEST.MF";
        static final boolean COPY_INPATH_DIR_RESOURCES = false;
@@ -281,6 +282,15 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
             if (buildConfig.isEmacsSymMode()) {
                 new org.aspectj.ajdt.internal.core.builder.EmacsStructureModelManager().externalizeModel();
             }
+            
+            // for bug 113554: support ajsym file generation for command line builds
+            if (buildConfig.isGenerateCrossRefsMode()) {
+                String configFileProxy = buildConfig.getOutputDir().getAbsolutePath() 
+                       + File.separator 
+                       + CROSSREFS_FILE_NAME; 
+               AsmManager.getDefault().writeStructureModel(configFileProxy);
+            }
+            
             // have to tell state we succeeded or next is not incremental
             state.successfulCompile(buildConfig,batch);
 
index 2e1196b3a561a58ec68ac874040a4d1758bae03b..7481b4ffc5238fb33f5cba354c3c2999ada879ee 100644 (file)
@@ -79,6 +79,12 @@ public class AjCompilerOptions extends CompilerOptions {
        public boolean generateEmacsSymFiles = false;
        public boolean noAtAspectJProcessing = false;
        
+       /**
+        * Generates a map of cross references based on information
+        * in the structure model.
+        */
+       public boolean generateCrossRefs = false;
+       
        public boolean proceedOnError = false;