17.5.6. AutoIncludeFile Plugins

AutoIncludeFile plugins are used to include source code files in archives. It could be that you want to bundle a source file containing a depack macro together with a segment modifier that packs a segment.

AutoIncludeFile plugins have an interface like all other plugins, but in 99% of all cases you can use the standard implementation included in the KickAssembler jar. Suppose you have a source file (MyAutoInclude.asm) with a macro you want to auto include when importing the archive:

//FILE: MyAutoInclude.asm
.macro SetColor(color) {
   lda #color
   sta $d020

Then you put MyAutoInclude.asm in your jar-file in the package 'include' and add an object of the class AutoIncludeFile to your archive. You archive could look like this:

public class MyArchive implements IArchive{

   public List<IPlugin> getPluginObjects() {
      ArrayList<IPlugin> plugins = new ArrayList<>(); 
      plugins.add(new SomePlugin1());
      plugins.add(new SomePlugin2());
      plugins.add(new AutoIncludeFile("MyArcive.jar",getClass(),"/include/MyAutoInclude.asm"));
      return plugins;

In the AutoIncludeFile-constructor you give:

  1. The jar-name - for use when printing error messages

  2. A random 'class'-object from the jar - this is used to open the resource.

  3. A path to the resource - the placement inside the jar.

The file will now be compiled with the rest of the source if the archive is imported.

For completeness, here is the IAutoIncludeFile-interface, but as mentioned, you probably wont need it.

public interface IAutoIncludeFile extends IPlugin {
   AutoIncludeFileDefinition getDefinition();
   InputStream openStream(); 

public class AutoIncludeFileDefinition {
   private String filePath;
   private String jarName;