diff --git a/CMakeLists.txt b/CMakeLists.txt index 125269efb38c571babf5e2d417e1e6bd2b5232b6..a8583a66feb71e972772a94a8fbee31e6c58fe0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -391,6 +391,9 @@ message (STATUS "ENABLE_BUNDLED_LIBEIO: ${ENABLE_BUNDLED_LIBEIO}") message (STATUS "ENABLE_BUNDLED_LIBCORO: ${ENABLE_BUNDLED_LIBCORO}") message (STATUS "ENABLE_DOC: ${ENABLE_DOC}") list_optional_packages() +if (TARGET_OS_DARWIN) + message (STATUS "DARWIN_BUILD_TYPE: ${DARWIN_BUILD_TYPE}") +endif() message (STATUS "") message (STATUS "To view or modify configuration results, check out CMakeCache.txt.") message (STATUS "") diff --git a/README.MacOSX b/README.MacOSX index a2161320ccd978f8738f1a3a1de5d2385b592abb..cf24c08f1f4e88e6cdc31b4e7b33482b824daba9 100644 --- a/README.MacOSX +++ b/README.MacOSX @@ -2,7 +2,11 @@ OS X Readme =========== This manual explains how to manually build tarantool from sources. -If you just need a working binary, please use homebrew: + +Supporting kinds of build with default Apple developer software and external as +homebrew as MacPorts. + +If you want to build at the Homebrew environment execute just: brew install http://tarantool.org/dist/tarantool.rb @@ -13,9 +17,17 @@ First of all, make sure mac ports are available (to install packages from). 1. Install necessary packages (ports): ------------- -port install autoconf binutils cmake ncurses zlib readline +Default build depended by Developer tools by Apple and -DDARWIN_BUILD_TYPE=None: + + sudo xcode-select --install + sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer + +To enable build type with MacPorts set up the flag -DDARWIN_BUILD_TYPE=Ports: + + port install autoconf binutils cmake ncurses zlib readline 2. Upgrade clang to 3.2+ +------------- Go to http://developer.apple.com/ to download and install the latest version of "Command Line Tools for Xcode". This package contains /usr/bin/clang and @@ -36,10 +48,16 @@ the directory the module's archive deflates into. 4. Download & build tarantool source code: ------------- +NOTE: If you want to get DMG package go to section 6. + git clone --recursive git://github.com/tarantool/tarantool.git cd tarantool -CC=clang CXX=clang++ cmake . -DCMAKE_BUILD_TYPE=RelWithDebugInfo -DENABLE_CLIENT=true +mkdir build && cd build +CC=clang CXX=clang++ cmake .. \ + -DCMAKE_BUILD_TYPE=RelWithDebugInfo \ + -DENABLE_CLIENT=true \ + -DDARWIN_BUILD_TYPE=Ports make 5. Run tarantool test suite @@ -59,5 +77,28 @@ To run all tests then, execute: cd ~/build/tarantool/test ./run +6. Build DMG package +------------- + +Building DMG depended by "Auxiliary Tools for Xcode", which be able to download from: + +https://developer.apple.com (necessary login with Apple ID account). + +Execute commands to get DMG package by root (if you not root you'll get files with incorrect permissions): + +mkdir build && cd build +sudo -s +cmake .. \ + -DCMAKE_INSTALL_PREFIX=/usr/local \ + -DCMAKE_BUILD_TYPE=Rel \ + -DENABLE_BACKTRACE=OFF \ + -DCMAKE_C_COMPILER="clang" \ + -DCMAKE_CXX_COMPILER="clang++" \ + -DDARWIN_BUILD_TYPE=None \ + -DENABLE_CLIENT=ON + +make package + + -- EOF diff --git a/cmake/os.cmake b/cmake/os.cmake index 93b77a6d72db46dbd4ea4383551fa862b383fccf..35a1df12c4778a06ea21db07e9f1449415219776 100644 --- a/cmake/os.cmake +++ b/cmake/os.cmake @@ -23,9 +23,23 @@ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") message(STATUS "Building for FreeBSD") elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") set(TARGET_OS_DARWIN 1) - # Mac ports get installed into /opt/local, hence: - include_directories("/opt/local/include") - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/local/lib") + +# +# Default build type is None, which uses depends by Apple +# command line tools. Also supportting install with MacPorts. +# + if (NOT DARWIN_BUILD_TYPE) + set(DARWIN_BUILD_TYPE None CACHE STRING + "Choose the type of Darwin build, options are: None, Ports." + FORCE) + endif() + + if (${DARWIN_BUILD_TYPE} STREQUAL "Ports") + # Mac ports get installed into /opt/local, hence: + include_directories("/opt/local/include") + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/local/lib") + endif() + message(STATUS "Building for Mac OS X") else() message (FATAL_ERROR "Unsupported platform -- ${CMAKE_SYSTEM_NAME}") diff --git a/cmake/package.cmake b/cmake/package.cmake index 675d662221c16a7d8eef35f29a2ae5d2b2e7fe2f..66e0c4762197a507baea232bf09d75e3e0ad20fd 100644 --- a/cmake/package.cmake +++ b/cmake/package.cmake @@ -59,5 +59,17 @@ if (${CMAKE_BUILD_TYPE} STREQUAL "Debug") set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-debug") endif() + +if (${TARGET_OS_DARWIN}) + set (CPACK_GENERATOR "PackageMaker") + set (CPACK_SOURCE_GENERATOR "PackageMaker") + set (CPACK_PACKAGE_VENDOR "tarantool") + set (CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) + set (CPACK_POSTFLIGHT_SCRIPT "${CMAKE_BINARY_DIR}/extra/postflight") + set (CPACK_RESOURCE_FILE_WELCOME "${PROJECT_SOURCE_DIR}/extra/dmg/DESCRIPTION.rtf") + set (CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/extra/dmg/README.rtf") + set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/extra/dmg/LICENSE.rtf") +endif() + ## include (CPack) diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt index 05cd37454046b911f33717b8b6c06410bc83330f..bed63b73277250d3998d65e764420f792dc5e136 100644 --- a/extra/CMakeLists.txt +++ b/extra/CMakeLists.txt @@ -25,4 +25,27 @@ endif() configure_file(rpm.spec.in rpm.spec @ONLY) +if (TARGET_OS_DARWIN) + # NOTE: need add execution 'plutil -lint org.tarantool.tarantool_${TARANTOOL_PRODUCT}.plist + # to check syntax of plist file. + # Also cmake doesn't support changing package id from 'com.' to 'org.' + # Need chage to 'org.' after update lines this file: + # https://github.com/Kitware/CMake/blob/v2.8.11.2/Source/CPack/cmCPackPackageMakerGenerator.cxx#L763 + # + # ^^^ DO NOT CHANGE DARWIN_PACKAGE_ID BEFORE SEE URL ABOVE ^^^ + # + set (DARWIN_PACKAGE_ID "com") + set (LUANCHD_PLIST "${DARWIN_PACKAGE_ID}.${CPACK_PACKAGE_VENDOR}.tarantool_${TARANTOOL_PRODUCT}.plist") + # Configure scripts for *.pkg and luanchd daemon by templates + configure_file(dmg/postflight.in postflight @ONLY) + configure_file(org.tarantool.in ${LUANCHD_PLIST} @ONLY) + # chmod +x 644 + install (FILES ${CMAKE_BINARY_DIR}/extra/${LUANCHD_PLIST} + DESTINATION share/tarantool + PERMISSIONS + OWNER_READ OWNER_WRITE + GROUP_READ GROUP_READ + WORLD_READ WORLD_READ) +endif() + add_executable(txt2c txt2c.c) diff --git a/extra/dmg/DESCRIPTION.rtf b/extra/dmg/DESCRIPTION.rtf new file mode 100644 index 0000000000000000000000000000000000000000..de1a8e045d43e49e76c7a0c451d651fdab13a58f --- /dev/null +++ b/extra/dmg/DESCRIPTION.rtf @@ -0,0 +1,26 @@ +{\rtf1\ansi\ansicpg1252\cocoartf1265 +{\fonttbl\f0\froman\fcharset0 Times-Roman;} +{\colortbl;\red255\green255\blue255;\red0\green41\blue57;} +{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid1}} +{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}} +\margl1440\margr1440\vieww10800\viewh8400\viewkind0 +\deftab720 +\pard\pardeftab720\sl480\sa321 + +\f0\b\fs30 \cf2 Tarantool +\fs24 \ +\pard\pardeftab720\sa380 + +\b0 \cf2 Tarantool is an in-memory database designed to store the most volatile and highly accessible web content. Tarantool has been extensively used in production since 2009. It's +\b open source +\b0 , BSD licensed.\ +\pard\pardeftab720\sa241 + +\b \cf2 Features\ +\pard\tx220\tx720\pardeftab720\li720\fi-720 +\ls1\ilvl0 +\b0 \cf2 {\listtext \'95 }{\field{\*\fldinst{HYPERLINK "http://tarantool.org/benchmark.html"}}{\fldrslt \ul lowest CPU overhead}} to store or serve a piece of content,\ +{\listtext \'95 }optional Write Ahead Logging for persistency and reliability,\ +{\listtext \'95 }universal data access with {\field{\*\fldinst{HYPERLINK "http://github.com/mailru/tntlua"}}{\fldrslt \ul rich Lua stored procedures}}, which can exchange messages between each other or networked peers,\ +{\listtext \'95 }asynchronous master-slave replication and hot backup.\ +} \ No newline at end of file diff --git a/extra/dmg/LICENSE.rtf b/extra/dmg/LICENSE.rtf new file mode 100644 index 0000000000000000000000000000000000000000..3b0f4bdfc2a749e2d910b2d540d34873a76b1cb4 --- /dev/null +++ b/extra/dmg/LICENSE.rtf @@ -0,0 +1,23 @@ +{\rtf1\ansi\ansicpg1252\cocoartf1265 +{\fonttbl\f0\fswiss\fcharset0 Helvetica;} +{\colortbl;\red255\green255\blue255;\red0\green41\blue57;} +\margl1440\margr1440\vieww10800\viewh8400\viewkind0 +\deftab720 +\pard\pardeftab720 + +\f0\fs24 \cf2 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\ +\ +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\ +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\ +\ +THIS SOFTWARE IS PROVIDED BY AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\ +\ +Copyright (C) 2010-2013 Tarantool AUTHORS:\ +\ +Aleksey Demakov, Aleksey Mashanov, Alexandre Kalendarev,\ +Damien Lefortier, Dmitry E. Oboukhov, Dmitry Simonenko,\ +Konstantin Osipov, Konstantin Shulgin, Mons Anderson,\ +Pavel Cherenkov, Roman Antipin, Roman Tokarev, Roman Tsisyk,\ +Teodor Sigaev, Timofey Khryukin, Yuriy Nevinitsin, Yuriy Vostrikov\ +Veniamin Gvozdikov\ +} \ No newline at end of file diff --git a/extra/dmg/README.rtf b/extra/dmg/README.rtf new file mode 100644 index 0000000000000000000000000000000000000000..6dd38114b251e5208c53cf81c983e34739ff8673 --- /dev/null +++ b/extra/dmg/README.rtf @@ -0,0 +1,43 @@ +{\rtf1\ansi\ansicpg1252\cocoartf1265 +{\fonttbl\f0\froman\fcharset0 Times-Roman;} +{\colortbl;\red255\green255\blue255;\red26\green26\blue26;\red48\green48\blue48;} +\margl1440\margr1440\vieww12600\viewh7800\viewkind0 +\deftab720 +\pard\pardeftab720\sa298 + +\f0\b\fs24 \cf2 What is Tarantool?\ +\pard\pardeftab720\sa380 + +\b0 \cf2 Tarantool is an in-memory NoSQL database. The code is available for free under the terms of {\field{\*\fldinst{HYPERLINK "http://www.gnu.org/licenses/license-list.html#ModifiedBSD"}}{\fldrslt +\i \ul \ulc3 BSD license}}. Supported platforms are GNU/Linux, Mac OS and FreeBSD.\ +\pard\pardeftab720\sa298 + +\b \cf2 An overview of the architecture\ +\pard\pardeftab720\sa380 + +\b0 \cf2 The server +\b maintains all its data in random-access memory +\b0 , and therefore has very low read latency. At the same time, a copy of the data is kept on non-volatile storage (a disk drive), and inserts and updates are performed atomically.\ +To ensure atomicity, consistency and crash-safety of the persistent copy, a write-ahead log (WAL) is maintained, and each change is recorded in the WAL before it is considered complete. The logging subsystem supports group commit.\ +If update and delete rate is high, a constantly growing write-ahead log file (or files) can pose a disk space problem, and significantly increase time necessary to restart from disk. A simple solution is employed: the server +\b can be requested to save a concise snapshot +\b0 of its current data. The underlying operating system's \'93copy-on-write\'94 feature is employed to take the snapshot in a quick, resource-savvy and non-blocking manner. The \'93copy-on-write\'94 technique guarantees that snapshotting has minimal impact on server performance.\ +\pard\pardeftab720\sa380 + +\b \cf2 Tarantool is lock-free +\b0 . Instead of the operating system's concurrency primitives, such as threads and mutexes, Tarantool uses a cooperative multitasking environment to simultaneously operate on thousands of connections. A fixed number of independent execution threads within the server do not share state, but exchange data using low overhead message queues. While this approach limits server scalability to a few CPU cores, it removes competition for the memory bus and sets the scalability limit to the top of memory and network throughput. CPU utilization of a typical highly-loaded Tarantool server is under 10%.\ +\pard\pardeftab720\sa298 + +\b \cf2 Key features\ +\pard\pardeftab720\sa380 + +\b0 \cf2 Unlike most of NoSQL databases, Tarantool supports primary, +\b secondary keys, multi-part keys +\b0 , HASH, TREE and BITSET index types.\ +Tarantool supports +\b Lua stored procedures +\b0 , which can access and modify data atomically. Procedures can be created, modified and dropped at runtime.\ +Use of Lua as an extension language does not end with stored procedures: Lua programs can be used during startup, to define triggers and background tasks, interact with networked peers. Unlike popular application development frameworks implemented around "reactor" pattern, networking in server-side Lua is sequential, yet very efficient, as is built on top of the cooperating multitasking environment used by the server itself.\ +Extended with Lua, Tarantool typically replaces more not one but a few existing components with a single well-performing system, changing and simplifying complex multi-tier Web application architectures.\ +Tarantool supports replication. Replicas may run locally or on a remote host. Tarantool replication is asynchronous and does not block writes to the master. When or if the master becomes unavailable, the replica can be switched to assume the role of the master without server restart.\ +} \ No newline at end of file diff --git a/extra/dmg/postflight.in b/extra/dmg/postflight.in new file mode 100644 index 0000000000000000000000000000000000000000..a012814545bb9745039f94e770426e290fb938f2 --- /dev/null +++ b/extra/dmg/postflight.in @@ -0,0 +1,22 @@ +#!/usr/bin/env sh + +PLIST_PRODUCT=@LUANCHD_PLIST@ +LUANCHD_PLIST=/Library/LaunchDaemons/${PLIST_PRODUCT} + +if [ -f ${LUANCHD_PLIST} ] +then + launchctl unload ${LUANCHD_PLIST} + rm -f ${LUANCHD_PLIST} +fi + +cp ${3}@CMAKE_INSTALL_PREFIX@/share/tarantool/${PLIST_PRODUCT} ${LUANCHD_PLIST} + +if [ -f ${LUANCHD_PLIST} ] +then + launchctl load ${LUANCHD_PLIST} +else + echo "${LUANCHD_PLIST} could not install" + exit 1 +fi + +exit 0 diff --git a/extra/org.tarantool.in b/extra/org.tarantool.in new file mode 100644 index 0000000000000000000000000000000000000000..86cbb75cdac91383d11b60ef9d9ef99e00768812 --- /dev/null +++ b/extra/org.tarantool.in @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>StandardOutPath</key> + <string>/var/log/tarantool_@TARANTOOL_PRODUCT@.log</string> + <key>StandardErrorPath</key> + <string>/var/log/tarantool_@TARANTOOL_PRODUCT@.log</string> + <key>WorkingDirectory</key> + <string>@CMAKE_INSTALL_PREFIX@</string> + <key>EnvironmentVariables</key> + <dict> + <key>PATH</key> + <string>@CMAKE_INSTALL_PREFIX@/bin:/bin:/sbin:/opt/bin</string> + </dict> + <key>KeepAlive</key> + <dict> + <key>SuccessfulExit</key> + <false/> + </dict> + <key>Label</key> + <string>@DARWIN_PACKAGE_ID@.@CPACK_PACKAGE_VENDOR@.tarantool_@TARANTOOL_PRODUCT@</string> + <key>ProgramArguments</key> + <array> + <string>tarantool_@TARANTOOL_PRODUCT@</string> + <string>--config=@CMAKE_INSTALL_PREFIX@/etc/tarantool.cfg</string> + </array> + <key>RunAtLoad</key> + <true/> +</dict> +</plist> diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 88f26e30f802817c8231269ab53af2b1219ff9c4..023488a2bbc3fcc751694870df0ee6951475e45f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,16 +13,23 @@ add_subdirectory(unit) add_subdirectory(box) add_subdirectory(connector_c) -if (ENABLE_RPM) - install (FILES ${CMAKE_SOURCE_DIR}/test/share/tarantool_rpm.cfg - DESTINATION ${CMAKE_SYSCONF_DIR}/tarantool/ +macro(install_cfg type_cfg dest) + install (FILES ${CMAKE_SOURCE_DIR}/test/share/tarantool_${type_cfg}.cfg + DESTINATION ${dest} RENAME "tarantool.cfg") +endmacro(install_cfg) + +if (ENABLE_RPM) + install_cfg(rpm ${CMAKE_SYSCONF_DIR}/tarantool/) install (FILES ${CMAKE_SOURCE_DIR}/test/box/00000000000000000001.snap DESTINATION share/tarantool) else() - install (FILES ${CMAKE_SOURCE_DIR}/test/share/tarantool_tgz.cfg - DESTINATION "${CMAKE_SYSCONF_DIR}" - RENAME "tarantool.cfg") + if (TARGET_OS_DARWIN) + install_cfg(dmg ${CMAKE_SYSCONF_DIR}) + else() + install_cfg(tgz ${CMAKE_SYSCONF_DIR}) + endif() + install (FILES ${CMAKE_SOURCE_DIR}/test/box/00000000000000000001.snap DESTINATION "${CMAKE_LOCALSTATE_DIR}/lib/tarantool") endif() diff --git a/test/share/tarantool_dmg.cfg b/test/share/tarantool_dmg.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b734433be37b119715789e34dd8e2420a6d84c0e --- /dev/null +++ b/test/share/tarantool_dmg.cfg @@ -0,0 +1,45 @@ +# +# Limit of memory used to store tuples to 100MB +# (0.1 GB) +# This effectively limits the memory, used by +# Tarantool. However, index and connection memory +# is stored outside the slab allocator, hence +# the effective memory usage can be higher (sometimes +# twice as high). +slab_alloc_arena = 0.1 + +# +# Store the pid in this file. Relative to +# startup dir. +pid_file = "/var/run/box.pid" + +# +# Read only and read-write port. +primary_port = 33013 + +# +# Read-only port. +secondary_port = 33014 + +# +# The port for administrative commands. +admin_port = 33015 + +# +# Each write ahead log contains this many rows. +# When the limit is reached, Tarantool closes +# the WAL and starts a new one. +rows_per_wal = 50000 + +# +# Define a simple space with 1 HASH-based +# primary key. +space[0].enabled = 1 +space[0].index[0].type = "HASH" +space[0].index[0].unique = 1 +space[0].index[0].key_field[0].fieldno = 0 +space[0].index[0].key_field[0].type = "NUM" + +# +# working directory (daemon will chdir(2) to it) +work_dir = "var/lib/tarantool"