Generate multiple targets from single source Follow
Hi,
as stated into the section "How to generate multiple targets from single source?" of the Generator cookbook, I would like to use the second option: have no generator into my language plus one language for each desired target, each one with its generator.
I would like to have also a solution for each target for example to add a parameter to each generation target. So we have this model:
and this generators
The question is: I would like each target generator be able "to see" models from MySol while generating its solution, for example the java solution, without the need for the java solution to reference each nodes of the MySol solution somewhere. It's possible?
Obviously a simple solution is to have a container concept into the java solution that references all root nodes of MySol. But this way I have to change the java solution each time a root node is addeded/removed from MySol.
And if using "Language engaged on generation" I should put everything into one single solution.
Thx,
Mar
as stated into the section "How to generate multiple targets from single source?" of the Generator cookbook, I would like to use the second option: have no generator into my language plus one language for each desired target, each one with its generator.
I would like to have also a solution for each target for example to add a parameter to each generation target. So we have this model:
- language MyLang (no generator)
- solution MySol using MyLang
and this generators
- language toJava, with generator to generator java
- solution using toJava with details for Java (import MySol).
- language toXml, with generator to generator xml
- solution using toXml with details for XML (import MySol).
- ecc.
The question is: I would like each target generator be able "to see" models from MySol while generating its solution, for example the java solution, without the need for the java solution to reference each nodes of the MySol solution somewhere. It's possible?
Obviously a simple solution is to have a container concept into the java solution that references all root nodes of MySol. But this way I have to change the java solution each time a root node is addeded/removed from MySol.
And if using "Language engaged on generation" I should put everything into one single solution.
Thx,
Mar
Please sign in to leave a comment.
can a generator while generating SolutionB see nodes from SolutionA just because SolutionB is importing SolutionA? I mean without having nodes from SolutionB referencing nodes of SolutionA?
Thx,
Mar
Longer answer would be "It's possible", and depends how far you'd like to go down the road of internal and non=stable API ;). genContext.originalModel gives you model object which you could cast to openapi.SModel, and then internal API j.m.smodel.SModelOperations.getImportedModelUIDs() gives you list of model imports, which you'd need to resolve to get to SModel/model object again.
However I did not need to go that deep: with your hint about genContext.originalModel I saw it has the method rootsIncludingImported() and this is actually returning roots from the imported solution.
I created reference nodes into a transient input model using a pre-precessing script, indeed my first pre-processing script.
Don't know if it's the best implementation but it works. Thx!