Brian Dolan
Brian Dolan

Reputation: 3136

Disambiguate source files in Chapel build

Following up on this question about including source files. I am including a Chapel modules that contains one file called classes.chpl, but my current project also has a classes.chpl. What is the correct disambiguation pattern? When I do

chpl -M/path/src

it notes the conflict, then chooses the classes.chpl in the current directory. Should I compile the module for export as in this page or is there another pattern.

== UPDATE ==

The directory structure looks like

projA/alpha.chpl
     /classes.chpl

projB/beta.chpl
     /classes.chpl

Where each project depends on the classes in the respective classes.chpl file. Trying to compile projA I am currently using

chpl alpha.chpl -M../projB/

But this causes a conflict, as it tries to use projA/classes.cphl for the classes in both beta.chpl and alpha.chpl.

Upvotes: 3

Views: 35

Answers (1)

David Iten
David Iten

Reputation: 545

As described in the module search paths tech note, the Chapel compiler searches for user modules by, in this order:

  1. Looking at .chpl files specified on the command line
  2. Looking at other .chpl files in the directories containing the files specified on the command line
  3. Looking at .chpl files in the paths specified via the -M option or the CHPL_MODULE_PATH environment variable

Since the compiler finds the classes.chpl from the project directory using rule 2, and only finds the /path/src/classes.chpl with rule 3, it chooses the one in the project directory. To get it to choose /path/src/classes.chpl instead, you can specify it on the command line so it is found with rule 1.

chpl mainModule.chpl /path/src/classes.chpl

Upvotes: 3

Related Questions