aboutsummaryrefslogtreecommitdiff
path: root/jerry-libc
diff options
context:
space:
mode:
authorRobert Sipka <rsipka.uszeged@partner.samsung.com>2016-07-27 09:48:10 +0200
committerRobert Sipka <rsipka.uszeged@partner.samsung.com>2016-07-28 12:29:55 +0200
commitddab1d815268aa41d1177f79fdf780a34d8750d8 (patch)
tree1ef1d17d61a1a398b98a3c8ab7b55c170e8b4787 /jerry-libc
parent778f3c001e955aac3782b06701f3d3363adb9906 (diff)
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
Diffstat (limited to 'jerry-libc')
-rw-r--r--jerry-libc/CMakeLists.txt157
-rw-r--r--jerry-libc/target/mcu-stubs/jerry-libc-target.c69
2 files changed, 28 insertions, 198 deletions
diff --git a/jerry-libc/CMakeLists.txt b/jerry-libc/CMakeLists.txt
index 1bee1217..3b7e2b8b 100644
--- a/jerry-libc/CMakeLists.txt
+++ b/jerry-libc/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.
@@ -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()
-
-# Platform-specific configuration
- set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_${PLATFORM}})
-
-# Targets declaration
- add_custom_target (jerry-libc-all)
+endif()
- string(TOLOWER ${PLATFORM_EXT} PLATFORM_L)
- set(TARGET_NAME jerry-libc.${PLATFORM_L})
+# Include directories
+set(INCLUDE_LIBC "${CMAKE_CURRENT_SOURCE_DIR}")
- 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}})
+# Sources
+file(GLOB SOURCE_LIBC *.c)
- # 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)
+# 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()
- # 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()
+add_library(${JERRY_LIBC_NAME} STATIC ${SOURCE_LIBC} ${TARGET_SPECIFIC_LIBC_SOURCE})
- 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")
diff --git a/jerry-libc/target/mcu-stubs/jerry-libc-target.c b/jerry-libc/target/mcu-stubs/jerry-libc-target.c
deleted file mode 100644
index 0a9e9ad7..00000000
--- a/jerry-libc/target/mcu-stubs/jerry-libc-target.c
+++ /dev/null
@@ -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 */