Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added csharp meta-example generation and include generated examples i…
…n test build and cookbook
- Loading branch information
Showing
6 changed files
with
96 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
SET(CSHARP_FLAGS "/lib:${CSHARP_MODULAR_BUILD_DIR};/r:modshogun") | ||
|
||
# add test case for each generated example | ||
# (not generated yet so have to fake filenames from META_EXAMPLES list) | ||
FOREACH(META_EXAMPLE ${META_EXAMPLES}) | ||
# assume a structure <target_language>/<category>/listing.sg | ||
STRING(REGEX REPLACE ".*/(.*).sg" "\\1" EXAMPLE_NAME ${META_EXAMPLE}) | ||
STRING(REGEX REPLACE ".*/(.*/.*).sg" "\\1" EXAMPLE_NAME_WITH_DIR ${META_EXAMPLE}) | ||
STRING(REGEX REPLACE "/" "-" EXAMPLE_NAME_WITH_DIR ${EXAMPLE_NAME_WITH_DIR}) | ||
STRING(REGEX REPLACE ".*/(.*)/.*.sg" "\\1" EXAMPLE_REL_DIR ${META_EXAMPLE}) | ||
|
||
ADD_CUSTOM_COMMAND(OUTPUT ${EXAMPLE_NAME_WITH_DIR}.exe | ||
COMMAND ${CSHARP_COMPILER} ${EXAMPLE_NAME}.cs ${CSHARP_FLAGS} -out:${EXAMPLE_NAME}.exe | ||
DEPENDS csharp_modular | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE_REL_DIR}) | ||
LIST(APPEND CSHARP_EXAMPLES ${EXAMPLE_NAME_WITH_DIR}.exe) | ||
|
||
add_test(NAME generated_csharp-${EXAMPLE_NAME_WITH_DIR} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
COMMAND ${CSHARP_INTERPRETER} ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE_REL_DIR}/${EXAMPLE_NAME}.exe) | ||
set_property(TEST generated_csharp-${EXAMPLE_NAME_WITH_DIR} PROPERTY | ||
ENVIRONMENT "MONO_PATH=${CSHARP_MODULAR_BUILD_DIR}") | ||
ENDFOREACH() | ||
|
||
add_custom_target(build_csharp_meta_examples ALL | ||
DEPENDS ${CSHARP_EXAMPLES} | ||
COMMENT "C# examples") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"Program": "using System;\n\npublic class classifier_knn_modular {\n public static void Main() {\n modshogun.init_shogun_with_defaults();\n\n$program\n }\n}\n", | ||
"Dependencies": { | ||
"AllDependencies": "$enumDependencies\n\n", | ||
"EnumDependencies": "$enums", | ||
"DependencyListElementClass": "$element", | ||
"DependencyListElementEnum": "import static org.shogun.$type.$value;", | ||
"DependencyListSeparator": "\n" | ||
}, | ||
"Statement": " $statement;\n", | ||
"Comment": " //$comment\n", | ||
"Init": { | ||
"Construct": "$type $name = new $type($arguments)", | ||
"Copy": "$type $name = $expr" | ||
}, | ||
"Assign": "$name = $expr", | ||
"Type": { | ||
"Default": "$type", | ||
"bool": "bool", | ||
"string": "String", | ||
"BoolVector": "bool[]", | ||
"CharVector": "char[]", | ||
"ByteVector": "byte[]", | ||
"WordVector": "ushort[]", | ||
"ShortVector": "short[]", | ||
"IntVector": "int[]", | ||
"LongIntVector": "long[]", | ||
"ULongIntVector": "ulongint[]", | ||
"ShortRealVector": "float[]", | ||
"RealVector": "double[]", | ||
"LongRealVector": "double[]", | ||
"ComplexVector": "???", | ||
"BoolMatrix": "bool[,]", | ||
"CharMatrix": "char[,]", | ||
"ByteMatrix": "byte[,]", | ||
"WordMatrix": "ushort[,]", | ||
"ShortMatrix": "short[,]", | ||
"IntMatrix": "int[,]", | ||
"LongIntMatrix": "long[,]", | ||
"ULongIntMatrix": "ulongint[,]", | ||
"ShortRealMatrix": "float[,]", | ||
"RealMatrix": "float[,]", | ||
"LongRealMatrix": "double[,]", | ||
"ComplexMatrix": "????" | ||
}, | ||
"Expr": { | ||
"StringLiteral": "\"$literal\"", | ||
"BoolLiteral": { | ||
"True": "true", | ||
"False": "false" | ||
}, | ||
"NumberLiteral": "$number", | ||
"MethodCall": "$object.$method($arguments)", | ||
"Identifier": "$identifier", | ||
"Enum":"$value" | ||
}, | ||
"Print": "Console.Write($expr)", | ||
"OutputDirectoryName": "csharp", | ||
"FileExtension": ".cs" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters