nim-libnx/libnxGen.cfg
2018-07-13 18:09:57 +09:00

359 lines
7.9 KiB
INI

[n.global]
output="src/libnx/wrapper"
c_compiler="aarch64-none-elf-gcc"
cpp_compiler="aarch64-none-elf-g++"
filter=lock
[n.include]
"${output}/nx/include"
"${output}/nx/include/switch"
"${output}/nx/include/switch/arm"
"${output}/nx/include/switch/kernel"
"${output}/nx/include/switch/services"
"${output}/nx/include/switch/audio"
"${output}/nx/include/switch/gfx"
"${output}/nx/include/switch/runtime"
"${output}/nx/include/switch/runtime/util"
"${output}/nx/include/switch/runtime/devices"
"${DEVKITPRO}/devkitA64/aarch64-none-elf/include/"
"${DEVKITA64}/aarch64-none-elf/include/"
[n.exclude]
"${output}/nim.cfg"
"${output}/config.nims"
[n.wildcard]
wildcard.1 = "console.h"
rename = "$replace(console=con)"
search = "_Bool"
replace = "bool"
wildcard.2 = "*.h"
search.u8 = "u8"
replace.u8 = "uint8"
search.u16 = "u16"
replace.u16 = "uint16"
search.u32 = "u32"
replace.u32 = "uint32"
search.u64 = "u64"
replace.u64 = "uint64"
wildcard.3 = "*.nim"
search.bool = "_Bool"
replace.bool = "bool"
search.lib = "src/libnx/wrapper"
replace.lib = "libnx/wrapper"
search.kimport = "../kernel/"
replace.kimport = "libnx/wrapper/"
search.resimport = "../result"
replace.resimport = "libnx/wrapper/result"
search.armimport = "../arm/"
replace.armimport = "libnx/wrapper/"
search.lock = "_LOCK"
replace.lock = "LOCK"
search.cdecl = "stdcall"
replace.cdecl = "cdecl"
[n.prepare]
git = "https://github.com/switchbrew/libnx"
execute = """
cd ${output}
make
"""
[n.post]
reset=true
[src/libnx/wrapper/nim.cfg]
create = """
--path:"../"
--path:"../../"
"""
[src/libnx/wrapper/config.nims]
create = """
switch("passC", "-I" & thisDir() & "/nx/include")
switch("passL", "-specs=" & thisDir() & "/nx/switch.specs -L" & thisDir() & "/nx/lib -lnx")
"""
[result.h]
defines = true
[hid.h]
defines = true
search.static_assert = "static_assert"
replace.static_assert = "// static_assert"
search.touch = "touchPosition"
replace.touch = "TouchPosition"
[ipc.h]
defines = true
[romfs_dev.h]
search = "romfs_"
replace = "Romfs_"
[gfx.h]
defines = true
[ioctl.h]
defines = true
search = "_NV_"
replace = "UNV_"
search.nv = "__nv_"
replace.nv = "DUnv_"
[svc.h]
search = "PACKED"
replace = ""
search.noreturn = "NORETURN"
replace.noreturn = ""
defines=true
pipe = "vim -es +'g/^static inline.*{/norm f{d%r;' -es +%print -es +q! $file"
[switch.h]
preprocess = true
defines = true
recurse = true
[types.nim]
search.o = " uint8*"
prepend.o = """
u8* = uint8
u16* = uint16
u32* = uint32
u64* = uint64
int8_t* = int8
int16_t* = int16
int32_t* = int32
int64_t* = int64
ssize_t* = int
"""
search.s128 = " s128* = __int128_t"
replace.s128 = ""
search.u128 = " u128* = __uint128_t"
replace.u128 = ""
search.uint8 = "uint8* = uint8_t"
replace.uint8 = "uint8_t* = uint8"
search.uint16 = "uint16* = uint16_t"
replace.uint16 = "uint16_t* = uint16"
search.uint32 = "uint32* = uint32_t"
replace.uint32 = "uint32_t* = uint32"
search.uint64 = "uint64* = uint64_t"
replace.uint64 = "uint64_t* = uint64"
search.import = "type\n"
prepend.import = """
import libnx/ext/integer128
template BIT*(n): auto = (1.uint shl n)
"""
[svc.nim]
search.timport = "../types"
replace.timport = "libnx/wrapper/types"
search.permx = "Perm_X = BIT(2), ## /< Execute permission."
replace.permx = "Perm_Rw = Perm_R.int or Perm_W.int, ## /< Read/write permissions."
search.permrw = "Perm_Rw = Perm_R or Perm_W, ## /< Read/write permissions."
replace.permrw = "Perm_X = BIT(2), ## /< Execute permission."
search.permrx = "Perm_Rx = Perm_R or Perm_X, ## /< Read/execute permissions."
replace.permrx = "Perm_Rx = Perm_R.int or Perm_X.int, ## /< Read/execute permissions."
[shmem.nim]
search.import = "type\n"
prepend.import = """
import libnx/wrapper/svc
"""
[nacp.nim]
search.t = "type"
prepend.t = """
import libnx/wrapper/types
"""
[lock.nim]
search.flock_t = " __lock_t"
replace.flock_t = " DUlock_t"
search.nlock_t = "= __lock_t"
replace.nlock_t = "= DUlock_t"
search.import = "type"
prepend.import = """
import libnx/wrapper/types
"""
search.proc_under = "proc __"
replace.proc_under = "proc DU"
[ipc.nim]
search.o = "UINT32_MAX"
replace.o = "uint32.high"
search.import = "import\n"
append.import = """
libnx/wrapper/types,
"""
[audin.nim]
search.o = "import "
prepend.o = """
import libnx/wrapper/types
"""
[audout.nim]
search.o = "import "
prepend.o = """
import libnx/wrapper/types
"""
[hid.nim]
search.servimport = "../services/"
replace.servimport = "libnx/wrapper/"
search.timport = "../types"
replace.timport = "libnx/wrapper/types"
search.o = """ KEY_JOYCON_RIGHT = BIT(0), KEY_JOYCON_DOWN = BIT(1), KEY_JOYCON_UP = BIT(2), KEY_JOYCON_LEFT = BIT(
3),"""
replace.o = ""
search.key_left = "KEY_LEFT = KEY_DLEFT or KEY_LSTICK_LEFT or KEY_RSTICK_LEFT, ## /< D-Pad Left or Sticks Left"
replace.key_left = ""
search.key_rstick_up = " KEY_RSTICK_UP"
prepend.key_rstick_up = """
KEY_LEFT = KEY_DLEFT.int or KEY_LSTICK_LEFT.int or KEY_RSTICK_LEFT.int, ## /< D-Pad Left or Sticks Left
"""
search.key_right = " KEY_RIGHT = KEY_DRIGHT or KEY_LSTICK_RIGHT or KEY_RSTICK_RIGHT ## /< D-Pad Right or Sticks Right"
replace.key_right = ""
search.key_rstick_down = " KEY_RSTICK_DOWN"
prepend.key_rstick_down = """
KEY_RIGHT = KEY_DRIGHT.int or KEY_LSTICK_RIGHT.int or KEY_RSTICK_RIGHT.int, ## /< D-Pad Right or Sticks Right
"""
search.key_up = " KEY_UP = KEY_DUP or KEY_LSTICK_UP or KEY_RSTICK_UP, ## /< D-Pad Up or Sticks Up"
replace.key_up = ""
search.key_rstick_right = " KEY_RSTICK_RIGHT"
prepend.key_rstick_right = """
KEY_UP = KEY_DUP.int or KEY_LSTICK_UP.int or KEY_RSTICK_UP.int, ## /< D-Pad Up or Sticks Up
"""
search.key_down = " KEY_DOWN = KEY_DDOWN or KEY_LSTICK_DOWN or KEY_RSTICK_DOWN, ## /< D-Pad Down or Sticks Down"
replace.key_down = ""
search.key_sl = " KEY_SL"
prepend.key_sl = """
KEY_DOWN = KEY_DDOWN.int or KEY_LSTICK_DOWN.int or KEY_RSTICK_DOWN.int, ## /< D-Pad Down or Sticks Down
"""
[nifm.nim]
search.o = "import libnx"
prepend.o = """
import libnx/wrapper/types
"""
[set.nim]
search.o = "import libnx"
prepend.o = """
import libnx/wrapper/types
"""
[parcel.nim]
search.o = "import libnx"
prepend.o = """
import libnx/wrapper/types
"""
[fs_dev.nim]
search.o = "import libnx"
prepend.o = """
import libnx/wrapper/types
"""
[buffer_producer.nim]
search.o = "import libnx"
prepend.o = """
import libnx/wrapper/types
import libnx/wrapper/binder
"""
[nxlink.nim]
search.o = "var __nxlink"
replace.o = "var DUnxlink"
[fs.nim]
search.o = "import libnx"
prepend.o = """
import libnx/ext/integer128
"""
[acc.nim]
prepend.o = """
import libnx/ext/integer128
"""
[con.nim]
search.o = "type\n"
prepend.o = """
template CONSOLE_ESC*(x: string): string = "\x1b[" & $x
# Colors
template CONSOLE_RESET*: string = CONSOLE_ESC("0m")
template CONSOLE_BLACK*: string = CONSOLE_ESC("30m")
template CONSOLE_RED*: string = CONSOLE_ESC("31;1m")
template CONSOLE_GREEN*: string = CONSOLE_ESC("32;1m")
template CONSOLE_YELLOW*: string = CONSOLE_ESC("33;1m")
template CONSOLE_BLUE*: string = CONSOLE_ESC("34;1m")
template CONSOLE_MAGENTA*: string = CONSOLE_ESC("35;1m")
template CONSOLE_CYAN*: string = CONSOLE_ESC("36;1m")
template CONSOLE_WHITE*: string = CONSOLE_ESC("37;1m")
# Styles
template CONSOLE_COLOR_BOLD*: int = BIT(0).int
template CONSOLE_COLOR_FAINT*: int = BIT(1).int
template CONSOLE_ITALIC*: int = BIT(2).int
template CONSOLE_UNDERLINE*: int = BIT(3).int
template CONSOLE_BLINK_SLOW*: int = BIT(4).int
template CONSOLE_BLINK_FAST*: int = BIT(5).int
template CONSOLE_COLOR_REVERSE*: int = BIT(6).int
template CONSOLE_CONCEAL*: int = BIT(7).int
template CONSOLE_CROSSED_OUT*: int = BIT(8).int
"""
search.threedmoo = "debugDevice_3DMOO"
replace.threedmoo = "debugDevice_3DMOO*"
[gfx.nim]
search.timport = "../types"
replace.timport = "libnx/wrapper/types"
[romfs_dev.nim]
search.timport = "../types"
replace.timport = "libnx/wrapper/types"
search.servimport = "../services/"
replace.servimport = "libnx/wrapper/"
[n.sourcefile]
"${output}/*.nim"