diff --git a/cmake/config.cmake b/cmake/config.cmake index adfe2477db..66c3a15941 100644 --- a/cmake/config.cmake +++ b/cmake/config.cmake @@ -14,6 +14,24 @@ cmake_minimum_required(VERSION 2.8) +string(TOLOWER ${CMAKE_SYSTEM_NAME} CFG_SYS_NAME) +string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} CFG_SYS_PROCESSOR) + +if(${CFG_SYS_NAME} STREQUAL "linux") + if(${CFG_SYS_PROCESSOR} STREQUAL "x86" OR + ${CFG_SYS_PROCESSOR} STREQUAL "x86_64") + set(DEVICE_DEPENDS "x86-linux") + elseif(${CFG_SYS_PROCESSOR} STREQUAL "armv7l-hf") + set(DEVICE_DEPENDS "arm-linux") + endif() +elseif(${CFG_SYS_NAME} STREQUAL "darwin") + message(fatal "Darwin not ready") +elseif(${CFG_SYS_NAME} STREQUAL "external") + if(${CFG_SYS_PROCESSOR} STREQUAL "arm") + set(DEVICE_DEPENDS "arm-nuttx") + endif() +endif() + set(CC ${CMAKE_C_COMPILER}) set(CXX ${CMAKE_CXX_COMPILER}) diff --git a/cmake/config/arm-linux.cmake b/cmake/config/arm-linux.cmake new file mode 100644 index 0000000000..a91930e6d2 --- /dev/null +++ b/cmake/config/arm-linux.cmake @@ -0,0 +1,39 @@ +# Copyright 2015 Samsung Electronics Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include(CMakeForceCompiler) + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR armv7l-hf) + +set(EXTERNAL_CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) +set(EXTERNAL_CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) + +CMAKE_FORCE_C_COMPILER(${EXTERNAL_CMAKE_C_COMPILER} GNU) +CMAKE_FORCE_CXX_COMPILER(${EXTERNAL_CMAKE_CXX_COMPILER} GNU) + +set(FLAGS_COMMON -mlittle-endian + -mthumb + -mfpu=vfpv3-d16 + -D__LINUX__ + -D__ARM__) + +foreach(FLAG ${FLAGS_COMMON}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAG}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}") +endforeach() + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") diff --git a/cmake/config/arm-nuttx.cmake b/cmake/config/arm-nuttx.cmake index 0e45ed8ea2..e84a345c01 100644 --- a/cmake/config/arm-nuttx.cmake +++ b/cmake/config/arm-nuttx.cmake @@ -16,7 +16,6 @@ include(CMakeForceCompiler) set(CMAKE_SYSTEM_NAME EXTERNAL) set(CMAKE_SYSTEM_PROCESSOR arm) -set(CMAKE_SYSTEM_VERSION NUTTX) set(EXTERNAL_CMAKE_C_COMPILER arm-none-eabi-gcc) set(EXTERNAL_CMAKE_CXX_COMPILER arm-none-eabi-g++) @@ -26,7 +25,6 @@ CMAKE_FORCE_CXX_COMPILER(${EXTERNAL_CMAKE_CXX_COMPILER} GNU) set(NO_PTHREAD YES) set(BUILD_TO_LIB YES) -set(DEVICE_DEPENDS "nuttx-stm32f4disco") set(FLAGS_COMMON -mcpu=cortex-m4 -mthumb diff --git a/cmake/config/i686-linux.cmake b/cmake/config/i686-linux.cmake index 32e29458d9..e86571c83e 100644 --- a/cmake/config/i686-linux.cmake +++ b/cmake/config/i686-linux.cmake @@ -17,8 +17,6 @@ include(CMakeForceCompiler) set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR x86) -set(DEVICE_DEPENDS "linux-x86") - set(FLAGS_COMMON -D__LINUX__ -D__i686__ -fno-builtin) diff --git a/cmake/config/x86_64-linux.cmake b/cmake/config/x86_64-linux.cmake index 4f64c55108..856f4e4f7e 100644 --- a/cmake/config/x86_64-linux.cmake +++ b/cmake/config/x86_64-linux.cmake @@ -17,8 +17,6 @@ include(CMakeForceCompiler) set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR x86_64) -set(DEVICE_DEPENDS "linux-x86") - set(FLAGS_COMMON -D__LINUX__ -D__x86_64__ -fno-builtin) diff --git a/src/device/arm-linux/giopctl-arm-linux.cpp b/src/device/arm-linux/giopctl-arm-linux.cpp new file mode 100644 index 0000000000..227ed81121 --- /dev/null +++ b/src/device/arm-linux/giopctl-arm-linux.cpp @@ -0,0 +1,82 @@ +/* Copyright 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "iotjs_def.h" +#include "iotjs_module_gpioctl.h" + + +namespace iotjs { + + +class GpioControlInst : public GpioControl { +public: + explicit GpioControlInst(JObject& jgpioctl); + virtual int Initialize(void); + virtual void Release(void); + virtual int PinMode(uint32_t portpin); + virtual int WritePin(uint32_t portpin, uint8_t data); + virtual int ReadPin(uint32_t portpin, uint8_t* pdata); +}; + + +//----------------------------------------------------------------------------- + +GpioControl* GpioControl::Create(JObject& jgpioctl) +{ + return new GpioControlInst(jgpioctl); +} + + +GpioControlInst::GpioControlInst(JObject& jgpioctl) + : GpioControl(jgpioctl) { +} + + +int GpioControlInst::Initialize(void) { + if (_fd > 0 ) + return IOTJS_GPIO_INUSE; + + _fd = 1; + return _fd; +} + + +void GpioControlInst::Release(void) { + _fd = 0; +} + + +int GpioControlInst::PinMode(uint32_t portpin) { + if (_fd <= 0) + return IOTJS_GPIO_NOTINITED; + return 0; +} + + +int GpioControlInst::WritePin(uint32_t portpin, uint8_t data) { + if (_fd <= 0) + return IOTJS_GPIO_NOTINITED; + return 0; +} + + +int GpioControlInst::ReadPin(uint32_t portpin, uint8_t* pdata) { + if (_fd <= 0) + return IOTJS_GPIO_NOTINITED; + return 0; +} + + +} // namespace iotjs diff --git a/src/device/nuttx-stm32f4disco/gpioctl_nuttx_stm32f4disco.cpp b/src/device/arm-nuttx/gpioctl_arm_nuttx.cpp similarity index 100% rename from src/device/nuttx-stm32f4disco/gpioctl_nuttx_stm32f4disco.cpp rename to src/device/arm-nuttx/gpioctl_arm_nuttx.cpp diff --git a/src/device/linux-x86/gpioctl_linux_x86.cpp b/src/device/x86-linux/gpioctl_x86_linux.cpp similarity index 100% rename from src/device/linux-x86/gpioctl_linux_x86.cpp rename to src/device/x86-linux/gpioctl_x86_linux.cpp diff --git a/src/iotjs_module_gpioctl.h b/src/iotjs_module_gpioctl.h index 2980cd7fd7..f79a520a40 100644 --- a/src/iotjs_module_gpioctl.h +++ b/src/iotjs_module_gpioctl.h @@ -17,6 +17,7 @@ #define IOTJS_MODULE_GPIOCTL_H #include "iotjs_binding.h" +#include "iotjs_objectwrap.h" namespace iotjs { diff --git a/tools/build.py b/tools/build.py index 6169f8a139..581388c232 100755 --- a/tools/build.py +++ b/tools/build.py @@ -136,6 +136,7 @@ def sys_machine(): 'tidy': True, 'jerry-memstats': False, 'checktest': True, + 'jerry-heaplimit': 81, } boolean_opts = ['buildlib', @@ -189,6 +190,9 @@ def opt_jerry_memstats(): def opt_checktest(): return options['checktest'] +def opt_jerry_heaplimit() : + return options['jerry-heaplimit'] + def parse_boolean_opt(name, arg): if arg.endswith(name): options[name] = False if arg.startswith('no') else True @@ -217,6 +221,8 @@ def parse_args(): options[opt] = val elif opt == 'nuttx-home': options[opt] = val + elif opt == 'jerry-heaplimit': + options[opt] = val else: for opt_name in boolean_opts: if parse_boolean_opt(opt_name, opt): @@ -275,6 +281,8 @@ def build_libuv(): # libuv is using gyp. run the system according to build target. if opt_target_arch() == 'arm' and opt_target_os() =='nuttx': check_run_cmd('./nuttx-configure', [opt_nuttx_home()]) + elif opt_target_arch() == 'arm' and opt_target_os() =='linux': + check_run_cmd('./armlinux-configure') else: check_run_cmd('./gyp_uv.py', ['-f', 'make']) @@ -378,12 +386,17 @@ def build_libjerry(): jerry_cmake_opt.append('-DCMAKE_TOOLCHAIN_FILE=' + opt_cmake_toolchain_file()) + # for nuttx build. if opt_target_arch() == 'arm' and opt_target_os() =='nuttx': # nuttx include path. jerry_cmake_opt.append('-DEXTERNAL_LIBC_INTERFACE=' + join_path([opt_nuttx_home(), 'include'])) - jerry_cmake_opt.append('-DPLATFORM_EXT=NUTTX') + jerry_cmake_opt.append('-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=arm') + jerry_cmake_opt.append('-DEXTERNAL_MEM_HEAP_SIZE_KB=' + + str(opt_jerry_heaplimit())) + elif opt_target_arch() == 'arm' and opt_target_os() =='linux': + jerry_cmake_opt.append('-DUSE_COMPILER_DEFAULT_LIBC=YES') # run cmake. # FIXME: Running cmake once cause a problem because cmake does not know