diff options
| author | ruki <[email protected]> | 2021-10-21 22:58:58 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-10-21 22:58:58 +0800 |
| commit | efa63d26a7d3c5a76344141150771fe76137ef3a (patch) | |
| tree | 607d63228d4684e41d97c08b9010e7407cb104ec | |
| parent | 6af62c9f179ad500ae8a0a6c1f3607f77839dc92 (diff) | |
add nim templates
| -rw-r--r-- | tests/projects/nim/shared_library/src/foo.nim | 4 | ||||
| -rw-r--r-- | tests/projects/nim/shared_library/src/main.nim | 4 | ||||
| -rwxr-xr-x | xmake/templates/nim/console/project/src/main | bin | 0 -> 92184 bytes | |||
| -rw-r--r-- | xmake/templates/nim/console/project/src/main.nim | 1 | ||||
| -rw-r--r-- | xmake/templates/nim/console/project/xmake.lua | 7 | ||||
| -rw-r--r-- | xmake/templates/nim/console/template.lua | 2 | ||||
| -rw-r--r-- | xmake/templates/nim/shared/project/src/foo.nim | 6 | ||||
| -rw-r--r-- | xmake/templates/nim/shared/project/src/main.nim | 3 | ||||
| -rw-r--r-- | xmake/templates/nim/shared/project/xmake.lua | 14 | ||||
| -rw-r--r-- | xmake/templates/nim/shared/template.lua | 2 | ||||
| -rw-r--r-- | xmake/templates/nim/static/project/src/foo.nim | 6 | ||||
| -rw-r--r-- | xmake/templates/nim/static/project/src/main.nim | 3 | ||||
| -rw-r--r-- | xmake/templates/nim/static/project/xmake.lua | 14 | ||||
| -rw-r--r-- | xmake/templates/nim/static/template.lua | 2 | ||||
| -rw-r--r-- | xmake/templates/rust/console/project/xmake.lua | 6 |
15 files changed, 64 insertions, 10 deletions
diff --git a/tests/projects/nim/shared_library/src/foo.nim b/tests/projects/nim/shared_library/src/foo.nim index 4a3e920ff..db968d723 100644 --- a/tests/projects/nim/shared_library/src/foo.nim +++ b/tests/projects/nim/shared_library/src/foo.nim @@ -1,5 +1,5 @@ -proc fibonacci(n: int): int {.cdecl, exportc, dynlib.} = +proc foo(n: int): int {.cdecl, exportc, dynlib.} = if n < 2: result = n else: - result = fibonacci(n - 1) + (n - 2).fibonacci + result = foo(n - 1) + (n - 2).foo diff --git a/tests/projects/nim/shared_library/src/main.nim b/tests/projects/nim/shared_library/src/main.nim index c473c5401..81a64bda0 100644 --- a/tests/projects/nim/shared_library/src/main.nim +++ b/tests/projects/nim/shared_library/src/main.nim @@ -1,4 +1,4 @@ -proc fibonacci(n: int): int {.cdecl, importc} +proc foo(n: int): int {.cdecl, importc} -echo fibonacci(2) +echo foo(2) diff --git a/xmake/templates/nim/console/project/src/main b/xmake/templates/nim/console/project/src/main Binary files differnew file mode 100755 index 000000000..84f0819ac --- /dev/null +++ b/xmake/templates/nim/console/project/src/main diff --git a/xmake/templates/nim/console/project/src/main.nim b/xmake/templates/nim/console/project/src/main.nim new file mode 100644 index 000000000..17179284f --- /dev/null +++ b/xmake/templates/nim/console/project/src/main.nim @@ -0,0 +1 @@ +echo "hello xmake!" diff --git a/xmake/templates/nim/console/project/xmake.lua b/xmake/templates/nim/console/project/xmake.lua new file mode 100644 index 000000000..1aa5639db --- /dev/null +++ b/xmake/templates/nim/console/project/xmake.lua @@ -0,0 +1,7 @@ +add_rules("mode.debug", "mode.release") + +target("${TARGETNAME}") + set_kind("binary") + add_files("src/*.nim") + +${FAQ} diff --git a/xmake/templates/nim/console/template.lua b/xmake/templates/nim/console/template.lua new file mode 100644 index 000000000..ed2e13b57 --- /dev/null +++ b/xmake/templates/nim/console/template.lua @@ -0,0 +1,2 @@ +template("console") + add_configfiles("xmake.lua") diff --git a/xmake/templates/nim/shared/project/src/foo.nim b/xmake/templates/nim/shared/project/src/foo.nim new file mode 100644 index 000000000..cde4de7ca --- /dev/null +++ b/xmake/templates/nim/shared/project/src/foo.nim @@ -0,0 +1,6 @@ +proc foo(n: int): int {.cdecl, exportc, dynlib.} = + if n < 2: + result = n + else: + result = foo(n - 1) + (n - 2).foo + diff --git a/xmake/templates/nim/shared/project/src/main.nim b/xmake/templates/nim/shared/project/src/main.nim new file mode 100644 index 000000000..1be3abe69 --- /dev/null +++ b/xmake/templates/nim/shared/project/src/main.nim @@ -0,0 +1,3 @@ +proc foo(n: int): int {.cdecl, importc} + +echo foo(2) diff --git a/xmake/templates/nim/shared/project/xmake.lua b/xmake/templates/nim/shared/project/xmake.lua new file mode 100644 index 000000000..e2d380ac6 --- /dev/null +++ b/xmake/templates/nim/shared/project/xmake.lua @@ -0,0 +1,14 @@ +add_rules("mode.debug", "mode.release") + +target("${TARGETNAME}") + set_kind("shared") + add_files("src/foo.nim") + +target("${TARGETNAME}_demo") + set_kind("binary") + add_deps("${TARGETNAME}") + add_files("src/main.nim") + +${FAQ} + + diff --git a/xmake/templates/nim/shared/template.lua b/xmake/templates/nim/shared/template.lua new file mode 100644 index 000000000..d7ec5bae4 --- /dev/null +++ b/xmake/templates/nim/shared/template.lua @@ -0,0 +1,2 @@ +template("shared") + add_configfiles("xmake.lua") diff --git a/xmake/templates/nim/static/project/src/foo.nim b/xmake/templates/nim/static/project/src/foo.nim new file mode 100644 index 000000000..be0904262 --- /dev/null +++ b/xmake/templates/nim/static/project/src/foo.nim @@ -0,0 +1,6 @@ +proc foo(n: int): int {.cdecl, exportc} = + if n < 2: + result = n + else: + result = foo(n - 1) + (n - 2).foo + diff --git a/xmake/templates/nim/static/project/src/main.nim b/xmake/templates/nim/static/project/src/main.nim new file mode 100644 index 000000000..1be3abe69 --- /dev/null +++ b/xmake/templates/nim/static/project/src/main.nim @@ -0,0 +1,3 @@ +proc foo(n: int): int {.cdecl, importc} + +echo foo(2) diff --git a/xmake/templates/nim/static/project/xmake.lua b/xmake/templates/nim/static/project/xmake.lua new file mode 100644 index 000000000..cf70acb9e --- /dev/null +++ b/xmake/templates/nim/static/project/xmake.lua @@ -0,0 +1,14 @@ +add_rules("mode.debug", "mode.release") + +target("${TARGETNAME}") + set_kind("static") + add_files("src/foo.nim") + +target("${TARGETNAME}_demo") + set_kind("binary") + add_deps("${TARGETNAME}") + add_files("src/main.nim") + +${FAQ} + + diff --git a/xmake/templates/nim/static/template.lua b/xmake/templates/nim/static/template.lua new file mode 100644 index 000000000..abfe91a4b --- /dev/null +++ b/xmake/templates/nim/static/template.lua @@ -0,0 +1,2 @@ +template("static") + add_configfiles("xmake.lua") diff --git a/xmake/templates/rust/console/project/xmake.lua b/xmake/templates/rust/console/project/xmake.lua index 7a363c461..5c3f06804 100644 --- a/xmake/templates/rust/console/project/xmake.lua +++ b/xmake/templates/rust/console/project/xmake.lua @@ -1,13 +1,7 @@ --- add modes: debug and release add_rules("mode.debug", "mode.release") --- add target target("${TARGETNAME}") - - -- set kind set_kind("binary") - - -- add files add_files("src/*.rs") ${FAQ} |
