mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Re-thinking the build system to bring it more into line with the conventions.
We removed that implementation where the build directory isn't set up to build with exactly one configuration of the project but potentially several variants: the same build directory can/must be used for debug and release builds, for full or compact profile versions, etc. So we reworked the CMakeLists, and now one build dir deal with exactly one configuration of the project's libraries and tools. JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
This commit is contained in:
parent
778f3c001e
commit
ddab1d8152
15
.gitignore
vendored
15
.gitignore
vendored
@ -1,9 +1,6 @@
|
||||
# Produced files
|
||||
|
||||
build/bin
|
||||
build/obj*
|
||||
build/prerequisites
|
||||
build/tests
|
||||
build/*
|
||||
|
||||
# IDE related files
|
||||
nbproject
|
||||
@ -22,19 +19,13 @@ vgcore.*
|
||||
**.patch
|
||||
.tags*
|
||||
cscope.*
|
||||
__pycache__
|
||||
*.pyc
|
||||
|
||||
# ctags and ID database
|
||||
tags
|
||||
ID
|
||||
|
||||
# Prerequisites
|
||||
.prerequisites
|
||||
third-party/STM32F3-Discovery_FW_V1.1.0
|
||||
third-party/STM32F4-Discovery_FW_V1.1.0
|
||||
third-party/nuttx
|
||||
third-party/vera++
|
||||
third-party/cppcheck
|
||||
|
||||
# targets
|
||||
jerry_targetjs.h
|
||||
targets/mbedk64f/libjerry
|
||||
|
||||
16
.travis.yml
16
.travis.yml
@ -11,20 +11,20 @@ before_install:
|
||||
|
||||
install:
|
||||
|
||||
script: "make -j VERBOSE=1 NINJA=1 $TARGET"
|
||||
script: "python tools/run-tests.py $OPTS"
|
||||
|
||||
env:
|
||||
- TARGET="check-signed-off check-vera check-cppcheck"
|
||||
- TARGET="build.linux test-js"
|
||||
- TARGET="build.linux test-js" TOOLCHAIN=build/configs/toolchain_linux_armv7l-hf.cmake TIMEOUT=300
|
||||
- TARGET=test-buildoptions
|
||||
- TARGET=test-unit
|
||||
- OPTS="--check-signed-off --check-cppcheck --check-vera"
|
||||
- OPTS="--jerry-tests --jerry-test-suite"
|
||||
- OPTS="--jerry-tests --jerry-test-suite --toolchain=cmake/toolchain_linux_armv7l-hf.cmake" TIMEOUT=300
|
||||
- OPTS=--buildoption-test
|
||||
- OPTS=--unittests
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: osx
|
||||
env: TARGET="build.darwin test-js"
|
||||
env: OPTS="--jerry-tests --jerry-test-suite"
|
||||
- os: osx
|
||||
env: TARGET=test-unit
|
||||
env: OPTS=--unittests
|
||||
allow_failures:
|
||||
- os: osx
|
||||
|
||||
611
CMakeLists.txt
611
CMakeLists.txt
@ -1,4 +1,5 @@
|
||||
# Copyright 2015-2016 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2016 University of Szeged.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@ -16,495 +17,209 @@ cmake_minimum_required (VERSION 2.8.12)
|
||||
project (Jerry C ASM)
|
||||
|
||||
# Determining platform
|
||||
set(PLATFORM "${CMAKE_SYSTEM_NAME}")
|
||||
string(TOUPPER "${PLATFORM}" PLATFORM)
|
||||
|
||||
# Compiler configuration
|
||||
if(NOT (("${PLATFORM}" STREQUAL "DARWIN") OR ("${PLATFORM}" STREQUAL "EXTERNAL")))
|
||||
if(NOT CMAKE_COMPILER_IS_GNUCC)
|
||||
message(FATAL_ERROR "gcc compiler is required")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Imported targets prefix
|
||||
set(PREFIX_IMPORTED_LIB imported_)
|
||||
|
||||
# Architecture-specific compile/link flags
|
||||
foreach(FLAG ${FLAGS_COMMON_ARCH})
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAG}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAG}")
|
||||
endforeach()
|
||||
set(PLATFORM "${CMAKE_SYSTEM_NAME}")
|
||||
string(TOUPPER "${PLATFORM}" PLATFORM)
|
||||
|
||||
# Remove rdynamic option
|
||||
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS )
|
||||
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS )
|
||||
|
||||
# Defining options
|
||||
option(ENABLE_VALGRIND "Enable valgrind helpers in memory allocators" OFF)
|
||||
option(ENABLE_VALGRIND_FREYA "Enable valgrind-freya helpers in memory allocators" OFF)
|
||||
option(ENABLE_LTO "Enable LTO build" ON)
|
||||
option(ENABLE_LOG "Enable LOG build" OFF)
|
||||
option(ENABLE_ALL_IN_ONE "Enable ALL_IN_ONE build" OFF)
|
||||
option(ENABLE_ERROR_MESSAGES "Enable error messages for builtin error objects" OFF)
|
||||
# Components
|
||||
set(JERRY_CORE ON CACHE BOOL "Use jerry-core?")
|
||||
set(JERRY_LIBC ON CACHE BOOL "Use jerry-libc?")
|
||||
set(JERRY_LIBM ON CACHE BOOL "Use jerry-libm?")
|
||||
set(JERRY_CMDLINE ON CACHE BOOL "Use jerry command line tool?")
|
||||
set(UNITTESTS OFF CACHE BOOL "Use unit tests?")
|
||||
|
||||
if("${PLATFORM}" STREQUAL "LINUX")
|
||||
set(PLATFORM_EXT "LINUX")
|
||||
set(EXTERNAL_BUILD FALSE)
|
||||
# Optional build settings
|
||||
set(PORT_DIR "${CMAKE_SOURCE_DIR}/targets/default" CACHE STRING "Should we use default or external port?")
|
||||
set(COMPILER_DEFAULT_LIBC OFF CACHE BOOL "Enable compiler default libc?")
|
||||
set(ENABLE_LTO OFF CACHE BOOL "Enable LTO build?")
|
||||
set(ENABLE_ALL_IN_ONE ON CACHE BOOL "Enable all-in-one build?")
|
||||
set(ENABLE_STRIP ON CACHE BOOL "Discards all symbols from object files?")
|
||||
|
||||
option(STRIP_RELEASE_BINARY "Strip symbols from release binaries" ON)
|
||||
elseif("${PLATFORM}" STREQUAL "DARWIN")
|
||||
option(ENABLE_LTO "Enable LTO build" OFF)
|
||||
option(ENABLE_ALL_IN_ONE "Enable ALL_IN_ONE build" ON)
|
||||
set(PLATFORM_EXT "DARWIN")
|
||||
set(EXTERNAL_BUILD FALSE)
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
endif()
|
||||
|
||||
option(STRIP_RELEASE_BINARY "Strip symbols from release binaries" ON)
|
||||
elseif("${PLATFORM}" STREQUAL "MCU")
|
||||
if (("${ENABLE_VALGRIND}" STREQUAL "ON") OR ("${ENABLE_VALGRIND_FREYA}" STREQUAL "ON"))
|
||||
message(FATAL_ERROR "This target isn't supported with Valgrind.")
|
||||
endif()
|
||||
if("${PLATFORM}" STREQUAL "DARWIN")
|
||||
set(ENABLE_LTO "OFF")
|
||||
set(ENABLE_ALL_IN_ONE "ON")
|
||||
endif()
|
||||
|
||||
set(PLATFORM_EXT "MCU_${CMAKE_SYSTEM_VERSION}")
|
||||
set(EXTERNAL_BUILD FALSE)
|
||||
# Status messages
|
||||
message(STATUS "CMAKE_SYSTEM_NAME " ${CMAKE_SYSTEM_NAME})
|
||||
message(STATUS "CMAKE_SYSTEM_PROCESSOR " ${CMAKE_SYSTEM_PROCESSOR})
|
||||
message(STATUS "CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE})
|
||||
message(STATUS "JERRY_CORE " ${JERRY_CORE})
|
||||
message(STATUS "JERRY_LIBC " ${JERRY_LIBC})
|
||||
message(STATUS "JERRY_LIBM " ${JERRY_LIBM})
|
||||
message(STATUS "JERRY_CMDLINE " ${JERRY_CMDLINE})
|
||||
message(STATUS "UNITTESTS " ${UNITTESTS})
|
||||
message(STATUS "PORT_DIR " ${PORT_DIR})
|
||||
message(STATUS "COMPILER_DEFAULT_LIBC " ${COMPILER_DEFAULT_LIBC})
|
||||
message(STATUS "ENABLE_LTO " ${ENABLE_LTO})
|
||||
message(STATUS "ENABLE_ALL_IN_ONE " ${ENABLE_ALL_IN_ONE})
|
||||
message(STATUS "ENABLE_STRIP " ${ENABLE_STRIP})
|
||||
|
||||
option(STRIP_RELEASE_BINARY "Strip symbols from release binaries" OFF)
|
||||
set(MCU_SCRIPT_FILE "tests/blinky.js" CACHE STRING "Script to run on MCU")
|
||||
elseif("${PLATFORM}" STREQUAL "EXTERNAL")
|
||||
set(PLATFORM_EXT "EXTERNAL")
|
||||
set(EXTERNAL_BUILD TRUE)
|
||||
# Setup directories
|
||||
# Project binary dir
|
||||
set(PROJECT_BINARY_DIR "${CMAKE_BINARY_DIR}")
|
||||
|
||||
set(EXTERNAL_LIBC_INTERFACE "UNDEFINED" CACHE STRING "Path to external libc include directory")
|
||||
set(EXTERNAL_LIBS_INTERFACE "UNDEFINED" CACHE STRING "Path to external libraries' include directory")
|
||||
set(EXTERNAL_MEM_HEAP_SIZE_KB "256" CACHE STRING "Size of memory heap, in kilobytes")
|
||||
elseif("${PLATFORM}" STREQUAL "OPENWRT")
|
||||
set(PLATFORM_EXT "LINUX")
|
||||
set(EXTERNAL_BUILD FALSE)
|
||||
# Library output directory
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/")
|
||||
|
||||
option(STRIP_RELEASE_BINARY "Strip symbols from release binaries" ON)
|
||||
else()
|
||||
message(FATAL_ERROR "Platform '${PLATFORM}' is not supported")
|
||||
endif()
|
||||
# Executable output directory
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/")
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
if("${ENABLE_LTO}" STREQUAL "ON")
|
||||
# Use gcc-ar and gcc-ranlib to support LTO
|
||||
get_filename_component(PATH_TO_GCC ${CMAKE_C_COMPILER} REALPATH)
|
||||
get_filename_component(DIRECTORY_GCC ${PATH_TO_GCC} DIRECTORY)
|
||||
get_filename_component(FILE_NAME_GCC ${PATH_TO_GCC} NAME)
|
||||
string(REPLACE "gcc" "gcc-ar" CMAKE_AR ${FILE_NAME_GCC})
|
||||
string(REPLACE "gcc" "gcc-ranlib" CMAKE_RANLIB ${FILE_NAME_GCC})
|
||||
set(CMAKE_AR ${DIRECTORY_GCC}/${CMAKE_AR})
|
||||
set(CMAKE_RANLIB ${DIRECTORY_GCC}/${CMAKE_RANLIB})
|
||||
endif()
|
||||
endif()
|
||||
# Archive targets output Directory
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/")
|
||||
|
||||
# Intermediate files
|
||||
# Script to run on MCU
|
||||
set(MCU_SCRIPT_GENERATED_HEADER ${CMAKE_BINARY_DIR}/generated.h)
|
||||
# Compile/link flags
|
||||
# build mode specific compile/link flags
|
||||
set(CMAKE_C_FLAGS_RELEASE "-Os")
|
||||
|
||||
# Should we use external libc?
|
||||
if(DEFINED COMPILER_DEFAULT_LIBC AND COMPILER_DEFAULT_LIBC STREQUAL "ON")
|
||||
if(DEFINED EXTERNAL_LIBC_INTERFACE AND NOT EXTERNAL_LIBC_INTERFACE STREQUAL "UNDEFINED")
|
||||
message(FATAL_ERROR "EXTERNAL_LIBC_INTERFACE='${EXTERNAL_LIBC_INTERFACE}' should not be set in case compiler's default libc is used (COMPILER_DEFAULT_LIBC=ON)")
|
||||
endif()
|
||||
# Architecture-specific compile/link flags
|
||||
foreach(FLAG ${FLAGS_COMMON_ARCH})
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAG}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAG}")
|
||||
endforeach()
|
||||
|
||||
set(USE_JERRY_LIBC FALSE)
|
||||
elseif(NOT DEFINED EXTERNAL_LIBC_INTERFACE OR EXTERNAL_LIBC_INTERFACE STREQUAL "UNDEFINED")
|
||||
set(USE_JERRY_LIBC TRUE)
|
||||
else()
|
||||
set(USE_JERRY_LIBC FALSE)
|
||||
# Use jerry libc
|
||||
if(JERRY_LIBC AND COMPILER_DEFAULT_LIBC)
|
||||
message(FATAL_ERROR "JERRY_LIBC and COMPILER_DEFAULT_LIBC is enabled at the same time!")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${EXTERNAL_LIBC_INTERFACE}/stdlib.h")
|
||||
message(FATAL_ERROR "It seems that external libc interface '${EXTERNAL_LIBC_INTERFACE}' doesn't provide stdlib.h header")
|
||||
endif()
|
||||
|
||||
set(INCLUDE_LIBC_INTERFACE ${EXTERNAL_LIBC_INTERFACE})
|
||||
endif()
|
||||
|
||||
|
||||
# Should we use external port?
|
||||
if(DEFINED EXTERNAL_PORT_DIR AND NOT EXTERNAL_PORT_DIR STREQUAL "UNDEFINED")
|
||||
set(PORT_DIR ${EXTERNAL_PORT_DIR})
|
||||
else()
|
||||
set(PORT_DIR ${CMAKE_SOURCE_DIR}/targets/default)
|
||||
endif()
|
||||
|
||||
# Are there any interfaces for external libraries, other than libc, that should be registered?
|
||||
if(DEFINED EXTERNAL_LIBS_INTERFACE AND NOT EXTERNAL_LIBS_INTERFACE STREQUAL "UNDEFINED")
|
||||
set(INCLUDE_EXTERNAL_LIBS_INTERFACE )
|
||||
|
||||
foreach(EXTERNAL_LIB_INTERFACE ${EXTERNAL_LIBS_INTERFACE})
|
||||
if (NOT EXISTS "${EXTERNAL_LIB_INTERFACE}")
|
||||
message(FATAL_ERROR "Interface directory of the external library doesn't exist: ${EXTERNAL_LIB_INTERFACE}")
|
||||
endif()
|
||||
|
||||
set(INCLUDE_EXTERNAL_LIBS_INTERFACE ${INCLUDE_EXTERNAL_LIBS_INTERFACE} ${EXTERNAL_LIB_INTERFACE})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Build modes
|
||||
# Debug
|
||||
set(BUILD_MODE_PREFIX_DEBUG debug)
|
||||
|
||||
# Release
|
||||
set(BUILD_MODE_PREFIX_RELEASE release)
|
||||
|
||||
# Unit tests
|
||||
set(BUILD_MODE_PREFIX_UNITTESTS unittests)
|
||||
|
||||
# Modifiers
|
||||
# Profiles
|
||||
# Full profile (default, so - no suffix)
|
||||
set(MODIFIER_SUFFIX_FULL_PROFILE "")
|
||||
|
||||
# Compact profile
|
||||
set(MODIFIER_SUFFIX_COMPACT_PROFILE -cp)
|
||||
|
||||
# Minimal compact profile
|
||||
set(MODIFIER_SUFFIX_COMPACT_PROFILE_MINIMAL -cp_minimal)
|
||||
|
||||
# Memory statistics
|
||||
set(MODIFIER_SUFFIX_MEMORY_STATISTICS -mem_stats)
|
||||
|
||||
# Memory management stress-test mode
|
||||
set(MODIFIER_SUFFIX_MEM_STRESS_TEST -mem_stress_test)
|
||||
|
||||
# Modifier lists
|
||||
# Linux
|
||||
set(MODIFIERS_LISTS_LINUX
|
||||
"FULL_PROFILE"
|
||||
"FULL_PROFILE MEM_STRESS_TEST"
|
||||
"COMPACT_PROFILE"
|
||||
"COMPACT_PROFILE_MINIMAL"
|
||||
"FULL_PROFILE MEMORY_STATISTICS"
|
||||
"COMPACT_PROFILE_MINIMAL MEMORY_STATISTICS")
|
||||
|
||||
# Darwin
|
||||
set(MODIFIERS_LISTS_DARWIN
|
||||
"FULL_PROFILE"
|
||||
"FULL_PROFILE MEM_STRESS_TEST"
|
||||
"COMPACT_PROFILE"
|
||||
"COMPACT_PROFILE_MINIMAL"
|
||||
"FULL_PROFILE MEMORY_STATISTICS"
|
||||
"COMPACT_PROFILE_MINIMAL MEMORY_STATISTICS")
|
||||
|
||||
# MCU
|
||||
# stm32f3
|
||||
set(MODIFIERS_LISTS_MCU_STM32F3
|
||||
"FULL_PROFILE"
|
||||
"COMPACT_PROFILE"
|
||||
"COMPACT_PROFILE_MINIMAL")
|
||||
|
||||
# stm32f4
|
||||
set(MODIFIERS_LISTS_MCU_STM32F4
|
||||
"FULL_PROFILE"
|
||||
"COMPACT_PROFILE"
|
||||
"COMPACT_PROFILE_MINIMAL")
|
||||
|
||||
# External
|
||||
set(MODIFIERS_LISTS_EXTERNAL
|
||||
"FULL_PROFILE"
|
||||
"COMPACT_PROFILE"
|
||||
"COMPACT_PROFILE_MINIMAL"
|
||||
"FULL_PROFILE MEMORY_STATISTICS"
|
||||
"COMPACT_PROFILE MEMORY_STATISTICS")
|
||||
|
||||
# Compiler / Linker flags
|
||||
set(COMPILE_FLAGS_JERRY "-fno-builtin")
|
||||
if(NOT ("${PLATFORM}" STREQUAL "DARWIN"))
|
||||
set(LINKER_FLAGS_COMMON "-Wl,-z,noexecstack")
|
||||
endif()
|
||||
set(LINKER_FLAGS_COMMON_DARWIN "-lSystem")
|
||||
|
||||
# Turn off linking to compiler's default libc, in case jerry-libc is used
|
||||
if(${USE_JERRY_LIBC})
|
||||
set(LINKER_FLAGS_COMMON "${LINKER_FLAGS_COMMON} -nostdlib")
|
||||
endif()
|
||||
|
||||
# LTO
|
||||
if("${ENABLE_LTO}" STREQUAL "ON")
|
||||
set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -flto")
|
||||
if(NOT ("${PLATFORM}" STREQUAL "DARWIN"))
|
||||
set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -fno-fat-lto-objects")
|
||||
endif()
|
||||
set(LINKER_FLAGS_COMMON "${LINKER_FLAGS_COMMON} -flto")
|
||||
endif()
|
||||
|
||||
# Generage map file
|
||||
if("${PLATFORM}" STREQUAL "DARWIN")
|
||||
set(MAP_FILE_FLAGS "-Xlinker -map -Xlinker jerry.map")
|
||||
else()
|
||||
set(MAP_FILE_FLAGS "-Xlinker -Map -Xlinker jerry.map")
|
||||
endif()
|
||||
set(LINKER_FLAGS_COMMON "${LINKER_FLAGS_COMMON} ${MAP_FILE_FLAGS}")
|
||||
|
||||
# Turn off stack protector
|
||||
set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -fno-stack-protector")
|
||||
|
||||
# Debug information
|
||||
set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -g -gdwarf-4")
|
||||
|
||||
# Warnings
|
||||
macro(append variable value)
|
||||
set(${variable} "${${variable}} ${value}")
|
||||
endmacro()
|
||||
|
||||
macro(add_jerry_compile_flags)
|
||||
foreach(_flag ${ARGV})
|
||||
append(COMPILE_FLAGS_JERRY ${_flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
macro(add_jerry_compile_warnings)
|
||||
foreach(_warning ${ARGV})
|
||||
add_jerry_compile_flags(-W${_warning})
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
add_jerry_compile_flags(-Werror=${_warning})
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
add_jerry_compile_warnings(all extra format-nonliteral init-self conversion sign-conversion format-security missing-declarations)
|
||||
add_jerry_compile_flags(-Wno-stack-protector -Wno-attributes)
|
||||
# LTO
|
||||
if(ENABLE_LTO)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto")
|
||||
set(LINKER_FLAGS_COMMON "${LINKER_FLAGS_COMMON} -flto")
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
if(${USE_JERRY_LIBC})
|
||||
add_jerry_compile_flags(-Werror)
|
||||
if(NOT "${PLATFORM}" STREQUAL "DARWIN")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-fat-lto-objects")
|
||||
endif()
|
||||
add_jerry_compile_warnings(logical-op)
|
||||
else()
|
||||
add_jerry_compile_flags(-Wno-nested-anon-types)
|
||||
# Use gcc-ar and gcc-ranlib to support LTO
|
||||
set(CMAKE_AR "gcc-ar")
|
||||
set(CMAKE_RANLIB "gcc-ranlib")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(DEFINED EXTERNAL_COMPILE_FLAGS)
|
||||
foreach(FLAG ${EXTERNAL_COMPILE_FLAGS})
|
||||
set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} ${FLAG}")
|
||||
endforeach()
|
||||
endif()
|
||||
# Define _BSD_SOURCE if we use default port and compiler default libc
|
||||
if(${PORT_DIR} STREQUAL "${CMAKE_SOURCE_DIR}/targets/default" AND COMPILER_DEFAULT_LIBC)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} _BSD_SOURCE)
|
||||
endif()
|
||||
|
||||
# Static build
|
||||
if(NOT ("${PLATFORM}" STREQUAL "DARWIN"))
|
||||
set(LINKER_FLAGS_STATIC "-static")
|
||||
endif()
|
||||
|
||||
# C
|
||||
set(C_FLAGS_JERRY "-std=c99 -pedantic")
|
||||
|
||||
# Platform-specific
|
||||
# MCU
|
||||
# stm32f3
|
||||
set(LINKER_FLAGS_COMMON_MCU_STM32F3 "-T${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Project/Peripheral_Examples/FLASH_Program/TrueSTUDIO/FLASH_Program/STM32_FLASH.ld")
|
||||
# stm32f4
|
||||
set(LINKER_FLAGS_COMMON_MCU_STM32F4 "-T${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Project/Peripheral_Examples/FLASH_Program/TrueSTUDIO/FLASH_Program/stm32_flash.ld")
|
||||
|
||||
# Debug
|
||||
set(FLAGS_COMMON_DEBUG "")
|
||||
|
||||
# Release
|
||||
set(FLAGS_COMMON_RELEASE "-Os")
|
||||
|
||||
# Unit tests
|
||||
set(FLAGS_COMMON_UNITTESTS "-O3")
|
||||
|
||||
# Include directories
|
||||
# Core interface
|
||||
set(INCLUDE_CORE_INTERFACE
|
||||
${CMAKE_SOURCE_DIR}/jerry-core)
|
||||
|
||||
# Sources
|
||||
# Platform-specific
|
||||
# Jerry standalone
|
||||
# Linux
|
||||
set(SOURCE_JERRY_STANDALONE_MAIN_LINUX main-unix.c)
|
||||
|
||||
# Darwin
|
||||
set(SOURCE_JERRY_STANDALONE_MAIN_DARWIN main-unix.c)
|
||||
|
||||
# MCU
|
||||
# stm32f3
|
||||
set(SOURCE_JERRY_STANDALONE_MAIN_MCU_STM32F3 main-mcu.c)
|
||||
|
||||
# stm32f4
|
||||
set(SOURCE_JERRY_STANDALONE_MAIN_MCU_STM32F4 main-mcu.c)
|
||||
|
||||
# Unit tests main modules
|
||||
file(GLOB SOURCE_UNIT_TEST_MAIN_MODULES tests/unit/*.c)
|
||||
# Imported targets prefix
|
||||
set(PREFIX_IMPORTED_LIB imported_)
|
||||
|
||||
# Imported libraries
|
||||
if(("${PLATFORM}" STREQUAL "DARWIN") AND (NOT CMAKE_COMPILER_IS_GNUCC))
|
||||
# libclang_rt.osx
|
||||
add_library(${PREFIX_IMPORTED_LIB}libclang_rt.osx STATIC IMPORTED)
|
||||
# libclang_rt.osx
|
||||
set(IMPORTED_LIB "${PREFIX_IMPORTED_LIB}libclang_rt.osx")
|
||||
add_library(${IMPORTED_LIB} STATIC IMPORTED)
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} ${FLAGS_COMMON_ARCH} -print-file-name=
|
||||
OUTPUT_VARIABLE IMPORTED_LIBCLANG_RT_LOCATION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
set(IMPORTED_LIBCLANG_RT_LOCATION "${IMPORTED_LIBCLANG_RT_LOCATION}/lib/darwin/libclang_rt.osx.a")
|
||||
set_property(TARGET ${PREFIX_IMPORTED_LIB}libclang_rt.osx
|
||||
set_property(TARGET ${IMPORTED_LIB}
|
||||
PROPERTY IMPORTED_LOCATION ${IMPORTED_LIBCLANG_RT_LOCATION})
|
||||
else()
|
||||
# libgcc
|
||||
add_library(${PREFIX_IMPORTED_LIB}libgcc STATIC IMPORTED)
|
||||
# libgcc
|
||||
set(IMPORTED_LIB "${PREFIX_IMPORTED_LIB}libgcc")
|
||||
add_library(${IMPORTED_LIB} STATIC IMPORTED)
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} ${FLAGS_COMMON_ARCH} -print-file-name=libgcc.a
|
||||
OUTPUT_VARIABLE IMPORTED_LIBGCC_LOCATION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
set_property(TARGET ${PREFIX_IMPORTED_LIB}libgcc
|
||||
set_property(TARGET ${IMPORTED_LIB}
|
||||
PROPERTY IMPORTED_LOCATION ${IMPORTED_LIBGCC_LOCATION})
|
||||
endif()
|
||||
|
||||
# Platform-specific configuration
|
||||
set(MODIFIERS_LISTS ${MODIFIERS_LISTS_${PLATFORM_EXT}})
|
||||
set(LINKER_FLAGS_COMMON "${LINKER_FLAGS_COMMON} ${LINKER_FLAGS_COMMON_${PLATFORM_EXT}}")
|
||||
set(SOURCE_JERRY_STANDALONE_MAIN ${SOURCE_JERRY_STANDALONE_MAIN_${PLATFORM_EXT}})
|
||||
# Compiler / Linker flags
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-builtin")
|
||||
if(("${PLATFORM}" STREQUAL "DARWIN"))
|
||||
set(LINKER_FLAGS_COMMON "-lSystem")
|
||||
else()
|
||||
set(LINKER_FLAGS_COMMON "-Wl,-z,noexecstack")
|
||||
endif()
|
||||
|
||||
# Component targets
|
||||
# Jerry's libc
|
||||
if(${USE_JERRY_LIBC})
|
||||
add_subdirectory(jerry-libc)
|
||||
endif()
|
||||
# Turn off linking to compiler's default libc, in case jerry-libc or external is used
|
||||
if(NOT COMPILER_DEFAULT_LIBC)
|
||||
set(LINKER_FLAGS_COMMON "${LINKER_FLAGS_COMMON} -nostdlib")
|
||||
endif()
|
||||
|
||||
# Jerry's libm
|
||||
add_subdirectory(jerry-libm)
|
||||
# Turn off stack protector
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-stack-protector")
|
||||
|
||||
# Jerry's Core
|
||||
add_subdirectory(jerry-core)
|
||||
# Debug information
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -gdwarf-4")
|
||||
|
||||
# Targets declaration
|
||||
string(TOLOWER "${PLATFORM_EXT}" PLATFORM_L)
|
||||
|
||||
function(declare_targets_for_build_mode BUILD_MODE)
|
||||
set(TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}.${PLATFORM_L})
|
||||
if (${USE_JERRY_LIBC})
|
||||
set(LIBC_TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}.jerry-libc.${PLATFORM_L}.lib)
|
||||
endif()
|
||||
|
||||
function(declare_target_with_modifiers) # modifiers are passed in ARGN implicit argument
|
||||
set(CORE_TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}})
|
||||
foreach(MODIFIER ${ARGN})
|
||||
set(TARGET_NAME ${TARGET_NAME}${MODIFIER_SUFFIX_${MODIFIER}})
|
||||
|
||||
set(CORE_TARGET_NAME ${CORE_TARGET_NAME}${MODIFIER_SUFFIX_${MODIFIER}})
|
||||
endforeach()
|
||||
set(LIBM_TARGET_NAME ${CORE_TARGET_NAME}.jerry-libm.lib)
|
||||
set(CORE_TARGET_NAME ${CORE_TARGET_NAME}.jerry-core)
|
||||
|
||||
set(DEFINES_JERRY )
|
||||
|
||||
if(NOT ${EXTERNAL_BUILD})
|
||||
add_executable(${TARGET_NAME} ${SOURCE_JERRY_STANDALONE_MAIN})
|
||||
|
||||
if("${PLATFORM}" STREQUAL "MCU")
|
||||
set(MCU_SCRIPT_GENERATED_HEADER ${MCU_SCRIPT_GENERATED_HEADER}.${TARGET_NAME})
|
||||
add_custom_command(OUTPUT ${MCU_SCRIPT_GENERATED_HEADER}
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/tools/generator.sh "${CMAKE_SOURCE_DIR}/${MCU_SCRIPT_FILE}" ${MCU_SCRIPT_GENERATED_HEADER}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
add_custom_target(mcu_header_with_script_to_run.${TARGET_NAME} DEPENDS ${MCU_SCRIPT_GENERATED_HEADER})
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_MCU_SCRIPT_HEADER="${MCU_SCRIPT_GENERATED_HEADER}")
|
||||
elseif(("${PLATFORM}" STREQUAL "LINUX") OR ("${PLATFORM}" STREQUAL "DARWIN"))
|
||||
if("${ENABLE_LOG}" STREQUAL "ON")
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_LOG)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set_property(TARGET ${TARGET_NAME}
|
||||
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_JERRY} ${FLAGS_COMMON_${BUILD_MODE}} ${C_FLAGS_JERRY}")
|
||||
set_property(TARGET ${TARGET_NAME}
|
||||
PROPERTY LINK_FLAGS "${COMPILE_FLAGS_JERRY} ${FLAGS_COMMON_${BUILD_MODE}} ${LINKER_FLAGS_COMMON} ${LINKER_FLAGS_STATIC}")
|
||||
target_compile_definitions(${TARGET_NAME} PRIVATE ${DEFINES_JERRY})
|
||||
target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_CORE_INTERFACE})
|
||||
target_include_directories(${TARGET_NAME} PRIVATE ${PORT_DIR})
|
||||
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${INCLUDE_LIBC_INTERFACE})
|
||||
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${INCLUDE_EXTERNAL_LIBS_INTERFACE})
|
||||
if(("${PLATFORM}" STREQUAL "DARWIN") AND (NOT (CMAKE_COMPILER_IS_GNUCC)))
|
||||
target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME}
|
||||
${LIBM_TARGET_NAME} ${PREFIX_IMPORTED_LIB}libclang_rt.osx)
|
||||
else()
|
||||
target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME}
|
||||
${LIBM_TARGET_NAME} ${PREFIX_IMPORTED_LIB}libgcc)
|
||||
endif()
|
||||
|
||||
if("${PLATFORM}" STREQUAL "MCU")
|
||||
add_dependencies(${TARGET_NAME} mcu_header_with_script_to_run.${TARGET_NAME})
|
||||
add_custom_target(${TARGET_NAME}.bin
|
||||
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${TARGET_NAME}> $<TARGET_FILE:${TARGET_NAME}>.bin
|
||||
DEPENDS ${TARGET_NAME})
|
||||
add_custom_target(${TARGET_NAME}.flash
|
||||
COMMAND st-flash write $<TARGET_FILE:${TARGET_NAME}>.bin 0x08000000
|
||||
DEPENDS ${TARGET_NAME}.bin)
|
||||
endif()
|
||||
|
||||
if("${BUILD_MODE}" STREQUAL "RELEASE")
|
||||
if(${STRIP_RELEASE_BINARY} STREQUAL "ON")
|
||||
add_custom_command(TARGET ${TARGET_NAME}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:${TARGET_NAME}>)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
add_custom_target(${TARGET_NAME} ALL)
|
||||
|
||||
add_custom_command(TARGET ${TARGET_NAME}
|
||||
POST_BUILD
|
||||
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/${TARGET_NAME}
|
||||
COMMAND echo $<TARGET_FILE:${LIBM_TARGET_NAME}> > ${CMAKE_BINARY_DIR}/${TARGET_NAME}/list
|
||||
COMMAND echo $<TARGET_FILE:${CORE_TARGET_NAME}> >> ${CMAKE_BINARY_DIR}/${TARGET_NAME}/list)
|
||||
|
||||
if(DEFINED EXTERNAL_BUILD_ENTRY_FILE)
|
||||
add_library(${TARGET_NAME}-entry STATIC ${EXTERNAL_BUILD_ENTRY_FILE})
|
||||
set_property(TARGET ${TARGET_NAME}-entry
|
||||
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_JERRY} ${FLAGS_COMMON_${BUILD_MODE}}")
|
||||
target_compile_definitions(${TARGET_NAME}-entry PRIVATE ${DEFINES_JERRY})
|
||||
target_include_directories(${TARGET_NAME}-entry PRIVATE ${INCLUDE_CORE_INTERFACE})
|
||||
target_include_directories(${TARGET_NAME}-entry SYSTEM PRIVATE ${CMAKE_SOURCE_DIR})
|
||||
target_include_directories(${TARGET_NAME}-entry SYSTEM PRIVATE ${INCLUDE_LIBC_INTERFACE})
|
||||
target_include_directories(${TARGET_NAME}-entry SYSTEM PRIVATE ${INCLUDE_EXTERNAL_LIBS_INTERFACE})
|
||||
add_dependencies(${TARGET_NAME} ${TARGET_NAME}-entry)
|
||||
endif()
|
||||
|
||||
if(${USE_JERRY_LIBC})
|
||||
add_custom_command(TARGET ${TARGET_NAME}
|
||||
POST_BUILD
|
||||
COMMAND echo $<TARGET_FILE:${LIBC_TARGET_NAME}> >> ${CMAKE_BINARY_DIR}/${TARGET_NAME}/list)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
foreach(MODIFIERS_LIST ${MODIFIERS_LISTS})
|
||||
separate_arguments(MODIFIERS_LIST)
|
||||
|
||||
declare_target_with_modifiers(${MODIFIERS_LIST})
|
||||
macro(add_jerry_compile_flags)
|
||||
foreach(_flag ${ARGV})
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_flag}")
|
||||
endforeach()
|
||||
endfunction()
|
||||
endmacro()
|
||||
|
||||
declare_targets_for_build_mode(DEBUG)
|
||||
declare_targets_for_build_mode(RELEASE)
|
||||
|
||||
# Unit tests declaration
|
||||
if(("${PLATFORM}" STREQUAL "LINUX") OR ("${PLATFORM}" STREQUAL "DARWIN"))
|
||||
add_custom_target(unittests)
|
||||
|
||||
foreach(SOURCE_UNIT_TEST_MAIN ${SOURCE_UNIT_TEST_MAIN_MODULES})
|
||||
get_filename_component(TARGET_NAME ${SOURCE_UNIT_TEST_MAIN} NAME_WE)
|
||||
set(TARGET_NAME unit-${TARGET_NAME})
|
||||
|
||||
set(CORE_TARGET_NAME unittests.jerry-core)
|
||||
if (${USE_JERRY_LIBC})
|
||||
set(LIBC_TARGET_NAME unittests.jerry-libc.${PLATFORM_L}.lib)
|
||||
endif ()
|
||||
set(LIBM_TARGET_NAME unittests.jerry-libm.lib)
|
||||
|
||||
add_executable(${TARGET_NAME} ${SOURCE_UNIT_TEST_MAIN})
|
||||
set_property(TARGET ${TARGET_NAME}
|
||||
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_JERRY} ${C_FLAGS_JERRY} ${FLAGS_COMMON_UNITTESTS}")
|
||||
set_property(TARGET ${TARGET_NAME}
|
||||
PROPERTY LINK_FLAGS "${COMPILE_FLAGS_JERRY} ${FLAGS_COMMON_UNITTESTS} ${LINKER_FLAGS_COMMON}")
|
||||
target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_CORE_INTERFACE})
|
||||
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${INCLUDE_LIBC_INTERFACE})
|
||||
|
||||
if(("${PLATFORM}" STREQUAL "DARWIN") AND (NOT (CMAKE_COMPILER_IS_GNUCC)))
|
||||
target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME} ${LIBM_TARGET_NAME}
|
||||
${PREFIX_IMPORTED_LIB}libclang_rt.osx)
|
||||
else()
|
||||
target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME} ${LIBM_TARGET_NAME}
|
||||
${PREFIX_IMPORTED_LIB}libgcc)
|
||||
macro(add_jerry_compile_warnings)
|
||||
foreach(_warning ${ARGV})
|
||||
add_jerry_compile_flags(-W${_warning})
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
add_jerry_compile_flags(-Werror=${_warning})
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
add_dependencies(unittests ${TARGET_NAME})
|
||||
endforeach()
|
||||
add_jerry_compile_warnings(all extra format-nonliteral init-self conversion sign-conversion format-security missing-declarations)
|
||||
add_jerry_compile_flags(-Wno-stack-protector -Wno-attributes)
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
if(JERRY_LIBC)
|
||||
add_jerry_compile_flags(-Werror)
|
||||
endif()
|
||||
add_jerry_compile_warnings(logical-op)
|
||||
else()
|
||||
add_jerry_compile_flags(-Wno-nested-anon-types)
|
||||
endif()
|
||||
|
||||
if(DEFINED EXTERNAL_COMPILE_FLAGS)
|
||||
foreach(FLAG ${EXTERNAL_COMPILE_FLAGS})
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAG}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(DEFINED EXTERNAL_LINKER_FLAGS)
|
||||
foreach(FLAG ${EXTERNAL_LINKER_FLAGS})
|
||||
set(LINKER_FLAGS_COMMON "${LINKER_FLAGS_COMMON} ${FLAG}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# C
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -pedantic")
|
||||
|
||||
# Strip binary
|
||||
if(ENABLE_STRIP AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(LINKER_FLAGS_COMMON "${LINKER_FLAGS_COMMON} -s")
|
||||
endif()
|
||||
|
||||
# Jerry's libc
|
||||
if(JERRY_LIBC)
|
||||
add_subdirectory(jerry-libc)
|
||||
endif()
|
||||
|
||||
# Jerry's libm
|
||||
if(JERRY_LIBM)
|
||||
add_subdirectory(jerry-libm)
|
||||
endif()
|
||||
|
||||
# Jerry's core
|
||||
if(JERRY_CORE)
|
||||
add_subdirectory(jerry-core)
|
||||
endif()
|
||||
|
||||
# Jerry commandline tool
|
||||
if(JERRY_CMDLINE)
|
||||
add_subdirectory(jerry-main)
|
||||
endif()
|
||||
|
||||
# Unittests
|
||||
if(UNITTESTS)
|
||||
add_subdirectory(tests/unit)
|
||||
endif()
|
||||
|
||||
416
Makefile
416
Makefile
@ -1,416 +0,0 @@
|
||||
# Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2016 University of Szeged
|
||||
#
|
||||
# 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.
|
||||
|
||||
#
|
||||
# Target naming scheme
|
||||
#
|
||||
# Main targets: {debug,release}.{linux,darwin,mcu_stm32f{3,4}}
|
||||
#
|
||||
# Target mode part (before dot):
|
||||
# debug: - JERRY_NDEBUG; - optimizations; + debug symbols; + -Werror | debug build
|
||||
# release: + JERRY_NDEBUG; + optimizations; - debug symbols; + -Werror | release build
|
||||
#
|
||||
# Target system and modifiers part (after first dot):
|
||||
# linux - target system is linux
|
||||
# darwin - target system is Mac OS X
|
||||
# mcu_stm32f{3,4} - target is STM32F{3,4} board
|
||||
#
|
||||
# Modifiers can be added after '-' sign.
|
||||
# For list of modifiers for NATIVE target - see NATIVE_MODS, for MCU target - MCU_MODS.
|
||||
#
|
||||
# Unit test target: test-unit
|
||||
#
|
||||
# Parallel run
|
||||
# To build all targets in parallel, please, use make build -j
|
||||
# To run precommit in parallel mode, please, use make precommit -j
|
||||
#
|
||||
# Parallel build of several selected targets started manually is not supported.
|
||||
#
|
||||
|
||||
export NATIVE_SYSTEM := $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
||||
export MCU_SYSTEMS := stm32f3 stm32f4
|
||||
|
||||
export DEBUG_MODES := debug
|
||||
export RELEASE_MODES := release
|
||||
|
||||
export MCU_MODS := cp cp_minimal
|
||||
export NATIVE_MODS := $(MCU_MODS) mem_stats mem_stress_test
|
||||
|
||||
# Options
|
||||
CMAKE_DEFINES:=
|
||||
BUILD_NAME:=
|
||||
|
||||
# Valgrind
|
||||
ifneq ($(VALGRIND),)
|
||||
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DENABLE_VALGRIND=$(VALGRIND)
|
||||
BUILD_NAME:=$(BUILD_NAME)-VALGRIND-$(VALGRIND)
|
||||
endif
|
||||
|
||||
# Valgrind Freya
|
||||
ifneq ($(VALGRIND_FREYA),)
|
||||
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DENABLE_VALGRIND_FREYA=$(VALGRIND_FREYA)
|
||||
BUILD_NAME:=$(BUILD_NAME)-VALGRIND_FREYA-$(VALGRIND_FREYA)
|
||||
endif
|
||||
|
||||
# LTO
|
||||
ifneq ($(LTO),)
|
||||
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DENABLE_LTO=$(LTO)
|
||||
BUILD_NAME:=$(BUILD_NAME)-LTO-$(LTO)
|
||||
endif
|
||||
|
||||
# LOG
|
||||
ifneq ($(LOG),)
|
||||
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DENABLE_LOG=$(LOG)
|
||||
BUILD_NAME:=$(BUILD_NAME)-LOG-$(LOG)
|
||||
endif
|
||||
|
||||
# Fill error messages for builtin error objects
|
||||
ifneq ($(ERROR_MESSAGES),)
|
||||
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DENABLE_ERROR_MESSAGES=$(ERROR_MESSAGES)
|
||||
BUILD_NAME:=$(BUILD_NAME)-ERROR_MESSAGES-$(ERROR_MESSAGES)
|
||||
endif
|
||||
|
||||
# All-in-one build
|
||||
ifneq ($(ALL_IN_ONE),)
|
||||
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DENABLE_ALL_IN_ONE=$(ALL_IN_ONE)
|
||||
BUILD_NAME:=$(BUILD_NAME)-ALL_IN_ONE-$(ALL_IN_ONE)
|
||||
endif
|
||||
|
||||
# Flag, indicating whether to use compiler's default libc (ON / OFF)
|
||||
ifneq ($(COMPILER_DEFAULT_LIBC),)
|
||||
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DCOMPILER_DEFAULT_LIBC=$(COMPILER_DEFAULT_LIBC)
|
||||
BUILD_NAME:=$(BUILD_NAME)-COMPILER_DEFAULT_LIBC-$(COMPILER_DEFAULT_LIBC)
|
||||
endif
|
||||
|
||||
# Apply strip to release binaries
|
||||
ifneq ($(STRIP_RELEASE_BINARY),)
|
||||
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DSTRIP_RELEASE_BINARY=$(STRIP_RELEASE_BINARY)
|
||||
endif
|
||||
|
||||
# For testing build-options
|
||||
export BUILD_OPTIONS_TEST_NATIVE := LTO LOG ERROR_MESSAGES ALL_IN_ONE VALGRIND VALGRIND_FREYA COMPILER_DEFAULT_LIBC
|
||||
|
||||
# Directories
|
||||
export ROOT_DIR := $(shell pwd)
|
||||
export BUILD_DIR_PREFIX := $(ROOT_DIR)/build/obj
|
||||
export BUILD_DIR := $(BUILD_DIR_PREFIX)$(BUILD_NAME)
|
||||
export OUT_DIR := $(ROOT_DIR)/build/bin
|
||||
export PREREQUISITES_STATE_DIR := $(ROOT_DIR)/build/prerequisites
|
||||
|
||||
SHELL := /bin/bash
|
||||
|
||||
# Build targets
|
||||
export JERRY_NATIVE_TARGETS := \
|
||||
$(foreach __MODE,$(DEBUG_MODES) $(RELEASE_MODES), \
|
||||
$(__MODE).$(NATIVE_SYSTEM) \
|
||||
$(foreach __MOD,$(NATIVE_MODS), \
|
||||
$(__MODE).$(NATIVE_SYSTEM)-$(__MOD)))
|
||||
|
||||
export JERRY_STM32F3_TARGETS := \
|
||||
$(foreach __MODE,$(RELEASE_MODES), \
|
||||
$(__MODE).mcu_stm32f3 \
|
||||
$(foreach __MOD,$(MCU_MODS), \
|
||||
$(__MODE).mcu_stm32f3-$(__MOD)))
|
||||
|
||||
export JERRY_STM32F4_TARGETS := \
|
||||
$(foreach __MODE,$(DEBUG_MODES) $(RELEASE_MODES), \
|
||||
$(__MODE).mcu_stm32f4 \
|
||||
$(foreach __MOD,$(MCU_MODS), \
|
||||
$(__MODE).mcu_stm32f4-$(__MOD)))
|
||||
|
||||
# JS test targets (has to be a subset of JERRY_NATIVE_TARGETS)
|
||||
export JERRY_TEST_TARGETS := \
|
||||
$(foreach __MODE,$(DEBUG_MODES) $(RELEASE_MODES), \
|
||||
$(__MODE).$(NATIVE_SYSTEM))
|
||||
|
||||
export JERRY_TEST_TARGETS_CP := \
|
||||
$(foreach __MODE,$(DEBUG_MODES) $(RELEASE_MODES), \
|
||||
$(__MODE).$(NATIVE_SYSTEM)-cp)
|
||||
|
||||
# Build-options test targets
|
||||
export JERRY_BUILD_OPTIONS_TEST_TARGETS_NATIVE := \
|
||||
$(foreach __MODE,$(RELEASE_MODES), \
|
||||
$(__MODE).$(NATIVE_SYSTEM))
|
||||
|
||||
JERRY_BUILD_OPTIONS_TEST_TARGETS_NATIVE += unittests
|
||||
|
||||
# JS test suites (in the format of id:path)
|
||||
export JERRY_TEST_SUITE_J := j:$(ROOT_DIR)/tests/jerry
|
||||
export JERRY_TEST_SUITE_JTS := jts:$(ROOT_DIR)/tests/jerry-test-suite
|
||||
export JERRY_TEST_SUITE_JTS_CP := jts-cp:$(ROOT_DIR)/tests/jerry-test-suite/compact-profile-list
|
||||
|
||||
# Default make target
|
||||
.PHONY: all
|
||||
all: precommit
|
||||
|
||||
# Verbosity control
|
||||
|
||||
ifdef VERBOSE
|
||||
Q :=
|
||||
else
|
||||
Q := @
|
||||
endif
|
||||
|
||||
# Shell command macro to invoke a command and redirect its output to a log file.
|
||||
#
|
||||
# $(1) - command to execute
|
||||
# $(2) - log file to write (only in non-verbose mode)
|
||||
# $(3) - command description (printed if command fails)
|
||||
ifdef VERBOSE
|
||||
define SHLOG
|
||||
$(1) || (echo -e "\e[1;33m$(3) failed. No log file generated. (Run make without VERBOSE if log is needed.)\e[0m"; exit 1;)
|
||||
endef
|
||||
else
|
||||
define SHLOG
|
||||
( mkdir -p $$(dirname $(2)) ; $(1) 2>&1 | tee $(2) >/dev/null ; ( exit $${PIPESTATUS[0]} ) ) || (echo -e "\e[1;33m$(3) failed. See $(2) for details.\e[0m"; exit 1;)
|
||||
endef
|
||||
endif
|
||||
|
||||
# Build system control
|
||||
ifdef NINJA
|
||||
BUILD_GENERATOR := Ninja
|
||||
BUILD_COMMAND := ninja -v
|
||||
else
|
||||
BUILD_GENERATOR := "Unix Makefiles"
|
||||
BUILD_COMMAND := $(MAKE) -w VERBOSE=1
|
||||
endif
|
||||
|
||||
# Targets to prepare the build directories
|
||||
|
||||
# Shell command macro to write $TOOLCHAIN shell variable to toolchain.config
|
||||
# file in the build directory, and clean it if found dirty.
|
||||
#
|
||||
# $(1) - build directory to write toolchain.config into
|
||||
define WRITE_TOOLCHAIN_CONFIG
|
||||
if [ -d $(1) ]; \
|
||||
then \
|
||||
grep -s -q "$$TOOLCHAIN" $(1)/toolchain.config || rm -rf $(1) ; \
|
||||
fi; \
|
||||
mkdir -p $(1); \
|
||||
echo "$$TOOLCHAIN" > $(1)/toolchain.config
|
||||
endef
|
||||
|
||||
.PHONY: $(BUILD_DIR)/$(NATIVE_SYSTEM)/toolchain.config
|
||||
.PHONY: $(BUILD_DIR)/$(NATIVE_SYSTEM)/unittests/toolchain.config
|
||||
$(BUILD_DIR)/$(NATIVE_SYSTEM)/toolchain.config \
|
||||
$(BUILD_DIR)/$(NATIVE_SYSTEM)/unittests/toolchain.config:
|
||||
$(Q) if [ "$$TOOLCHAIN" == "" ]; \
|
||||
then \
|
||||
arch=`uname -m`; \
|
||||
if [ "$$arch" == "armv7l" ]; \
|
||||
then \
|
||||
readelf -A /proc/self/exe | grep Tag_ABI_VFP_args && arch=$$arch"-hf" || arch=$$arch"-el"; \
|
||||
fi; \
|
||||
TOOLCHAIN="build/configs/toolchain_$(NATIVE_SYSTEM)_$$arch.cmake"; \
|
||||
fi; \
|
||||
$(call WRITE_TOOLCHAIN_CONFIG,$(dir $@))
|
||||
|
||||
# Make rule macro to generate toolchain.config for MCUs.
|
||||
#
|
||||
# $(1) - mcu system name
|
||||
define GEN_MCU_TOOLCHAIN_CONFIG_RULE
|
||||
.PHONY: $$(BUILD_DIR)/$(1)/toolchain.config
|
||||
$$(BUILD_DIR)/$(1)/toolchain.config: prerequisites
|
||||
$$(Q) TOOLCHAIN="build/configs/toolchain_mcu_$(1).cmake"; \
|
||||
$$(call WRITE_TOOLCHAIN_CONFIG,$$(BUILD_DIR)/$(1))
|
||||
endef
|
||||
|
||||
$(foreach __SYSTEM,$(MCU_SYSTEMS), \
|
||||
$(eval $(call GEN_MCU_TOOLCHAIN_CONFIG_RULE,$(__SYSTEM))))
|
||||
|
||||
# Make rule macro to generate Makefile in build directory with cmake.
|
||||
#
|
||||
# $(1) - build directory to generate Makefile into
|
||||
define GEN_MAKEFILE_RULE
|
||||
.PHONY: $(1)/Makefile
|
||||
$(1)/Makefile: $(1)/toolchain.config
|
||||
$$(Q) $$(call SHLOG,(cd $(1) && cmake -G $$(BUILD_GENERATOR) \
|
||||
$$(CMAKE_DEFINES) \
|
||||
-DCMAKE_TOOLCHAIN_FILE=`cat toolchain.config` $$(ROOT_DIR) 2>&1),$(1)/cmake.log,CMake run)
|
||||
endef
|
||||
|
||||
$(foreach __SYSTEM,$(NATIVE_SYSTEM) $(MCU_SYSTEMS), \
|
||||
$(eval $(call GEN_MAKEFILE_RULE,$(BUILD_DIR)/$(__SYSTEM))))
|
||||
|
||||
$(eval $(call GEN_MAKEFILE_RULE,$(BUILD_DIR)/$(NATIVE_SYSTEM)/unittests))
|
||||
|
||||
# Targets to perform build and test steps in the build directories
|
||||
|
||||
# Make rule macro to build a/some target(s) and copy out the result(s).
|
||||
#
|
||||
# $(1) - rule to define in the current Makefile
|
||||
# $(2) - name of the system which has a cmake-generated Makefile
|
||||
# $(3) - target(s) to build with the cmake-generated Makefile
|
||||
define BUILD_RULE
|
||||
.PHONY: $(1)
|
||||
$(1): $$(BUILD_DIR)/$(2)/Makefile
|
||||
$$(Q) $$(call SHLOG,$$(BUILD_COMMAND) -C $$(BUILD_DIR)/$(2) $(3),$$(BUILD_DIR)/$(2)/$(1).log,Build)
|
||||
$$(Q) $$(foreach __TARGET,$(3), \
|
||||
mkdir -p $$(OUT_DIR)/$$(__TARGET); \
|
||||
$$(if $$(findstring unittests,$$(__TARGET)), \
|
||||
cp $$(BUILD_DIR)/$(2)/unit-test-* $$(OUT_DIR)/$$(__TARGET); \
|
||||
, \
|
||||
$$(if $$(findstring .bin,$$(__TARGET)), \
|
||||
cp $$(BUILD_DIR)/$(2)/$$(__TARGET) $$(OUT_DIR)/$$(__TARGET)/jerry.bin; \
|
||||
cp $$(BUILD_DIR)/$(2)/$$(patsubst %.bin,%,$$(__TARGET)) $$(OUT_DIR)/$$(__TARGET)/jerry; \
|
||||
, \
|
||||
cp $$(BUILD_DIR)/$(2)/$$(__TARGET) $$(OUT_DIR)/$$(__TARGET)/jerry;)) \
|
||||
)
|
||||
endef
|
||||
|
||||
$(foreach __TARGET,$(JERRY_NATIVE_TARGETS), \
|
||||
$(eval $(call BUILD_RULE,$(__TARGET),$(NATIVE_SYSTEM),$(__TARGET))))
|
||||
|
||||
$(eval $(call BUILD_RULE,build.$(NATIVE_SYSTEM),$(NATIVE_SYSTEM),$(JERRY_NATIVE_TARGETS)))
|
||||
|
||||
$(foreach __TARGET,$(JERRY_STM32F3_TARGETS), \
|
||||
$(eval $(call BUILD_RULE,$(__TARGET),stm32f3,$(__TARGET).bin)))
|
||||
|
||||
$(eval $(call BUILD_RULE,build.mcu_stm32f3,stm32f3,$(patsubst %,%.bin,$(JERRY_STM32F3_TARGETS))))
|
||||
|
||||
$(foreach __TARGET,$(JERRY_STM32F4_TARGETS), \
|
||||
$(eval $(call BUILD_RULE,$(__TARGET),stm32f4,$(__TARGET).bin)))
|
||||
|
||||
$(eval $(call BUILD_RULE,build.mcu_stm32f4,stm32f4,$(patsubst %,%.bin,$(JERRY_STM32F4_TARGETS))))
|
||||
|
||||
$(eval $(call BUILD_RULE,unittests,$(NATIVE_SYSTEM)/unittests,unittests))
|
||||
|
||||
# Make rule macro to test a build target with a test suite.
|
||||
#
|
||||
# $(1) - name of target to test
|
||||
# $(2) - id of the test suite
|
||||
# $(3) - path to the test suite
|
||||
#
|
||||
# FIXME: the dependency of the defined rule is sub-optimal, but if every rule
|
||||
# would have its own proper dependency ($(1)), then potentially multiple builds
|
||||
# would work in the same directory in parallel, and they would overwrite each
|
||||
# others output. This manifests mostly in the repeated builds of jerry-libc and
|
||||
# its non-deterministically vanishing .a files.
|
||||
define JSTEST_RULE
|
||||
test-js.$(1).$(2): build.$$(NATIVE_SYSTEM)
|
||||
$$(Q) mkdir -p $$(OUT_DIR)/$(1)/check/$(2)
|
||||
$$(Q) $$(call SHLOG,cd $$(OUT_DIR)/$(1)/check/$(2) && $$(ROOT_DIR)/tools/runners/run-test-suite.sh \
|
||||
$$(OUT_DIR)/$(1)/jerry \
|
||||
$(3),$$(OUT_DIR)/$(1)/check/$(2)/test.log,Testing)
|
||||
test-js.$(1).$(2).snapshot: build.$$(NATIVE_SYSTEM)
|
||||
$$(Q) mkdir -p $$(OUT_DIR)/$(1)/check/$(2)
|
||||
$$(Q) $$(call SHLOG,cd $$(OUT_DIR)/$(1)/check/$(2) && $$(ROOT_DIR)/tools/runners/run-test-suite.sh \
|
||||
$$(OUT_DIR)/$(1)/jerry \
|
||||
$(3) --snapshot,$$(OUT_DIR)/$(1)/check/$(2)/snapshot.test.log,Testing)
|
||||
endef
|
||||
|
||||
$(foreach __TARGET,$(JERRY_TEST_TARGETS), \
|
||||
$(foreach __SUITE,$(JERRY_TEST_SUITE_J) $(JERRY_TEST_SUITE_JTS), \
|
||||
$(eval $(call JSTEST_RULE,$(__TARGET),$(firstword $(subst :, ,$(__SUITE))),$(lastword $(subst :, ,$(__SUITE)))))))
|
||||
|
||||
$(foreach __TARGET,$(JERRY_TEST_TARGETS_CP), \
|
||||
$(foreach __SUITE,$(JERRY_TEST_SUITE_JTS_CP), \
|
||||
$(eval $(call JSTEST_RULE,$(__TARGET),$(firstword $(subst :, ,$(__SUITE))),$(lastword $(subst :, ,$(__SUITE)))))))
|
||||
|
||||
# Make rule macro to test a build target with a build option.
|
||||
#
|
||||
# $(1) - name of the target to test
|
||||
# $(2) - name of the option to test
|
||||
define OPTIONSTEST_RULE
|
||||
.PHONY: test-option.$(1)-$(2)
|
||||
test-option.$(1)-$(2):
|
||||
$$(Q)+$(MAKE) --no-print-directory $(2)=ON $(1)
|
||||
endef
|
||||
|
||||
$(foreach __TARGET,$(JERRY_BUILD_OPTIONS_TEST_TARGETS_NATIVE), \
|
||||
$(foreach __OPTION, $(BUILD_OPTIONS_TEST_NATIVE), \
|
||||
$(eval $(call OPTIONSTEST_RULE,$(__TARGET),$(__OPTION)))))
|
||||
|
||||
# Targets to perform batch builds, checks, and tests
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(Q) rm -rf $(BUILD_DIR_PREFIX)* $(OUT_DIR)
|
||||
|
||||
.PHONY: check-signed-off
|
||||
check-signed-off:
|
||||
$(Q) ./tools/check-signed-off.sh
|
||||
|
||||
.PHONY: check-vera
|
||||
check-vera:
|
||||
$(Q) $(call SHLOG,./tools/check-vera.sh,$(OUT_DIR)/vera.log,Vera++)
|
||||
|
||||
.PHONY: check-cppcheck
|
||||
check-cppcheck:
|
||||
$(Q) $(call SHLOG,./tools/check-cppcheck.sh,$(OUT_DIR)/cppcheck.log,Cppcheck)
|
||||
|
||||
.PHONY: build
|
||||
build: build.$(NATIVE_SYSTEM) $(foreach __SYSTEM,$(MCU_SYSTEMS),build.mcu_$(__SYSTEM))
|
||||
|
||||
.PHONY: test-unit
|
||||
test-unit: unittests
|
||||
$(Q) mkdir -p $(OUT_DIR)/unittests/check
|
||||
$(Q) $(call SHLOG,cd $(OUT_DIR)/unittests/check && $(ROOT_DIR)/tools/runners/run-unittests.sh $(OUT_DIR)/unittests,$(OUT_DIR)/unittests/check/unittests.log,Unit tests)
|
||||
|
||||
.PHONY: test-js
|
||||
test-js: \
|
||||
$(foreach __TARGET,$(JERRY_TEST_TARGETS), \
|
||||
$(foreach __SUITE,$(JERRY_TEST_SUITE_J) $(JERRY_TEST_SUITE_JTS), \
|
||||
test-js.$(__TARGET).$(firstword $(subst :, ,$(__SUITE))) \
|
||||
test-js.$(__TARGET).$(firstword $(subst :, ,$(__SUITE))).snapshot)) \
|
||||
$(foreach __TARGET,$(JERRY_TEST_TARGETS_CP), \
|
||||
$(foreach __SUITE,$(JERRY_TEST_SUITE_JTS_CP), \
|
||||
test-js.$(__TARGET).$(firstword $(subst :, ,$(__SUITE))) \
|
||||
test-js.$(__TARGET).$(firstword $(subst :, ,$(__SUITE))).snapshot))
|
||||
|
||||
.PHONY: test-buildoptions
|
||||
test-buildoptions: \
|
||||
$(foreach __TARGET,$(JERRY_BUILD_OPTIONS_TEST_TARGETS_NATIVE), \
|
||||
$(foreach __OPTION, $(BUILD_OPTIONS_TEST_NATIVE), \
|
||||
test-option.$(__TARGET)-$(__OPTION)))
|
||||
|
||||
.PHONY: precommit
|
||||
precommit: prerequisites
|
||||
$(Q)+$(MAKE) --no-print-directory clean
|
||||
$(Q) echo "Running checks..."
|
||||
$(Q)+$(MAKE) --no-print-directory check-signed-off check-vera check-cppcheck
|
||||
$(Q) echo "...building engine..."
|
||||
$(Q)+$(MAKE) --no-print-directory build
|
||||
$(Q) echo "...building and running unit tests..."
|
||||
$(Q)+$(MAKE) --no-print-directory test-unit
|
||||
$(Q) echo "...running precommit JS tests..."
|
||||
$(Q)+$(MAKE) --no-print-directory test-js
|
||||
$(Q) echo "...SUCCESS"
|
||||
|
||||
# Targets to install and clean prerequisites
|
||||
|
||||
.PHONY: prerequisites
|
||||
prerequisites:
|
||||
$(Q) mkdir -p $(PREREQUISITES_STATE_DIR)
|
||||
$(Q) $(call SHLOG,./tools/prerequisites.sh $(PREREQUISITES_STATE_DIR)/.prerequisites,$(PREREQUISITES_STATE_DIR)/prerequisites.log,Prerequisites setup)
|
||||
|
||||
.PHONY: prerequisites_clean
|
||||
prerequisites_clean:
|
||||
$(Q) ./tools/prerequisites.sh $(PREREQUISITES_STATE_DIR)/.prerequisites clean
|
||||
$(Q) rm -rf $(PREREQUISITES_STATE_DIR)
|
||||
|
||||
# Git helper targets
|
||||
|
||||
.PHONY: push
|
||||
push: ./tools/git-scripts/push.sh
|
||||
$(Q) ./tools/git-scripts/push.sh
|
||||
|
||||
.PHONY: pull
|
||||
pull: ./tools/git-scripts/pull.sh
|
||||
$(Q) ./tools/git-scripts/pull.sh
|
||||
|
||||
.PHONY: log
|
||||
log: ./tools/git-scripts/log.sh
|
||||
$(Q) ./tools/git-scripts/log.sh
|
||||
@ -27,7 +27,7 @@ cd jerryscript
|
||||
|
||||
### Building JerryScript
|
||||
```bash
|
||||
make release.linux -j
|
||||
python tools/build.py
|
||||
```
|
||||
|
||||
For additional information see [Getting Started](docs/01.GETTING-STARTED.md).
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
# Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2015-2016 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.
|
||||
@ -15,8 +15,6 @@
|
||||
set(CMAKE_SYSTEM_NAME Darwin)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
||||
|
||||
find_program(CMAKE_C_COMPILER NAMES gcc cc)
|
||||
# FIXME: This could break cross compilation, when the strip is not for the target architecture
|
||||
find_program(CMAKE_STRIP NAMES strip)
|
||||
find_program(CMAKE_C_COMPILER NAMES gcc cc)
|
||||
|
||||
#set(FLAGS_COMMON_ARCH )
|
||||
@ -1,4 +1,4 @@
|
||||
# Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2015-2016 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.
|
||||
@ -16,7 +16,5 @@ set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR armv7l-el)
|
||||
|
||||
set(CMAKE_C_COMPILER arm-linux-gnueabi-gcc)
|
||||
# FIXME: This could break cross compilation, when the strip is not for the target architecture
|
||||
find_program(CMAKE_STRIP NAMES arm-linux-gnueabi-strip strip)
|
||||
|
||||
set(FLAGS_COMMON_ARCH -mlittle-endian -mthumb)
|
||||
@ -1,4 +1,4 @@
|
||||
# Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2015-2016 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.
|
||||
@ -16,8 +16,6 @@ set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR armv7l-hf)
|
||||
|
||||
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
|
||||
# FIXME: This could break cross compilation, when the strip is not for the target architecture
|
||||
find_program(CMAKE_STRIP NAMES arm-linux-gnueabihf-strip strip)
|
||||
#
|
||||
# Limit fpu to VFPv3 with d0-d15 registers
|
||||
#
|
||||
@ -1,4 +1,4 @@
|
||||
# Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2015-2016 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.
|
||||
@ -16,5 +16,3 @@ set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR i686)
|
||||
|
||||
find_program(CMAKE_C_COMPILER NAMES i686-linux-gnu-gcc i686-unknown-linux-gnu-gcc)
|
||||
# FIXME: This could break cross compilation, when the strip is not for the target architecture
|
||||
find_program(CMAKE_STRIP NAMES i686-linux-gnu-strip i686-unknown-linux-gnu-strip strip)
|
||||
@ -1,4 +1,4 @@
|
||||
# Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2015-2016 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.
|
||||
@ -16,7 +16,5 @@ set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
||||
|
||||
find_program(CMAKE_C_COMPILER NAMES x86_64-linux-gnu-gcc x86_64-unknown-linux-gnu-gcc)
|
||||
# FIXME: This could break cross compilation, when the strip is not for the target architecture
|
||||
find_program(CMAKE_STRIP NAMES x86_64-linux-gnu-strip x86_64-unknown-linux-gnu-strip strip)
|
||||
|
||||
set(FLAGS_COMMON_ARCH -ffixed-rbp)
|
||||
@ -16,5 +16,3 @@ set(CMAKE_SYSTEM_NAME Openwrt)
|
||||
set(CMAKE_SYSTEM_PROCESSOR mips)
|
||||
|
||||
set(CMAKE_C_COMPILER mipsel-openwrt-linux-gcc)
|
||||
# FIXME: This could break cross compilation, when the strip is not for the target architecture
|
||||
find_program(CMAKE_STRIP NAMES mipsel-openwrt-linux-strip strip)
|
||||
@ -4,64 +4,68 @@ Currently, only Ubuntu 14.04+ is officially supported as primary development env
|
||||
|
||||
There are several dependencies, that should be installed manually. The following list is required for building:
|
||||
|
||||
- `gcc` higher than `4.8.2`
|
||||
- `gcc` or any C99-compliant compiler
|
||||
- native
|
||||
- arm-none-eabi
|
||||
- `cmake` higher than `2.8.12.2`
|
||||
- `make` higher than `3.81`
|
||||
- `bash` higher than `4.3.11`
|
||||
- `cppcheck` higher than 1.61
|
||||
- `vera++` higher than 1.2.1
|
||||
- `cmake` >= `2.8.12.2`
|
||||
- `bash` >= `4.3.11`
|
||||
- `cppcheck` >= `1.61`
|
||||
- `vera++` >= `1.2.1`
|
||||
- `python` >= `2.7.6`
|
||||
|
||||
```bash
|
||||
sudo apt-get install gcc g++ gcc-arm-none-eabi cmake cppcheck vera++
|
||||
sudo apt-get install gcc g++ gcc-arm-none-eabi cmake cppcheck vera++ python
|
||||
```
|
||||
|
||||
To make our scripts run correctly, several shell utilities should be available on the system:
|
||||
|
||||
- `find`
|
||||
- `bc`
|
||||
- `awk`
|
||||
- `sed`
|
||||
- `sha256sum`
|
||||
- `wget`
|
||||
|
||||
Upon first build, `make` would try to setup prerequisites, required for further development and pre-commit testing:
|
||||
|
||||
- STM32F3 and STM32F4 libraries
|
||||
|
||||
```bash
|
||||
make prerequisites -j
|
||||
```
|
||||
|
||||
It may take time, so go grab some coffee:
|
||||
|
||||
```bash
|
||||
Setting up prerequisites... (log file: ./build/prerequisites/prerequisites.log)
|
||||
```
|
||||
|
||||
### Building Debug Version
|
||||
|
||||
To build debug version for Linux:
|
||||
|
||||
```bash
|
||||
make debug.linux -j
|
||||
python tools/build.py --debug
|
||||
```
|
||||
|
||||
To build debug version for Linux without LTO (Link Time Optimization):
|
||||
|
||||
```bash
|
||||
LTO=OFF make debug.linux -j
|
||||
python tools/build.py --debug --lto=off
|
||||
```
|
||||
|
||||
Add custom arguments to CMake:
|
||||
|
||||
```bash
|
||||
python tools/build.py --cmake-param CMAKE_PARAM
|
||||
```
|
||||
|
||||
Add toolchain file:
|
||||
|
||||
The cmake dir already contains some usable toolchain files.
|
||||
|
||||
```bash
|
||||
python tools/build.py --toolchain TOOLCHAIN
|
||||
```
|
||||
|
||||
Use (jerry|compiler-default|external libc) libc:
|
||||
|
||||
```bash
|
||||
python tools/build.py --libc LIBC
|
||||
```
|
||||
The possible arguments are `jerry` , `compiler` , `<path of external lib>`
|
||||
|
||||
To get more available buildoptions for Linux:
|
||||
|
||||
```bash
|
||||
python tools/build.py --help
|
||||
```
|
||||
|
||||
### Checking Patch
|
||||
|
||||
```bash
|
||||
make precommit -j
|
||||
```
|
||||
|
||||
If some style guidelines, build or test runs fail during precommit, then this is indicated with a message like this:
|
||||
|
||||
```
|
||||
Build failed. See ./build/bin/unittests/make.log for details.
|
||||
python tools/run-tests.py --precommit
|
||||
```
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# Copyright 2015-2016 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2016 University of Szeged.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@ -13,10 +14,103 @@
|
||||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required (VERSION 2.8.12)
|
||||
project (JerryCore C ASM)
|
||||
set(JERRY_CORE_NAME jerry-core)
|
||||
project (${JERRY_CORE_NAME} C)
|
||||
|
||||
# Optional features
|
||||
set(FEATURE_PROFILE "full" CACHE STRING "ES5.1 profile: full, compact, minimal")
|
||||
set(FEATURE_ERROR_MESSAGES OFF CACHE BOOL "Enable error messages?")
|
||||
set(FEATURE_LOG OFF CACHE BOOL "Enable logging?")
|
||||
set(FEATURE_VALGRIND OFF CACHE BOOL "Enable Valgrind support?")
|
||||
set(FEATURE_VALGRIND_FREYA OFF CACHE BOOL "Enable Valgrind-Freya support?")
|
||||
set(FEATURE_MEM_STRESS_TEST OFF CACHE BOOL "Enable mem-stress test?")
|
||||
set(FEATURE_MEM_STATS OFF CACHE BOOL "Enable memory-statistics?")
|
||||
set(FEATURE_SNAPSHOT_SAVE OFF CACHE BOOL "Allow to save snapshot files?")
|
||||
set(FEATURE_SNAPSHOT_EXEC OFF CACHE BOOL "Allow to execute snapshot files?")
|
||||
set(MEM_HEAP_SIZE_KB "512" CACHE STRING "Size of memory heap, in kilobytes")
|
||||
|
||||
# Status messages
|
||||
message(STATUS "FEATURE_PROFILE " ${FEATURE_PROFILE})
|
||||
message(STATUS "FEATURE_ERROR_MESSAGES " ${FEATURE_ERROR_MESSAGES})
|
||||
message(STATUS "FEATURE_LOG " ${FEATURE_LOG})
|
||||
message(STATUS "FEATURE_VALGRIND " ${FEATURE_VALGRIND})
|
||||
message(STATUS "FEATURE_VALGRIND_FREYA " ${FEATURE_VALGRIND_FREYA})
|
||||
message(STATUS "FEATURE_MEM_STRESS_TEST " ${FEATURE_MEM_STRESS_TEST})
|
||||
message(STATUS "FEATURE_MEM_STATS " ${FEATURE_MEM_STATS})
|
||||
message(STATUS "FEATURE_SNAPSHOT_SAVE " ${FEATURE_SNAPSHOT_SAVE})
|
||||
message(STATUS "FEATURE_SNAPSHOT_EXEC " ${FEATURE_SNAPSHOT_EXEC})
|
||||
message(STATUS "MEM_HEAP_SIZE_KB " ${MEM_HEAP_SIZE_KB})
|
||||
|
||||
# Include directories
|
||||
set(INCLUDE_CORE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/ecma/base"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/ecma/builtin-objects"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/ecma/operations"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/jcontext"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/jmem"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/jrt"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/lit"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/parser/js"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/parser/regexp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/vm")
|
||||
|
||||
# Sources
|
||||
# Jerry core
|
||||
file(GLOB SOURCE_CORE_API *.c)
|
||||
file(GLOB SOURCE_CORE_ECMA_BASE ecma/base/*.c)
|
||||
file(GLOB SOURCE_CORE_ECMA_BUILTINS ecma/builtin-objects/*.c)
|
||||
file(GLOB SOURCE_CORE_ECMA_OPERATIONS ecma/operations/*.c)
|
||||
file(GLOB SOURCE_CORE_JCONTEXT jcontext/*.c)
|
||||
file(GLOB SOURCE_CORE_JMEM jmem/*.c)
|
||||
file(GLOB SOURCE_CORE_JRT jrt/*.c)
|
||||
file(GLOB SOURCE_CORE_LIT lit/*.c)
|
||||
file(GLOB SOURCE_CORE_PARSER_JS parser/js/*.c)
|
||||
file(GLOB SOURCE_CORE_PARSER_REGEXP parser/regexp/*.c)
|
||||
file(GLOB SOURCE_CORE_VM vm/*.c)
|
||||
|
||||
set(SOURCE_CORE_FILES
|
||||
${SOURCE_CORE_API}
|
||||
${SOURCE_CORE_ECMA_BASE}
|
||||
${SOURCE_CORE_ECMA_BUILTINS}
|
||||
${SOURCE_CORE_ECMA_OPERATIONS}
|
||||
${SOURCE_CORE_JCONTEXT}
|
||||
${SOURCE_CORE_JMEM}
|
||||
${SOURCE_CORE_JRT}
|
||||
${SOURCE_CORE_LIT}
|
||||
${SOURCE_CORE_PARSER_JS}
|
||||
${SOURCE_CORE_PARSER_REGEXP}
|
||||
${SOURCE_CORE_VM})
|
||||
|
||||
# Jerry port
|
||||
file(GLOB SOURCE_PORT_FILES "${PORT_DIR}/*.c")
|
||||
|
||||
# All-in-one build
|
||||
if(ENABLE_ALL_IN_ONE)
|
||||
set(ALL_IN_FILE "${CMAKE_BINARY_DIR}/jerry-all-in.c")
|
||||
list(SORT SOURCE_CORE_FILES)
|
||||
file(REMOVE ${ALL_IN_FILE})
|
||||
|
||||
foreach(FILE ${SOURCE_CORE_FILES})
|
||||
file(APPEND ${ALL_IN_FILE} "#include \"${FILE}\"\n")
|
||||
endforeach()
|
||||
|
||||
foreach(FILE ${SOURCE_PORT_FILES})
|
||||
file(APPEND ${ALL_IN_FILE} "#include \"${FILE}\"\n")
|
||||
endforeach()
|
||||
|
||||
set(SOURCE_CORE ${ALL_IN_FILE})
|
||||
else()
|
||||
set(SOURCE_CORE ${SOURCE_CORE_FILES} ${SOURCE_PORT_FILES})
|
||||
endif()
|
||||
|
||||
# Third-party
|
||||
# Valgrind
|
||||
set(INCLUDE_THIRD_PARTY_VALGRIND "${CMAKE_SOURCE_DIR}/third-party/valgrind")
|
||||
|
||||
# Definitions
|
||||
# Get version information from git
|
||||
# Get version information from git
|
||||
if(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git")
|
||||
execute_process(COMMAND git symbolic-ref -q HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE JERRY_GIT_BRANCH
|
||||
@ -25,220 +119,118 @@ project (JerryCore C ASM)
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE JERRY_GIT_COMMIT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
# Get build date
|
||||
execute_process(COMMAND date +%d/%m/%Y
|
||||
OUTPUT_VARIABLE JERRY_BUILD_DATE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
else()
|
||||
set(JERRY_GIT_BRANCH "UNDEFINED")
|
||||
set(JERRY_GIT_COMMIT "UNDEFINED")
|
||||
endif()
|
||||
|
||||
# Get build date
|
||||
execute_process(COMMAND date +%d/%m/%Y
|
||||
OUTPUT_VARIABLE JERRY_BUILD_DATE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
set(DEFINES_JERRY
|
||||
${DEFINES_JERRY}
|
||||
JERRY_BUILD_DATE="${JERRY_BUILD_DATE}"
|
||||
JERRY_COMMIT_HASH="${JERRY_GIT_COMMIT}"
|
||||
JERRY_BRANCH_NAME="${JERRY_GIT_BRANCH}")
|
||||
|
||||
# build mode specific compile/link flags
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_PRETTY_PRINTER)
|
||||
else()
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_NDEBUG)
|
||||
endif()
|
||||
|
||||
# ES5.1 profiles
|
||||
# Full profile
|
||||
if(FEATURE_PROFILE STREQUAL "full")
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} CONFIG_ECMA_NUMBER_TYPE=CONFIG_ECMA_NUMBER_FLOAT64)
|
||||
|
||||
# Compact profile
|
||||
elseif(FEATURE_PROFILE STREQUAL "compact")
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} CONFIG_ECMA_COMPACT_PROFILE)
|
||||
|
||||
# Minimal compact profile
|
||||
elseif(FEATURE_PROFILE STREQUAL "minimal")
|
||||
set(DEFINES_JERRY
|
||||
JERRY_ENABLE_SNAPSHOT_SAVE
|
||||
JERRY_ENABLE_SNAPSHOT_EXEC
|
||||
JERRY_BUILD_DATE="${JERRY_BUILD_DATE}"
|
||||
JERRY_COMMIT_HASH="${JERRY_GIT_COMMIT}"
|
||||
JERRY_BRANCH_NAME="${JERRY_GIT_BRANCH}")
|
||||
|
||||
# Build modes
|
||||
# Debug
|
||||
set(DEFINES_JERRY_DEBUG JERRY_ENABLE_PRETTY_PRINTER)
|
||||
|
||||
# Release
|
||||
set(DEFINES_JERRY_RELEASE JERRY_NDEBUG)
|
||||
|
||||
# Unit tests
|
||||
set(DEFINES_JERRY_UNITTESTS JERRY_ENABLE_PRETTY_PRINTER)
|
||||
|
||||
# Modifiers
|
||||
# Full profile
|
||||
set(DEFINES_FULL_PROFILE CONFIG_ECMA_NUMBER_TYPE=CONFIG_ECMA_NUMBER_FLOAT64)
|
||||
|
||||
# Compact profile
|
||||
set(DEFINES_COMPACT_PROFILE
|
||||
CONFIG_ECMA_COMPACT_PROFILE)
|
||||
|
||||
# Minimal compact profile
|
||||
set(DEFINES_COMPACT_PROFILE_MINIMAL
|
||||
CONFIG_ECMA_COMPACT_PROFILE
|
||||
${DEFINES_JERRY}
|
||||
CONFIG_ECMA_COMPACT_PROFILE
|
||||
#
|
||||
# Date and RegExp built-in objects are also disabled in non-minimal compact profile build
|
||||
#
|
||||
# CONFIG_ECMA_COMPACT_PROFILE_DISABLE_DATE_BUILTIN
|
||||
# CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN
|
||||
#
|
||||
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_NUMBER_BUILTIN
|
||||
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_STRING_BUILTIN
|
||||
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_BOOLEAN_BUILTIN
|
||||
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ERROR_BUILTINS
|
||||
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ARRAY_BUILTIN
|
||||
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_MATH_BUILTIN
|
||||
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_JSON_BUILTIN)
|
||||
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_NUMBER_BUILTIN
|
||||
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_STRING_BUILTIN
|
||||
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_BOOLEAN_BUILTIN
|
||||
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ERROR_BUILTINS
|
||||
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ARRAY_BUILTIN
|
||||
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_MATH_BUILTIN
|
||||
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_JSON_BUILTIN)
|
||||
|
||||
# Memory management stress-test mode
|
||||
set(DEFINES_MEM_STRESS_TEST
|
||||
JMEM_GC_BEFORE_EACH_ALLOC)
|
||||
else()
|
||||
message(FATAL_ERROR "FEATURE_PROFILE='${FEATURE_PROFILE}' doesn't supported")
|
||||
endif()
|
||||
|
||||
# Memory statistics
|
||||
set(DEFINES_MEMORY_STATISTICS JMEM_STATS)
|
||||
|
||||
# Valgrind
|
||||
set(DEFINES_JERRY_VALGRIND JERRY_VALGRIND)
|
||||
|
||||
# Valgrind Freya
|
||||
set(DEFINES_JERRY_VALGRIND_FREYA JERRY_VALGRIND_FREYA)
|
||||
|
||||
# Platform-specific
|
||||
# Linux
|
||||
|
||||
# MCU
|
||||
# stm32f3
|
||||
math(EXPR MEM_HEAP_AREA_SIZE_16K "16 * 1024")
|
||||
set(DEFINES_JERRY_MCU_STM32F3 CONFIG_MEM_HEAP_AREA_SIZE=${MEM_HEAP_AREA_SIZE_16K})
|
||||
# stm32f4
|
||||
math(EXPR MEM_HEAP_AREA_SIZE_16K "16 * 1024")
|
||||
set(DEFINES_JERRY_MCU_STM32F4 CONFIG_MEM_HEAP_AREA_SIZE=${MEM_HEAP_AREA_SIZE_16K})
|
||||
|
||||
# External
|
||||
if(DEFINED EXTERNAL_MEM_HEAP_SIZE_KB)
|
||||
math(EXPR MEM_HEAP_AREA_SIZE_EXTERNAL "${EXTERNAL_MEM_HEAP_SIZE_KB} * 1024")
|
||||
set(DEFINES_JERRY_EXTERNAL CONFIG_MEM_HEAP_AREA_SIZE=${MEM_HEAP_AREA_SIZE_EXTERNAL})
|
||||
endif()
|
||||
|
||||
# Include directories
|
||||
set(INCLUDE_CORE
|
||||
${CMAKE_SOURCE_DIR}/jerry-core
|
||||
${CMAKE_SOURCE_DIR}/jerry-core/ecma/base
|
||||
${CMAKE_SOURCE_DIR}/jerry-core/ecma/builtin-objects
|
||||
${CMAKE_SOURCE_DIR}/jerry-core/ecma/operations
|
||||
${CMAKE_SOURCE_DIR}/jerry-core/jcontext
|
||||
${CMAKE_SOURCE_DIR}/jerry-core/jmem
|
||||
${CMAKE_SOURCE_DIR}/jerry-core/jrt
|
||||
${CMAKE_SOURCE_DIR}/jerry-core/lit
|
||||
${CMAKE_SOURCE_DIR}/jerry-core/parser/js
|
||||
${CMAKE_SOURCE_DIR}/jerry-core/parser/regexp
|
||||
${CMAKE_SOURCE_DIR}/jerry-core/vm)
|
||||
|
||||
# Third-party
|
||||
# Valgrind
|
||||
set(INCLUDE_THIRD_PARTY_VALGRIND ${CMAKE_SOURCE_DIR}/third-party/valgrind)
|
||||
|
||||
# Sources
|
||||
# Jerry core
|
||||
file(GLOB SOURCE_CORE_API *.c)
|
||||
file(GLOB SOURCE_CORE_ECMA_BASE ecma/base/*.c)
|
||||
file(GLOB SOURCE_CORE_ECMA_BUILTINS ecma/builtin-objects/*.c)
|
||||
file(GLOB SOURCE_CORE_ECMA_OPERATIONS ecma/operations/*.c)
|
||||
file(GLOB SOURCE_CORE_JCONTEXT jcontext/*.c)
|
||||
file(GLOB SOURCE_CORE_JMEM jmem/*.c)
|
||||
file(GLOB SOURCE_CORE_JRT jrt/*.c)
|
||||
file(GLOB SOURCE_CORE_LIT lit/*.c)
|
||||
file(GLOB SOURCE_CORE_PARSER_JS parser/js/*.c)
|
||||
file(GLOB SOURCE_CORE_PARSER_REGEXP parser/regexp/*.c)
|
||||
file(GLOB SOURCE_CORE_VM vm/*.c)
|
||||
|
||||
set(SOURCE_CORE_FILES
|
||||
${SOURCE_CORE_API}
|
||||
${SOURCE_CORE_ECMA_BASE}
|
||||
${SOURCE_CORE_ECMA_BUILTINS}
|
||||
${SOURCE_CORE_ECMA_OPERATIONS}
|
||||
${SOURCE_CORE_JCONTEXT}
|
||||
${SOURCE_CORE_JMEM}
|
||||
${SOURCE_CORE_JRT}
|
||||
${SOURCE_CORE_LIT}
|
||||
${SOURCE_CORE_PARSER_JS}
|
||||
${SOURCE_CORE_PARSER_REGEXP}
|
||||
${SOURCE_CORE_VM})
|
||||
|
||||
# Jerry port
|
||||
if(NOT ("${PORT_DIR}" STREQUAL ""))
|
||||
file(GLOB SOURCE_PORT_FILES ${PORT_DIR}/*.c)
|
||||
if (NOT USE_JERRY_LIBC)
|
||||
set (DEFINES_JERRY ${DEFINES_JERRY} _BSD_SOURCE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# All-in-one build
|
||||
if("${ENABLE_ALL_IN_ONE}" STREQUAL "ON")
|
||||
set(ALL_IN_FILE "${CMAKE_BINARY_DIR}/jerry-all-in.c")
|
||||
list(SORT SOURCE_CORE_FILES)
|
||||
file(REMOVE ${ALL_IN_FILE})
|
||||
|
||||
foreach(FILE ${SOURCE_CORE_FILES})
|
||||
file(APPEND ${ALL_IN_FILE} "#include \"${FILE}\"\n")
|
||||
endforeach()
|
||||
|
||||
foreach(FILE ${SOURCE_PORT_FILES})
|
||||
file(APPEND ${ALL_IN_FILE} "#include \"${FILE}\"\n")
|
||||
endforeach()
|
||||
|
||||
set(SOURCE_CORE ${ALL_IN_FILE})
|
||||
else()
|
||||
set(SOURCE_CORE ${SOURCE_CORE_FILES} ${SOURCE_PORT_FILES})
|
||||
endif()
|
||||
|
||||
# Per-option configuration
|
||||
# Valgrind
|
||||
if("${ENABLE_VALGRIND}" STREQUAL "ON")
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} ${DEFINES_JERRY_VALGRIND})
|
||||
set(INCLUDE_CORE ${INCLUDE_CORE} ${INCLUDE_THIRD_PARTY_VALGRIND})
|
||||
endif()
|
||||
|
||||
# Valgrind Freya
|
||||
if("${ENABLE_VALGRIND_FREYA}" STREQUAL "ON")
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} ${DEFINES_JERRY_VALGRIND_FREYA})
|
||||
set(INCLUDE_CORE ${INCLUDE_CORE} ${INCLUDE_THIRD_PARTY_VALGRIND})
|
||||
endif()
|
||||
|
||||
# JERRY_HEAP_SECTION_ATTR
|
||||
if(DEFINED JERRY_HEAP_SECTION_ATTR)
|
||||
# Jerry heap-section
|
||||
if(DEFINED JERRY_HEAP_SECTION_ATTR)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_HEAP_SECTION_ATTR=${JERRY_HEAP_SECTION_ATTR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Log
|
||||
if("${ENABLE_LOG}" STREQUAL "ON")
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_LOG)
|
||||
endif()
|
||||
# Fill error messages for builtin error objects
|
||||
if(FEATURE_ERROR_MESSAGES)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_ERROR_MESSAGES)
|
||||
endif()
|
||||
|
||||
# Fill error messages for builtin error objects
|
||||
if("${ENABLE_ERROR_MESSAGES}" STREQUAL "ON")
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_ERROR_MESSAGES)
|
||||
endif()
|
||||
# Log
|
||||
if(FEATURE_LOG)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_LOG)
|
||||
endif()
|
||||
|
||||
# Platform-specific configuration
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} ${DEFINES_JERRY_${PLATFORM_EXT}})
|
||||
# Valgrind
|
||||
if(FEATURE_VALGRIND)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_VALGRIND)
|
||||
set(INCLUDE_CORE ${INCLUDE_CORE} ${INCLUDE_THIRD_PARTY_VALGRIND})
|
||||
endif()
|
||||
|
||||
# Targets declaration
|
||||
function(declare_targets_for_build_mode BUILD_MODE)
|
||||
set(TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}})
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} ${DEFINES_JERRY_${BUILD_MODE}})
|
||||
# Valgrind Freya
|
||||
if(FEATURE_VALGRIND_FREYA)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_VALGRIND_FREYA)
|
||||
set(INCLUDE_CORE ${INCLUDE_CORE} ${INCLUDE_THIRD_PARTY_VALGRIND})
|
||||
endif()
|
||||
|
||||
function(declare_target_with_modifiers ) # modifiers are passed in ARGN implicit argument
|
||||
foreach(MODIFIER ${ARGN})
|
||||
set(TARGET_NAME ${TARGET_NAME}${MODIFIER_SUFFIX_${MODIFIER}})
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} ${DEFINES_${MODIFIER}})
|
||||
endforeach()
|
||||
# Memory management stress-test mode
|
||||
if(FEATURE_MEM_STRESS_TEST)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JMEM_GC_BEFORE_EACH_ALLOC)
|
||||
endif()
|
||||
|
||||
add_library(${TARGET_NAME}.jerry-core STATIC ${SOURCE_CORE})
|
||||
set_property(TARGET ${TARGET_NAME}.jerry-core
|
||||
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_JERRY} ${C_FLAGS_JERRY} ${FLAGS_COMMON_${BUILD_MODE}}")
|
||||
target_compile_definitions(${TARGET_NAME}.jerry-core PRIVATE ${DEFINES_JERRY})
|
||||
target_include_directories(${TARGET_NAME}.jerry-core PRIVATE ${INCLUDE_CORE})
|
||||
target_include_directories(${TARGET_NAME}.jerry-core PRIVATE ${INCLUDE_LIBM})
|
||||
target_include_directories(${TARGET_NAME}.jerry-core SYSTEM PRIVATE ${INCLUDE_LIBC_INTERFACE})
|
||||
target_include_directories(${TARGET_NAME}.jerry-core SYSTEM PRIVATE ${INCLUDE_EXTERNAL_LIBS_INTERFACE})
|
||||
# Memory statistics
|
||||
if(FEATURE_MEM_STATS)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JMEM_STATS)
|
||||
endif()
|
||||
|
||||
if("${BUILD_MODE}" STREQUAL "UNITTESTS")
|
||||
target_compile_definitions(${TARGET_NAME}.jerry-core INTERFACE ${DEFINES_JERRY})
|
||||
target_include_directories(${TARGET_NAME}.jerry-core INTERFACE ${INCLUDE_CORE})
|
||||
endif()
|
||||
endfunction()
|
||||
# Snapshot save
|
||||
if(FEATURE_SNAPSHOT_SAVE)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_SNAPSHOT_SAVE)
|
||||
endif()
|
||||
|
||||
foreach(MODIFIERS_LIST ${MODIFIERS_LISTS})
|
||||
separate_arguments(MODIFIERS_LIST)
|
||||
# Snapshot exec
|
||||
if(FEATURE_SNAPSHOT_EXEC)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_SNAPSHOT_EXEC)
|
||||
endif()
|
||||
|
||||
declare_target_with_modifiers(${MODIFIERS_LIST})
|
||||
endforeach()
|
||||
endfunction()
|
||||
# Size of heap
|
||||
math(EXPR MEM_HEAP_AREA_SIZE "${MEM_HEAP_SIZE_KB} * 1024")
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} CONFIG_MEM_HEAP_AREA_SIZE=${MEM_HEAP_AREA_SIZE})
|
||||
|
||||
declare_targets_for_build_mode(DEBUG)
|
||||
declare_targets_for_build_mode(RELEASE)
|
||||
declare_targets_for_build_mode(UNITTESTS)
|
||||
add_library(${JERRY_CORE_NAME} STATIC ${SOURCE_CORE})
|
||||
|
||||
target_compile_definitions(${JERRY_CORE_NAME} PUBLIC ${DEFINES_JERRY})
|
||||
target_include_directories(${JERRY_CORE_NAME} PUBLIC ${INCLUDE_CORE})
|
||||
|
||||
if (JERRY_LIBC)
|
||||
target_include_directories(${JERRY_CORE_NAME} SYSTEM PRIVATE "${CMAKE_SOURCE_DIR}/jerry-libc/include")
|
||||
endif()
|
||||
|
||||
|
||||
@ -2062,11 +2062,12 @@ jerry_parse_and_save_snapshot (const jerry_char_t *source_p, /**< script source
|
||||
|
||||
return snapshot_buffer_write_offset;
|
||||
#else /* !JERRY_ENABLE_SNAPSHOT_SAVE */
|
||||
(void) source_p;
|
||||
(void) source_size;
|
||||
(void) is_for_global;
|
||||
(void) buffer_p;
|
||||
(void) buffer_size;
|
||||
JERRY_UNUSED (source_p);
|
||||
JERRY_UNUSED (source_size);
|
||||
JERRY_UNUSED (is_for_global);
|
||||
JERRY_UNUSED (is_strict);
|
||||
JERRY_UNUSED (buffer_p);
|
||||
JERRY_UNUSED (buffer_size);
|
||||
|
||||
return 0;
|
||||
#endif /* JERRY_ENABLE_SNAPSHOT_SAVE */
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# Copyright 2015-2016 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2016 University of Szeged.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@ -13,140 +14,38 @@
|
||||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required (VERSION 2.8.12)
|
||||
project (Jerry_LibC C ASM)
|
||||
|
||||
# Compiler / linker flags
|
||||
set(COMPILE_FLAGS_LIBC "${COMPILE_FLAGS_JERRY} ${C_FLAGS_JERRY}")
|
||||
|
||||
# Definitions
|
||||
set(DEFINES_LIBC )
|
||||
|
||||
# Debug
|
||||
set(DEFINES_LIBC_DEBUG )
|
||||
|
||||
# Release
|
||||
set(DEFINES_LIBC_RELEASE NDEBUG)
|
||||
|
||||
# Architecture-specific
|
||||
# x86_64
|
||||
set(DEFINES_LIBC_X86_64 __TARGET_HOST_x64)
|
||||
# ARMv7-hf
|
||||
set(DEFINES_LIBC_ARMV7_HF __TARGET_HOST_ARMv7 __TARGET_HOST_ARMv7_HARD_FLOAT)
|
||||
# ARMv7-el
|
||||
set(DEFINES_LIBC_ARMV7_EL __TARGET_HOST_ARMv7 __TARGET_HOST_ARMv7_SOFT_FLOAT)
|
||||
# x86
|
||||
set(DEFINES_LIBC_X86 __TARGET_HOST_x86)
|
||||
|
||||
# Platform-specific
|
||||
# Linux
|
||||
set(DEFINES_LIBC_LINUX __TARGET_HOST)
|
||||
# Darwin
|
||||
set(DEFINES_LIBC_DARWIN __TARGET_HOST)
|
||||
# MCU
|
||||
set(DEFINES_LIBC_MCU __TARGET_MCU)
|
||||
# stm32f3
|
||||
set(DEFINES_LIBC_MCU_STM32F3 __TARGET_MCU_STM32F3)
|
||||
# stm32f4
|
||||
set(DEFINES_LIBC_MCU_STM32F4 __TARGET_MCU_STM32F4)
|
||||
|
||||
# Include directories
|
||||
set(INCLUDE_LIBC ${CMAKE_SOURCE_DIR}/jerry-libc)
|
||||
set(INCLUDE_LIBC_INTERFACE ${CMAKE_SOURCE_DIR}/jerry-libc/include)
|
||||
set(INCLUDE_LIBC_INTERFACE ${INCLUDE_LIBC_INTERFACE} PARENT_SCOPE)
|
||||
|
||||
# Third-party
|
||||
# Platform-specific
|
||||
# Linux
|
||||
set(INCLUDE_THIRD_PARTY_LINUX )
|
||||
|
||||
# Darwin
|
||||
set(INCLUDE_THIRD_PARTY_DARWIN )
|
||||
|
||||
# MCU
|
||||
# STM32F3
|
||||
set(INCLUDE_THIRD_PARTY_MCU_STM32F3
|
||||
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Include
|
||||
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Include)
|
||||
# STM32F4
|
||||
set(INCLUDE_THIRD_PARTY_MCU_STM32F4
|
||||
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Include
|
||||
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/Include)
|
||||
|
||||
# Sources
|
||||
file(GLOB SOURCE_LIBC *.c)
|
||||
|
||||
# Platform-specific
|
||||
# Linux
|
||||
file(GLOB SOURCE_LIBC_LINUX target/posix/*.c target/posix/*.S)
|
||||
|
||||
# Darwin
|
||||
file(GLOB SOURCE_LIBC_DARWIN target/posix/*.c target/posix/*.S)
|
||||
|
||||
# MCU
|
||||
# stm32f3
|
||||
file(GLOB SOURCE_LIBC_MCU_STM32F3 target/mcu-stubs/*.c target/mcu-stubs/*.S)
|
||||
# stm32f4
|
||||
file(GLOB SOURCE_LIBC_MCU_STM32F4 target/mcu-stubs/*.c target/mcu-stubs/*.S)
|
||||
|
||||
# Third-party
|
||||
# Platform-specific
|
||||
# MCU
|
||||
# stm32f3
|
||||
set(SOURCE_THIRD_PARTY_MCU_STM32F3
|
||||
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Source/Templates/system_stm32f30x.c
|
||||
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Source/Templates/gcc_ride7/startup_stm32f30x.s)
|
||||
# stm32f4
|
||||
set(SOURCE_THIRD_PARTY_MCU_STM32F4
|
||||
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c
|
||||
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f4xx.s)
|
||||
set(JERRY_LIBC_NAME jerry-libc)
|
||||
project (${JERRY_LIBC_NAME} C ASM)
|
||||
|
||||
# Architecture-specific configuration
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
|
||||
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_X86_64})
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l-hf")
|
||||
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_ARMV7_HF})
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l-el")
|
||||
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_ARMV7_EL})
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
|
||||
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_X86})
|
||||
else()
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
|
||||
set(DEFINES_LIBC ${DEFINES_LIBC} __TARGET_HOST_x64)
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l-hf")
|
||||
set(DEFINES_LIBC ${DEFINES_LIBC} __TARGET_HOST_ARMv7 __TARGET_HOST_ARMv7_HARD_FLOAT)
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l-el")
|
||||
set(DEFINES_LIBC ${DEFINES_LIBC} __TARGET_HOST_ARMv7 __TARGET_HOST_ARMv7_SOFT_FLOAT)
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
|
||||
set(DEFINES_LIBC ${DEFINES_LIBC} __TARGET_HOST_x86)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported machine architecture")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Platform-specific configuration
|
||||
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_${PLATFORM}})
|
||||
# Include directories
|
||||
set(INCLUDE_LIBC "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
# Targets declaration
|
||||
add_custom_target (jerry-libc-all)
|
||||
# Sources
|
||||
file(GLOB SOURCE_LIBC *.c)
|
||||
|
||||
string(TOLOWER ${PLATFORM_EXT} PLATFORM_L)
|
||||
set(TARGET_NAME jerry-libc.${PLATFORM_L})
|
||||
# Platform-specific
|
||||
# Linux
|
||||
if(DEFINED PLATFORM AND ((PLATFORM STREQUAL "LINUX") OR (PLATFORM STREQUAL "DARWIN")))
|
||||
file(GLOB TARGET_SPECIFIC_LIBC_SOURCE target/posix/*.c target/posix/*.S)
|
||||
set(INCLUDE_LIBC ${INCLUDE_LIBC} __TARGET_HOST)
|
||||
set(DEFINES_LIBC ${DEFINES_LIBC} __TARGET_HOST)
|
||||
endif()
|
||||
|
||||
function(declare_targets_for_build_mode BUILD_MODE)
|
||||
set(TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}.${TARGET_NAME})
|
||||
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_${BUILD_MODE}})
|
||||
set(INCLUDE_LIBC ${INCLUDE_LIBC} ${INCLUDE_LIBC_${PLATFORM_EXT}})
|
||||
add_library(${JERRY_LIBC_NAME} STATIC ${SOURCE_LIBC} ${TARGET_SPECIFIC_LIBC_SOURCE})
|
||||
|
||||
# Jerry
|
||||
add_library(${TARGET_NAME}.lib STATIC ${SOURCE_LIBC} ${SOURCE_LIBC_${PLATFORM_EXT}})
|
||||
set_property(TARGET ${TARGET_NAME}.lib
|
||||
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_LIBC} ${FLAGS_COMMON_${BUILD_MODE}}")
|
||||
target_compile_definitions(${TARGET_NAME}.lib PRIVATE ${DEFINES_LIBC})
|
||||
target_include_directories(${TARGET_NAME}.lib PRIVATE ${INCLUDE_LIBC})
|
||||
target_include_directories(${TARGET_NAME}.lib SYSTEM PRIVATE ${INCLUDE_LIBC_INTERFACE})
|
||||
add_dependencies(jerry-libc-all ${TARGET_NAME}.lib)
|
||||
|
||||
# Third-party MCU library
|
||||
if(DEFINED SOURCE_THIRD_PARTY_${PLATFORM_EXT})
|
||||
add_library(${TARGET_NAME}${SUFFIX_THIRD_PARTY_LIB} STATIC ${SOURCE_THIRD_PARTY_${PLATFORM_EXT}})
|
||||
set_property(TARGET ${TARGET_NAME}${SUFFIX_THIRD_PARTY_LIB}
|
||||
PROPERTY COMPILE_FLAGS "${FLAGS_COMMON_${BUILD_MODE}}")
|
||||
target_include_directories(${TARGET_NAME}${SUFFIX_THIRD_PARTY_LIB} PRIVATE ${INCLUDE_THIRD_PARTY_${PLATFORM_EXT}})
|
||||
target_include_directories(${TARGET_NAME}${SUFFIX_THIRD_PARTY_LIB} SYSTEM PRIVATE ${INCLUDE_LIBC_INTERFACE})
|
||||
target_link_libraries(${TARGET_NAME}.lib ${TARGET_NAME}${SUFFIX_THIRD_PARTY_LIB})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
declare_targets_for_build_mode(DEBUG)
|
||||
declare_targets_for_build_mode(RELEASE)
|
||||
declare_targets_for_build_mode(UNITTESTS)
|
||||
target_compile_definitions(${JERRY_LIBC_NAME} PRIVATE ${DEFINES_LIBC})
|
||||
target_include_directories(${JERRY_LIBC_NAME} PRIVATE ${INCLUDE_LIBC})
|
||||
target_include_directories(${JERRY_LIBC_NAME} SYSTEM PUBLIC "${CMAKE_SOURCE_DIR}/jerry-libc/include")
|
||||
|
||||
@ -1,69 +0,0 @@
|
||||
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Jerry libc platform-specific functions stm32f4 implementation
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "jerry-libc-defs.h"
|
||||
|
||||
/** exit - cause normal process termination */
|
||||
void __attr_noreturn___ __attr_used___
|
||||
exit (int status __attr_unused___)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
}
|
||||
} /* exit */
|
||||
|
||||
/** abort - cause abnormal process termination */
|
||||
void __attr_noreturn___ __attr_used___
|
||||
abort (void)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
}
|
||||
} /* abort */
|
||||
|
||||
/**
|
||||
* fwrite
|
||||
*
|
||||
* @return number of bytes written
|
||||
*/
|
||||
size_t
|
||||
fwrite (const void *ptr __attr_unused___, /**< data to write */
|
||||
size_t size, /**< size of elements to write */
|
||||
size_t nmemb, /**< number of elements */
|
||||
FILE *stream __attr_unused___) /**< stream pointer */
|
||||
{
|
||||
return size * nmemb;
|
||||
} /* fwrite */
|
||||
|
||||
/**
|
||||
* This function can get the time as well as a timezone.
|
||||
*
|
||||
* @return 0 if success, -1 otherwise
|
||||
*/
|
||||
int
|
||||
gettimeofday (void *tp __attr_unused___, /**< struct timeval */
|
||||
void *tzp __attr_unused___) /**< struct timezone */
|
||||
{
|
||||
return -1;
|
||||
} /* gettimeofday */
|
||||
@ -14,51 +14,26 @@
|
||||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required (VERSION 2.8.12)
|
||||
project (Jerry_LibM C)
|
||||
set(JERRY_LIBM_NAME jerry-libm)
|
||||
project (${JERRY_LIBM_NAME} C)
|
||||
|
||||
# Compiler / linker flags
|
||||
# TODO: Reduce the below list of warning/error disablings as much as possible
|
||||
set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_JERRY} ${C_FLAGS_JERRY}")
|
||||
set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-error=sign-compare")
|
||||
set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-error=sign-conversion")
|
||||
set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-sign-conversion")
|
||||
set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-sign-compare")
|
||||
set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-strict-aliasing")
|
||||
|
||||
# Include directories
|
||||
set(INCLUDE_LIBM ${CMAKE_SOURCE_DIR}/jerry-libm/include)
|
||||
set(INCLUDE_LIBM ${INCLUDE_LIBM} PARENT_SCOPE)
|
||||
set(INCLUDE_LIBM "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
|
||||
# Source directories
|
||||
file(GLOB SOURCE_LIBM *.c)
|
||||
|
||||
add_custom_target (jerry-libm-all)
|
||||
add_library(${JERRY_LIBM_NAME} STATIC ${SOURCE_LIBM})
|
||||
set_property(TARGET ${JERRY_LIBM_NAME}
|
||||
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_LIBM}")
|
||||
|
||||
# Targets declaration
|
||||
function(declare_targets_for_build_mode BUILD_MODE)
|
||||
set(TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}})
|
||||
|
||||
function(declare_target_with_modifiers ) # modifiers are passed in ARGN implicit argument
|
||||
foreach(MODIFIER ${ARGN})
|
||||
set(TARGET_NAME ${TARGET_NAME}${MODIFIER_SUFFIX_${MODIFIER}})
|
||||
endforeach()
|
||||
|
||||
add_library(${TARGET_NAME}.jerry-libm.lib STATIC ${SOURCE_LIBM})
|
||||
set_property(TARGET ${TARGET_NAME}.jerry-libm.lib
|
||||
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_LIBM}")
|
||||
target_include_directories(${TARGET_NAME}.jerry-libm.lib PRIVATE ${INCLUDE_LIBM})
|
||||
|
||||
if("${BUILD_MODE}" STREQUAL "UNITTESTS")
|
||||
target_include_directories(${TARGET_NAME}.jerry-libm.lib INTERFACE ${INCLUDE_LIBM})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
foreach(MODIFIERS_LIST ${MODIFIERS_LISTS})
|
||||
separate_arguments(MODIFIERS_LIST)
|
||||
|
||||
declare_target_with_modifiers(${MODIFIERS_LIST})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
declare_targets_for_build_mode(DEBUG)
|
||||
declare_targets_for_build_mode(RELEASE)
|
||||
declare_targets_for_build_mode(UNITTESTS)
|
||||
target_include_directories(${JERRY_LIBM_NAME} PRIVATE ${INCLUDE_LIBM})
|
||||
target_include_directories(${JERRY_LIBM_NAME} INTERFACE ${INCLUDE_LIBM})
|
||||
|
||||
58
jerry-main/CMakeLists.txt
Normal file
58
jerry-main/CMakeLists.txt
Normal file
@ -0,0 +1,58 @@
|
||||
# Copyright 2016 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2016 University of Szeged.
|
||||
#
|
||||
# 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.
|
||||
|
||||
cmake_minimum_required (VERSION 2.8.12)
|
||||
set(JERRY_NAME jerry)
|
||||
project (${JERRY_NAME} C)
|
||||
|
||||
# Sources
|
||||
# Jerry standalone
|
||||
set(SOURCE_JERRY_STANDALONE_MAIN main-unix.c)
|
||||
|
||||
# Generage map file
|
||||
if("${PLATFORM}" STREQUAL "DARWIN")
|
||||
set(MAP_FILE_FLAGS "-Xlinker -map")
|
||||
else()
|
||||
set(MAP_FILE_FLAGS "-Xlinker -Map")
|
||||
endif()
|
||||
|
||||
set(MAP_FILE_FLAGS "${MAP_FILE_FLAGS} -Xlinker jerry.map")
|
||||
set(LINKER_FLAGS_COMMON "${LINKER_FLAGS_COMMON} ${MAP_FILE_FLAGS}")
|
||||
|
||||
# Disable static build
|
||||
if(NOT ("${PLATFORM}" STREQUAL "DARWIN"))
|
||||
set(LINKER_FLAGS_STATIC "-static")
|
||||
endif()
|
||||
|
||||
add_executable(${JERRY_NAME} ${SOURCE_JERRY_STANDALONE_MAIN})
|
||||
set_property(TARGET ${JERRY_NAME}
|
||||
PROPERTY LINK_FLAGS "${LINKER_FLAGS_STATIC} ${LINKER_FLAGS_COMMON}")
|
||||
target_compile_definitions(${JERRY_NAME} PRIVATE ${DEFINES_JERRY})
|
||||
target_include_directories(${JERRY_NAME} PRIVATE ${PORT_DIR})
|
||||
link_directories(${CMAKE_BINARY_DIR})
|
||||
|
||||
set(JERRY_LIBS jerry-core)
|
||||
|
||||
if(JERRY_LIBM)
|
||||
set(JERRY_LIBS ${JERRY_LIBS} jerry-libm)
|
||||
endif()
|
||||
|
||||
if(JERRY_LIBC)
|
||||
set(JERRY_LIBS ${JERRY_LIBS} jerry-libc)
|
||||
endif()
|
||||
|
||||
set(JERRY_LIBS ${JERRY_LIBS} ${IMPORTED_LIB})
|
||||
|
||||
target_link_libraries(${JERRY_NAME} ${JERRY_LIBS})
|
||||
38
main-mcu.c
38
main-mcu.c
@ -1,38 +0,0 @@
|
||||
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged.
|
||||
*
|
||||
* 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 "jerry-api.h"
|
||||
|
||||
/**
|
||||
* Standalone Jerry exit codes
|
||||
*/
|
||||
#define JERRY_STANDALONE_EXIT_CODE_OK (0)
|
||||
#define JERRY_STANDALONE_EXIT_CODE_FAIL (1)
|
||||
|
||||
#include JERRY_MCU_SCRIPT_HEADER
|
||||
|
||||
static const char generated_source[] = JERRY_MCU_SCRIPT;
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
const char *source_p = generated_source;
|
||||
const size_t source_size = sizeof (generated_source);
|
||||
|
||||
bool ret_code = jerry_run_simple ((jerry_char_t *) source_p, source_size, JERRY_INIT_EMPTY);
|
||||
|
||||
return (ret_code ? JERRY_STANDALONE_EXIT_CODE_OK : JERRY_STANDALONE_EXIT_CODE_FAIL);
|
||||
} /* main */
|
||||
54
tests/unit/CMakeLists.txt
Normal file
54
tests/unit/CMakeLists.txt
Normal file
@ -0,0 +1,54 @@
|
||||
# Copyright 2016 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2016 University of Szeged.
|
||||
#
|
||||
# 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.
|
||||
|
||||
cmake_minimum_required (VERSION 2.8.12)
|
||||
project (Unittest C)
|
||||
|
||||
if(NOT FEATURE_PROFILE STREQUAL "full")
|
||||
message(FATAL_ERROR "FEATURE_PROFILE='${FEATURE_PROFILE}' doesn't supported with UNITTESTS=ON option")
|
||||
endif()
|
||||
|
||||
# Unit tests main modules
|
||||
file(GLOB SOURCE_UNIT_TEST_MAIN_MODULES *.c)
|
||||
|
||||
# Unit tests declaration
|
||||
add_custom_target(unittests)
|
||||
|
||||
foreach(SOURCE_UNIT_TEST_MAIN ${SOURCE_UNIT_TEST_MAIN_MODULES})
|
||||
get_filename_component(TARGET_NAME ${SOURCE_UNIT_TEST_MAIN} NAME_WE)
|
||||
set(TARGET_NAME unit-${TARGET_NAME})
|
||||
|
||||
add_executable(${TARGET_NAME} ${SOURCE_UNIT_TEST_MAIN})
|
||||
set_property(TARGET ${TARGET_NAME}
|
||||
PROPERTY LINK_FLAGS "${LINKER_FLAGS_COMMON}")
|
||||
|
||||
link_directories(${CMAKE_BINARY_DIR})
|
||||
|
||||
set(JERRY_LIBS jerry-core)
|
||||
|
||||
if(JERRY_LIBM)
|
||||
set(JERRY_LIBS ${JERRY_LIBS} jerry-libm)
|
||||
endif()
|
||||
|
||||
if(JERRY_LIBC)
|
||||
set(JERRY_LIBS ${JERRY_LIBS} jerry-libc)
|
||||
endif()
|
||||
|
||||
set(JERRY_LIBS ${JERRY_LIBS} ${IMPORTED_LIB})
|
||||
|
||||
target_link_libraries(${TARGET_NAME} ${JERRY_LIBS})
|
||||
|
||||
add_dependencies(unittests ${TARGET_NAME})
|
||||
endforeach()
|
||||
@ -73,7 +73,7 @@ handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
|
||||
printf ("ok %d %d %p %d\n", func_obj_val, this_val, args_p, args_cnt);
|
||||
|
||||
JERRY_ASSERT (args_cnt == 2);
|
||||
TEST_ASSERT (args_cnt == 2);
|
||||
|
||||
JERRY_ASSERT (jerry_value_is_string (args_p[0]));
|
||||
sz = jerry_get_string_size (args_p[0]);
|
||||
@ -81,10 +81,10 @@ handler (const jerry_value_t func_obj_val, /**< function object */
|
||||
sz = jerry_string_to_char_buffer (args_p[0],
|
||||
(jerry_char_t *) buffer,
|
||||
sz);
|
||||
JERRY_ASSERT (sz == 1);
|
||||
JERRY_ASSERT (!strncmp (buffer, "1", (size_t) sz));
|
||||
TEST_ASSERT (sz == 1);
|
||||
TEST_ASSERT (!strncmp (buffer, "1", (size_t) sz));
|
||||
|
||||
JERRY_ASSERT (jerry_value_is_boolean (args_p[1]));
|
||||
TEST_ASSERT (jerry_value_is_boolean (args_p[1]));
|
||||
|
||||
return jerry_create_string ((jerry_char_t *) "string from handler");
|
||||
} /* handler */
|
||||
@ -103,7 +103,7 @@ handler_throw_test (const jerry_value_t func_obj_val, /**< function object */
|
||||
static void
|
||||
handler_construct_freecb (uintptr_t native_p)
|
||||
{
|
||||
JERRY_ASSERT (native_p == (uintptr_t) 0x0012345678abcdefull);
|
||||
TEST_ASSERT (native_p == (uintptr_t) 0x0012345678abcdefull);
|
||||
printf ("ok object free callback\n");
|
||||
|
||||
test_api_is_free_callback_was_called = true;
|
||||
@ -117,11 +117,11 @@ handler_construct (const jerry_value_t func_obj_val, /**< function object */
|
||||
{
|
||||
printf ("ok construct %d %d %p %d\n", func_obj_val, this_val, args_p, args_cnt);
|
||||
|
||||
JERRY_ASSERT (jerry_value_is_object (this_val));
|
||||
TEST_ASSERT (jerry_value_is_object (this_val));
|
||||
|
||||
JERRY_ASSERT (args_cnt == 1);
|
||||
JERRY_ASSERT (jerry_value_is_boolean (args_p[0]));
|
||||
JERRY_ASSERT (jerry_get_boolean_value (args_p[0]) == true);
|
||||
TEST_ASSERT (args_cnt == 1);
|
||||
TEST_ASSERT (jerry_value_is_boolean (args_p[0]));
|
||||
TEST_ASSERT (jerry_get_boolean_value (args_p[0]) == true);
|
||||
|
||||
jerry_value_t field_name = jerry_create_string ((jerry_char_t *) "value_field");
|
||||
jerry_set_property (this_val, field_name, args_p[0]);
|
||||
@ -131,7 +131,7 @@ handler_construct (const jerry_value_t func_obj_val, /**< function object */
|
||||
(uintptr_t) 0x0000000000000000ull,
|
||||
handler_construct_freecb);
|
||||
|
||||
uintptr_t ptr;
|
||||
uintptr_t ptr = (uintptr_t) NULL;
|
||||
bool is_ok = jerry_get_object_native_handle (this_val, &ptr);
|
||||
JERRY_ASSERT (is_ok && ptr == (uintptr_t) 0x0000000000000000ull);
|
||||
|
||||
@ -226,6 +226,8 @@ foreach (const jerry_value_t name, /**< field name */
|
||||
|
||||
JERRY_ASSERT (false);
|
||||
return false;
|
||||
|
||||
|
||||
} /* foreach */
|
||||
|
||||
static bool
|
||||
@ -241,7 +243,7 @@ foreach_exception (const jerry_value_t name, /**< field name */
|
||||
|
||||
if (!strncmp (str_buf_p, "foxtrot", (size_t) sz))
|
||||
{
|
||||
JERRY_ASSERT (false);
|
||||
TEST_ASSERT (false);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -389,7 +391,7 @@ main (void)
|
||||
sz = jerry_string_to_char_buffer (res, (jerry_char_t *) buffer, sz);
|
||||
JERRY_ASSERT (sz == 4);
|
||||
jerry_release_value (res);
|
||||
JERRY_ASSERT (!strncmp (buffer, "abcd", (size_t) sz));
|
||||
TEST_ASSERT (!strncmp (buffer, "abcd", (size_t) sz));
|
||||
jerry_release_value (args[0]);
|
||||
jerry_release_value (args[1]);
|
||||
|
||||
@ -482,7 +484,7 @@ main (void)
|
||||
sz = jerry_string_to_char_buffer (res, (jerry_char_t *) buffer, sz);
|
||||
JERRY_ASSERT (sz == 19);
|
||||
jerry_release_value (res);
|
||||
JERRY_ASSERT (!strncmp (buffer, "string from handler", (size_t) sz));
|
||||
TEST_ASSERT (!strncmp (buffer, "string from handler", (size_t) sz));
|
||||
|
||||
// Create native handler bound function object and set it to 'external_construct' variable
|
||||
external_construct_val = jerry_create_external_function (handler_construct);
|
||||
@ -508,7 +510,7 @@ main (void)
|
||||
jerry_release_value (val_value_field);
|
||||
jerry_release_value (external_construct_val);
|
||||
|
||||
uintptr_t ptr;
|
||||
uintptr_t ptr = (uintptr_t) NULL;
|
||||
is_ok = jerry_get_object_native_handle (res, &ptr);
|
||||
JERRY_ASSERT (is_ok
|
||||
&& ptr == (uintptr_t) 0x0012345678abcdefull);
|
||||
@ -545,7 +547,7 @@ main (void)
|
||||
jerry_release_value (val_t);
|
||||
|
||||
// 'res' should contain exception object
|
||||
JERRY_ASSERT (jerry_value_is_object (res));
|
||||
TEST_ASSERT (jerry_value_is_object (res));
|
||||
jerry_release_value (res);
|
||||
|
||||
// Test: Call of non-function
|
||||
@ -554,7 +556,7 @@ main (void)
|
||||
JERRY_ASSERT (jerry_value_has_error_flag (res));
|
||||
|
||||
// 'res' should contain exception object
|
||||
JERRY_ASSERT (jerry_value_is_object (res));
|
||||
TEST_ASSERT (jerry_value_is_object (res));
|
||||
jerry_release_value (res);
|
||||
|
||||
jerry_release_value (obj_val);
|
||||
@ -569,7 +571,7 @@ main (void)
|
||||
jerry_release_value (val_t);
|
||||
|
||||
// 'res' should contain exception object
|
||||
JERRY_ASSERT (jerry_value_is_object (res));
|
||||
TEST_ASSERT (jerry_value_is_object (res));
|
||||
jerry_release_value (res);
|
||||
|
||||
// Test: Call of non-function as constructor
|
||||
@ -578,7 +580,7 @@ main (void)
|
||||
JERRY_ASSERT (jerry_value_has_error_flag (res));
|
||||
|
||||
// 'res' should contain exception object
|
||||
JERRY_ASSERT (jerry_value_is_object (res));
|
||||
TEST_ASSERT (jerry_value_is_object (res));
|
||||
jerry_release_value (res);
|
||||
|
||||
jerry_release_value (obj_val);
|
||||
@ -592,7 +594,7 @@ main (void)
|
||||
jerry_set_property_by_index (array_obj_val, 5, v_in);
|
||||
jerry_value_t v_out = jerry_get_property_by_index (array_obj_val, 5);
|
||||
|
||||
JERRY_ASSERT (jerry_value_is_number (v_out)
|
||||
TEST_ASSERT (jerry_value_is_number (v_out)
|
||||
&& jerry_get_number_value (v_out) == 10.5);
|
||||
|
||||
jerry_release_value (v_in);
|
||||
@ -703,7 +705,7 @@ main (void)
|
||||
|
||||
jerry_cleanup ();
|
||||
|
||||
JERRY_ASSERT (test_api_is_free_callback_was_called);
|
||||
TEST_ASSERT (test_api_is_free_callback_was_called);
|
||||
|
||||
// External Magic String
|
||||
jerry_init (JERRY_INIT_SHOW_OPCODES);
|
||||
@ -739,7 +741,7 @@ main (void)
|
||||
false,
|
||||
global_mode_snapshot_buffer,
|
||||
sizeof (global_mode_snapshot_buffer));
|
||||
JERRY_ASSERT (global_mode_snapshot_size != 0);
|
||||
TEST_ASSERT (global_mode_snapshot_size != 0);
|
||||
jerry_cleanup ();
|
||||
|
||||
jerry_init (JERRY_INIT_SHOW_OPCODES);
|
||||
@ -749,7 +751,7 @@ main (void)
|
||||
false,
|
||||
eval_mode_snapshot_buffer,
|
||||
sizeof (eval_mode_snapshot_buffer));
|
||||
JERRY_ASSERT (eval_mode_snapshot_size != 0);
|
||||
TEST_ASSERT (eval_mode_snapshot_size != 0);
|
||||
jerry_cleanup ();
|
||||
|
||||
jerry_init (JERRY_INIT_SHOW_OPCODES);
|
||||
@ -778,7 +780,7 @@ main (void)
|
||||
sz = jerry_string_to_char_buffer (res, (jerry_char_t *) buffer, sz);
|
||||
JERRY_ASSERT (sz == 20);
|
||||
jerry_release_value (res);
|
||||
JERRY_ASSERT (!strncmp (buffer, "string from snapshot", (size_t) sz));
|
||||
TEST_ASSERT (!strncmp (buffer, "string from snapshot", (size_t) sz));
|
||||
|
||||
jerry_cleanup ();
|
||||
}
|
||||
|
||||
@ -25,12 +25,8 @@
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* Verify that unit tests are built with enabled debug check
|
||||
*/
|
||||
#ifdef JERRY_NDEBUG
|
||||
# error "defined (JERRY_NDEBUG) in a unit test"
|
||||
#endif /* JERRY_NDEBUG */
|
||||
#define TEST_ASSERT(x) do { if (__builtin_expect (!(x), 0)) { \
|
||||
jerry_assert_fail (#x, __FILE__, __func__, __LINE__); } } while (0)
|
||||
|
||||
/**
|
||||
* Test initialization statement that should be included
|
||||
|
||||
@ -36,53 +36,53 @@ main ()
|
||||
{
|
||||
/* int ecma_date_day (time)*/
|
||||
|
||||
JERRY_ASSERT (ecma_date_day (0) == 0);
|
||||
JERRY_ASSERT (ecma_date_day (MS_PER_DAY) == 1);
|
||||
TEST_ASSERT (ecma_date_day (0) == 0);
|
||||
TEST_ASSERT (ecma_date_day (MS_PER_DAY) == 1);
|
||||
|
||||
/* ecma_number_t ecma_date_time_within_day (time) */
|
||||
|
||||
JERRY_ASSERT (ecma_date_time_within_day (0) == 0);
|
||||
JERRY_ASSERT (ecma_date_time_within_day (42) == 42);
|
||||
JERRY_ASSERT (ecma_date_time_within_day (42.51) == 42.51);
|
||||
JERRY_ASSERT (ecma_date_time_within_day (MS_PER_DAY + 42) == 42);
|
||||
TEST_ASSERT (ecma_date_time_within_day (0) == 0);
|
||||
TEST_ASSERT (ecma_date_time_within_day (42) == 42);
|
||||
TEST_ASSERT (ecma_date_time_within_day (42.51) == 42.51);
|
||||
TEST_ASSERT (ecma_date_time_within_day (MS_PER_DAY + 42) == 42);
|
||||
|
||||
/* int ecma_date_days_in_year (year) */
|
||||
|
||||
JERRY_ASSERT (ecma_date_days_in_year (0) == 366);
|
||||
JERRY_ASSERT (ecma_date_days_in_year (1600) == 366);
|
||||
JERRY_ASSERT (ecma_date_days_in_year (1603) == 365);
|
||||
JERRY_ASSERT (ecma_date_days_in_year (1900) == 365);
|
||||
JERRY_ASSERT (ecma_date_days_in_year (1970) == 365);
|
||||
JERRY_ASSERT (ecma_date_days_in_year (2000) == 366);
|
||||
JERRY_ASSERT (ecma_date_days_in_year (2000.45) == 366);
|
||||
JERRY_ASSERT (ecma_date_days_in_year (2012) == 366);
|
||||
JERRY_ASSERT (ecma_date_days_in_year (2015) == 365);
|
||||
JERRY_ASSERT (ecma_date_days_in_year (285616 + 1970) == 365);
|
||||
JERRY_ASSERT (ecma_date_days_in_year (-1970) == 365);
|
||||
TEST_ASSERT (ecma_date_days_in_year (0) == 366);
|
||||
TEST_ASSERT (ecma_date_days_in_year (1600) == 366);
|
||||
TEST_ASSERT (ecma_date_days_in_year (1603) == 365);
|
||||
TEST_ASSERT (ecma_date_days_in_year (1900) == 365);
|
||||
TEST_ASSERT (ecma_date_days_in_year (1970) == 365);
|
||||
TEST_ASSERT (ecma_date_days_in_year (2000) == 366);
|
||||
TEST_ASSERT (ecma_date_days_in_year (2000.45) == 366);
|
||||
TEST_ASSERT (ecma_date_days_in_year (2012) == 366);
|
||||
TEST_ASSERT (ecma_date_days_in_year (2015) == 365);
|
||||
TEST_ASSERT (ecma_date_days_in_year (285616 + 1970) == 365);
|
||||
TEST_ASSERT (ecma_date_days_in_year (-1970) == 365);
|
||||
|
||||
/* int ecma_date_day_from_year (year) */
|
||||
|
||||
JERRY_ASSERT (ecma_date_day_from_year (1969) == -365);
|
||||
JERRY_ASSERT (ecma_date_day_from_year (1970) == 0);
|
||||
JERRY_ASSERT (ecma_date_day_from_year (1971) == 365);
|
||||
JERRY_ASSERT (ecma_date_day_from_year (2000) == 10957);
|
||||
TEST_ASSERT (ecma_date_day_from_year (1969) == -365);
|
||||
TEST_ASSERT (ecma_date_day_from_year (1970) == 0);
|
||||
TEST_ASSERT (ecma_date_day_from_year (1971) == 365);
|
||||
TEST_ASSERT (ecma_date_day_from_year (2000) == 10957);
|
||||
|
||||
/* int ecma_date_year_from_time (time) */
|
||||
|
||||
JERRY_ASSERT (ecma_date_year_from_time (0) == 1970);
|
||||
JERRY_ASSERT (ecma_date_year_from_time (0) == 1970);
|
||||
JERRY_ASSERT (ecma_date_year_from_time (MS_PER_DAY) == 1970);
|
||||
JERRY_ASSERT (ecma_date_year_from_time ((MS_PER_DAY) * (ecma_number_t) 365 - 1) == 1970);
|
||||
JERRY_ASSERT (ecma_date_year_from_time (MS_PER_DAY * (ecma_number_t) 365) == 1971);
|
||||
JERRY_ASSERT (ecma_date_year_from_time (MS_PER_DAY * (ecma_number_t) (365 * (2015 - 1970)))
|
||||
TEST_ASSERT (ecma_date_year_from_time (0) == 1970);
|
||||
TEST_ASSERT (ecma_date_year_from_time (0) == 1970);
|
||||
TEST_ASSERT (ecma_date_year_from_time (MS_PER_DAY) == 1970);
|
||||
TEST_ASSERT (ecma_date_year_from_time ((MS_PER_DAY) * (ecma_number_t) 365 - 1) == 1970);
|
||||
TEST_ASSERT (ecma_date_year_from_time (MS_PER_DAY * (ecma_number_t) 365) == 1971);
|
||||
TEST_ASSERT (ecma_date_year_from_time (MS_PER_DAY * (ecma_number_t) (365 * (2015 - 1970)))
|
||||
== 2014);
|
||||
JERRY_ASSERT (ecma_date_year_from_time (MS_PER_DAY * (ecma_number_t) (365.25 * (2015 - 1970)))
|
||||
TEST_ASSERT (ecma_date_year_from_time (MS_PER_DAY * (ecma_number_t) (365.25 * (2015 - 1970)))
|
||||
== 2015);
|
||||
JERRY_ASSERT (ecma_date_year_from_time (-MS_PER_YEAR) == 1969);
|
||||
JERRY_ASSERT (ecma_date_year_from_time (-1970 * MS_PER_YEAR) == 1);
|
||||
JERRY_ASSERT (ecma_date_year_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
|
||||
JERRY_ASSERT (ecma_date_year_from_time (START_OF_GREGORIAN_CALENDAR - 1) == -1);
|
||||
JERRY_ASSERT (ecma_date_year_from_time (START_OF_GREGORIAN_CALENDAR - 3 * MS_PER_YEAR) == -3);
|
||||
TEST_ASSERT (ecma_date_year_from_time (-MS_PER_YEAR) == 1969);
|
||||
TEST_ASSERT (ecma_date_year_from_time (-1970 * MS_PER_YEAR) == 1);
|
||||
TEST_ASSERT (ecma_date_year_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
|
||||
TEST_ASSERT (ecma_date_year_from_time (START_OF_GREGORIAN_CALENDAR - 1) == -1);
|
||||
TEST_ASSERT (ecma_date_year_from_time (START_OF_GREGORIAN_CALENDAR - 3 * MS_PER_YEAR) == -3);
|
||||
|
||||
/* int ecma_date_day_within_year (time) */
|
||||
|
||||
@ -90,17 +90,17 @@ main ()
|
||||
|
||||
/* int ecma_date_month_from_time (time) */
|
||||
|
||||
JERRY_ASSERT (ecma_date_month_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
|
||||
JERRY_ASSERT (ecma_date_month_from_time (0) == 0);
|
||||
JERRY_ASSERT (ecma_date_month_from_time (-MS_PER_DAY) == 11);
|
||||
JERRY_ASSERT (ecma_date_month_from_time (31 * MS_PER_DAY) == 1);
|
||||
TEST_ASSERT (ecma_date_month_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
|
||||
TEST_ASSERT (ecma_date_month_from_time (0) == 0);
|
||||
TEST_ASSERT (ecma_date_month_from_time (-MS_PER_DAY) == 11);
|
||||
TEST_ASSERT (ecma_date_month_from_time (31 * MS_PER_DAY) == 1);
|
||||
|
||||
/* int ecma_date_date_from_time (time) */
|
||||
|
||||
JERRY_ASSERT (ecma_date_date_from_time (START_OF_GREGORIAN_CALENDAR) == 1);
|
||||
JERRY_ASSERT (ecma_date_date_from_time (0) == 1);
|
||||
JERRY_ASSERT (ecma_date_date_from_time (-MS_PER_DAY) == 31);
|
||||
JERRY_ASSERT (ecma_date_date_from_time (31 * MS_PER_DAY) == 1);
|
||||
TEST_ASSERT (ecma_date_date_from_time (START_OF_GREGORIAN_CALENDAR) == 1);
|
||||
TEST_ASSERT (ecma_date_date_from_time (0) == 1);
|
||||
TEST_ASSERT (ecma_date_date_from_time (-MS_PER_DAY) == 31);
|
||||
TEST_ASSERT (ecma_date_date_from_time (31 * MS_PER_DAY) == 1);
|
||||
|
||||
/* int ecma_date_week_day (ecma_number_t time) */
|
||||
|
||||
@ -124,31 +124,31 @@ main ()
|
||||
|
||||
/* ecma_number_t ecma_date_hour_from_time (time) */
|
||||
|
||||
JERRY_ASSERT (ecma_date_hour_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
|
||||
JERRY_ASSERT (ecma_date_hour_from_time (0) == 0);
|
||||
JERRY_ASSERT (ecma_date_hour_from_time (-MS_PER_DAY) == 0);
|
||||
JERRY_ASSERT (ecma_date_hour_from_time (-1) == 23);
|
||||
TEST_ASSERT (ecma_date_hour_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
|
||||
TEST_ASSERT (ecma_date_hour_from_time (0) == 0);
|
||||
TEST_ASSERT (ecma_date_hour_from_time (-MS_PER_DAY) == 0);
|
||||
TEST_ASSERT (ecma_date_hour_from_time (-1) == 23);
|
||||
|
||||
/* ecma_number_t ecma_date_min_from_time (time) */
|
||||
|
||||
JERRY_ASSERT (ecma_date_min_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
|
||||
JERRY_ASSERT (ecma_date_min_from_time (0) == 0);
|
||||
JERRY_ASSERT (ecma_date_min_from_time (-MS_PER_DAY) == 0);
|
||||
JERRY_ASSERT (ecma_date_min_from_time (-1) == 59);
|
||||
TEST_ASSERT (ecma_date_min_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
|
||||
TEST_ASSERT (ecma_date_min_from_time (0) == 0);
|
||||
TEST_ASSERT (ecma_date_min_from_time (-MS_PER_DAY) == 0);
|
||||
TEST_ASSERT (ecma_date_min_from_time (-1) == 59);
|
||||
|
||||
/* ecma_number_t ecma_date_sec_from_time (time) */
|
||||
|
||||
JERRY_ASSERT (ecma_date_sec_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
|
||||
JERRY_ASSERT (ecma_date_sec_from_time (0) == 0);
|
||||
JERRY_ASSERT (ecma_date_sec_from_time (-MS_PER_DAY) == 0);
|
||||
JERRY_ASSERT (ecma_date_sec_from_time (-1) == 59);
|
||||
TEST_ASSERT (ecma_date_sec_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
|
||||
TEST_ASSERT (ecma_date_sec_from_time (0) == 0);
|
||||
TEST_ASSERT (ecma_date_sec_from_time (-MS_PER_DAY) == 0);
|
||||
TEST_ASSERT (ecma_date_sec_from_time (-1) == 59);
|
||||
|
||||
/* ecma_number_t ecma_date_ms_from_time (time) */
|
||||
|
||||
JERRY_ASSERT (ecma_date_ms_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
|
||||
JERRY_ASSERT (ecma_date_ms_from_time (0) == 0);
|
||||
JERRY_ASSERT (ecma_date_ms_from_time (-MS_PER_DAY) == 0);
|
||||
JERRY_ASSERT (ecma_date_ms_from_time (-1) == 999);
|
||||
TEST_ASSERT (ecma_date_ms_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
|
||||
TEST_ASSERT (ecma_date_ms_from_time (0) == 0);
|
||||
TEST_ASSERT (ecma_date_ms_from_time (-MS_PER_DAY) == 0);
|
||||
TEST_ASSERT (ecma_date_ms_from_time (-1) == 999);
|
||||
|
||||
/* ecma_number_t ecma_date_make_time (hour, min, sec, ms) */
|
||||
|
||||
@ -156,12 +156,12 @@ main ()
|
||||
|
||||
/* ecma_number_t ecma_date_make_day (year, month, date) */
|
||||
|
||||
JERRY_ASSERT (ecma_date_make_day (1970, 0, 1) == 0);
|
||||
JERRY_ASSERT (ecma_date_make_day (1970, -1, 1) == -31);
|
||||
JERRY_ASSERT (ecma_date_make_day (1970, 0, 2.5) == 1);
|
||||
JERRY_ASSERT (ecma_date_make_day (1970, 1, 35) == 65);
|
||||
JERRY_ASSERT (ecma_date_make_day (1970, 13, 35) == 430);
|
||||
JERRY_ASSERT (ecma_date_make_day (2016, 2, 1) == 16861);
|
||||
TEST_ASSERT (ecma_date_make_day (1970, 0, 1) == 0);
|
||||
TEST_ASSERT (ecma_date_make_day (1970, -1, 1) == -31);
|
||||
TEST_ASSERT (ecma_date_make_day (1970, 0, 2.5) == 1);
|
||||
TEST_ASSERT (ecma_date_make_day (1970, 1, 35) == 65);
|
||||
TEST_ASSERT (ecma_date_make_day (1970, 13, 35) == 430);
|
||||
TEST_ASSERT (ecma_date_make_day (2016, 2, 1) == 16861);
|
||||
|
||||
/* ecma_number_t ecma_date_make_date (day, time) */
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ test_heap_give_some_memory_back (jmem_free_unused_memory_severity_t severity)
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (severity == JMEM_FREE_UNUSED_MEMORY_SEVERITY_HIGH);
|
||||
TEST_ASSERT (severity == JMEM_FREE_UNUSED_MEMORY_SEVERITY_HIGH);
|
||||
|
||||
p = 1;
|
||||
}
|
||||
@ -58,7 +58,7 @@ test_heap_give_some_memory_back (jmem_free_unused_memory_severity_t severity)
|
||||
{
|
||||
for (size_t k = 0; k < sizes[i]; k++)
|
||||
{
|
||||
JERRY_ASSERT (ptrs[i][k] == 0);
|
||||
TEST_ASSERT (ptrs[i][k] == 0);
|
||||
}
|
||||
|
||||
jmem_heap_free_block_size_stored (ptrs[i]);
|
||||
@ -89,7 +89,7 @@ main ()
|
||||
ptrs[j] = (uint8_t *) jmem_heap_alloc_block_store_size (size);
|
||||
sizes[j] = size;
|
||||
|
||||
JERRY_ASSERT (sizes[j] == 0 || ptrs[j] != NULL);
|
||||
TEST_ASSERT (sizes[j] == 0 || ptrs[j] != NULL);
|
||||
memset (ptrs[j], 0, sizes[j]);
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ main ()
|
||||
{
|
||||
for (size_t k = 0; k < sizes[j]; k++)
|
||||
{
|
||||
JERRY_ASSERT (ptrs[j][k] == 0);
|
||||
TEST_ASSERT (ptrs[j][k] == 0);
|
||||
}
|
||||
|
||||
jmem_heap_free_block_size_stored (ptrs[j]);
|
||||
|
||||
@ -45,33 +45,33 @@ main ()
|
||||
|
||||
// test 1-byte-long unicode sequences
|
||||
length = lit_char_get_utf8_length (lexer_hex_to_character (0, _1_byte_long1 + 2, 4));
|
||||
JERRY_ASSERT (length == 1);
|
||||
TEST_ASSERT (length == 1);
|
||||
|
||||
length = lit_char_get_utf8_length (lexer_hex_to_character (0, _1_byte_long2 + 2, 4));
|
||||
JERRY_ASSERT (length == 1);
|
||||
TEST_ASSERT (length == 1);
|
||||
|
||||
length = lit_char_get_utf8_length (lexer_hex_to_character (0, _1_byte_long3 + 2, 4));
|
||||
JERRY_ASSERT (length == 1);
|
||||
TEST_ASSERT (length == 1);
|
||||
|
||||
// test 2-byte-long unicode sequences
|
||||
length = lit_char_get_utf8_length (lexer_hex_to_character (0, _2_byte_long1 + 2, 4));
|
||||
JERRY_ASSERT (length == 2);
|
||||
TEST_ASSERT (length == 2);
|
||||
|
||||
length = lit_char_get_utf8_length (lexer_hex_to_character (0, _2_byte_long2 + 2, 4));
|
||||
JERRY_ASSERT (length == 2);
|
||||
TEST_ASSERT (length == 2);
|
||||
|
||||
length = lit_char_get_utf8_length (lexer_hex_to_character (0, _2_byte_long3 + 2, 4));
|
||||
JERRY_ASSERT (length == 2);
|
||||
TEST_ASSERT (length == 2);
|
||||
|
||||
// test 3-byte-long unicode sequences
|
||||
length = lit_char_get_utf8_length (lexer_hex_to_character (0, _3_byte_long1 + 2, 4));
|
||||
JERRY_ASSERT (length != 2);
|
||||
TEST_ASSERT (length != 2);
|
||||
|
||||
length = lit_char_get_utf8_length (lexer_hex_to_character (0, _3_byte_long2 + 2, 4));
|
||||
JERRY_ASSERT (length == 3);
|
||||
TEST_ASSERT (length == 3);
|
||||
|
||||
length = lit_char_get_utf8_length (lexer_hex_to_character (0, _3_byte_long3 + 2, 4));
|
||||
JERRY_ASSERT (length == 3);
|
||||
TEST_ASSERT (length == 3);
|
||||
|
||||
ecma_finalize ();
|
||||
jmem_finalize (true);
|
||||
|
||||
@ -83,13 +83,13 @@ main ()
|
||||
ecma_find_or_create_literal_string (strings[j], lengths[j]);
|
||||
strings[j][lengths[j]] = '\0';
|
||||
ptrs[j] = strings[j];
|
||||
JERRY_ASSERT (ptrs[j]);
|
||||
TEST_ASSERT (ptrs[j]);
|
||||
}
|
||||
else if (type == 1)
|
||||
{
|
||||
lit_magic_string_id_t msi = (lit_magic_string_id_t) (rand () % LIT_MAGIC_STRING__COUNT);
|
||||
ptrs[j] = lit_get_magic_string_utf8 (msi);
|
||||
JERRY_ASSERT (ptrs[j]);
|
||||
TEST_ASSERT (ptrs[j]);
|
||||
lengths[j] = (lit_utf8_size_t) lit_zt_utf8_string_size (ptrs[j]);
|
||||
ecma_find_or_create_literal_string (ptrs[j], lengths[j]);
|
||||
}
|
||||
@ -112,21 +112,21 @@ main ()
|
||||
{
|
||||
lit1 = ecma_find_or_create_literal_string (ptrs[j], lengths[j]);
|
||||
lit2 = ecma_find_or_create_literal_string (ptrs[j], lengths[j]);
|
||||
JERRY_ASSERT (lit1 == lit2);
|
||||
TEST_ASSERT (lit1 == lit2);
|
||||
}
|
||||
else
|
||||
{
|
||||
lit1 = ecma_find_or_create_literal_number (numbers[j]);
|
||||
lit2 = ecma_find_or_create_literal_number (numbers[j]);
|
||||
JERRY_ASSERT (lit1 == lit2);
|
||||
TEST_ASSERT (lit1 == lit2);
|
||||
}
|
||||
JERRY_ASSERT (lit1);
|
||||
JERRY_ASSERT (lit2);
|
||||
JERRY_ASSERT (lit1 == lit2);
|
||||
TEST_ASSERT (lit1);
|
||||
TEST_ASSERT (lit2);
|
||||
TEST_ASSERT (lit1 == lit2);
|
||||
}
|
||||
|
||||
// Check empty string exists
|
||||
JERRY_ASSERT (ecma_find_or_create_literal_string (NULL, 0) != JMEM_CP_NULL);
|
||||
TEST_ASSERT (ecma_find_or_create_literal_string (NULL, 0) != JMEM_CP_NULL);
|
||||
}
|
||||
|
||||
ecma_finalize_lit_storage ();
|
||||
|
||||
@ -46,22 +46,22 @@ test_setjmp_longjmp (volatile int depth)
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (k == depth + 1);
|
||||
TEST_ASSERT (k == depth + 1);
|
||||
|
||||
JERRY_ASSERT (a == 1);
|
||||
JERRY_ASSERT (b == 2);
|
||||
JERRY_ASSERT (c == 3);
|
||||
TEST_ASSERT (a == 1);
|
||||
TEST_ASSERT (b == 2);
|
||||
TEST_ASSERT (c == 3);
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
JERRY_ASSERT (array[i] == i);
|
||||
TEST_ASSERT (array[i] == i);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int t = rand () % depth;
|
||||
JERRY_ASSERT (t >= 0 && t < depth);
|
||||
TEST_ASSERT (t >= 0 && t < depth);
|
||||
|
||||
longjmp (buffers[t], t + 1);
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ main ()
|
||||
i < sizeof (test_cases_uint32) / sizeof (test_cases_uint32[0]);
|
||||
i++)
|
||||
{
|
||||
JERRY_ASSERT (ecma_number_to_uint32 (test_cases_uint32[i].num) == test_cases_uint32[i].uint32_num);
|
||||
TEST_ASSERT (ecma_number_to_uint32 (test_cases_uint32[i].num) == test_cases_uint32[i].uint32_num);
|
||||
}
|
||||
|
||||
int32_test_case_t test_cases_int32[] =
|
||||
@ -101,7 +101,7 @@ main ()
|
||||
i < sizeof (test_cases_int32) / sizeof (test_cases_int32[0]);
|
||||
i++)
|
||||
{
|
||||
JERRY_ASSERT (ecma_number_to_int32 (test_cases_int32[i].num) == test_cases_int32[i].int32_num);
|
||||
TEST_ASSERT (ecma_number_to_int32 (test_cases_int32[i].num) == test_cases_int32[i].int32_num);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@ -71,7 +71,7 @@ main ()
|
||||
|
||||
if (ptrs[j] != NULL)
|
||||
{
|
||||
JERRY_ASSERT (!memcmp (data[j], ptrs[j], JMEM_POOL_CHUNK_SIZE));
|
||||
TEST_ASSERT (!memcmp (data[j], ptrs[j], JMEM_POOL_CHUNK_SIZE));
|
||||
|
||||
jmem_pools_free (ptrs[j]);
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ static lit_utf8_size_t
|
||||
generate_cesu8_char (utf8_char_size char_size,
|
||||
lit_utf8_byte_t *buf)
|
||||
{
|
||||
JERRY_ASSERT (char_size >= 0 && char_size <= LIT_CESU8_MAX_BYTES_IN_CODE_UNIT);
|
||||
TEST_ASSERT (char_size >= 0 && char_size <= LIT_CESU8_MAX_BYTES_IN_CODE_UNIT);
|
||||
lit_code_point_t code_point = (lit_code_point_t) rand ();
|
||||
|
||||
if (char_size == 1)
|
||||
@ -88,14 +88,14 @@ generate_cesu8_string (lit_utf8_byte_t *buf_p,
|
||||
|
||||
lit_utf8_size_t bytes_generated = generate_cesu8_char (char_size, buf_p);
|
||||
|
||||
JERRY_ASSERT (lit_is_cesu8_string_valid (buf_p, bytes_generated));
|
||||
TEST_ASSERT (lit_is_cesu8_string_valid (buf_p, bytes_generated));
|
||||
|
||||
size += bytes_generated;
|
||||
buf_p += bytes_generated;
|
||||
length++;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (size == buf_size);
|
||||
TEST_ASSERT (size == buf_size);
|
||||
|
||||
return length;
|
||||
} /* generate_cesu8_string */
|
||||
@ -119,10 +119,10 @@ main ()
|
||||
|
||||
ecma_string_t *char_collection_string_p = ecma_new_ecma_string_from_utf8 (cesu8_string, cesu8_string_size);
|
||||
ecma_length_t char_collection_len = ecma_string_get_length (char_collection_string_p);
|
||||
JERRY_ASSERT (char_collection_len == length);
|
||||
TEST_ASSERT (char_collection_len == length);
|
||||
ecma_deref_ecma_string (char_collection_string_p);
|
||||
|
||||
JERRY_ASSERT (lit_utf8_string_length (cesu8_string, cesu8_string_size) == length);
|
||||
TEST_ASSERT (lit_utf8_string_length (cesu8_string, cesu8_string_size) == length);
|
||||
|
||||
const lit_utf8_byte_t *curr_p = cesu8_string;
|
||||
const lit_utf8_byte_t *end_p = cesu8_string + cesu8_string_size;
|
||||
@ -140,7 +140,7 @@ main ()
|
||||
lit_utf8_incr (&curr_p);
|
||||
}
|
||||
|
||||
JERRY_ASSERT (length == calculated_length);
|
||||
TEST_ASSERT (length == calculated_length);
|
||||
|
||||
if (code_units_count > 0)
|
||||
{
|
||||
@ -148,73 +148,73 @@ main ()
|
||||
{
|
||||
ecma_length_t index = (ecma_length_t) rand () % code_units_count;
|
||||
curr_p = saved_positions[index];
|
||||
JERRY_ASSERT (lit_utf8_peek_next (curr_p) == code_units[index]);
|
||||
TEST_ASSERT (lit_utf8_peek_next (curr_p) == code_units[index]);
|
||||
}
|
||||
}
|
||||
|
||||
curr_p = (lit_utf8_byte_t *) end_p;
|
||||
while (curr_p > cesu8_string)
|
||||
{
|
||||
JERRY_ASSERT (code_units_count > 0);
|
||||
TEST_ASSERT (code_units_count > 0);
|
||||
calculated_length--;
|
||||
JERRY_ASSERT (code_units[calculated_length] == lit_utf8_peek_prev (curr_p));
|
||||
TEST_ASSERT (code_units[calculated_length] == lit_utf8_peek_prev (curr_p));
|
||||
lit_utf8_decr (&curr_p);
|
||||
}
|
||||
|
||||
JERRY_ASSERT (calculated_length == 0);
|
||||
TEST_ASSERT (calculated_length == 0);
|
||||
|
||||
while (curr_p < end_p)
|
||||
{
|
||||
ecma_char_t code_unit = lit_utf8_read_next (&curr_p);
|
||||
JERRY_ASSERT (code_unit == code_units[calculated_length]);
|
||||
TEST_ASSERT (code_unit == code_units[calculated_length]);
|
||||
calculated_length++;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (length == calculated_length);
|
||||
TEST_ASSERT (length == calculated_length);
|
||||
|
||||
while (curr_p > cesu8_string)
|
||||
{
|
||||
JERRY_ASSERT (code_units_count > 0);
|
||||
TEST_ASSERT (code_units_count > 0);
|
||||
calculated_length--;
|
||||
JERRY_ASSERT (code_units[calculated_length] == lit_utf8_read_prev (&curr_p));
|
||||
TEST_ASSERT (code_units[calculated_length] == lit_utf8_read_prev (&curr_p));
|
||||
}
|
||||
|
||||
JERRY_ASSERT (calculated_length == 0);
|
||||
TEST_ASSERT (calculated_length == 0);
|
||||
}
|
||||
|
||||
/* Overlong-encoded code point */
|
||||
lit_utf8_byte_t invalid_cesu8_string_1[] = {0xC0, 0x82};
|
||||
JERRY_ASSERT (!lit_is_cesu8_string_valid (invalid_cesu8_string_1, sizeof (invalid_cesu8_string_1)));
|
||||
TEST_ASSERT (!lit_is_cesu8_string_valid (invalid_cesu8_string_1, sizeof (invalid_cesu8_string_1)));
|
||||
|
||||
/* Overlong-encoded code point */
|
||||
lit_utf8_byte_t invalid_cesu8_string_2[] = {0xE0, 0x80, 0x81};
|
||||
JERRY_ASSERT (!lit_is_cesu8_string_valid (invalid_cesu8_string_2, sizeof (invalid_cesu8_string_2)));
|
||||
TEST_ASSERT (!lit_is_cesu8_string_valid (invalid_cesu8_string_2, sizeof (invalid_cesu8_string_2)));
|
||||
|
||||
/* Pair of surrogates: 0xD901 0xDFF0 which encode Unicode character 0x507F0 */
|
||||
lit_utf8_byte_t invalid_cesu8_string_3[] = {0xED, 0xA4, 0x81, 0xED, 0xBF, 0xB0};
|
||||
JERRY_ASSERT (lit_is_cesu8_string_valid (invalid_cesu8_string_3, sizeof (invalid_cesu8_string_3)));
|
||||
TEST_ASSERT (lit_is_cesu8_string_valid (invalid_cesu8_string_3, sizeof (invalid_cesu8_string_3)));
|
||||
|
||||
/* Isolated high surrogate 0xD901 */
|
||||
lit_utf8_byte_t valid_utf8_string_1[] = {0xED, 0xA4, 0x81};
|
||||
JERRY_ASSERT (lit_is_cesu8_string_valid (valid_utf8_string_1, sizeof (valid_utf8_string_1)));
|
||||
TEST_ASSERT (lit_is_cesu8_string_valid (valid_utf8_string_1, sizeof (valid_utf8_string_1)));
|
||||
|
||||
lit_utf8_byte_t res_buf[3];
|
||||
lit_utf8_size_t res_size;
|
||||
|
||||
res_size = lit_code_unit_to_utf8 (0x73, res_buf);
|
||||
JERRY_ASSERT (res_size == 1);
|
||||
JERRY_ASSERT (res_buf[0] == 0x73);
|
||||
TEST_ASSERT (res_size == 1);
|
||||
TEST_ASSERT (res_buf[0] == 0x73);
|
||||
|
||||
res_size = lit_code_unit_to_utf8 (0x41A, res_buf);
|
||||
JERRY_ASSERT (res_size == 2);
|
||||
JERRY_ASSERT (res_buf[0] == 0xD0);
|
||||
JERRY_ASSERT (res_buf[1] == 0x9A);
|
||||
TEST_ASSERT (res_size == 2);
|
||||
TEST_ASSERT (res_buf[0] == 0xD0);
|
||||
TEST_ASSERT (res_buf[1] == 0x9A);
|
||||
|
||||
res_size = lit_code_unit_to_utf8 (0xD7FF, res_buf);
|
||||
JERRY_ASSERT (res_size == 3);
|
||||
JERRY_ASSERT (res_buf[0] == 0xED);
|
||||
JERRY_ASSERT (res_buf[1] == 0x9F);
|
||||
JERRY_ASSERT (res_buf[2] == 0xBF);
|
||||
TEST_ASSERT (res_size == 3);
|
||||
TEST_ASSERT (res_buf[0] == 0xED);
|
||||
TEST_ASSERT (res_buf[1] == 0x9F);
|
||||
TEST_ASSERT (res_buf[2] == 0xBF);
|
||||
|
||||
ecma_finalize ();
|
||||
jmem_finalize (true);
|
||||
|
||||
@ -19,4 +19,4 @@ sudo apt-get update -q
|
||||
sudo apt-get install -q -y \
|
||||
make cmake ninja-build \
|
||||
gcc gcc-arm-none-eabi \
|
||||
cppcheck vera++
|
||||
cppcheck vera++ python
|
||||
|
||||
142
tools/build.py
Executable file
142
tools/build.py
Executable file
@ -0,0 +1,142 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 2016 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2016 University of Szeged.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import argparse
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from os import makedirs
|
||||
from settings import *
|
||||
|
||||
BUILD_DIR = path.join(PROJECT_DIR, 'build')
|
||||
|
||||
def add_build_args(parser):
|
||||
parser.add_argument('--verbose', '-v', action='store_const', const='ON', default='OFF', help='Increase verbosity')
|
||||
parser.add_argument('--unittests', action='store_const', const='ON', default='OFF', help='Build unittests too')
|
||||
parser.add_argument('--clean', action='store_true', default=False, help='Clean build')
|
||||
parser.add_argument('--builddir', action='store', default=BUILD_DIR, help='Specify output directory (default: %(default)s)')
|
||||
parser.add_argument('--strip', choices=['on', 'off'], default='on', help='Strip release binary (default: %(default)s)')
|
||||
parser.add_argument('--all-in-one', choices=['on', 'off'], default='off', help='All-in-one build (default: %(default)s)')
|
||||
parser.add_argument('--debug', action='store_const', const='Debug', default='Release', dest='build_type', help='Debug build')
|
||||
parser.add_argument('--lto', choices=['on', 'off'], default='on', help='Enable link-time optimizations (default: %(default)s)')
|
||||
parser.add_argument('--profile', choices=['full', 'compact', 'minimal'], default='full', help='Specify the ECMAScript profile (default: %(default)s)')
|
||||
parser.add_argument('--error-messages', choices=['on', 'off'], default='off', help='Enable error messages (default: %(default)s)')
|
||||
parser.add_argument('--log', choices=['on', 'off'], default='off', help='Enable logging (default: %(default)s)')
|
||||
parser.add_argument('--valgrind', choices=['on', 'off'], default='off', help='Enable Valgrind support (default: %(default)s)')
|
||||
parser.add_argument('--valgrind-freya', choices=['on', 'off'], default='off', help='Enable Valgrind-Freya support (default: %(default)s)')
|
||||
parser.add_argument('--mem-stats', choices=['on', 'off'], default='off', help='Enable memory-statistics (default: %(default)s)')
|
||||
parser.add_argument('--mem-stress-test', choices=['on', 'off'], default='off', help='Enable mem-stress test (default: %(default)s)')
|
||||
parser.add_argument('--snapshot-save', choices=['on', 'off'], default='on', help='Allow to save snapshot files (default: %(default)s)')
|
||||
parser.add_argument('--snapshot-exec', choices=['on', 'off'], default='on', help='Allow to execute snapshot files (default: %(default)s)')
|
||||
parser.add_argument('--cmake-param', action='append', default=[], help='Add custom arguments to CMake')
|
||||
parser.add_argument('--compile-flag', action='append', default=[], help='Add custom compile flag')
|
||||
parser.add_argument('--linker-flag', action='append', default=[], help='Add custom linker flag')
|
||||
parser.add_argument('--toolchain', action='store', default='', help='Add toolchain file')
|
||||
parser.add_argument('--jerry-libc', choices=['on', 'off'], default='on', help='Use jerry-libc (default: %(default)s)')
|
||||
parser.add_argument('--compiler-default-libc', choices=['on', 'off'], default='off', help='Use compiler-default libc (default: %(default)s)')
|
||||
parser.add_argument('--jerry-core', choices=['on', 'off'], default='on', help='Use jerry-core (default: %(default)s)')
|
||||
parser.add_argument('--jerry-libm', choices=['on', 'off'], default='on', help='Use jerry-libm (default: %(default)s)')
|
||||
parser.add_argument('--jerry-cmdline', choices=['on', 'off'], default='on', help='Use jerry commandline tool (default: %(default)s)')
|
||||
|
||||
def get_arguments():
|
||||
parser = argparse.ArgumentParser()
|
||||
add_build_args(parser)
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
def generate_build_options(arguments):
|
||||
build_options = []
|
||||
|
||||
build_options.append('-DJERRY_LIBC=%s' % arguments.jerry_libc.upper())
|
||||
build_options.append('-DJERRY_CORE=%s' % arguments.jerry_core.upper())
|
||||
build_options.append('-DJERRY_LIBM=%s' % arguments.jerry_libm.upper())
|
||||
build_options.append('-DJERRY_CMDLINE=%s' % arguments.jerry_cmdline.upper())
|
||||
build_options.append('-DCOMPILER_DEFAULT_LIBC=%s' % arguments.compiler_default_libc.upper())
|
||||
build_options.append('-DCMAKE_VERBOSE_MAKEFILE=%s' % arguments.verbose)
|
||||
build_options.append('-DCMAKE_BUILD_TYPE=%s' % arguments.build_type)
|
||||
build_options.append('-DFEATURE_PROFILE=%s' % arguments.profile)
|
||||
build_options.append('-DFEATURE_ERROR_MESSAGES=%s' % arguments.error_messages.upper())
|
||||
build_options.append('-DFEATURE_LOG=%s' % arguments.log.upper())
|
||||
build_options.append('-DFEATURE_VALGRIND=%s' % arguments.valgrind.upper())
|
||||
build_options.append('-DFEATURE_VALGRIND_FREYA=%s' % arguments.valgrind_freya.upper())
|
||||
build_options.append('-DFEATURE_MEM_STATS=%s' % arguments.mem_stats.upper())
|
||||
build_options.append('-DFEATURE_MEM_STRESS_TEST=%s' % arguments.mem_stress_test.upper())
|
||||
build_options.append('-DFEATURE_SNAPSHOT_SAVE=%s' % arguments.snapshot_save.upper())
|
||||
build_options.append('-DFEATURE_SNAPSHOT_EXEC=%s' % arguments.snapshot_exec.upper())
|
||||
build_options.append('-DENABLE_ALL_IN_ONE=%s' % arguments.all_in_one.upper())
|
||||
build_options.append('-DENABLE_LTO=%s' % arguments.lto.upper())
|
||||
build_options.append('-DENABLE_STRIP=%s' % arguments.strip.upper())
|
||||
build_options.append('-DUNITTESTS=%s' % arguments.unittests)
|
||||
|
||||
build_options.extend(arguments.cmake_param)
|
||||
|
||||
build_options.append('-DEXTERNAL_COMPILE_FLAGS=' + ' '.join(arguments.compile_flag))
|
||||
build_options.append('-DEXTERNAL_LINKER_FLAGS=' + ' '.join(arguments.linker_flag))
|
||||
|
||||
if arguments.toolchain:
|
||||
build_options.append('-DCMAKE_TOOLCHAIN_FILE=%s' % arguments.toolchain)
|
||||
|
||||
return build_options
|
||||
|
||||
def configure_output_dir(arguments):
|
||||
global BUILD_DIR
|
||||
|
||||
if os.path.isabs(arguments.builddir):
|
||||
BUILD_DIR = arguments.builddir
|
||||
else:
|
||||
BUILD_DIR = path.join(PROJECT_DIR, arguments.builddir)
|
||||
|
||||
if arguments.clean and os.path.exists(BUILD_DIR):
|
||||
shutil.rmtree(BUILD_DIR)
|
||||
|
||||
if not os.path.exists(BUILD_DIR):
|
||||
makedirs(BUILD_DIR)
|
||||
|
||||
def configure_build(arguments):
|
||||
configure_output_dir(arguments)
|
||||
|
||||
build_options = generate_build_options(arguments)
|
||||
|
||||
cmake_cmd = ['cmake', '-B' + BUILD_DIR, '-H' + PROJECT_DIR]
|
||||
cmake_cmd.extend(build_options)
|
||||
|
||||
return subprocess.call(cmake_cmd)
|
||||
|
||||
def build_jerry(arguments):
|
||||
return subprocess.call(['make', '--no-print-directory','-j', '-C', BUILD_DIR])
|
||||
|
||||
def print_result(ret):
|
||||
print('=' * 30)
|
||||
if ret:
|
||||
print('Build failed with exit code: %s' % (ret))
|
||||
else:
|
||||
print('Build succeeded!')
|
||||
print('=' * 30)
|
||||
|
||||
def main():
|
||||
arguments = get_arguments()
|
||||
ret = configure_build(arguments)
|
||||
|
||||
if not ret:
|
||||
ret = build_jerry(arguments)
|
||||
|
||||
print_result(ret)
|
||||
sys.exit(ret)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@ -35,7 +35,7 @@ actual_signed_off_by_line=`git show -s --format=%B $commit_hash | sed '/^$/d' |
|
||||
|
||||
if [ "$actual_signed_off_by_line" != "$required_signed_off_by_line" ]
|
||||
then
|
||||
echo -e "\e[1;33m Signed-off-by message is incorrect. The following line should be at the end of the $commit_hash commit's message: '$required_signed_off_by_line'. \e[0m\n"
|
||||
echo -e "\e[1;33mSigned-off-by message is incorrect. The following line should be at the end of the $commit_hash commit's message: '$required_signed_off_by_line'. \e[0m"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -19,7 +19,7 @@ JERRY_CORE_FILES=`find ./jerry-core -name "*.c" -or -name "*.h"`
|
||||
JERRY_PORT_DEFAULT_FILES=`find ./targets/default -name "*.c" -or -name "*.h"`
|
||||
JERRY_LIBC_FILES=`find ./jerry-libc -name "*.c" -or -name "*.h"`
|
||||
JERRY_LIBM_FILES=`find ./jerry-libm -name "*.c" -or -name "*.h"`
|
||||
JERRY_MAIN_FILES=`find . -maxdepth 1 -name "*.c" -or -name "*.h"`
|
||||
JERRY_MAIN_FILES=`find ./jerry-main -name "*.c" -or -name "*.h"`
|
||||
UNIT_TEST_FILES=`find ./tests/unit -name "*.c" -or -name "*.h"`
|
||||
|
||||
if [ -n "$1" ]
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2014-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.
|
||||
|
||||
git log --graph --branches --decorate \
|
||||
--show-notes=perf --show-notes=mem --show-notes=test_build_env \
|
||||
--show-notes=arm-linux-perf \
|
||||
--show-notes=arm-linux-memory-consumption \
|
||||
--show-notes=arm-linux-binary-size \
|
||||
--show-notes=stm32f4-binary-size
|
||||
|
||||
exit 0
|
||||
@ -1,35 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 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.
|
||||
|
||||
git pull --rebase
|
||||
status_code=$?
|
||||
|
||||
if [ $status_code -ne 0 ]
|
||||
then
|
||||
echo "Pulling master failed"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git fetch origin refs/notes/*:refs/notes/*
|
||||
status_code=$?
|
||||
|
||||
if [ $status_code -ne 0 ]
|
||||
then
|
||||
echo "Pulling notes failed"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
@ -1,160 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2014-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.
|
||||
|
||||
GIT_STATUS_NOT_CLEAN_MSG="Git status of current directory is not clean"
|
||||
GIT_STATUS_CONSIDER_CLEAN_MSG="Consider removing all untracked files, locally commiting all changes and running $0 again"
|
||||
|
||||
clear
|
||||
|
||||
gitignore_files_list=`find . -name .gitignore`
|
||||
|
||||
if [ "$gitignore_files_list" != "./.gitignore" ]
|
||||
then
|
||||
echo -e "\n\e[1;33mInvalid .gitignore configuration\e[0m\n"
|
||||
echo -e -n ".gitignore files list:\t"
|
||||
echo $gitignore_files_list
|
||||
echo
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "`git status --porcelain 2>&1 | wc -l`" != "0" ]
|
||||
then
|
||||
echo -e "\n \e[1;90m$GIT_STATUS_NOT_CLEAN_MSG:\n"
|
||||
git status
|
||||
echo -e "\n\n $GIT_STATUS_CONSIDER_CLEAN_MSG.\e[0m\n"
|
||||
fi
|
||||
|
||||
ok_to_push=1
|
||||
|
||||
current_branch=`git branch | grep "^* " | cut -d ' ' -f 2`
|
||||
git branch -r | grep "^ *origin/$current_branch$" 2>&1 > /dev/null
|
||||
have_remote=$?
|
||||
|
||||
if [ $have_remote -eq 0 ]
|
||||
then
|
||||
base_ref="origin/$current_branch"
|
||||
|
||||
echo "Pulling..."
|
||||
|
||||
make pull
|
||||
status_code=$?
|
||||
|
||||
if [ $status_code -ne 0 ]
|
||||
then
|
||||
echo "Pull failed"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
base_ref=`git merge-base master $current_branch`
|
||||
status_code=$?
|
||||
|
||||
if [ $status_code -ne 0 ]
|
||||
then
|
||||
echo "Cannot determine merge-base for '$current_branch' and 'master' branches."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
commits_to_push=`git log $base_ref..$current_branch | grep "^commit [0-9a-f]*$" | awk 'BEGIN { s = ""; } { s = $2" "s; } END { print s; }'`
|
||||
|
||||
echo $commits_to_push | grep "[^ ]" >&/dev/null
|
||||
status_code=$?
|
||||
if [ $status_code -ne 0 ]
|
||||
then
|
||||
echo "Nothing to push"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
trap ctrl_c INT
|
||||
|
||||
function ctrl_c() {
|
||||
git checkout $current_branch >&/dev/null
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo
|
||||
echo "===== Starting pre-push commit testing series ====="
|
||||
echo
|
||||
echo "Commits list: $commits_to_push"
|
||||
echo
|
||||
|
||||
for commit_hash in $commits_to_push
|
||||
do
|
||||
git checkout $commit_hash >&/dev/null
|
||||
status_code=$?
|
||||
|
||||
if [ $status_code -ne 0 ]
|
||||
then
|
||||
echo "git checkout $commit_hash failed"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo " > Testing $commit_hash"
|
||||
echo -n " > "
|
||||
git log --pretty=format:"%H %s" | grep $commit_hash | grep -o " .*"
|
||||
echo
|
||||
|
||||
make -s -j precommit 2>&1
|
||||
status_code=$?
|
||||
if [ $status_code -ne 0 ]
|
||||
then
|
||||
echo "Pre-commit quality testing for '$commit_hash' failed"
|
||||
echo
|
||||
|
||||
ok_to_push=0
|
||||
break
|
||||
fi
|
||||
|
||||
echo "Pre-commit quality testing for '$commit_hash' passed successfully"
|
||||
done
|
||||
|
||||
git checkout $current_branch >&/dev/null
|
||||
|
||||
echo
|
||||
echo "Pre-commit testing passed successfully"
|
||||
echo
|
||||
|
||||
if [ $ok_to_push -eq 1 ]
|
||||
then
|
||||
if [ "`git status --porcelain 2>&1 | wc -l`" == "0" ]
|
||||
then
|
||||
echo "Pushing..."
|
||||
echo
|
||||
|
||||
git push -u origin $current_branch
|
||||
status_code=$?
|
||||
|
||||
if [ $status_code -eq 0 ]
|
||||
then
|
||||
echo -e "\n\e[0;32m Pushed successfully\e[0m\n"
|
||||
else
|
||||
echo -e "\n\e[1;33m Push failed\e[0m"
|
||||
fi
|
||||
|
||||
exit $status_code
|
||||
else
|
||||
echo -e "\e[1;33m $GIT_STATUS_NOT_CLEAN_MSG. $GIT_STATUS_CONSIDER_CLEAN_MSG.\e[0m\n"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo -e "\e[1;33mPre-commit testing not passed. Cancelling push.\e[0m"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
@ -1,138 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2015-2016 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.
|
||||
|
||||
PREREQUISITES_INSTALLED_LIST_FILE="$1"
|
||||
shift
|
||||
|
||||
if [ "$1" == "clean" ]
|
||||
then
|
||||
CLEAN_MODE=yes
|
||||
else
|
||||
CLEAN_MODE=no
|
||||
fi
|
||||
|
||||
trap clean_on_exit INT
|
||||
|
||||
function clean_on_exit() {
|
||||
rm -rf $TMP_DIR
|
||||
|
||||
[[ $1 == "OK" ]] || exit 1
|
||||
exit 0
|
||||
}
|
||||
|
||||
function fail_msg() {
|
||||
echo "$1"
|
||||
|
||||
clean_on_exit "FAIL"
|
||||
}
|
||||
|
||||
function remove_gitignore_files_at() {
|
||||
DEST="$1"
|
||||
gitignore_files_list=`find "$DEST" -name .gitignore`
|
||||
[ $? -eq 0 ] || fail_msg "Failed to search for .gitignore in '$DEST'."
|
||||
|
||||
rm -rf $gitignore_files_list || fail_msg "Failed to remove .gitignore files from '$DEST'."
|
||||
}
|
||||
|
||||
function setup_from_zip() {
|
||||
NAME="$1"
|
||||
shift
|
||||
|
||||
DEST=$(pwd)/"$1"
|
||||
shift
|
||||
|
||||
URL="$1"
|
||||
shift
|
||||
|
||||
CHECKSUM="$1"
|
||||
shift
|
||||
|
||||
LIST="$*"
|
||||
|
||||
FAIL_MSG="Failed to setup '$NAME' prerequisite"
|
||||
|
||||
if [ "$CLEAN_MODE" == "no" ]
|
||||
then
|
||||
echo "$CHECKSUM $NAME" >> $TMP_DIR/.prerequisites
|
||||
grep -q "^$CHECKSUM $NAME\$" $TMP_DIR/.prerequisites.prev && return 0
|
||||
|
||||
echo "Setting up $NAME prerequisite"
|
||||
fi
|
||||
|
||||
if [ -e "$DEST" ]
|
||||
then
|
||||
chmod -R u+w "$DEST" || fail_msg "$FAIL_MSG. Failed to add write permission to '$DEST' directory contents."
|
||||
rm -rf "$DEST" || fail_msg "$FAIL_MSG. Cannot remove '$DEST' directory."
|
||||
fi
|
||||
|
||||
if [ "$CLEAN_MODE" == "yes" ]
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
|
||||
wget --no-check-certificate -O "$TMP_DIR/$NAME.zip" "$URL" || fail_msg "$FAIL_MSG. Cannot download '$URL' zip archive."
|
||||
|
||||
echo "$CHECKSUM $TMP_DIR/$NAME.zip" | $SHA256SUM --check || fail_msg "$FAIL_MSG. Archive's checksum doesn't match."
|
||||
|
||||
unzip "$TMP_DIR/$NAME.zip" -d "$TMP_DIR/$NAME" || fail_msg "$FAIL_MSG. Failed to unpack zip archive."
|
||||
mkdir "$DEST" || fail_msg "$FAIL_MSG. Failed to create '$DEST' directory."
|
||||
|
||||
for part in "$LIST"
|
||||
do
|
||||
mv "$TMP_DIR/$NAME"/$part "$DEST" || fail_msg "$FAIL_MSG. Failed to move '$part' to '$DEST'."
|
||||
done
|
||||
|
||||
remove_gitignore_files_at "$DEST"
|
||||
chmod -R u-w "$DEST" || fail_msg "$FAIL_MSG. Failed to remove write permission from '$DEST' directory contents."
|
||||
}
|
||||
|
||||
HOST_OS=`uname -s`
|
||||
|
||||
if [ "$HOST_OS" == "Darwin" ]
|
||||
then
|
||||
SHA256SUM="shasum -a 256"
|
||||
TMP_DIR=`mktemp -d -t jerryscript`
|
||||
else
|
||||
SHA256SUM="sha256sum --strict"
|
||||
TMP_DIR=`mktemp -d --tmpdir=./`
|
||||
fi
|
||||
|
||||
if [ "$CLEAN_MODE" == "yes" ]
|
||||
then
|
||||
rm -f $PREREQUISITES_INSTALLED_LIST_FILE
|
||||
else
|
||||
touch $PREREQUISITES_INSTALLED_LIST_FILE || fail_msg "Failed to create '$PREREQUISITES_INSTALLED_LIST_FILE'."
|
||||
mv $PREREQUISITES_INSTALLED_LIST_FILE $TMP_DIR/.prerequisites.prev
|
||||
fi
|
||||
|
||||
setup_from_zip "stm32f3" \
|
||||
"./third-party/STM32F3-Discovery_FW_V1.1.0" \
|
||||
"http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/firmware/stm32f3discovery_fw.zip" \
|
||||
"cf81efd07d627adb58adc20653eecb415878b6585310b77b0ca54a34837b3855" \
|
||||
"STM32F3-Discovery_FW_V1.1.0/*"
|
||||
|
||||
setup_from_zip "stm32f4" \
|
||||
"./third-party/STM32F4-Discovery_FW_V1.1.0" \
|
||||
"http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/firmware/stsw-stm32068.zip" \
|
||||
"8e67f7b930c6c02bd7f89a266c8d1cae3b530510b7979fbfc0ee0d57e7f88b81" \
|
||||
"STM32F4-Discovery_FW_V1.1.0/*"
|
||||
|
||||
if [ "$CLEAN_MODE" == "no" ]
|
||||
then
|
||||
mv $TMP_DIR/.prerequisites $PREREQUISITES_INSTALLED_LIST_FILE || fail_msg "Failed to write '$PREREQUISITES_INSTALLED_LIST_FILE'"
|
||||
fi
|
||||
|
||||
clean_on_exit "OK"
|
||||
197
tools/run-tests.py
Executable file
197
tools/run-tests.py
Executable file
@ -0,0 +1,197 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 2016 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2016 University of Szeged.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import argparse
|
||||
from subprocess import CalledProcessError
|
||||
from settings import *
|
||||
|
||||
OUTPUT_DIR = path.join(PROJECT_DIR, 'build', 'tests')
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--toolchain', action='store', default='', help='Add toolchain file')
|
||||
parser.add_argument('--outdir', action='store', default=OUTPUT_DIR, help='Specify output directory (default: %(default)s)')
|
||||
parser.add_argument('--check-signed-off', action='store_true', default=False, help='Run signed-off check')
|
||||
parser.add_argument('--check-cppcheck', action='store_true', default=False, help='Run cppcheck')
|
||||
parser.add_argument('--check-vera', action='store_true', default=False, help='Run vera check')
|
||||
parser.add_argument('--buildoption-test', action='store_true', default=False, help='Run buildoption-test')
|
||||
parser.add_argument('--jerry-tests', action='store_true', default=False, help='Run jerry-tests')
|
||||
parser.add_argument('--jerry-test-suite', action='store_true', default=False, help='Run jerry-test-suite')
|
||||
parser.add_argument('--unittests', action='store_true', default=False, help='Run unittests')
|
||||
parser.add_argument('--precommit', action='store_true', default=False, dest='all', help='Run all test')
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
script_args = parser.parse_args()
|
||||
|
||||
if os.path.isabs(script_args.outdir):
|
||||
OUTPUT_DIR = script_args.outdir
|
||||
else:
|
||||
OUTPUT_DIR = path.join(PROJECT_DIR, script_args.outdir)
|
||||
|
||||
class Options:
|
||||
out_dir = ''
|
||||
build_args = []
|
||||
test_args = []
|
||||
|
||||
def __init__(self, name = '', build_args = [], test_args = []):
|
||||
self.out_dir = os.path.join(OUTPUT_DIR, name)
|
||||
self.build_args = build_args
|
||||
self.build_args.append('--builddir=%s' % self.out_dir)
|
||||
self.test_args = test_args
|
||||
|
||||
|
||||
# Test options for unittests
|
||||
jerry_unittests_options = [
|
||||
Options('unittests', ['--unittests']),
|
||||
Options('unittests-debug', ['--unittests', '--debug']),
|
||||
]
|
||||
|
||||
# Test options for jerry-tests
|
||||
jerry_tests_options = [
|
||||
Options('jerry_tests'),
|
||||
Options('jerry_tests-snapshot', ['--snapshot-save=on', '--snapshot-exec=on'], ['--snapshot']),
|
||||
Options('jerry_tests-debug', ['--debug']),
|
||||
Options('jerry_tests-debug-snapshot', ['--debug', '--snapshot-save=on', '--snapshot-exec=on'], ['--snapshot']),
|
||||
]
|
||||
|
||||
# Test options for jerry-test-suite
|
||||
jerry_test_suite_options = jerry_tests_options[:]
|
||||
jerry_test_suite_options.append(Options('jerry_test_suite-compact', ['--profile=compact']))
|
||||
jerry_test_suite_options.append(Options('jerry_test_suite-compact-snapshot', ['--profile=compact', '--snapshot-save=on', '--snapshot-exec=on'], ['--snapshot']))
|
||||
jerry_test_suite_options.append(Options('jerry_test_suite-compact-debug', ['--debug', '--profile=compact']))
|
||||
jerry_test_suite_options.append(Options('jerry_test_suite-compact-debug-snapshot', ['--debug', '--profile=compact', '--snapshot-save=on', '--snapshot-exec=on'], ['--snapshot']))
|
||||
|
||||
# Test options for buildoption-test
|
||||
jerry_buildoptions = [
|
||||
Options('buildoption_test-lto', ['--lto=on']),
|
||||
Options('buildoption_test-log', ['--log=on']),
|
||||
Options('buildoption_test-error_messages', ['--error-messages=on']),
|
||||
Options('buildoption_test-all_in_one', ['--all-in-one=on']),
|
||||
Options('buildoption_test-valgrind', ['--valgrind=on']),
|
||||
Options('buildoption_test-valgrind_freya', ['--valgrind-freya=on']),
|
||||
Options('buildoption_test-jerry_libc', ['--jerry-libc=on', '--compiler-default-libc=off']),
|
||||
Options('buildoption_test-compiler_default_libc', ['--compiler-default-libc=on', '--jerry-libc=off']),
|
||||
]
|
||||
|
||||
def get_bin_dir_path(out_dir):
|
||||
return path.join(out_dir, 'bin')
|
||||
|
||||
def get_binary_path(out_dir):
|
||||
return path.join(get_bin_dir_path(out_dir), 'jerry')
|
||||
|
||||
def create_binary(buildoptions):
|
||||
build_cmd = [BUILD_SCRIPT]
|
||||
build_cmd.extend(buildoptions)
|
||||
|
||||
if script_args.toolchain:
|
||||
build_cmd.append('--toolchain=%s' % script_args.toolchain)
|
||||
|
||||
sys.stderr.write('Build command: %s\n' % ' '.join(build_cmd))
|
||||
|
||||
try:
|
||||
script_output = subprocess.check_output(build_cmd)
|
||||
except CalledProcessError as e:
|
||||
return e.returncode
|
||||
|
||||
return 0
|
||||
|
||||
def run_jerry_tests():
|
||||
for job in jerry_tests_options:
|
||||
ret = create_binary(job.build_args)
|
||||
|
||||
if not ret:
|
||||
test_cmd = [TEST_RUNNER_SCRIPT, get_binary_path(job.out_dir), JERRY_TESTS_DIR]
|
||||
if job.test_args:
|
||||
test_cmd.extend(job.test_args)
|
||||
|
||||
ret = run_check(test_cmd)
|
||||
else:
|
||||
break
|
||||
|
||||
return ret
|
||||
|
||||
def run_jerry_test_suite():
|
||||
for job in jerry_test_suite_options:
|
||||
ret = create_binary(job.build_args)
|
||||
|
||||
if not ret:
|
||||
test_cmd = [TEST_RUNNER_SCRIPT, get_binary_path(job.out_dir)]
|
||||
|
||||
if '--profile=compact' in job.build_args:
|
||||
test_cmd.append(JERRY_TEST_SUITE_COMPACT_LIST)
|
||||
else:
|
||||
test_cmd.append(JERRY_TEST_SUITE_DIR)
|
||||
|
||||
if job.test_args:
|
||||
test_cmd.extend(job.test_args)
|
||||
|
||||
ret = run_check(test_cmd)
|
||||
else:
|
||||
break
|
||||
|
||||
return ret
|
||||
|
||||
def run_unittests():
|
||||
for job in jerry_unittests_options:
|
||||
ret = create_binary(job.build_args)
|
||||
|
||||
if not ret:
|
||||
ret = run_check([UNITTEST_RUNNER_SCRIPT, get_bin_dir_path(job.out_dir)])
|
||||
else:
|
||||
break
|
||||
|
||||
return ret
|
||||
|
||||
def run_buildoption_test():
|
||||
for job in jerry_buildoptions:
|
||||
ret = create_binary(job.build_args)
|
||||
if ret:
|
||||
break
|
||||
|
||||
return ret
|
||||
|
||||
def main():
|
||||
ret = 0
|
||||
|
||||
if script_args.all or script_args.check_signed_off:
|
||||
ret = run_check(SIGNED_OFF_SCRIPT)
|
||||
|
||||
if not ret and script_args.all or script_args.check_cppcheck:
|
||||
ret = run_check(CPPCHECK_SCRIPT)
|
||||
|
||||
if not ret and script_args.all or script_args.check_vera:
|
||||
ret = run_check(VERA_SCRIPT)
|
||||
|
||||
if not ret and script_args.all or script_args.jerry_tests:
|
||||
ret = run_jerry_tests()
|
||||
|
||||
if not ret and script_args.all or script_args.jerry_test_suite:
|
||||
ret = run_jerry_test_suite()
|
||||
|
||||
if not ret and script_args.all or script_args.unittests:
|
||||
ret = run_unittests()
|
||||
|
||||
if not ret and script_args.all or script_args.buildoption_test:
|
||||
ret = run_buildoption_test()
|
||||
|
||||
sys.exit(ret)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@ -20,21 +20,24 @@
|
||||
|
||||
TIMEOUT=${TIMEOUT:=5}
|
||||
|
||||
TEST_FILES=test.files
|
||||
TEST_FAILED=test.failed
|
||||
TEST_PASSED=test.passed
|
||||
|
||||
ENGINE="$1"
|
||||
shift
|
||||
|
||||
TESTS="$1"
|
||||
shift
|
||||
|
||||
OUTPUT_DIR=`dirname $ENGINE`
|
||||
TESTS_BASENAME=`basename $TESTS`
|
||||
|
||||
TEST_FILES=$OUTPUT_DIR/$TESTS_BASENAME.files
|
||||
TEST_FAILED=$OUTPUT_DIR/$TESTS_BASENAME.failed
|
||||
TEST_PASSED=$OUTPUT_DIR/$TESTS_BASENAME.passed
|
||||
|
||||
if [ "$1" == "--snapshot" ]
|
||||
then
|
||||
TEST_FILES="snapshot.$TEST_FILES"
|
||||
TEST_FAILED="snapshot.$TEST_FAILED"
|
||||
TEST_PASSED="snapshot.$TEST_PASSED"
|
||||
TEST_FILES="$TEST_FILES.snapshot"
|
||||
TEST_FAILED="$TEST_FAILED.snapshot"
|
||||
TEST_PASSED="$TEST_PASSED.snapshot"
|
||||
IS_SNAPSHOT=true;
|
||||
shift
|
||||
fi
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
DIR="$1"
|
||||
shift
|
||||
|
||||
UNITTEST_ERROR=unittests.failed
|
||||
UNITTEST_OK=unittests.passed
|
||||
UNITTEST_ERROR=$DIR/unittests.failed
|
||||
UNITTEST_OK=$DIR/unittests.passed
|
||||
|
||||
rm -f $UNITTEST_ERROR $UNITTEST_OK
|
||||
|
||||
|
||||
43
tools/settings.py
Executable file
43
tools/settings.py
Executable file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 2016 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2016 University of Szeged.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from subprocess import CalledProcessError
|
||||
from os import path
|
||||
|
||||
TOOLS_DIR = path.dirname(path.abspath(__file__))
|
||||
PROJECT_DIR = path.normpath(path.join(TOOLS_DIR, '..'))
|
||||
JERRY_TESTS_DIR = path.join(PROJECT_DIR, 'tests/jerry')
|
||||
JERRY_TEST_SUITE_DIR = path.join(PROJECT_DIR, 'tests/jerry-test-suite')
|
||||
JERRY_TEST_SUITE_COMPACT_LIST = path.join(PROJECT_DIR, 'tests/jerry-test-suite/compact-profile-list')
|
||||
|
||||
BUILD_SCRIPT = path.join(TOOLS_DIR, 'build.py')
|
||||
CPPCHECK_SCRIPT = path.join(TOOLS_DIR, 'check-cppcheck.sh')
|
||||
SIGNED_OFF_SCRIPT = path.join(TOOLS_DIR, 'check-signed-off.sh')
|
||||
VERA_SCRIPT = path.join(TOOLS_DIR, 'check-vera.sh')
|
||||
TEST_RUNNER_SCRIPT = path.join(TOOLS_DIR, 'runners/run-test-suite.sh')
|
||||
UNITTEST_RUNNER_SCRIPT = path.join(TOOLS_DIR, 'runners/run-unittests.sh')
|
||||
|
||||
def run_check(runnable):
|
||||
try:
|
||||
ret = subprocess.check_call(runnable)
|
||||
except CalledProcessError as e:
|
||||
return e.returncode
|
||||
|
||||
return ret
|
||||
Loading…
x
Reference in New Issue
Block a user