Compilation of Ruby script files

Hi there,
I'm generating my GDS files using Ruby macro script.
My script contains many "rb" files where each file contains a function that I wrote (I have almost 20 different functions/files).
I found that each time that I'm starting KLayout, I need to compile all the files and then run the main file which calls all the functions.
Is there a way to avoid the compilation of each individual file before running the program? Is there a script method that complies a file?
Appropriate your support


  • Hi sunSeeker,

    what do you mean by "compile"?

    You can use "require" or "load" in Ruby to import your library files.

    Here is the concept:

    In your KLayout application folder ("~/.klayout" on Linux or "c:\users\yourself\KLayout" on Windows) you'll find two places relevant for this: "macros" and "ruby".

    The "ruby" folder is in Ruby's search path, so you can "load" a file there. For example look here:

    You will see one primary macro ".lym" in "macros". This is the file which is auto-loaded by KLayout. You will also see some ".rb" files in "ruby". The main entry file is this: This script will only load the other scripts there.

    So in the main macro I can write:


    which will pull in "xsection.rb" from the "ruby" folder which itself loads all the other files with their functions, classes and modules.


Sign In or Register to comment.