diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000..a80796b441 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,71 @@ +cmake_minimum_required(VERSION 2.6) +project(node) + +# +# options +# + +option(SHARED_V8 "use system shared V8 library") +option(SHARED_LIBEV "use system shared libev library") +option(SHARED_CARES "use system shared c-ares library") +option(V8_SNAPSHOT "turn on snapshot when building stock v8") + + +# cmake policies to get rid of some warnings +cmake_policy(SET CMP0009 NEW) + +# generic cmake configuration +include("cmake/configure.cmake") + +# find and configure libs +include("cmake/libs.cmake") + +# setup node build targets +include("cmake/node_build.cmake") + +# setup v8 build targets +include("cmake/v8_build.cmake") + +# docs +include("cmake/docs.cmake") + +# tests +include("cmake/tests.cmake") + +# package +include("cmake/package.cmake") + + +# +# Final build configuration output +# + +message("** Build Summary **") +message(" Version: ${node_version_string}") +message(" Prefix: ${PREFIX}") +message(" Build Type: ${CMAKE_BUILD_TYPE}") +message(" Architecture: ${CMAKE_SYSTEM_PROCESSOR}") + +if(SHARED_V8) +message(" V8: ${V8_LIBRARY_PATH}") +#else() +#message(" V8 jobs: ${parallel_jobs}") +endif() + +if(SHARED_libev) + message(" libev: ${LIBEV_LIBRARY}") +endif() + +if(SHARED_CARES) + message(" libc-ares: ${LIBCARES_LIBRARY}") +endif() + +message(" RT library: ${RT}") +message(" DL library: ${DL}") + +if(${OPENSSL_FOUND} MATCHES TRUE) + message(" OpenSSL: Found!") +endif() + +# message(" CCFLAGS: ${CCFLAGS}") +# message(" CPPFLAGS: ${CPPFLAGS}") diff --git a/cmake/CTestCustom.cmake b/cmake/CTestCustom.cmake new file mode 100644 index 0000000000..65af3254c1 --- /dev/null +++ b/cmake/CTestCustom.cmake @@ -0,0 +1,2 @@ +set(CTEST_CUSTOM_PRE_TEST "sh -c \"rm -rf ../test/tmp && mkdir ../test/tmp\"") +set(CTEST_CUSTOM_POST_TEST ${CTEST_CUSTOM_PRE_TEST}) diff --git a/cmake/configure.cmake b/cmake/configure.cmake new file mode 100644 index 0000000000..2a4cf10d9a --- /dev/null +++ b/cmake/configure.cmake @@ -0,0 +1,93 @@ +# +# configure node for building +# +include(CheckFunctionExists) + + +if(NOT "v${CMAKE_BUILD_TYPE}" MATCHES vDebug) + set(CMAKE_BUILD_TYPE "Release") +endif() + +string(TOLOWER ${CMAKE_SYSTEM_NAME} node_platform) + +# Get system architecture +if(${CMAKE_SYSTEM_PROCESSOR} MATCHES i686*) + set(node_arch x86) +elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES i386*) + set(node_arch x86) +else() + set(node_arch ${CMAKE_SYSTEM_PROCESSOR}) +endif() + +if(${node_arch} MATCHES unknown) + set(node_arch x86) +endif() + + +# Copy tools directory for out-of-source build +string(COMPARE EQUAL $(PROJECT_BINARY_DIR) ${PROJECT_SOURCE_DIR} in_source_build) +if(NOT ${in_source_build}) + execute_process(COMMAND cmake -E copy_directory ${PROJECT_SOURCE_DIR}/tools ${PROJECT_BINARY_DIR}/tools) +endif() + +# Set some compiler/linker flags.. +set(CMAKE_C_FLAGS_DEBUG "-O0 -Wall -g -Wextra -DDEBUG $ENV{CFLAGS}") +set(CMAKE_CXX_FLAGS_DEBUG "-O0 -Wall -g -Wextra -DDEBUG $ENV{CXXFLAGS}") + +set(CMAKE_C_FLAGS_RELEASE "-g -O3 -DNDEBUG $ENV{CFLAGS}") +set(CMAKE_CXX_FLAGS_RELEASE "-g -O3 -DNDEBUG $ENV{CXXFLAGS}") + +if(${node_platform} MATCHES sunos) + # shouldn't this be added to CMAE_C_FLAGS or something? + add_definitions(-threads) +elseif(NOT ${node_platform} MATCHES cygwin*) + # shouldn't this be added to CMAE_C_FLAGS or something? + add_definitions(-pthread) + set(CMAKE_C_FLAGS -rdynamic) + set(CMAKE_EXE_LINKER_FLAGS -pthread) +endif() + +if(${node_platform} MATCHES darwin) + set(CMAKE_EXE_LINKER_FLAGS "-framework Carbon") +endif() + +check_function_exists(fdatasync HAVE_FDATASYNC) +if(HAVE_FDATASYNC) + add_definitions(-DHAVE_FDATASYNC=1) +else() + add_definitions(-DHAVE_FDATASYNC=0) +endif() + +add_definitions( + -DPLATFORM=${node_platform} + -DX_STACKSIZE=65536 + -D_LARGEFILE_SOURCE + -D_FILE_OFFSET_BITS=64 + -DEV_MULTIPLICITY=0 + ) + +# set the exec output path to be compatible with the current waf build system +if(${CMAKE_BUILD_TYPE} MATCHES Debug) + set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/debug/) +else() + set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/default/) +endif() + +# +## --------------------------------------------------------- +# + +file(GLOB js2c_files ${PROJECT_SOURCE_DIR}/lib/*.js) +set(js2c_files ${PROJECT_SOURCE_DIR}/src/node.js ${js2c_files}) +file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/src) + +set(PREFIX ${CMAKE_INSTALL_PREFIX}) +if(${CMAKE_BUILD_TYPE} MATCHES Debug) + set(CCFLAGS "${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_FLAGS}") +else() + set(CCFLAGS "${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_FLAGS}") +endif() +get_directory_property(compile_defs COMPILE_DEFINITIONS) +foreach(def ${compile_defs}) + set(CPPFLAGS "${CPPFLAGS} -D${def}") +endforeach() diff --git a/cmake/docs.cmake b/cmake/docs.cmake new file mode 100644 index 0000000000..dcf37e0406 --- /dev/null +++ b/cmake/docs.cmake @@ -0,0 +1,80 @@ +# +# docs +# + +file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/doc) + +set(node_binary ${PROJECT_BINARY_DIR}/default/node) +set(doctool tools/doctool/doctool.js) +set(changelog_html ${PROJECT_BINARY_DIR}/doc/changelog.html) + +file(GLOB_RECURSE doc_sources RELATIVE ${PROJECT_SOURCE_DIR} doc/*) + +foreach(FILE ${doc_sources}) + string(REGEX REPLACE "(.*)api_assets(.*)" "\\1api/assets\\2" OUT_FILE ${FILE}) + add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/${OUT_FILE} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/${FILE} ${PROJECT_BINARY_DIR}/${OUT_FILE} + DEPENDS ${PROJECT_SOURCE_DIR}/${FILE} + ) + list(APPEND doc_sources_copy ${PROJECT_BINARY_DIR}/${OUT_FILE}) +endforeach() + +file(GLOB_RECURSE api_markdown RELATIVE ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/doc/api/*) + +foreach(file ${api_markdown}) + string(REGEX REPLACE "(.*)\\.markdown" "\\1" tmp ${file}) + set(api_basenames ${api_basenames} ${tmp}) +endforeach() + +foreach(api ${api_basenames}) + set(api_html ${api_html} ${PROJECT_BINARY_DIR}/${api}.html) + add_custom_command( + OUTPUT "${PROJECT_BINARY_DIR}/${api}.html" + COMMAND ${node_binary} ${doctool} ${PROJECT_BINARY_DIR}/doc/template.html "${PROJECT_BINARY_DIR}/${api}.markdown" > "${PROJECT_BINARY_DIR}/${api}.html" + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + DEPENDS node ${doctool} ${doc_sources_copy} + VERBATIM + ) +endforeach() + +add_custom_target( + doc + DEPENDS node ${doc_sources_copy} ${api_html} ${changelog_html} + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + ) + +#add_custom_command( +# OUTPUT ${PROJECT_BINARY_DIR}/doc/api.html +# COMMAND ${PROJECT_BINARY_DIR}/default/node tools/ronnjs/bin/ronn.js --fragment doc/api.markdown +# | sed "s/

\\\(.*\\\)<\\/h2>/

\\1<\\/h2>/g" +# | cat doc/api_header.html - doc/api_footer.html > ${PROJECT_BINARY_DIR}/doc/api.html +# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} +# DEPENDS node doc/api.markdown doc/api_header.html doc/api_footer.html +# VERBATIM +# ) + +add_custom_command( + OUTPUT ${changelog_html} + COMMAND ${node_binary} ${doctool} doc/template.html ChangeLog + | sed "s|assets/|api/assets/|g" + | sed "s|||g" > ${changelog_html} + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + DEPENDS ChangeLog node ${doctool} ${doc_sources_copy} + VERBATIM + ) + +#add_custom_command( +# OUTPUT ${PROJECT_BINARY_DIR}/doc/changelog.html +# COMMAND cat doc/changelog_header.html ChangeLog doc/changelog_footer.html > ${PROJECT_BINARY_DIR}/doc/changelog.html +# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} +# DEPENDS ChangeLog doc/changelog_header.html doc/changelog_footer.html +# VERBATIM +# ) + +#add_custom_command( +# OUTPUT ${PROJECT_BINARY_DIR}/doc/node.1 +# COMMAND ${PROJECT_BINARY_DIR}/default/node tools/ronnjs/bin/ronn.js --roff doc/api.markdown > ${PROJECT_BINARY_DIR}/doc/node.1 +# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} +# DEPENDS node doc/api.markdown tools/ronnjs/bin/ronn.js +# VERBATIM +# ) diff --git a/cmake/libc-ares.cmake b/cmake/libc-ares.cmake new file mode 100644 index 0000000000..939864aceb --- /dev/null +++ b/cmake/libc-ares.cmake @@ -0,0 +1,18 @@ +if(SHARED_CARES) + find_library(LIBCARES_LIBRARY NAMES cares) + find_path(LIBCARES_INCLUDE_DIR ares.h + PATH_SUFFIXES include + ) # Find header + find_package_handle_standard_args(libcares DEFAULT_MSG LIBCARES_LIBRARY LIBCARES_INCLUDE_DIR) +else() + set(cares_arch ${node_arch}) + + if(${node_arch} MATCHES x86_64) + set(cares_arch x64) + elseif(${node_arch} MATCHES x86) + set(cares_arch ia32) + endif() + + add_subdirectory(deps/c-ares) + set(LIBCARES_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/deps/c-ares ${CMAKE_SOURCE_DIR}/deps/c-ares/${node_platform}-${cares_arch}) +endif() diff --git a/cmake/libev.cmake b/cmake/libev.cmake new file mode 100644 index 0000000000..5905175f57 --- /dev/null +++ b/cmake/libev.cmake @@ -0,0 +1,10 @@ +if(SHARED_LIBEV) + find_library(LIBEV_LIBRARY NAMES ev) + find_path(LIBEV_INCLUDE_DIR ev.h + PATH_SUFFIXES include/ev include + ) # Find header + find_package_handle_standard_args(libev DEFAULT_MSG LIBEV_LIBRARY LIBEV_INCLUDE_DIR) +else() + add_subdirectory(deps/libev) + set(LIBEV_INCLUDE_DIR deps/libev) +endif() diff --git a/cmake/libs.cmake b/cmake/libs.cmake new file mode 100644 index 0000000000..e953bbe327 --- /dev/null +++ b/cmake/libs.cmake @@ -0,0 +1,39 @@ +# +# libraries +# + +include(FindPackageHandleStandardArgs) +set(HAVE_CONFIG_H True) +add_definitions(-DHAVE_CONFIG_H=1) + +find_package(OpenSSL QUIET) +find_package(Threads) +find_library(RT rt) +find_library(DL dl) + +if(RT) + set(extra_libs ${extra_libs} ${RT}) +endif() + +if(DL) + set(extra_libs ${extra_libs} ${DL}) +endif() + +if(${node_platform} MATCHES freebsd) + find_library(KVM NAMES kvm) + set(extra_libs ${extra_libs} KVM) +endif() + +if(${OPENSSL_FOUND} MATCHES True) + add_definitions(-DHAVE_OPENSSL=1) + set(HAVE_OPENSSL True) + set(node_extra_src ${node_extra_src} src/node_crypto.cc) + set(extra_libs ${extra_libs} ${OPENSSL_LIBRARIES}) +endif() + +include("cmake/libc-ares.cmake") +include("cmake/libev.cmake") +include("cmake/libv8.cmake") + +add_subdirectory(deps/libeio) +add_subdirectory(deps/http_parser) diff --git a/cmake/libv8.cmake b/cmake/libv8.cmake new file mode 100644 index 0000000000..21d741081a --- /dev/null +++ b/cmake/libv8.cmake @@ -0,0 +1,15 @@ +set(V8_INCLUDE_NAMES v8.h v8-debug.h v8-profiler.h) +set(V8_LIBRARY_NAMES v8) + +if(SHARED_V8) + find_path(V8_INCLUDE_DIR NAMES ${V8_INCLUDE_NAMES}) + find_library(V8_LIBRARY_PATH NAMES ${V8_LIBRARY_NAMES} NO_CMAKE_PATH) +else() + set(V8_INCLUDE_DIR "${PROJECT_BINARY_DIR}/deps/v8/include") + if(${CMAKE_BUILD_TYPE} MATCHES Debug) + set(v8_fn "libv8_g.a") + else() + set(v8_fn "libv8.a") + endif() + set(V8_LIBRARY_PATH "${PROJECT_BINARY_DIR}/deps/v8/${v8_fn}") +endif() diff --git a/cmake/node_build.cmake b/cmake/node_build.cmake new file mode 100644 index 0000000000..f98aa103bf --- /dev/null +++ b/cmake/node_build.cmake @@ -0,0 +1,76 @@ +# +# node build stuff +# + +add_custom_command( + OUTPUT ${PROJECT_BINARY_DIR}/src/node_natives.h + COMMAND tools/js2c.py ${PROJECT_BINARY_DIR}/src/node_natives.h ${js2c_files} + DEPENDS ${js2c_files}) + +set(node_extra_src "src/platform_${node_platform}.cc") + +if(NOT EXISTS ${CMAKE_SOURCE_DIR}/${node_extra_src}) + set(node_extra_src "src/platform_none.cc") +endif() + +set(node_sources + src/node_main.cc + src/node.cc + src/node_buffer.cc + src/node_javascript.cc + src/node_extensions.cc + src/node_http_parser.cc + src/node_net.cc + src/node_io_watcher.cc + src/node_child_process.cc + src/node_constants.cc + src/node_cares.cc + src/node_events.cc + src/node_file.cc + src/node_signal_watcher.cc + src/node_stat_watcher.cc + src/node_stdio.cc + src/node_timer.cc + src/node_script.cc + src/node_natives.h + ${node_extra_src}) + +configure_file(src/node_config.h.in ${PROJECT_BINARY_DIR}/src/node_config.h) +configure_file(config.h.cmake ${PROJECT_BINARY_DIR}/config.h) + +include_directories( + src + deps/libeio + deps/http_parser + ${V8_INCLUDE_DIR} + ${LIBEV_INCLUDE_DIR} + ${LIBCARES_INCLUDE_DIR} + + ${PROJECT_BINARY_DIR} + ${PROJECT_BINARY_DIR}/src +) + +add_executable(node ${node_sources}) +set_target_properties(node PROPERTIES DEBUG_POSTFIX "_g") +target_link_libraries(node + ev + eio + cares + http_parser + ${V8_LIBRARY_PATH} + ${CMAKE_THREAD_LIBS_INIT} + ${extra_libs}) + + +install(TARGETS node RUNTIME DESTINATION bin) +install(FILES + ${PROJECT_BINARY_DIR}/config.h + src/node.h + src/node_object_wrap.h + src/node_buffer.h + src/node_events.h + src/node_version.h + ${PROJECT_BINARY_DIR}/src/node_config.h + + DESTINATION include/node +) diff --git a/cmake/package.cmake b/cmake/package.cmake new file mode 100644 index 0000000000..aeca62100d --- /dev/null +++ b/cmake/package.cmake @@ -0,0 +1,33 @@ +# +# package +# + +if(${node_platform} MATCHES darwin) + set(CPACK_GENERATOR "TGZ;PackageMaker") + # CPack requires the files to end in .txt + configure_file(LICENSE ${PROJECT_BINARY_DIR}/LICENSE.txt COPYONLY) + configure_file(ChangeLog ${PROJECT_BINARY_DIR}/ChangeLog.txt COPYONLY) + set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_BINARY_DIR}/LICENSE.txt") + set(CPACK_RESOURCE_FILE_README "${PROJECT_BINARY_DIR}/ChangeLog.txt") + #set(CPACK_RESOURCE_FILE_WELCOME "") +else() + set(CPACK_GENERATOR "TGZ;DEB;RPM") +endif() +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Tom Hughes ") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Evented I/O for V8 JavaScript.") +set(CPACK_PACKAGE_DESCRIPTION "Node's goal is to provide an easy way to + build scalable network programs. + + Node is similar in design to and influenced by systems like Ruby's Event + Machine or Python's Twisted. Node takes the event model a bit further—it + presents the event loop as a language construct instead of as a library.") +set(CPACK_DEBIAN_PACKAGE_SECTION "web") +file(READ ${PROJECT_SOURCE_DIR}/src/node_version.h node_version_h LIMIT 1024 OFFSET 0) +string(REGEX REPLACE ".*NODE_MAJOR_VERSION[ ]*([0-9]+).*" "\\1" CPACK_PACKAGE_VERSION_MAJOR "${node_version_h}") +string(REGEX REPLACE ".*NODE_MINOR_VERSION[ ]*([0-9]+).*" "\\1" CPACK_PACKAGE_VERSION_MINOR "${node_version_h}") +string(REGEX REPLACE ".*NODE_PATCH_VERSION[ ]*([0-9]+).*" "\\1" CPACK_PACKAGE_VERSION_PATCH "${node_version_h}") +set(node_version_string "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") + +# Note: this is intentionally at the bottom so that the above CPACK variables +# are used by CPack. +include(CPack) diff --git a/cmake/tests.cmake b/cmake/tests.cmake new file mode 100644 index 0000000000..fb24e44b32 --- /dev/null +++ b/cmake/tests.cmake @@ -0,0 +1,86 @@ +# +# tests +# + +if(${CMAKE_BUILD_TYPE} MATCHES Debug) + set(test_bin_dir debug) + get_target_property(node_bin node DEBUG_LOCATION) +else() + set(test_bin_dir default) + get_target_property(node_bin node LOCATION) +endif() + +enable_testing() +file(GLOB_RECURSE node_tests ${CMAKE_SOURCE_DIR}/test/*) + +foreach(test ${node_tests}) + if(test MATCHES ".*/test-[^./\ ]*.\\.js" AND NOT test MATCHES ".*disabled.*" + AND NOT test MATCHES ".*pummel.*") + + # build a fancy name for each test + string(REPLACE ${CMAKE_SOURCE_DIR}/test/ "" test_name ${test}) + string(REPLACE test- "" test_name ${test_name}) + string(REPLACE ".js" "" test_name ${test_name}) + string(REPLACE "/" "-" test_name ${test_name}) + + add_test(${test_name} ${node_bin} ${test}) + endif() +endforeach() + +configure_file(${CMAKE_SOURCE_DIR}/cmake/CTestCustom.cmake ${CMAKE_BINARY_DIR}/CTestCustom.cmake COPYONLY) + +add_custom_command( + TARGET node POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/${test_bin_dir} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${node_bin} ${PROJECT_BINARY_DIR}/${test_bin_dir} + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) + +# this target gets overriden by ctest's test target +# add_custom_target( +# test +# COMMAND python tools/test.py --mode=release simple message +# DEPENDS node +# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} +# ) + +add_custom_target(test-all + COMMAND python tools/test.py --mode=debug,release + DEPENDS node + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + ) + +add_custom_target(test-release + COMMAND python tools/test.py --mode=release + DEPENDS node + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + ) + +add_custom_target(test-debug + COMMAND python tools/test.py --mode=debug + DEPENDS node + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + ) + +add_custom_target(test-message + COMMAND python tools/test.py message + DEPENDS node + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + ) + +add_custom_target(test-simple + COMMAND python tools/test.py simple + DEPENDS node + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + ) + +add_custom_target(test-pummel + COMMAND python tools/test.py pummel + DEPENDS node + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + ) + +add_custom_target(test-internet + COMMAND python tools/test.py internet + DEPENDS node + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + ) diff --git a/cmake/v8_build.cmake b/cmake/v8_build.cmake new file mode 100644 index 0000000000..3f31e35325 --- /dev/null +++ b/cmake/v8_build.cmake @@ -0,0 +1,88 @@ +# +# v8 build stuff +# + +string(TOLOWER ${CMAKE_BUILD_TYPE} v8mode) +set(v8arch ${node_arch}) + +if(${node_arch} MATCHES x86_64) + set(v8arch x64) +elseif(${node_arch} MATCHES x86) + set(v8arch ia32) +endif() + + +if(NOT SHARED_V8) + if(V8_SNAPSHOT) + set(v8snapshot snapshot=on) + endif() + + if(${node_platform} MATCHES darwin) + execute_process(COMMAND hwprefs cpu_count OUTPUT_VARIABLE cpu_count) + elseif(${node_platform} MATCHES linux) + execute_process(COMMAND sh -c "cat /proc/cpuinfo | grep processor | sort | uniq | wc -l" + OUTPUT_VARIABLE cpu_count) + endif() + + if(${cpu_count} GREATER 1) + math(EXPR parallel_jobs ${cpu_count}*2) + else() + set(parallel_jobs 1) + endif() + + add_library(v8 STATIC IMPORTED) + set_property(TARGET v8 + PROPERTY IMPORTED_LOCATION ${PROJECT_BINARY_DIR}/deps/v8/${v8_fn}) + + + + if(CMAKE_VERSION VERSION_GREATER 2.8) + # use ExternalProject for CMake >2.8 + include(ExternalProject) + + ExternalProject_Add(v8_extprj + URL ${PROJECT_SOURCE_DIR}/deps/v8 + + BUILD_IN_SOURCE True + BUILD_COMMAND sh -c "${PROJECT_BINARY_DIR}/tools/scons/scons.py library=static visibility=default ${v8snapshot} mode=${v8mode} verbose=on arch=${v8arch} -j ${parallel_jobs}" + + SOURCE_DIR ${PROJECT_BINARY_DIR}/deps/v8 + # ignore this stuff, it's not needed for building v8 but ExternalProject + # demands these steps + + CONFIGURE_COMMAND "true" # fake configure + INSTALL_COMMAND "true" # fake install + ) + + add_dependencies(node v8_extprj) + else(CAMKE_VERSION VERSION_GREATER 2.8) + # copy v8 sources inefficiently with CMake versions <2.8 + file(GLOB_RECURSE v8_sources RELATIVE ${PROJECT_SOURCE_DIR} deps/v8/*) + + if(NOT ${in_source_build}) + file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/deps/v8) + + foreach(FILE ${v8_sources}) + add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/${FILE} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/${FILE} ${PROJECT_BINARY_DIR}/${FILE} + DEPENDS ${PROJECT_SOURCE_DIR}/${FILE} + ) + list(APPEND v8_sources_dest ${PROJECT_BINARY_DIR}/${FILE}) + endforeach() + else() + set(v8_sources_dest ${v8_sources}) + endif() + + add_custom_command( + OUTPUT ${PROJECT_BINARY_DIR}/deps/v8/${v8_fn} + COMMAND ${PROJECT_BINARY_DIR}/tools/scons/scons.py library=static visibility=default ${v8snapshot} mode=${v8mode} verbose=on arch=${v8arch} -j ${parallel_jobs} + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/deps/v8/ + DEPENDS ${v8_sources_dest} + ) + + add_custom_target(v8_stock ALL DEPENDS ${PROJECT_BINARY_DIR}/deps/v8/${v8_fn}) + set_property(TARGET v8 PROPERTY + IMPORTED_LOCATION ${PROJECT_BINARY_DIR}/deps/v8/${v8_fn}) + add_dependencies(node v8_stock) + endif() +endif() diff --git a/config.h.cmake b/config.h.cmake new file mode 100644 index 0000000000..2269c59d83 --- /dev/null +++ b/config.h.cmake @@ -0,0 +1,2 @@ +#cmakedefine HAVE_OPENSSL 1 +#cmakedefine HAVE_CONFIG_H 1 diff --git a/deps/c-ares/CMakeLists.txt b/deps/c-ares/CMakeLists.txt new file mode 100644 index 0000000000..98be04a376 --- /dev/null +++ b/deps/c-ares/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${node_platform}-${cares_arch}) +add_definitions(-DHAVE_CONFIG_H=1) + +file(GLOB lib_sources *.c) +add_library(cares ${lib_sources}) \ No newline at end of file diff --git a/deps/http_parser/CMakeLists.txt b/deps/http_parser/CMakeLists.txt new file mode 100644 index 0000000000..7dd9fd2c31 --- /dev/null +++ b/deps/http_parser/CMakeLists.txt @@ -0,0 +1,2 @@ +include_directories (.) +add_library (http_parser http_parser.c) \ No newline at end of file diff --git a/deps/libeio/CMakeLists.txt b/deps/libeio/CMakeLists.txt new file mode 100644 index 0000000000..78224db75c --- /dev/null +++ b/deps/libeio/CMakeLists.txt @@ -0,0 +1,27 @@ +include(CheckFunctionExists) +include(FindThreads) + +if(!${CMAKE_USE_PTHREADS_INIT}) + message(FATAL_ERROR "Unable to find pthreads") +endif() + +include_directories(${platform}) +add_definitions(-DHAVE_CONFIG_H=1 -D_GNU_SOURCE) + +check_function_exists(futimes HAVE_FUTIMES) +check_function_exists(readahead HAVE_READAHEAD) +check_function_exists(fdatasync HAVE_FDATASYNC) +check_function_exists(pread HAVE_PREAD) +check_function_exists(pwrite HAVE_PWRITE) +check_function_exists(sendfile HAVE_SENDFILE) +check_function_exists(sync_file_range HAVE_SYNC_FILE_RANGE) + +if(${HAVE_PREAD} AND ${HAVE_PWRITE}) + set(HAVE_PREADWRITE 1) +endif() + +configure_file(config.h.cmake ${PROJECT_BINARY_DIR}/deps/libeio/config.h) +include_directories(${PROJECT_BINARY_DIR}/deps/libeio) + +add_library(eio eio.c) +target_link_libraries(eio ${CMAKE_THREAD_LIBS_INIT}) diff --git a/deps/libeio/config.h.cmake b/deps/libeio/config.h.cmake new file mode 100644 index 0000000000..c4c128ce30 --- /dev/null +++ b/deps/libeio/config.h.cmake @@ -0,0 +1,17 @@ +/* futimes(2) is available */ +#cmakedefine HAVE_FUTIMES 1 + +/* readahead(2) is available (linux) */ +#cmakedefine HAVE_READAHEAD 1 + +/* fdatasync(2) is available */ +#cmakedefine HAVE_FDATASYNC 1 + +/* pread(2) and pwrite(2) are available */ +#cmakedefine HAVE_PREADWRITE 1 + +/* sendfile(2) is available and supported */ +#cmakedefine HAVE_SENDFILE 1 + +/* sync_file_range(2) is available */ +#cmakedefine HAVE_SYNC_FILE_RANGE 1 diff --git a/deps/libev/CMakeLists.txt b/deps/libev/CMakeLists.txt new file mode 100644 index 0000000000..9c84fc19c2 --- /dev/null +++ b/deps/libev/CMakeLists.txt @@ -0,0 +1,37 @@ +include(CheckIncludeFiles) +include(CheckFunctionExists) +include(CheckLibraryExists) + +#include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${PROJECT_BINARY_DIR}/deps/libev) +add_definitions(-DHAVE_CONFIG_H=1 -DEV_MULTIPLICITY=0) + +check_include_files(sys/inotify.h HAVE_SYS_INOTIFY_H) +check_include_files(sys/epoll.h HAVE_SYS_EPOLL_H) +check_include_files(sys/event.h HAVE_SYS_EVENT_H) +check_include_files(sys/queue.h HAVE_SYS_QUEUE_H) +check_include_files(port.h HAVE_PORT_H) +check_include_files(poll.h HAVE_POLL_H) +check_include_files(sys/select.h HAVE_SYS_SELECT_H) +check_include_files(sys/eventfd.h HAVE_SYS_EVENTFD_H) + +check_function_exists(inotify_init HAVE_INOTIFY_INIT) +check_function_exists(epoll_ctl HAVE_EPOLL_CTL) +check_function_exists(kqueue HAVE_KQUEUE) +check_function_exists(port_create HAVE_PORT_CREATE) +check_function_exists(poll HAVE_POLL) +check_function_exists(select HAVE_SELECT) +check_function_exists(eventfd HAVE_EVENTFD) +check_function_exists(nanosleep HAVE_NANOSLEEP) + +# check first without rt +check_function_exists(clock_gettime HAVE_CLOCK_GETTIME) + +check_library_exists(rt clock_gettime "" HAVE_LIBRT) +# then check with rt +check_library_exists(rt clock_gettime "" HAVE_CLOCK_GETTIME) + +check_library_exists(m ceil "" HAVE_LIBM) + +configure_file(config.h.cmake ${PROJECT_BINARY_DIR}/deps/libev/config.h) +add_library (ev ev.c) diff --git a/deps/libev/config.h.cmake b/deps/libev/config.h.cmake new file mode 100644 index 0000000000..54286b700a --- /dev/null +++ b/deps/libev/config.h.cmake @@ -0,0 +1,65 @@ +/* Define to 1 if you have the `clock_gettime' function. */ +#cmakedefine HAVE_CLOCK_GETTIME 1 + +/* "use syscall interface for clock_gettime" */ +#cmakedefine HAVE_CLOCK_SYSCALL 1 + +/* Define to 1 if you have the `epoll_ctl' function. */ +#cmakedefine HAVE_EPOLL_CTL 1 + +/* Define to 1 if you have the `eventfd' function. */ +#cmakedefine HAVE_EVENTFD 1 + +/* Define to 1 if you have the `inotify_init' function. */ +#cmakedefine HAVE_INOTIFY_INIT 1 + +/* Define to 1 if you have the `kqueue' function. */ +#cmakedefine HAVE_KQUEUE 1 + +/* Define to 1 if you have the `m' library (-lm). */ +#cmakedefine HAVE_LIBM 1 + +/* Define to 1 if you have the `rt' library (-lrt). */ +/* #undef HAVE_LIBRT */ + +/* Define to 1 if you have the `nanosleep' function. */ +#cmakedefine HAVE_NANOSLEEP 1 + +/* Define to 1 if you have the `poll' function. */ +#cmakedefine HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_POLL_H 1 + +/* Define to 1 if you have the `port_create' function. */ +#cmakedefine HAVE_PORT_CREATE 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_PORT_H 1 + +/* Define to 1 if you have the `select' function. */ +#cmakedefine HAVE_SELECT 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_EVENTFD_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_INOTIFY_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_QUEUE_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_SELECT_H 1 + +/* Name of package */ +#define PACKAGE "libev" + +/* Version number of package */ +#define VERSION "3.9" diff --git a/src/node.cc b/src/node.cc index f87e91333d..31f6d3cd2b 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1608,7 +1608,7 @@ static void Load(int argc, char *argv[]) { // process.platform - process->Set(String::NewSymbol("platform"), String::New(PLATFORM)); + process->Set(String::NewSymbol("platform"), String::New("PLATFORM")); // process.argv int i, j; diff --git a/tools/js2c.py b/tools/js2c.py index db4885553b..880ac529d4 100755 --- a/tools/js2c.py +++ b/tools/js2c.py @@ -351,3 +351,11 @@ def JS2C(source, target): 'get_script_name_cases': "".join(get_script_name_cases) }) output.close() + +def main(): + natives = sys.argv[1] + source_files = sys.argv[2:] + JS2C(source_files, [natives]) + +if __name__ == "__main__": + main()