diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c3db8460..d56180250 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,8 @@ option (BUILD_SHARED "Build rawtherapee with shared libraries" OFF) option (WITH_BZIP "Build with Bzip2 support" ON) option (WITH_MYFILE_MMAP "Build using memory mapped file" ON) option (WITH_LTO "Build with link-time optimizations" OFF) +option (WITH_SAN "Build with run-time sanitizer" OFF) +option (WITH_PROF "Build with profiling instrumentation" OFF) option (OPTION_OMP "Build with OpenMP support" ON) option (STRICT_MUTEX "True (recommended): MyMutex will behave like POSIX Mutex; False: MyMutex will behave like POSIX RecMutex; Note: forced to ON for Debug builds" ON) option (TRACE_MYRWMUTEX "Trace RT's custom R/W Mutex (Debug builds only); redirecting std::out to a file is strongly recommended!" OFF) @@ -274,6 +276,18 @@ if (WITH_LTO) SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto") endif (WITH_LTO) +if (WITH_SAN) + SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${WITH_SAN}") + SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${WITH_SAN}") + SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${WITH_SAN}") +endif (WITH_SAN) + +if (WITH_PROF) + SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") + SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") + SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") +endif (WITH_PROF) + if (OPTION_OMP) find_package(OpenMP) if (OPENMP_FOUND) diff --git a/rtdata/CMakeLists.txt b/rtdata/CMakeLists.txt index 9f6eee693..ad8fe3421 100644 --- a/rtdata/CMakeLists.txt +++ b/rtdata/CMakeLists.txt @@ -57,7 +57,7 @@ if (WIN32) include("${PROJECT_SOURCE_DIR}/ReleaseInfo.cmake") endif (REL_INFO_FILE STREQUAL REL_INFO_FILE-NOTFOUND) - configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/win/InnoSetup/WindowsInnoSetup.iss.in" "${CMAKE_CURRENT_BINARY_DIR}/WindowsInnoSetup.iss") + configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/../tools/win/InnoSetup/WindowsInnoSetup.iss.in" "${CMAKE_CURRENT_BINARY_DIR}/WindowsInnoSetup.iss") install (FILES "${CMAKE_CURRENT_BINARY_DIR}/WindowsInnoSetup.iss" DESTINATION ${BINDIR}) endif (WIN32) @@ -103,8 +103,8 @@ if (APPLE) elseif (PROC_BIT_DEPTH MATCHES 64) list (APPEND MACOSX_BUNDLE_COMMAND PROC_BIT_DEPTH=64) endif (PROC_BIT_DEPTH MATCHES 32) - list (APPEND MACOSX_BUNDLE_COMMAND sh "${PROJECT_SOURCE_DIR}/rtdata/osx/macosx_bundle.sh") - + list (APPEND MACOSX_BUNDLE_COMMAND sh "${PROJECT_SOURCE_DIR}/tools/osx/macosx_bundle.sh") + add_custom_target(macosx_bundle COMMAND ${MACOSX_BUNDLE_COMMAND} WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" diff --git a/rtengine/opthelper.h b/rtengine/opthelper.h index 555ea587c..bee97f6b2 100644 --- a/rtengine/opthelper.h +++ b/rtengine/opthelper.h @@ -69,7 +69,7 @@ #define ALIGNED64 #define ALIGNED16 #endif - #ifndef __clang__ - #define _RT_NESTED_OPENMP _OPENMP + #if !defined(__clang__) && defined _OPENMP + #define _RT_NESTED_OPENMP #endif #endif diff --git a/rtengine/safegtk.cc b/rtengine/safegtk.cc index 844afe40a..053507c3e 100644 --- a/rtengine/safegtk.cc +++ b/rtengine/safegtk.cc @@ -174,7 +174,7 @@ void safe_build_subdir_list (Glib::RefPtr &dir, std::vectorget_file_type() == Gio::FILE_TYPE_DIRECTORY && (!info->is_hidden() || add_hidden)) { subDirs.push_back (info->get_name()); diff --git a/rtgui/imagearea.cc b/rtgui/imagearea.cc index a37aa210d..1cde3ed52 100644 --- a/rtgui/imagearea.cc +++ b/rtgui/imagearea.cc @@ -476,7 +476,13 @@ void ImageArea::addCropWindow () cw->setEditSubscriber (getCurrSubscriber()); cw->enable(); // start processing! - cw->centerCrop(); + { + int anchorX = 0; + int anchorY = 0; + mainCropWindow->getCropAnchorPosition(anchorX, anchorY); + cw->setCropAnchorPosition(anchorX, anchorY); + } + mainCropWindow->setObservedCropWin (cropWins.front()); if(cropWins.size() == 1) { // after first detail window we already have high quality diff --git a/tools/generateSourceTarball b/tools/generateSourceTarball index eb4688037..98173c00f 100755 --- a/tools/generateSourceTarball +++ b/tools/generateSourceTarball @@ -1,16 +1,17 @@ #!/usr/bin/env bash if [[ ! "$1" ]]; then - printf "%s\n" "Usage: $0 " "Example: $0 4.0.10" + printf "%s\n" "Usage: $0 " "Example: $0 4.2" exit fi -hg update "$1" +git checkout "$1" || exit 0 tools/generateReleaseInfo mkdir rawtherapee-"$1" mv ReleaseInfo.cmake rawtherapee-"$1" -hg archive -X ".hg*" -X "rtgui/config.h" -X "rtgui/version.h" -X "rtdata/rawtherapee.desktop" rawtherapee-"$1".tar -tar -rf rawtherapee-"$1".tar rawtherapee-"$1"/ReleaseInfo.cmake +#hg archive -X ".hg*" -X "rtgui/config.h" -X "rtgui/version.h" -X "rtdata/rawtherapee.desktop" rawtherapee-"$1".tar +git archive --format=tar "$1" > rawtherapee-"$1".tar +tar --append --file=rawtherapee-"$1".tar rawtherapee-"$1"/ReleaseInfo.cmake xz -z -9e rawtherapee-"$1".tar rm -r rawtherapee-"$1" -hg update +git checkout diff --git a/rtdata/osx/Info.plist.in b/tools/osx/Info.plist.in similarity index 97% rename from rtdata/osx/Info.plist.in rename to tools/osx/Info.plist.in index 491d2ee85..5b08d63a1 100644 --- a/rtdata/osx/Info.plist.in +++ b/tools/osx/Info.plist.in @@ -111,7 +111,7 @@ CFBundleExecutable rawtherapee CFBundleGetInfoString - @version@, Copyright © 2004-2013 Gábor Horváth + @version@, Copyright © 2004-2010 Gábor Horváth, 2010-2016 RT dev team CFBundleIconFile rawtherapee.icns CFBundleIdentifier diff --git a/rtdata/osx/PkgInfo b/tools/osx/PkgInfo similarity index 100% rename from rtdata/osx/PkgInfo rename to tools/osx/PkgInfo diff --git a/rtdata/osx/executable_loader.in b/tools/osx/executable_loader.in similarity index 89% rename from rtdata/osx/executable_loader.in rename to tools/osx/executable_loader.in index d56cd1dc1..5f1911edb 100644 --- a/rtdata/osx/executable_loader.in +++ b/tools/osx/executable_loader.in @@ -4,7 +4,8 @@ cwd="$(cd "$(dirname "$0")"; pwd)" app="${cwd%/Contents/*}" etc="${cwd}"/etc -# for different os x version (issue 1795) +# for different os x versions +# see https://github.com/Beep6581/RawTherapee/issues/1779 cups_dir=/tmp/RT4 install -d ${cups_dir} cp -f /usr/lib/libcups.2.dylib ${cups_dir} diff --git a/tools/osx/libiconv_1.14_rt.patch b/tools/osx/libiconv_1.14_rt.patch new file mode 100644 index 000000000..7a01b1373 --- /dev/null +++ b/tools/osx/libiconv_1.14_rt.patch @@ -0,0 +1,30 @@ +diff --git a/lib/iconv.c b/lib/iconv.c +index 3785296..24a0f07 100644 +--- a/lib/iconv.c ++++ b/lib/iconv.c +@@ -607,4 +607,25 @@ strong_alias (libiconv, iconv) + strong_alias (libiconv_close, iconv_close) + #endif + ++#undef iconv_open ++#undef iconv ++#undef iconv_close ++ ++LIBICONV_DLL_EXPORTED iconv_t iconv_open (const char* tocode, const char* fromcode) ++{ ++ return libiconv_open(tocode, fromcode); ++} ++ ++LIBICONV_DLL_EXPORTED size_t iconv (iconv_t icd, ++ ICONV_CONST char * * inbuf, size_t *inbytesleft, ++ char * * outbuf, size_t *outbytesleft) ++{ ++ return libiconv(icd, inbuf, inbytesleft, outbuf, outbytesleft); ++} ++ ++LIBICONV_DLL_EXPORTED int iconv_close (iconv_t icd) ++{ ++ return libiconv_close(icd); ++} ++ + #endif diff --git a/rtdata/osx/macosx_bundle.sh b/tools/osx/macosx_bundle.sh similarity index 59% rename from rtdata/osx/macosx_bundle.sh rename to tools/osx/macosx_bundle.sh index 670343b08..411b2d331 100644 --- a/rtdata/osx/macosx_bundle.sh +++ b/tools/osx/macosx_bundle.sh @@ -5,40 +5,47 @@ # these are very important variables. Must be set into rtdata/CMakeLists.txt! # - PROJECT_NAME # - PROJECT_SOURCE_DIR -# - PROJECT_VERSION (if without mercurial) +# - PROJECT_VERSION (if without git) # - CMAKE_BUILD_TYPE # - PROC_BIT_DEPTH # - GTK_PREFIX function message { - printf '\e[34m-- %s\e[m\n' "$*" + printf '\e[34m-- %s\e[m\n' "$*" } + function GetDependencies { - otool -L "$1" | awk 'NR >= 2 && $1 !~ /^(\/usr\/lib|\/System|@executable_path|@rpath)\// { print $1 }' + otool -L "$1" | awk 'NR >= 2 && $1 !~ /^(\/usr\/lib|\/System|@executable_path|@rpath)\// { print $1 }' } + function CheckLink { - GetDependencies "$1" | while read; do - local dest="${LIB}/$(basename "${REPLY}")" - test -f "${dest}" || { ditto --arch ${arch} "${REPLY}" "${dest}"; CheckLink "${dest}"; } - done + GetDependencies "$1" | while read; do + local dest="${LIB}/$(basename "${REPLY}")" + test -f "${dest}" || { ditto --arch ${arch} "${REPLY}" "${dest}"; CheckLink "${dest}"; } + done } # source check if test ! -d "${CMAKE_BUILD_TYPE}"; then - printf "\e[31m${PWD}/${CMAKE_BUILD_TYPE} directory is not found. Please execute 'make install' first.\e[m\n" - exit 1 + printf "\e[31m${PWD}/${CMAKE_BUILD_TYPE} directory is not found. Please execute 'make install' first.\e[m\n" + exit 1 fi # update project version -if test -x $(which hg) -a -d "${PROJECT_SOURCE_DIR}/.hg"; then - PROJECT_VERSION=$(hg -R "${PROJECT_SOURCE_DIR}" parents --template "{latesttag}.{latesttagdistance}") +if test -x "$(which git)" -a -d "${PROJECT_SOURCE_DIR}/.git"; then + # This is what the version ought to look like to be accurate in the git universe: + PROJECT_FULL_VERSION="$(git describe --tags --always)_$(git symbolic-ref --short -q HEAD)" + # outputs: 4.2-677-g904467b_master + # but Apple requirements https://goo.gl/eWDQv6 state we should use this: + PROJECT_VERSION="$(git describe --tags --always | sed -e 's/-g.*//' -e 's/-/./')" + # outputs: 4.2.677 fi # if not specify CMAKE_OSX_DEPLOYMENT_TARGET when compiling, # 'MINIMUM_VERSION' will be used host OS X version. -MINIMUM_SYSTEM_VERSION=$(otool -l "${CMAKE_BUILD_TYPE}"/rawtherapee | grep -A2 'LC_VERSION_MIN_MACOSX' | awk '$1 ~ /version/ { printf $2 }') +MINIMUM_SYSTEM_VERSION="$(otool -l "${CMAKE_BUILD_TYPE}"/rawtherapee | grep -A2 'LC_VERSION_MIN_MACOSX' | awk '$1 ~ /version/ { printf $2 }')" if test ! -n "${MINIMUM_SYSTEM_VERSION}"; then - MINIMUM_SYSTEM_VERSION=$(sw_vers -productVersion | cut -d. -f-2) + MINIMUM_SYSTEM_VERSION="$(sw_vers -productVersion | cut -d. -f-2)" fi # check for pango-querymodules. Pango 1.38.0 and above do not include it. @@ -54,8 +61,8 @@ else fi case ${PROC_BIT_DEPTH} in - 64) arch=x86_64;; - 32) arch=i386;; + 64) arch=x86_64;; + 32) arch=i386;; esac cat <<__EOS__ @@ -82,9 +89,9 @@ rm -rf "${APP}" ${PROJECT_NAME}_*.dmg message "Creating bundle container" install -d "${RESOURCES}" \ - "${MACOS}" \ - "${LIB}" \ - "${ETC}" +"${MACOS}" \ +"${LIB}" \ +"${ETC}" message "Copying release files" ditto "${CMAKE_BUILD_TYPE}" "${MACOS}" @@ -93,9 +100,9 @@ message "Copying dependencies from ${GTK_PREFIX}" CheckLink "${EXECUTABLE}" message "Copying library modules from ${GTK_PREFIX}" -ditto --arch ${arch} {"${GTK_PREFIX}"/lib,"${LIB}"}/gdk-pixbuf-2.0 -ditto --arch ${arch} {"${GTK_PREFIX}"/lib,"${LIB}"}/gtk-2.0 -ditto --arch ${arch} {"${GTK_PREFIX}"/lib,"${LIB}"}/pango +ditto --arch "${arch}" {"${GTK_PREFIX}"/lib,"${LIB}"}/gdk-pixbuf-2.0 +ditto --arch "${arch}" {"${GTK_PREFIX}"/lib,"${LIB}"}/gtk-2.0 +ditto --arch "${arch}" {"${GTK_PREFIX}"/lib,"${LIB}"}/pango message "Removing static libraries and cache files" find -E "${LIB}" -type f -regex '.*\.(a|la|cache)$' | while read; do rm "${REPLY}"; done @@ -106,7 +113,7 @@ cp "${GTK_PREFIX}"/etc/gtk-2.0/im-multipress.conf "${ETC}"/gtk-2.0 "${GTK_PREFIX}"/bin/gdk-pixbuf-query-loaders "${LIB}"/gdk-pixbuf-2.0/*/loaders/*.so > "${ETC}"/gtk-2.0/gdk-pixbuf.loaders "${GTK_PREFIX}"/bin/gtk-query-immodules-2.0 "${LIB}"/gtk-2.0/*/immodules/*.so > "${ETC}"/gtk-2.0/gtk.immodules sed -i "" -e "s|${PWD}|/tmp|" "${ETC}"/gtk-2.0/gdk-pixbuf.loaders \ - "${ETC}"/gtk-2.0/gtk.immodules +"${ETC}"/gtk-2.0/gtk.immodules if [[ "$ExistPangoQuerymodules" = "true" ]]; then "${GTK_PREFIX}"/bin/pango-querymodules "${LIB}"/pango/*/modules/*.so > "${ETC}"/pango/pango.modules sed -i "" -e "s|${PWD}|/tmp|" "${ETC}"/pango/pango.modules @@ -122,23 +129,23 @@ install -d "${MACOS}"/share/themes/Raleigh/gtk-2.0 (cd "${MACOS}"/share/themes/Raleigh/gtk-2.0 && ln -s ../../Clearlooks/gtk-2.0/gtkrc) # fontconfig files (X11 backend only) if otool -L "${EXECUTABLE}" | grep -sq 'libgtk-x11-2.0'; then - message "Installing fontconfig files (Your library is X11 backend. 'FONTCONFIG_PATH' will be set by executable loader.)" - cp -RL "${GTK_PREFIX}"/etc/fonts "${ETC}" + message "Installing fontconfig files (Your library is X11 backend. 'FONTCONFIG_PATH' will be set by executable loader.)" + cp -RL "${GTK_PREFIX}"/etc/fonts "${ETC}" fi # install names find -E "${MACOS}" -type f -regex '.*/(rawtherapee|.*\.(dylib|so))' | while read x; do - message "Modifying install names: ${x}" - { - # id + message "Modifying install names: ${x}" + { + # id case ${x} in *.dylib) echo " install_name_tool -id '@rpath/$(basename "${x}")' '${x}'";; esac # names GetDependencies "${x}" | while read y; do - echo " install_name_tool -change '${y}' '@rpath/$(basename "${y}")' '${x}'" + echo " install_name_tool -change '${y}' '@rpath/$(basename "${y}")' '${x}'" done - } | bash -v +} | bash -v done message "Registering @loader_path into the executable" @@ -147,7 +154,7 @@ echo " install_name_tool -add_rpath @loader_path/lib '${EXECUTABLE}'" | bash - message "Installing required application bundle files" -PROJECT_SOURCE_DATA_DIR="${PROJECT_SOURCE_DIR}"/rtdata/osx +PROJECT_SOURCE_DATA_DIR="${PROJECT_SOURCE_DIR}"/tools/osx # executable loader # note: executable is renamed to 'rawtherapee-bin'. mv "${MACOS}"/rawtherapee{,-bin} @@ -157,39 +164,39 @@ cp "${PROJECT_SOURCE_DATA_DIR}"/{rawtherapee,profile}.icns "${RESOURCES}" cp "${PROJECT_SOURCE_DATA_DIR}"/PkgInfo "${CONTENTS}" install -m 0644 "${PROJECT_SOURCE_DATA_DIR}"/Info.plist.in "${CONTENTS}"/Info.plist sed -i "" -e "s|@version@|${PROJECT_VERSION}| - s|@shortVersion@|$(echo ${PROJECT_VERSION} | cut -d. -f-3)| - s|@arch@|${arch}|" \ - "${CONTENTS}"/Info.plist +s|@shortVersion@|${PROJECT_VERSION}| +s|@arch@|${arch}|" \ +"${CONTENTS}"/Info.plist plutil -convert binary1 "${CONTENTS}"/Info.plist function CreateDmg { - local srcdir=$(mktemp -dt $$) - - message "Preparing disk image sources at ${srcdir}" - mv "${APP}" ${srcdir} - cp AboutThisBuild.txt ${srcdir} - ln -s /Applications ${srcdir} - - # web bookmarks - function CreateWebloc { - defaults write ${srcdir}/"$1" URL "$2" - mv ${srcdir}/"$1".{plist,webloc} - } - CreateWebloc 'RawTherapee Blog' 'http://www.rawtherapee.com' - CreateWebloc 'Online Manual' 'https://docs.google.com/document/d/1DHLb_6xNQsEInxiuU8pz1-sWNinnj09bpBUA4_Vl8w8/edit' - - # disk image name - dmg_name="${PROJECT_NAME// /_}_OSX_${MINIMUM_SYSTEM_VERSION}_${PROC_BIT_DEPTH}_${PROJECT_VERSION}" - if ! echo ${CMAKE_BUILD_TYPE} | grep -sqi "release"; then - dmg_name="${dmg_name}_$(echo ${CMAKE_BUILD_TYPE} | tr '[:upper:]' '[:lower:]')" - fi - - message "Creating disk image" - hdiutil create -format UDBZ -srcdir ${srcdir} -volname "${PROJECT_NAME}_${PROJECT_VERSION}" "${dmg_name}".dmg - - message "Removing disk image caches" - rm -rf ${srcdir} + local srcdir="$(mktemp -dt $$)" + + message "Preparing disk image sources at ${srcdir}" + mv "${APP}" "${srcdir}" + cp AboutThisBuild.txt "${srcdir}" + ln -s /Applications "${srcdir}" + + # web bookmarks + function CreateWebloc { + defaults write "${srcdir}/$1" URL "$2" + mv "${srcdir}/$1".{plist,webloc} + } + CreateWebloc 'RawTherapee Blog' 'http://www.rawtherapee.com' + CreateWebloc 'Online Manual' 'http://rawpedia.rawtherapee.com/' + + # disk image name + dmg_name="${PROJECT_NAME// /_}_OSX_${MINIMUM_SYSTEM_VERSION}_${PROC_BIT_DEPTH}_${PROJECT_FULL_VERSION}" + if ! echo "${CMAKE_BUILD_TYPE}" | grep -sqi "release"; then + dmg_name="${dmg_name}_$(echo ${CMAKE_BUILD_TYPE} | tr '[:upper:]' '[:lower:]')" + fi + + message "Creating disk image" + hdiutil create -format UDBZ -srcdir "${srcdir}" -volname "${PROJECT_NAME}_${PROJECT_FULL_VERSION}" "${dmg_name}".dmg + + message "Removing disk image caches" + rm -rf "${srcdir}" } CreateDmg diff --git a/rtdata/osx/profile.icns b/tools/osx/profile.icns similarity index 100% rename from rtdata/osx/profile.icns rename to tools/osx/profile.icns diff --git a/rtdata/osx/rawtherapee.icns b/tools/osx/rawtherapee.icns similarity index 100% rename from rtdata/osx/rawtherapee.icns rename to tools/osx/rawtherapee.icns diff --git a/rtdata/win/InnoSetup/WindowsInnoSetup.iss.in b/tools/win/InnoSetup/WindowsInnoSetup.iss.in similarity index 100% rename from rtdata/win/InnoSetup/WindowsInnoSetup.iss.in rename to tools/win/InnoSetup/WindowsInnoSetup.iss.in diff --git a/rtdata/win/InnoSetup/installerStrip.bmp b/tools/win/InnoSetup/installerStrip.bmp similarity index 100% rename from rtdata/win/InnoSetup/installerStrip.bmp rename to tools/win/InnoSetup/installerStrip.bmp diff --git a/rtdata/win/InnoSetup/installerStrip.svg b/tools/win/InnoSetup/installerStrip.svg similarity index 100% rename from rtdata/win/InnoSetup/installerStrip.svg rename to tools/win/InnoSetup/installerStrip.svg diff --git a/rtdata/win/readme.txt b/tools/win/readme.txt similarity index 100% rename from rtdata/win/readme.txt rename to tools/win/readme.txt