Skip to content

Eliminate cpp featureset #876

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 28 additions & 49 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,30 @@
# limitations under the License.

cmake_minimum_required (VERSION 2.8.12)
project (Jerry CXX C ASM)
project (Jerry C ASM)

# Determining platform
set(PLATFORM "${CMAKE_SYSTEM_NAME}")
string(TOUPPER "${PLATFORM}" PLATFORM)

# Compiler configuration
if(NOT ("${PLATFORM}" STREQUAL "DARWIN"))
if(NOT CMAKE_COMPILER_IS_GNUCXX)
message(FATAL_ERROR "g++ compiler is required")
if(NOT CMAKE_COMPILER_IS_GNUCC)
message(FATAL_ERROR "gcc compiler is required")
endif()
endif()

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
# Require g++ of version >= 4.7.0
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
OUTPUT_VARIABLE GNU_CXX_VERSION
if(CMAKE_COMPILER_IS_GNUCC)
# Require gcc of version >= 4.7.0
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GNU_CC_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(${GNU_CXX_VERSION} VERSION_LESS 4.7.0)
message(FATAL_ERROR "g++ compiler version 4.7.0 or higher required")
if(${GNU_CC_VERSION} VERSION_LESS 4.7.0)
message(FATAL_ERROR "gcc compiler version 4.7.0 or higher required")
endif()
endif()


# Imported and third-party targets prefix
set(PREFIX_IMPORTED_LIB imported_)
set(SUFFIX_THIRD_PARTY_LIB .third_party.lib)
Expand All @@ -49,13 +50,11 @@ project (Jerry CXX C ASM)
# Architecture-specific compile/link flags
foreach(FLAG ${FLAGS_COMMON_ARCH})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAG}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAG}")
endforeach()

# Remove rdynamic option
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS )
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS )

# Defining options
option(ENABLE_VALGRIND "Enable valgrind helpers in memory allocators" OFF)
Expand Down Expand Up @@ -102,7 +101,7 @@ project (Jerry CXX C ASM)
message(FATAL_ERROR "Platform '${PLATFORM}' is not supported")
endif()

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
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)
Expand Down Expand Up @@ -273,15 +272,15 @@ project (Jerry CXX C ASM)
macro(add_jerry_compile_warnings)
foreach(_warning ${ARGV})
add_jerry_compile_flags(-W${_warning})
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
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(-pedantic -Wno-stack-protector -Wno-attributes)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_COMPILER_IS_GNUCC)
add_jerry_compile_warnings(logical-op)
else()
add_jerry_compile_flags(-Wno-nested-anon-types)
Expand All @@ -298,13 +297,6 @@ project (Jerry CXX C ASM)
set(LINKER_FLAGS_STATIC "-static")
endif()

# C++
set(CXX_FLAGS_JERRY "-std=c++11 -fno-exceptions -fno-rtti")
# Turn off implicit template instantiation
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CXX_FLAGS_JERRY "${CXX_FLAGS_JERRY} -fno-implicit-templates -fno-implicit-inline-templates")
endif()

# C
set(C_FLAGS_JERRY "-std=c99")

Expand Down Expand Up @@ -333,23 +325,23 @@ project (Jerry CXX C ASM)
# Platform-specific
# Jerry standalone
# Linux
set(SOURCE_JERRY_STANDALONE_MAIN_LINUX main-unix.cpp)
set(SOURCE_JERRY_STANDALONE_MAIN_LINUX main-unix.c)

# Darwin
set(SOURCE_JERRY_STANDALONE_MAIN_DARWIN main-unix.cpp)
set(SOURCE_JERRY_STANDALONE_MAIN_DARWIN main-unix.c)

# MCU
# stm32f3
set(SOURCE_JERRY_STANDALONE_MAIN_MCU_STM32F3 main-mcu.cpp)
set(SOURCE_JERRY_STANDALONE_MAIN_MCU_STM32F3 main-mcu.c)

# stm32f4
set(SOURCE_JERRY_STANDALONE_MAIN_MCU_STM32F4 main-mcu.cpp)
set(SOURCE_JERRY_STANDALONE_MAIN_MCU_STM32F4 main-mcu.c)

# Unit tests main modules
file(GLOB SOURCE_UNIT_TEST_MAIN_MODULES tests/unit/*.cpp)
file(GLOB SOURCE_UNIT_TEST_MAIN_MODULES tests/unit/*.c)

# Imported libraries
if(("${PLATFORM}" STREQUAL "DARWIN") AND (NOT (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)))
if(("${PLATFORM}" STREQUAL "DARWIN") AND (NOT CMAKE_COMPILER_IS_GNUCC))
# libclang_rt.osx
add_library(${PREFIX_IMPORTED_LIB}libclang_rt.osx STATIC IMPORTED)
execute_process(COMMAND ${CMAKE_C_COMPILER} ${FLAGS_COMMON_ARCH} -print-file-name=
Expand All @@ -366,19 +358,6 @@ else()
OUTPUT_STRIP_TRAILING_WHITESPACE)
set_property(TARGET ${PREFIX_IMPORTED_LIB}libgcc
PROPERTY IMPORTED_LOCATION ${IMPORTED_LIBGCC_LOCATION})
# libgcc_eh
add_library(${PREFIX_IMPORTED_LIB}libgcc_eh STATIC IMPORTED)
execute_process(COMMAND ${CMAKE_C_COMPILER} ${FLAGS_COMMON_ARCH} -print-file-name=libgcc_eh.a
OUTPUT_VARIABLE IMPORTED_LIBGCC_EH_LOCATION
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(EXISTS "${IMPORTED_LIBGCC_EH_LOCATION}")
set_property(TARGET ${PREFIX_IMPORTED_LIB}libgcc_eh
PROPERTY IMPORTED_LOCATION ${IMPORTED_LIBGCC_EH_LOCATION})
else()
# If libgcc_eh not found, reference libgcc instead
set_property(TARGET ${PREFIX_IMPORTED_LIB}libgcc_eh
PROPERTY IMPORTED_LOCATION ${IMPORTED_LIBGCC_LOCATION})
endif()
endif()

# Platform-specific configuration
Expand Down Expand Up @@ -436,19 +415,19 @@ endif()
endif()

set_property(TARGET ${TARGET_NAME}
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_JERRY} ${CXX_FLAGS_JERRY} ${FLAGS_COMMON_${BUILD_MODE}}")
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_JERRY} ${FLAGS_COMMON_${BUILD_MODE}} ${C_FLAGS_JERRY}")
set_property(TARGET ${TARGET_NAME}
PROPERTY LINK_FLAGS "${COMPILE_FLAGS_JERRY} ${CXX_FLAGS_JERRY} ${FLAGS_COMMON_${BUILD_MODE}} ${LINKER_FLAGS_COMMON} ${LINKER_FLAGS_STATIC}")
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} 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 OR CMAKE_COMPILER_IS_GNUCXX)))
if(("${PLATFORM}" STREQUAL "DARWIN") AND (NOT (CMAKE_COMPILER_IS_GNUCC)))
target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME}
${FDLIBM_TARGET_NAME} ${PREFIX_IMPORTED_LIB}libclang_rt.osx)
else()
target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME}
${FDLIBM_TARGET_NAME} ${PREFIX_IMPORTED_LIB}libgcc ${PREFIX_IMPORTED_LIB}libgcc_eh)
${FDLIBM_TARGET_NAME} ${PREFIX_IMPORTED_LIB}libgcc)
endif()

add_cppcheck_target(${TARGET_NAME})
Expand Down Expand Up @@ -483,7 +462,7 @@ endif()
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} ${CXX_FLAGS_JERRY} ${FLAGS_COMMON_${BUILD_MODE}}")
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})
Expand Down Expand Up @@ -530,18 +509,18 @@ endif()

add_executable(${TARGET_NAME} ${SOURCE_UNIT_TEST_MAIN})
set_property(TARGET ${TARGET_NAME}
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_JERRY} ${CXX_FLAGS_JERRY} ${FLAGS_COMMON_UNITTESTS}")
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_JERRY} ${C_FLAGS_JERRY} ${FLAGS_COMMON_UNITTESTS}")
set_property(TARGET ${TARGET_NAME}
PROPERTY LINK_FLAGS "${COMPILE_FLAGS_JERRY} ${CXX_FLAGS_JERRY} ${FLAGS_COMMON_UNITTESTS} ${LINKER_FLAGS_COMMON}")
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 OR CMAKE_COMPILER_IS_GNUCXX)))
if(("${PLATFORM}" STREQUAL "DARWIN") AND (NOT (CMAKE_COMPILER_IS_GNUCC)))
target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME} ${FDLIBM_TARGET_NAME}
${PREFIX_IMPORTED_LIB}libclang_rt.osx)
else()
target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME} ${FDLIBM_TARGET_NAME}
${PREFIX_IMPORTED_LIB}libgcc ${PREFIX_IMPORTED_LIB}libgcc_eh)
${PREFIX_IMPORTED_LIB}libgcc)
endif()

add_cppcheck_target(${TARGET_NAME})
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export TARGET_NATIVE_SYSTEMS = $(shell uname -s | tr '[:upper:]' '[:lower:]')
endif
# Compiler to use for external build
EXTERNAL_C_COMPILER ?= arm-none-eabi-gcc
EXTERNAL_CXX_COMPILER ?= arm-none-eabi-g++

export TARGET_DEBUG_MODES = debug
export TARGET_RELEASE_MODES = release
Expand Down
1 change: 0 additions & 1 deletion build/configs/toolchain_afl_i686.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR i686)

CMAKE_FORCE_C_COMPILER(afl-gcc GNU)
CMAKE_FORCE_CXX_COMPILER(afl-g++ GNU)
1 change: 0 additions & 1 deletion build/configs/toolchain_afl_x86_64.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)

CMAKE_FORCE_C_COMPILER(afl-gcc GNU)
CMAKE_FORCE_CXX_COMPILER(afl-g++ GNU)

set(FLAGS_COMMON_ARCH -ffixed-rbp)
1 change: 0 additions & 1 deletion build/configs/toolchain_darwin_x86_64.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ set(CMAKE_SYSTEM_NAME Darwin)
set(CMAKE_SYSTEM_PROCESSOR x86_64)

find_program(CMAKE_C_COMPILER NAMES gcc cc)
find_program(CMAKE_CXX_COMPILER NAMES g++ c++)
# FIXME: This could break cross compilation, when the strip is not for the target architecture
find_program(CMAKE_STRIP NAMES strip)

Expand Down
1 change: 0 additions & 1 deletion build/configs/toolchain_external.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ set(CMAKE_SYSTEM_NAME EXTERNAL)
set(CMAKE_SYSTEM_PROCESSOR "${EXTERNAL_CMAKE_SYSTEM_PROCESSOR}")

CMAKE_FORCE_C_COMPILER(${EXTERNAL_CMAKE_C_COMPILER} GNU)
CMAKE_FORCE_CXX_COMPILER(${EXTERNAL_CMAKE_CXX_COMPILER} GNU)
1 change: 0 additions & 1 deletion build/configs/toolchain_linux_armv7l-el.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR armv7l-el)

set(CMAKE_C_COMPILER arm-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++)
# 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)

Expand Down
1 change: 0 additions & 1 deletion build/configs/toolchain_linux_armv7l-hf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR armv7l-hf)

set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
# 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)
#
Expand Down
1 change: 0 additions & 1 deletion build/configs/toolchain_linux_i686.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ 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)
find_program(CMAKE_CXX_COMPILER NAMES i686-linux-gnu-g++ i686-unknown-linux-gnu-g++)
# 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 change: 0 additions & 1 deletion build/configs/toolchain_linux_x86_64.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ 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)
find_program(CMAKE_CXX_COMPILER NAMES x86_64-linux-gnu-g++ x86_64-unknown-linux-gnu-g++)
# 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)

Expand Down
1 change: 0 additions & 1 deletion build/configs/toolchain_mcu_stm32f3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ set(CMAKE_SYSTEM_VERSION STM32F3)
set(FLAGS_COMMON_ARCH -mlittle-endian -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard)

CMAKE_FORCE_C_COMPILER(arm-none-eabi-gcc GNU)
CMAKE_FORCE_CXX_COMPILER(arm-none-eabi-g++ GNU)
1 change: 0 additions & 1 deletion build/configs/toolchain_mcu_stm32f4.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ set(CMAKE_SYSTEM_VERSION STM32F4)
set(FLAGS_COMMON_ARCH -mlittle-endian -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard)

CMAKE_FORCE_C_COMPILER(arm-none-eabi-gcc GNU)
CMAKE_FORCE_CXX_COMPILER(arm-none-eabi-g++ GNU)
1 change: 0 additions & 1 deletion build/configs/toolchain_openwrt_mips.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ set(CMAKE_SYSTEM_NAME Openwrt)
set(CMAKE_SYSTEM_PROCESSOR mips)

set(CMAKE_C_COMPILER mipsel-openwrt-linux-gcc)
set(CMAKE_CXX_COMPILER mipsel-openwrt-linux-g++)
# 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)
2 changes: 1 addition & 1 deletion build/static-checkers/add_cppcheck_for_target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
foreach(SOURCE ${TARGET_SOURCES})
# Add to list if it is C or C++ source
get_filename_component(SOURCE_EXTENSION ${SOURCE} EXT)
if("${SOURCE_EXTENSION}" STREQUAL ".c" OR "${SOURCE_EXTENSION}" STREQUAL ".cpp")
if("${SOURCE_EXTENSION}" STREQUAL ".c")
set(CPPCHECK_SOURCES_LIST ${CPPCHECK_SOURCES_LIST} ${SOURCE})

set(ADD_CPPCHECK_COMMAND true)
Expand Down
12 changes: 6 additions & 6 deletions docs/API-EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This guide is intended to introduce you to JerryScript embedding API through cre

## Step 1. Execute JavaScript from your application

```cpp
```c
#include <string.h>
#include "jerry.h"

Expand Down Expand Up @@ -34,7 +34,7 @@ Here we perform the same actions, as `jerry_run_simple`, while splitting into se
- engine cleanup


```cpp
```c
#include <string.h>
#include "jerry.h"

Expand All @@ -60,7 +60,7 @@ Our code is more complex now, but it introduces possibilities to interact with J

## Step 3. Execution in 'eval'-mode

```cpp
```c
#include <string.h>
#include "jerry.h"

Expand Down Expand Up @@ -95,7 +95,7 @@ This way, we execute two independent script parts in one execution environment.

## Step 4. Interaction with JavaScript environment

```cpp
```c
#include <string.h>
#include "jerry.h"

Expand Down Expand Up @@ -164,7 +164,7 @@ Pointers to strings or objects and values should be released just when become un

The following example function will output a JavaScript value:

```cpp
```c
static void
print_value (const jerry_api_value_t * value_p)
{
Expand Down Expand Up @@ -234,7 +234,7 @@ Shell operation can be described with the following loop:
- print result of eval;
- loop.

```cpp
```c
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
Loading