Possible to define a "project root path" in Franca?

54 views
Skip to first unread message

lorenz...@googlemail.com

unread,
May 9, 2014, 1:17:03 AM5/9/14
to franca-f...@googlegroups.com
Hi Klaus,

It appears that currently, imports in Franca models have to be either relative to the current file or an absolute location.

Is it possible to declare imports relative to a common root directory?

I have the following project structure:

/path/to/my/project/folder1/file1.fidl
/path/to/my/project/folder2/file2.fidl

If I want to import elements from file1 in file2, - to keep things portable - I have to use a relative path: "../folder1/file1.fidl".
I would prefer to set the project root directory to /path/to/my/project and use this as base for all imports, so that I can write "folder1/file1.fidl" (or something equivalent) instead.

I tried Franca 0.8.11 and I couldn't find this feature, neither in the IDE nor in the Java API.

Thanks a lot!
Lorenz

Klaus Birken

unread,
May 9, 2014, 1:49:31 AM5/9/14
to franca-f...@googlegroups.com
Hi Lorenz,

currently (with 0.8.x and upcoming 0.9.0) this is only possible by using classpath-URIs. See an example and details here:


In a later version (0.9.x) Franca will likely support a more flexible scheme of import addressing, including the use case you mentioned. 

Best regards,
Klaus

klau...@intel.com

unread,
May 9, 2014, 7:57:57 AM5/9/14
to franca-f...@googlegroups.com
Hi Klaus,

for me a much more common situation than having a single root directory to which imports should be relative is having multiple potential roots in which relative import paths have to be searched (think of include search paths in C/C++ or the already mentioned classpath in Java).

Therefore, I want to add two questions:
(1) Will this be supported in a later Franca version? Are there concrete plans?
(2) You are stating that classpath URIs already support this. How can I configure (or extend) them with my own custom classpath entries - especially in a C/C++ project?

Kind regards
Klaus

h...@protos.de

unread,
May 9, 2014, 9:46:53 AM5/9/14
to franca-f...@googlegroups.com
Hi Klaus,

I had exactly the same requirement in a customer project.
And I came up with a fairly general solution where the model resolution algorithm is taken from extensions (if called e.g. from the editor) or can be set explicitly (if called in a non OSGi headless environment).

I'm one of the project leads of the Eclipse eTrice project (eclipse.org/etrice) and I've implemented this solution there.

In both, eTrice and the customer project using a patched Franca version, the solution is working like a charm.

There is also a Franca patch in preparation. This is still lacking a default resolution mechanism which would allow the unit tests to succeed again. As soon as I can find the time I would complete the task and send a pull request to the Franca project.

h...@protos.de

unread,
May 9, 2014, 9:50:19 AM5/9/14
to franca-f...@googlegroups.com
Hi Klaus,

I wouldn't use the classpath mechanism in C/C++ projects since it is (in my opinion) not transparent and also unnatural for C/C++ projects.

Regards,
Henrik

klau...@intel.com

unread,
May 9, 2014, 9:53:17 AM5/9/14
to franca-f...@googlegroups.com
Hi,

that sounds great. Maybe you can give Klaus Birken a heads up so that he can check if your solution fits the overall project structure (maybe you have already done so).

Kind regards
Klaus

klau...@intel.com

unread,
May 9, 2014, 9:56:52 AM5/9/14
to franca-f...@googlegroups.com
Hi Henrik,

I absolutely agree with you. It would only be a temporary solution until a better resolution mechanism is available.

Kind regards
Klaus

Klaus Birken

unread,
May 9, 2014, 10:24:58 AM5/9/14
to franca-f...@googlegroups.com
Hi Klaus,

I am aware of Henrik's activities, we are in contact about this extension. I am looking forward integrating the solution in the project.

@Henrik: Thanks for your (upcoming) contribution!

And: Yes, "classpath:" is just a workaround in C/C++ environments, a more generic design will be much better... BTW: For Franca 0.9.0, we did lots of dependency clean-up to get rid of the JDT dependencies in Franca. 

Regards,
Klaus

Klaus Birken

unread,
May 13, 2014, 7:20:56 AM5/13/14
to franca-f...@googlegroups.com
Hi all,

here is an update regarding classpath handling in C/C++ environments (as long as Henrik's contribution is not part of Franca). Franca 0.9.0 will dynamically detect in the IDE if JDT is installed (i.e., it checks for org.eclipse.jdt.core). If it is installed, your project has to have the Java nature (see .project file). In the project's Properties dialog in the IDE, select Java Build Path in order to add entries to the classpath. 

If Franca 0.9.0 doesn't detect JDT (e.g., in a pure CDT installation), the classpath-mechanism is not available. Then, only absolute paths or relative paths can be used.

Regards,
Klaus

Reply all
Reply to author
Forward
0 new messages