yafred / asn1-tool

A java tool to generate Java encoders and decoders from ASN.1 specifications.
MIT License
43 stars 22 forks source link

Behavior in Compiling Dependent Modules #16

Open dev-chirag opened 2 years ago

dev-chirag commented 2 years ago

Does the compiler requires all modules to be defined in the same ASN.1 file?

Is there any way to compile dependent modules in different ASN.1 files?

yafred commented 2 years ago

Yes, it only takes one input file

odiferousmint commented 2 years ago

If you know how to code, you may be able to modify https://github.com/yafred/asn1-tool/blob/master/tool/src/main/java/com/yafred/asn1/tool/Compiler.java to allow for multiple ASN.1 files.

I did the same thing some time ago. First argument is the output directory, and the rest are the ASN.1 files. I do not have the code though, I would have to re-write it.

dev-chirag commented 2 years ago

I actually implemented kind of a hack here:

ArrayList<ModuleDefinition> moduleDefinitions = new ArrayList<>(dependentModules); moduleDefinitions.addAll(model.getModuleDefinitionList()); model.setModuleDefinitionList(moduleDefinitions); validateASNSchema(resourceName, message, name, model); generator.processSpecification(model);

I parsed my dependent models first and added all the ModuleDefinitions to the main ASN.1 file. Not sure if this works for most cases, but I was able to generate the code for my ASN files through this.

Thanks

odiferousmint commented 2 years ago

I actually implemented kind of a hack here:

ArrayList<ModuleDefinition> moduleDefinitions = new ArrayList<>(dependentModules); moduleDefinitions.addAll(model.getModuleDefinitionList()); model.setModuleDefinitionList(moduleDefinitions); validateASNSchema(resourceName, message, name, model); generator.processSpecification(model);

I parsed my dependent models first and added all the ModuleDefinitions to the main ASN.1 file. Not sure if this works for most cases, but I was able to generate the code for my ASN files through this.

Thanks

So, can you have, say, a module file and another file for the protocol? Is that working successfully for you? If you want to, you may post a diff/patch here I suppose. People may appreciate it.