Skip to content

Commit

Permalink
Merge pull request #2 from Minres/develop
Browse files Browse the repository at this point in the history
Merge for patch release
  • Loading branch information
eyck authored Oct 5, 2017
2 parents a1bcd48 + 30653d0 commit 1260464
Show file tree
Hide file tree
Showing 23 changed files with 1,929 additions and 388 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: RDL Editor
Bundle-SymbolicName: com.minres.rdl.product;singleton:=true
Bundle-Version: 1.1.0.qualifier
Bundle-Version: 1.1.1.qualifier
Bundle-Vendor: MINRES
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.12.0"
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>

<product name="RDL" uid="com.minres.rdl.product.product" id="com.minres.rdl.product.product" application="org.eclipse.ui.ide.workbench" version="1.0.0.qualifier" useFeatures="true" includeLaunchers="true">

<product name="RDL" uid="com.minres.rdl.product.product" id="com.minres.rdl.product.product" application="org.eclipse.ui.ide.workbench" version="1.1.1.qualifier" useFeatures="true" includeLaunchers="true">

<configIni use="default">
</configIni>
Expand All @@ -14,14 +13,13 @@

<windowImages/>

<launcher>
<launcher name="rdl-editor">
<solaris/>
<win useIco="false">
<bmp/>
</win>
</launcher>


<vm>
</vm>

Expand Down
3 changes: 2 additions & 1 deletion com.minres.rdl.parent/com.minres.rdl.product/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.minres.rdl</groupId>
<artifactId>com.minres.rdl.parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>com.minres.rdl.product</artifactId>
<packaging>eclipse-application</packaging>
Expand All @@ -18,4 +18,5 @@
</plugins>
</build>

<version>1.1.1-SNAPSHOT</version>
</project>
3 changes: 2 additions & 1 deletion com.minres.rdl.parent/com.minres.rdl.standalone/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
<parent>
<artifactId>com.minres.rdl.parent</artifactId>
<groupId>com.minres.rdl</groupId>
<version>1.1.0-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
</parent>
<version>1.1.1-SNAPSHOT</version>
</project>
2 changes: 1 addition & 1 deletion com.minres.rdl.parent/com.minres.rdl.target/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.minres.rdl</groupId>
<artifactId>com.minres.rdl.parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>com.minres.rdl.target</artifactId>
<packaging>eclipse-target-definition</packaging>
Expand Down
1 change: 1 addition & 0 deletions com.minres.rdl.parent/com.minres.rdl.ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/plugin.xml_gen
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: com.minres.rdl.ui
Bundle-Vendor: My Company
Bundle-Version: 1.1.0.qualifier
Bundle-Version: 1.1.1.qualifier
Bundle-SymbolicName: com.minres.rdl.ui; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: com.minres.rdl,
Expand Down
3 changes: 2 additions & 1 deletion com.minres.rdl.parent/com.minres.rdl.ui/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ source.. = src/,\
xtend-gen/
bin.includes = .,\
META-INF/,\
plugin.xml
plugin.xml,\
icons/
bin.excludes = **/*.xtend
3 changes: 2 additions & 1 deletion com.minres.rdl.parent/com.minres.rdl.ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.minres.rdl</groupId>
<artifactId>com.minres.rdl.parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>com.minres.rdl.ui</artifactId>
<packaging>eclipse-plugin</packaging>
Expand All @@ -18,4 +18,5 @@
</plugins>
</build>

<version>1.1.1-SNAPSHOT</version>
</project>
4 changes: 4 additions & 0 deletions com.minres.rdl.parent/com.minres.rdl/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/Run RDL Generator DBT-RISCV (test).launch
/Run RDL Generator DBT-RISCV.launch
/Run RDL Generator SC-Components-Test.launch
/plugin.xml_gen
3 changes: 2 additions & 1 deletion com.minres.rdl.parent/com.minres.rdl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.minres.rdl</groupId>
<artifactId>com.minres.rdl.parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>com.minres.rdl</artifactId>
<packaging>eclipse-plugin</packaging>
Expand Down Expand Up @@ -146,4 +146,5 @@
</pluginManagement>
</build>

<version>1.1.0-SNAPSHOT</version>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.minres.rdl.generator

import com.minres.rdl.generator.RdlBaseGenerator
import com.minres.rdl.rdl.ComponentDefinition
import com.minres.rdl.IntegerWithRadix
import com.minres.rdl.rdl.ComponentDefinitionType

class AddrmapGenerator extends RdlBaseGenerator {

Expand All @@ -15,10 +17,12 @@ class AddrmapGenerator extends RdlBaseGenerator {
#ifndef _E300_PLAT_MAP_H_
#define _E300_PLAT_MAP_H_
// need double braces, see https://stackoverflow.com/questions/6893700/how-to-construct-stdarray-object-with-initializer-list#6894191
const std::array<sysc::target_memory_map_entry<32>, 3> e300_plat_map = {{
{&i_gpio, 0x10012000, 0x1000},
{&i_uart, 0x10013000, 0x1000},
{&i_spi, 0x10014000, 0x1000}
const std::array<sysc::target_memory_map_entry<32>, «componentDefinition.instanceCount(ComponentDefinitionType.REGFILE)»> e300_plat_map = {{
«FOR instantiation : componentDefinition.instantiationsOfType(ComponentDefinitionType.REGFILE)»
«FOR instance : instantiation.componentInstances»
{&i_«instance.name», 0x«Long.toHexString((instance.address as IntegerWithRadix).value)», 0x«Long.toHexString(instantiation.byteSize)»},
«ENDFOR»
«ENDFOR»
}};
#endif /* _E300_PLAT_MAP_H_ */
Expand All @@ -29,4 +33,5 @@ class AddrmapGenerator extends RdlBaseGenerator {
''
}


}
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.minres.rdl.generator


import com.google.inject.Inject
import com.google.inject.Provider
import com.minres.rdl.RDLStandaloneSetup
import java.lang.reflect.MalformedParametersException
import java.util.ArrayList
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.resource.ResourceSet
import org.eclipse.emf.mwe.utils.ProjectMapping
Expand All @@ -19,34 +17,33 @@ import org.eclipse.xtext.util.CancelIndicator
import org.eclipse.xtext.validation.CheckMode
import org.eclipse.xtext.validation.IResourceValidator
import java.text.ParseException
import com.minres.rdl.generator.Options.Multiplicity
import com.minres.rdl.generator.Options.Separator
import org.eclipse.xtext.generator.IFileSystemAccess

class Main {
static class Option {
String flag
String value
def Option(String flag, String value) {
this.flag = flag
this.value = value
}
}

private val USAGE_STR = "RDL2code [-h] [-v] [-I <RDL include dir] [-o <output dir>] <input file> <input file>";

def static main(String[] args) {
if (args.empty) {
System::err.println('Aborting: no path to EMF resource provided!')
System::err.println('Aborting: no path to RDL file provided!')
return
}

try {
val injector = new RDLStandaloneSetup().createInjectorAndDoEMFRegistration
injector.getInstance(Main).run(args)
} catch(MalformedParametersException e){
print("Command line error "+e.message)
} catch(IllegalArgumentException e){
print("generation error "+e.message)
val injector = new RDLStandaloneSetup().createInjectorAndDoEMFRegistration
val main = injector.getInstance(Main)
try {
main.run(args)
} catch (MalformedParametersException e) {
print("Command line error " + e.message)
System.exit(1)
} catch (IllegalArgumentException e) {
print("generation error " + e.message)
e.printStackTrace
} catch(ParseException e){
print("parse problem "+e.message+" ("+ e.errorOffset+")")

System.exit(2)
} catch (ParseException e) {
print("parse problem " + e.message + " (" + e.errorOffset + ")")
System.exit(3)
}
}

Expand All @@ -58,89 +55,71 @@ class Main {

@Inject JavaIoFileSystemAccess fileAccess

var optsList = new ArrayList<Option>();
var argsList = new ArrayList<String>()
val shortOptMap = newLinkedHashMap('i' -> 'incl-out', 's' -> 'src-out')

def protected parseOptions(String[] args) {
for (arg : args) {
switch (arg) {
case arg.startsWith('--'): {
if (arg.length < 3)
throw new MalformedParametersException("not a valid argument: " + arg);
val res = arg.substring(2).split('=')
var opt = new Option()
val longOpt = shortOptMap.values.findFirst[String s|s == res.get(0)]
if(longOpt === null) throw new IllegalArgumentException("unknown option: " + arg);
opt.flag = res.get(0)
if (res.size == 2)
opt.value = res.get(1)
optsList += opt
}
case arg.startsWith('-'): {
if (arg.length < 2)
throw new MalformedParametersException("not a valid argument: " + arg);
// -opt
var res = arg.substring(1).split('=')
val longOpt = shortOptMap.get(res.get(0))
if(longOpt === null) throw new MalformedParametersException("unknown option: " + arg);
var opt = new Option()
opt.flag = longOpt
if (res.size == 2)
opt.value = res.get(1)
optsList += opt
def run(String[] args) {

}
default: {
argsList += arg;
}
}
val opt = new Options(args, 0, Integer.MAX_VALUE);
opt.getSet().addOption("h", Multiplicity.ZERO_OR_ONE);
opt.getSet().addOption("v", Multiplicity.ZERO_OR_ONE);
opt.getSet().addOption("o", Separator.BLANK, Multiplicity.ZERO_OR_ONE);
opt.getSet().addOption("I", Separator.BLANK, Multiplicity.ZERO_OR_ONE);
if (!opt.check(false, false)) { // Print usage hints
System.err.println("Usage is: " + USAGE_STR);
throw new MalformedParametersException(opt.getCheckErrors());
}
// Normal processing
if (opt.getSet().isSet("h")) {
println("Usage: " + USAGE_STR);
return
}
val verbose = if(opt.getSet().isSet("v")) true else false;

}

def run(String[] args){
parseOptions(args)
val repo = optsList.findFirst[it.flag == "repository"]
if(repo!==null){
if (opt.getSet().isSet("I")) {
val projectMapping = new ProjectMapping
projectMapping.projectName = "RDL Repository"
projectMapping.path = repo.value
projectMapping.path = opt.getSet().getOption("I").getResultValue(0)
new StandaloneSetup().addProjectMapping(projectMapping)
}
argsList.forEach[runGenerator(it)]
}

def protected runGenerator(String string) {
// Load the resource
val resourceSet = resourceSetProvider.get as XtextResourceSet
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
val resource = resourceSet.getResource(URI.createFileURI(string), true)
// Validate the resource
val issues = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl)
if (!issues.empty) {
System.err.println("Error validating "+resource.URI)
issues.forEach[System.err.println(it)]
throw new ParseException("error validating "+resource.URI, issues.size)
}
// Configure and start the generator
fileAccess.outputPath = 'src-gen/'
optsList.filter[it.flag.matches('.*-out')].forEach[fileAccess.setOutputPath(it.flag, it.value)]
fileAccess.outputConfigurations.get('src-out')?.setOverrideExistingResources(true)

val context = new GeneratorContext => [ cancelIndicator = CancelIndicator.NullImpl ]
generator.generate(resource, fileAccess, context)

System.out.print('Code generation for '+string +' finished, ')
try{
System.out.print('includes are in '+fileAccess.getURI('', 'incl-out')+', ')
}catch(Exception e){
System.out.print('includes are in '+fileAccess.getURI('')+', ')
}
try{
System.out.println('sources are in '+fileAccess.getURI('', 'src-out')+', ')
}catch(Exception e){
System.out.println('sources are in '+fileAccess.getURI('')+', ')
if(opt.getSet().isSet('o')){
fileAccess.outputPath = opt.getSet().getOption('o').getResultValue(0)
fileAccess.outputConfigurations.get(IFileSystemAccess.DEFAULT_OUTPUT)?.setOverrideExistingResources(true)
}
// #{'incl-out' -> false, 'src-out' -> false, 'gen-out' -> true}.forEach[p1, p2|
// if(opt.getSet().isSet(p1.substring(0, 1)))
// fileAccess.setOutputPath(p1, opt.getSet().getOption(p1.substring(0, 1)).getResultValue(0)+'/')
// else
// fileAccess.setOutputPath(p1, 'src-gen/')
// fileAccess.outputConfigurations.get(p1)?.setOverrideExistingResources(p2)
// ]
opt.getSet().getData().forEach [ String string |
if(verbose) println("Processing " + string);
// Load the resource
val resourceSet = resourceSetProvider.get as XtextResourceSet
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
val resource = resourceSet.getResource(URI.createFileURI(string), true)
// Validate the resource
val issues = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl)
if (!issues.empty) {
System.err.println("Error validating " + resource.URI)
issues.forEach[System.err.println(it)]
throw new ParseException("error validating " + resource.URI, issues.size)
}

val context = new GeneratorContext => [cancelIndicator = CancelIndicator.NullImpl]
generator.generate(resource, fileAccess, context)

if(verbose) println('Code generation for ' + string + ' finished')
try {
if(verbose) println('includes are in ' + fileAccess.getURI('', 'incl-out'))
} catch (Exception e) {
println('includes are in ' + fileAccess.getURI(''))
}
try {
if(verbose) println('sources are in ' + fileAccess.getURI('', 'src-out'))
} catch (Exception e) {
println('sources are in ' + fileAccess.getURI(''))
}
]
}
}
Loading

0 comments on commit 1260464

Please sign in to comment.