Skip to content

Autorun(-early) doesn't seem to run when lym files are inside a package #21

@davidnhutch

Description

@davidnhutch

Something is broken about the macro autorun feature, under certain circumstances, in 0.25

Assumed problem:

It seems the autorun-on-startup feature probably only looks in KLayout/macros folder right now. I think it should also look in KLayout/salt/package-name/macros and KLayout/group-name/package-name/macros. This enables dependencies between packages without needing to "load 'filename.rb'" to manually run one code from the other code.

Steps to reproduce the problem:

  1. Create file1.lym and file2.lym under macros folder (the main macros folder, not inside a package)

file1.lym:

# Choose properties > Run early on startup
module MyModule
  class MyClass
    def MyMethod
      p 'hello world'
    end
  end
end

file2.lym:

include MyModule
MyClass.new.MyMethod
  1. Make file1.lym be auto-run early.
  2. Close then open KL.
  3. Run file2.lym via the Macro Editor. It works! (Nothing is wrong.)
  4. Now, create a package named "mypackage" using Tools > Manage Packages. Use the Ruby template.
  5. Move file1.lym and file2.lym to salt/mypackage/macros using the OS filesystem. (Or create them anew there and delete the old ones.)
  6. Close then open KL.
  7. Try to run file2.lym via the Macro Editor. It doesn't work. (Apparently file1.lym has not run, so it doesn't recognize MyModule.)
  8. Now, if you manually run file1.lym in the Macro Editor, then run file2.lym, it works. This indicates that there is nothing broken about the code. It is just that file1.lym is not autorunning on startup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions