Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add porting codes of rt-thread. #494

Merged
merged 4 commits into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The iwasm supports the following architectures:
Following platforms are supported. Refer to [WAMR porting guide](./doc/port_wamr.md) for how to port WAMR to a new platform.

- [Linux](./doc/build_wamr.md#linux), [Linux SGX (Intel Software Guard Extension)](./doc/linux_sgx.md), [MacOS](./doc/build_wamr.md#macos), [Android](./doc/build_wamr.md#android), [Windows](./doc/build_wamr.md#windows)
- [Zephyr](./doc/build_wamr.md#zephyr), [AliOS-Things](./doc/build_wamr.md#alios-things), [VxWorks](./doc/build_wamr.md#vxworks), [NuttX](./doc/build_wamr.md#nuttx)
- [Zephyr](./doc/build_wamr.md#zephyr), [AliOS-Things](./doc/build_wamr.md#alios-things), [VxWorks](./doc/build_wamr.md#vxworks), [NuttX](./doc/build_wamr.md#nuttx), [RT-Thread](./doc/build_wamr.md#RT-Thread)

### Build iwasm VM core (mini product)

Expand Down
33 changes: 33 additions & 0 deletions SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# Copyright (c) 2021, RT-Thread Development Team
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#

# for module compiling
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add license header for all files, for the new file, you might claim the copyright to yourself and set license to "Apache-2.0 WITH LLVM-exception", please ref to other file submitted by community developer, e.g. nuttx_platform.c.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have add license header to files I added, please check it.

import os

from building import *

objs = []
cwd = GetCurrentDir()
list = os.listdir(cwd)

if GetDepend(['PKG_USING_WAMR']):
wamr_entry_sconscript = os.path.join(cwd, "product-mini", "platforms", "rt-thread", 'SConscript')

if os.path.isfile(wamr_entry_sconscript):
objs = objs + SConscript(wamr_entry_sconscript)
else:
print("[WAMR] entry script wrong:", wamr_entry_sconscript)
Return('objs')

wamr_runlib_sconsript = os.path.join(cwd, "build-scripts", 'SConscript')

if os.path.isfile(wamr_runlib_sconsript):
objs = objs + SConscript(wamr_runlib_sconsript)
else:
print("[WAMR] runtime lib script wrong:", wamr_runlib_sconsript)

Return('objs')

88 changes: 88 additions & 0 deletions build-scripts/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#
# Copyright (c) 2021, RT-Thread Development Team
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#

import os
from building import *

cwd = GetCurrentDir()
objs = []

WAMR_ROOT_DIR = os.path.join(cwd, "..")


SHARED_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'shared')

IWASM_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'iwasm')

APP_MGR_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'app-mgr')

APP_FRAMEWORK_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'app-framework')

DEPS_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'deps')

if GetDepend(['WAMR_BUILD_INTERP']):
script_path = os.path.join(IWASM_DIR, 'interpreter', 'SConscript')
objs += SConscript(script_path)


if GetDepend(['WAMR_BUILD_AOT']):
script_path = os.path.join(IWASM_DIR, 'aot', 'SConscript')
objs += SConscript(script_path)
if GetDepend(['WAMR_BUILD_JIT']):
script_path = os.path.join(IWASM_DIR, 'compilation', 'SConscript')
objs += SConscript(script_path)


if GetDepend(['WAMR_BUILD_APP_FRAMEWORK']):
objs += SConscript(os.path.join(APP_FRAMEWORK_DIR, 'SConscript'))
objs += SConscript(os.path.join(SHARED_DIR, 'coap', 'SConscript'))
objs += SConscript(os.path.join(APP_MGR_DIR, 'app-manager', 'SConscript'))
objs += SConscript(os.path.join(APP_MGR_DIR, 'app-mgr-shared', 'SConscript'))



if GetDepend(['WAMR_BUILD_LIBC_BUILTIN']):
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-builtin', 'SConscript'))



if GetDepend(['WAMR_BUILD_LIBC_WASI']):
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-wasi', 'SConscript'))


if GetDepend(['WAMR_BUILD_LIB_PTHREAD']):
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-pthread', 'SConscript'))
# TODO: 这里加一下



# if (WAMR_BUILD_THREAD_MGR EQUAL 1)
# include (${IWASM_DIR}/libraries/thread-mgr/thread_mgr.cmake)
# endif ()

if GetDepend(['WAMR_BUILD_THREAD_MGR']):
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'thread-mgr', 'SConscript'))



# if (WAMR_BUILD_LIBC_EMCC EQUAL 1)
# include (${IWASM_DIR}/libraries/libc-emcc/libc_emcc.cmake)
# endif()

if GetDepend(['WAMR_BUILD_LIBC_EMCC']):
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-emmc', 'SConscript'))

objs += SConscript(os.path.join(cwd, 'SConscript_config'));


objs += SConscript(os.path.join(SHARED_DIR, 'platform', 'rt-thread', 'SConscript'))
objs += SConscript(os.path.join(SHARED_DIR, 'mem-alloc', 'SConscript'))
objs += SConscript(os.path.join(IWASM_DIR, 'common', 'SConscript'))
objs += SConscript(os.path.join(SHARED_DIR, 'utils', 'SConscript'))



Return('objs')
123 changes: 123 additions & 0 deletions build-scripts/SConscript_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@


import os
import re

from building import *
#
# Copyright (c) 2021, RT-Thread Development Team
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#

Import('rtconfig')

src = Split('''
''')
objs = []
cwd = GetCurrentDir()

IWASM_INC_DIR = os.path.join(cwd, '..', 'core', 'iwasm', 'include')

# include_directories (${IWASM_DIR}/include)

CPPPATH = [IWASM_INC_DIR]

if rtconfig.BUILD == 'debug':
CPPDEFINES = ['BH_DEBUG=1']
else:
CPPDEFINES = ['BH_DEBUG=0']

if rtconfig.ARCH == 'arm':
if re.match('^cortex-m.*', rtconfig.CPU):
print('[WAMR] using thumbv4t')
CPPDEFINES += ['BUILD_TARGET_THUMB']
CPPDEFINES += [r'BUILD_TARGET=\"thumbv4t\"']
elif re.match('^cortex-a.*', rtconfig.CPU):
print('[WAMR] using armv7')
CPPDEFINES += ['BUILD_TARGET_ARM']
CPPDEFINES += [r'BUILD_TARGET=\"armv7\"']
elif re.match('^cortex-r.*', rtconfig.CPU):
print('[WAMR] using armv7')
CPPDEFINES += ['BUILD_TARGET_ARM']
CPPDEFINES += [r'BUILD_TARGET=\"armv7\"']
elif rtconfig.CPU == 'armv6':
print('[WAMR] using armv6')
CPPDEFINES += ['BUILD_TARGET_ARM']
CPPDEFINES += [r'BUILD_TARGET=\"armv6\"']
elif re.match('^arm9*', rtconfig.CPU):
print('[WAMR] using armv4')
CPPDEFINES += ['BUILD_TARGET_ARM']
CPPDEFINES += [r'BUILD_TARGET=\"armv4\"']

else:
print("[WAMR] unknown arch", rtconfig.ARCH)


LIBS = ['m']

if GetDepend(['WAMR_BUILD_INTERP']):
CPPDEFINES += ['WASM_ENABLE_INTERP=1']
if GetDepend(['WAMR_BUILD_FAST_INTERP']):
CPPDEFINES += ['WASM_ENABLE_FAST_INTERP=1']
print("[WAMR] fast interpreter was enabled")
else:
CPPDEFINES += ['WASM_ENABLE_FAST_INTERP=0']
print("[WAMR] fast interpreter was disabled")
else:
CPPDEFINES += ['WASM_ENABLE_INTERP=0']

CPPDEFINES += ['WASM_ENABLE_JIT=0']

if GetDepend(['WAMR_BUILD_MULTI_MODULE']):
CPPDEFINES += ['WASM_ENABLE_MULTI_MODULE=1']
else:
CPPDEFINES += ['WASM_ENABLE_MULTI_MODULE=0']

if GetDepend(['WAMR_BUILD_SPEC_TEST']):
CPPDEFINES += ['WASM_ENABLE_SPEC_TEST=1']
print("[WAMR] spec test compatible mode was enabled")

if GetDepend(['WAMR_BUILD_BULK_MEMORY']):
CPPDEFINES += ['WASM_ENABLE_BULK_MEMORY=1']
print("[WAMR] Bulk memory feature was enabled")
else:
CPPDEFINES += ['WASM_ENABLE_BULK_MEMORY=0']

if GetDepend(['WAMR_BUILD_SHARED_MEMORY']):
CPPDEFINES += ['WASM_ENABLE_SHARED_MEMORY=1']
print("[WAMR] Shared memory enabled")
else:
CPPDEFINES += ['WASM_ENABLE_SHARED_MEMORY=0']

if GetDepend(['WAMR_BUILD_MINI_LOADER']):
CPPDEFINES += ['WASM_ENABLE_MINI_LOADER=1']
print("[WAMR] mini loader enabled")
else:
CPPDEFINES += ['WASM_ENABLE_MINI_LOADER=0']

if GetDepend(['WAMR_DISABLE_HW_BOUND_CHECK']):
CPPDEFINES += ['WASM_DISABLE_HW_BOUND_CHECK=1']
print("[WAMR] Hardware boundary check disabled")

if GetDepend(['WAMR_BUILD_SIMD']):
CPPDEFINES += ['WASM_ENABLE_SIMD=1']
print('[WAMR] SIMD enabled')

if GetDepend(['WAMR_BUILD_MEMORY_PROFILING']):
CPPDEFINES += ['WASM_ENABLE_MEMORY_PROFILING=1']
print('[WAMR] Memory profiling enabled')

if GetDepend(['WAMR_BUILD_CUSTOM_NAME_SECTION']):
CPPDEFINES += ['WASM_ENABLE_CUSTOM_NAME_SECTION=1']
print('[WAMR] Custom name section enabled')

if GetDepend(['WAMR_BUILD_TAIL_CALL']):
CPPDEFINES += ['WASM_ENABLE_TAIL_CALL=1']
print('[WAMR] Tail call enabledd')


group = DefineGroup('wamr_config_common', src, depend = ['PKG_USING_WAMR'], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS)

Return('group')

31 changes: 31 additions & 0 deletions core/iwasm/aot/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# Copyright (c) 2021, RT-Thread Development Team
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#

from building import *
import re
Import('rtconfig')

cwd = GetCurrentDir()

src = Split('''
aot_loader.c
aot_runtime.c
''')

if rtconfig.ARCH == 'arm':
if re.match('^cortex-m.*', rtconfig.CPU):
src += ['arch/aot_reloc_thumb.c']
elif re.match('^cortex-a.*', rtconfig.CPU):
src += ['arch/aot_reloc_arm.c']


CPPPATH = [cwd, cwd + '/../include']

CPPDEFINES = ['WASM_ENABLE_AOT=1']

group = DefineGroup('iwasm_aot', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)

Return('group')
26 changes: 26 additions & 0 deletions core/iwasm/common/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright (c) 2021, RT-Thread Development Team
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#

from building import *
import re

Import('rtconfig')

cwd = GetCurrentDir()

src = Glob('*.c')

if rtconfig.ARCH == 'arm':
if re.match('^cortex-m.*', rtconfig.CPU):
src += ['arch/invokeNative_thumb.s']
elif re.match('^cortex-a.*', rtconfig.CPU):
src += ['arch/invokeNative_arm.s']

CPPPATH = [cwd, cwd + '/../include']

group = DefineGroup('iwasm_common', src, depend = [''], CPPPATH = CPPPATH)

Return('group')
30 changes: 30 additions & 0 deletions core/iwasm/interpreter/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# Copyright (c) 2021, RT-Thread Development Team
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#

from building import *

cwd = GetCurrentDir()

src = Split('''
wasm_runtime.c
''')

if GetDepend(['WAMR_BUILD_FAST_INTERP']):
src += ["wasm_interp_fast.c"]
else:
src += ["wasm_interp_classic.c"]

if GetDepend(['WAMR_BUILD_MINI_LOADER']):
src += ["wasm_mini_loader.c"]
else:
src += ["wasm_loader.c"]


CPPPATH = [cwd]

group = DefineGroup('iwasm_interpreter', src, depend = [''], CPPPATH = CPPPATH)

Return('group')
20 changes: 20 additions & 0 deletions core/iwasm/libraries/lib-pthread/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright (c) 2021, RT-Thread Development Team
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#

from building import *

cwd = GetCurrentDir()

src = Split('''
libc_pthread_wrapper.c
''')

CPPPATH = [cwd]


group = DefineGroup('iwasm_libc_pthread', src, depend = [''], CPPPATH = CPPPATH)

Return('group')
24 changes: 24 additions & 0 deletions core/iwasm/libraries/libc-builtin/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright (c) 2021, RT-Thread Development Team
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#

from building import *

cwd = GetCurrentDir()

#src = Split('''
#libc_builtin_wrapper.c
#''')

src = Glob('*.c')

CPPDEFINES = ['WASM_ENABLE_LIBC_BUILTIN=1']

CPPPATH = [cwd]


group = DefineGroup('iwasm_libc_builtin', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)

Return('group')
Loading