Finding Imported Modules

General discussions about working with the Astrobe IDE and programming the Raspberry Pi RP2040 and the Pi Pico board.
Post Reply
gray
Posts: 158
Joined: Tue Feb 12, 2019 2:59 am
Location: Mauritius

Finding Imported Modules

Post by gray » Wed May 21, 2025 12:49 pm

From the Astrobe docs:
The editor, compiler, linker and builder first search the current folder when trying to locate imported source code, symbol and object files. They then search each of the folders listed in the current configuration’s Library Pathnames textbox.
Consider this test set-up:

Code: Select all

+ C:\Test
  + lib
    + Main.mod
    + M0.mod
    + M1.mod
  + prog
    + M1.mod
    + P.mod
Code:

Code: Select all

MODULE P;
  IMPORT Main, M0;
END P.

MODULE Main;
END Main.

MODULE M0;
  IMPORT M1;
END M0.

MODULE M1;
  (* same in 'lib' and 'prog' *)
END M1.
Library search path:

Code: Select all

C:\Test\lib
Buidling with all directories "clean" of any symbol and object files:

Code: Select all

Astrobe for RP2350 Builder v10.0.1
Builder Phase 1: Checking P.mod and imported modules...

Checking Module Main
  Imports:
  Folder: C:\Test\lib
  Status: Missing Main.arm file
Checking Module M1
  Imports:
  Folder: C:\Test\prog
  Status: Missing M1.arm file
Checking Module M0
  Imports:
    M1
  Folder: C:\Test\lib
  Status: Missing M0.arm file
Checking Module P
  Imports:
    Main
    M0
  Folder: C:\Test\prog
  Status: Missing P.arm file
------------------

Builder Phase 2: Compiling missing / outdated modules...

  compiling C:\Test\lib\Main.mod
new symbol file;  code generated = 8 bytes, data = 0 bytes, entries = 0, lines = 2, msecs = 11
------------------
  compiling C:\Test\prog\M1.mod
new symbol file;  code generated = 8 bytes, data = 0 bytes, entries = 0, lines = 2, msecs = 1
------------------
  compiling C:\Test\lib\M0.mod

  Line  Col
     2   13 Error: import not available
------------------
2 modules compiled, lines = 6, msecs = 13
That is, a compiled M1.mod in the same directory as M0.mod is not found, unsurprisingly, as M1.mod in 'prog' was compiled, not the one in 'lib', and the search path does not lead to 'prog'.

Running with this search path, again with clean directories:

Code: Select all

C:\Test\prog
C:\Test\lib
results in sucessful compilation and linking (only linker output shown):

Code: Select all

Astrobe for RP2350 Linker v10.0.1
module Main  6E69614DH
filename C:\Test\lib\Main.arm
module P  00000000H
filename C:\Test\prog\P.arm
  importing M0  0300304DH     0     0
module M0  0300304DH
filename C:\Test\lib\M0.arm
  importing M1  0300314DH     0     0
module M1  0300314DH
filename C:\Test\prog\M1.arm
  linking Main                 8 bytes
  linking M1                   8 bytes
  linking M0                   8 bytes
  linking P                    8 bytes
Unless I miss something here, this does not conform the documentation: in both cases, M1.mod in 'lib' should have been picked, since the imported module in the same directory as the importer should take precedence.

Now, I would prefer if the observed behaviour were the intended one, as it allows to easily replace library modules with custom ones. Please clarify, thanks.

Post Reply