From: Steve Brokenshire Date: Sat, 3 Oct 2020 09:34:15 +0000 (+0100) Subject: Setup CMake to build for macOS X-Git-Tag: release-0.24~8 X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=3ef806261b5482a584e05dc8311c8d7633f146b4;p=xestiaab%2F.git Setup CMake to build for macOS --- diff --git a/source/CMakeFunctions/Application.cmake b/source/CMakeFunctions/Application.cmake index 87a6208..d3b44f7 100644 --- a/source/CMakeFunctions/Application.cmake +++ b/source/CMakeFunctions/Application.cmake @@ -34,29 +34,13 @@ set(FILE_LIST main.cpp frmUpdate.cpp frmUpdate.h) -if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") +if(APPLE) list(APPEND FILE_LIST frmEditAccount.mm - frmNewAccount.mm) + frmNewAccount.mm + frmMain.mm + os/osx/XestiaAddressBook.icns) endif() -if (MSVC) - list(APPEND FILE_LIST os/msw/xestiaab.rc) - add_executable(xestiaab WIN32 - ${FILE_LIST}) -else() - add_executable(xestiaab - ${FILE_LIST}) -endif() - - -message("${RUNTIME_OUTPUT_NAME_bitmapcode}") - -target_include_directories(xestiaab - PUBLIC - ".") - -add_dependencies(xestiaab bitmapcode) - list(APPEND LIBRARIES ${wxWidgets_LIBRARIES} ${LIBXML2_LIBRARY} sfml-audio @@ -80,10 +64,68 @@ if (MSVC) crypt32) endif() -target_link_libraries(xestiaab - LINK_PUBLIC - ${LIBRARIES} -) +if (MSVC) + list(APPEND FILE_LIST os/msw/xestiaab.rc) + add_executable(xestiaab WIN32 + ${FILE_LIST}) +elseif(APPLE) + # Main icons + set_source_files_properties(os/osx/XestiaAddressBook.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") + set(MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/os/osx/Info.plist") + set(CMAKE_BUILD_PATH_USE_ORIGIN TRUE) + set(APPS "\${CMAKE_INSTALL_PREFIX}/xestiaab.app") + set(DIR ${CMAKE_BINARY_DIR}) + + install(CODE "include(BundleUtilities) + fixup_bundle(\"${APPS}\" \"\" \"\")") + + # Documentation + file(GLOB DocumentationFiles ${CMAKE_SOURCE_DIR}/../docs/*.fodt) + set_source_files_properties(${DocumentationFiles} + PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + + add_executable(xestiaab MACOSX_BUNDLE + ${FILE_LIST} + ${DocumentationFiles} + ${FrameworkFiles}) + + install(TARGETS xestiaab + BUNDLE DESTINATION . COMPONENT Runtime + RUNTIME DESTINATION bin COMPONENT Runtime) + + target_link_libraries(xestiaab LINK_PUBLIC + stdc++ + objc + ${COREFOUNDATION_FRAMEWORK} + ${SECURITY_FRAMEWORK} + ${SECURITYINTERFACE_FRAMEWORK} + ${LIBRARIES}) + + set_target_properties(xestiaab PROPERTIES + MACOSX_BUNDLE TRUE + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/os/osx/Info.plist) + + add_custom_command( + TARGET xestiaab + COMMAND ${CMAKE_COMMAND} -D SRC=$/Contents/MacOS/xestiaab + -D DST=$/Contents/Frameworks + -D SFML_FRAMEWORKS_LOCATION=${SFML_FRAMEWORKS_LOCATION} + -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeFunctions/CopyLibraries.cmake + POST_BUILD + ) +else() + add_executable(xestiaab + ${FILE_LIST}) +endif() + + +message("${RUNTIME_OUTPUT_NAME_bitmapcode}") + +target_include_directories(xestiaab + PUBLIC + ".") + +add_dependencies(xestiaab bitmapcode) file(GLOB DOCUMENTATION_INSTALL_FILES "${CMAKE_SOURCE_DIR}/../docs/*") foreach(ITEM ${DOCUMENTATION_INSTALL_FILES}) @@ -93,9 +135,3 @@ foreach(ITEM ${DOCUMENTATION_INSTALL_FILES}) list(APPEND DOCUMENTATION_DEPLOY_DIRECTORIES "${ITEM}") endif() endforeach() - -install(TARGETS xestiaab RUNTIME DESTINATION bin) -install(TARGETS odthelpbrowser RUNTIME DESTINATION bin) -install(FILES ${CMAKE_SOURCE_DIR}/xestiaab.1 DESTINATION share/man/man1) -install(FILES ${DOCUMENTATION_DEPLOY_FILES} DESTINATION share/doc/xestiaab) -install(FILES ${DOCUMENTATION_DEPLOY_DIRECTORIES} DESTINATION share/doc/xestiaab) \ No newline at end of file diff --git a/source/CMakeFunctions/CopyLibraries.cmake b/source/CMakeFunctions/CopyLibraries.cmake new file mode 100644 index 0000000..d5371ef --- /dev/null +++ b/source/CMakeFunctions/CopyLibraries.cmake @@ -0,0 +1,230 @@ +# list command no longer ignores empty elements +cmake_policy(SET CMP0007 NEW) + +function(Execute) + list(POP_FRONT ARGV outlist) + + execute_process( + COMMAND ${ARGV} + OUTPUT_VARIABLE cmd_out + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + string(REPLACE "\n" ";" cmd_out "${cmd_out}") + list(TRANSFORM cmd_out STRIP) + set(${outlist} ${cmd_out} PARENT_SCOPE) +endfunction() + +function(GatherRuntimePaths source) + Execute(output otool -l ${source}) + + set (line_index 0) + foreach (line ${output}) + if(line MATCHES "^.*cmd LC_RPATH") + set(line_index 1) + continue() + endif() + + if (line_index EQUAL 1) + set(line_index 2) + continue() + endif() + + if (line_index EQUAL 2) + string(REGEX REPLACE "^.*path" "" extracted_path ${line}) + string(REGEX REPLACE "\\(offset .*\\)$" "" extracted_path ${extracted_path}) + string(STRIP ${extracted_path} extracted_path) + list(APPEND runpaths ${extracted_path}) + set(line_index 0) + continue() + endif() + endforeach() + + set(runpaths ${runpaths} PARENT_SCOPE) +endfunction() + +function(GatherSFMLLibrariesForCopying libraries postcmds) + foreach(library ${libraries}) + Execute(output otool -L ${library}) + + foreach(line ${output}) + if(line MATCHES "^.*libsfml.*.[^0-9].[^0-9].[^0-9].*\\.dylib ") + string(REGEX REPLACE "dylib .*" "dylib" line "${line}") + + if(line MATCHES "^@rpath/") + get_filename_component(refname "${line}" NAME) + list(APPEND postcmds "sh -c 'install_name_tool -change ${line} @executable_path/../Frameworks/${refname} ${library}'") + list(APPEND libs ${dylib_location}) + endif() + elseif(line MATCHES "^@rpath/../Frameworks/.*.framework/Versions/.*/.*") + string(REGEX MATCH "^@rpath/../Frameworks/(.*)/Versions/.*$" _ ${line}) + list(APPEND frameworksToCopy ${CMAKE_MATCH_1}) + endif() + endforeach() + endforeach() + + set(postcmds ${postcmds} PARENT_SCOPE) + set(frameworksToCopy ${frameworksToCopy} PARENT_SCOPE) +endfunction() + +function (InstallSFMLDependencies frameworks postcmds destination) + foreach (framework ${frameworks}) + unset(frameworkLocation) + string(REGEX MATCH "(.*).framework" _ ${framework}) + string(APPEND frameworkLocation ${SFML_FRAMEWORKS_LOCATION} "/" ${framework}) + file(INSTALL ${frameworkLocation} DESTINATION ${destination}) + endforeach() +endfunction() + +function(AdjustSFMLDependencies libraries destination) + foreach (libraryFilename ${libraries}) + string(REGEX MATCH "(.*).framework" _ ${libraryFilename}) + string(CONCAT libraryName ${CMAKE_MATCH_1}) + string(CONCAT frameworkLocation ${destination} "/" ${libraryFilename} "/" ${libraryName}) + Execute(output otool -L ${frameworkLocation}) + + foreach (oldLocation ${output}) + string(REGEX REPLACE " \\\(compatibility .*" "" oldLocation ${oldLocation}) + if(oldLocation MATCHES "^@rpath") + string(REPLACE "@rpath/" "@executable_path/" newLocation ${oldLocation}) + execute_process( + COMMAND sh -c "install_name_tool -change ${oldLocation} ${newLocation} ${frameworkLocation}" + COMMAND_ECHO STDOUT + ) + endif() + endforeach() + endforeach() +endfunction() + +function(AdjustSFMLLibraries libraries) + foreach(library ${libraries}) + Execute(output otool -L ${library}) + + foreach(oldLocation ${output}) + string(REGEX REPLACE " \\\(compatibility .*" "" oldLocation ${oldLocation}) + if(oldLocation MATCHES "^@rpath") + string(REPLACE "@rpath/" "@executable_path/" newLocation ${oldLocation}) + execute_process( + COMMAND sh -c "install_name_tool -change ${oldLocation} ${newLocation} ${library}" + COMMAND_ECHO STDOUT + ) + endif() + endforeach() + endforeach() +endfunction() + +function(GatherLibrariesForCopying source) + if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin") + # Gather runtime paths first. + if(NOT source MATCHES "^@rpath") + GatherRuntimePaths(${source}) + endif() + + Execute(output otool -L ${source}) + + get_filename_component(LibraryName "${source}" NAME) + + if(LibraryName MATCHES ".*dylib") + string(PREPEND LibraryName "${DST}/") + else() + set(LibraryName "${source}") + endif() + + foreach (line ${output}) + if(line MATCHES "^@rpath/../Frameworks/.*.framework/Versions/.*/.*") + continue() + endif() + + if(line MATCHES "^@rpath") + string(REGEX REPLACE "^@rpath/" "" filename ${line}) + string(REGEX REPLACE "dylib .*" "dylib" filename ${filename}) + + set(dylib_found 0) + foreach (runpath ${runpaths}) + string(CONCAT dylib_location ${runpath} "/" ${filename}) + if (EXISTS ${dylib_location}) + set(dylib_location ${dylib_location} PARENT_SCOPE) + set(dylib_found 1) + break() + endif() + endforeach() + + if(dylib_found EQUAL 0) + message(FATAL_ERROR "Unable to find dynamic library ${filename} within the runtime paths.") + endif() + endif() + + # Dynamic Libraries + if(line MATCHES "^.*libwx.*\\.dylib " ) + string(REGEX REPLACE "dylib .*" "dylib" line "${line}") + if(NOT line STREQUAL "${source}" AND NOT line MATCHES "@executable") + set(lib ${line}) + if(line MATCHES "^@rpath/") + list(APPEND libs ${dylib_location}) + else() + list(APPEND libs ${lib}) + endif() + get_filename_component(refname "${lib}" NAME) + list(APPEND postcmds "sh -c 'install_name_tool -change ${lib} @executable_path/../Frameworks/${refname} ${LibraryName}'") + + GatherLibrariesForCopying(${lib}) + endif() + elseif(line MATCHES "^.*libsfml.*.[^0-9].[^0-9].[^0-9].*\\.dylib ") + string(REGEX REPLACE "dylib .*" "dylib" line "${line}") + set(lib ${line}) + if(line MATCHES "^@rpath/") + get_filename_component(refname "${dylib_location}" NAME) + list(APPEND postcmds "sh -c 'install_name_tool -change ${lib} @executable_path/../Frameworks/${refname} ${LibraryName}'") + list(APPEND libs ${dylib_location}) + elseif(line MATCHES "^@executable_path/") + continue() + else() + get_filename_component(refname "${lib}" NAME) + list(APPEND postcmds "sh -c 'install_name_tool -change ${lib} @executable_path/../Frameworks/${refname} ${LibraryName}'") + list(APPEND libs ${lib}) + endif() + get_filename_component(libraryPath "${LibraryName}" DIRECTORY) + string(APPEND libraryPath "/../Frameworks/${refname}") + list(APPEND sfmllibs ${libraryPath}) + elseif(line MATCHES "^.*libcurl.[0-9]\\.dylib " OR + line MATCHES "^.*libxml2.[0-9]\\.dylib ") + string(REGEX REPLACE "dylib .*" "dylib" line "${line}") + set(lib ${line}) + + if(line MATCHES "^@rpath/") + get_filename_component(refname "${dylib_location}" NAME) + list(APPEND postcmds "sh -c 'install_name_tool -change ${lib} @executable_path/../Frameworks/${refname} ${LibraryName}'") + list(APPEND libs ${dylib_location}) + elseif(line MATCHES "^@executable_path/") + continue() + else() + get_filename_component(refname "${lib}" NAME) + list(APPEND postcmds "sh -c 'install_name_tool -change ${lib} @executable_path/../Frameworks/${refname} ${LibraryName}'") + list(APPEND libs ${lib}) + endif() + endif() + endforeach() + endif() + + set(libs ${libs} PARENT_SCOPE) + set(sfmllibs ${sfmllibs} PARENT_SCOPE) + set(postcmds ${postcmds} PARENT_SCOPE) +endfunction() + +GatherLibrariesForCopying(${SRC}) + +list(REMOVE_DUPLICATES libs) +file(INSTALL ${libs} DESTINATION ${DST} FOLLOW_SYMLINK_CHAIN) + +GatherSFMLLibrariesForCopying("${sfmllibs}" "${postcmds}") +InstallSFMLDependencies("${frameworksToCopy}" "${postcmds}" "${DST}") + +foreach(cmd ${postcmds}) + execute_process( + COMMAND sh -c "${cmd}" + COMMAND_ECHO STDOUT + ) +endforeach() + +AdjustSFMLLibraries("${sfmllibs}") +AdjustSFMLDependencies("${frameworksToCopy}" ${DST}) diff --git a/source/CMakeFunctions/MacOSSupport.cmake b/source/CMakeFunctions/MacOSSupport.cmake new file mode 100644 index 0000000..0414679 --- /dev/null +++ b/source/CMakeFunctions/MacOSSupport.cmake @@ -0,0 +1,6 @@ +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -x objective-c++ -std=c++11") +#add_definitions(-std=c++11) + +find_library(COREFOUNDATION_FRAMEWORK CoreFoundation) +find_library(SECURITY_FRAMEWORK Security) +find_library(SECURITYINTERFACE_FRAMEWORK SecurityInterface) diff --git a/source/CMakeFunctions/Options.cmake b/source/CMakeFunctions/Options.cmake index 5801a3b..017958a 100644 --- a/source/CMakeFunctions/Options.cmake +++ b/source/CMakeFunctions/Options.cmake @@ -1,3 +1,11 @@ include(CMakeDependentOption) option(XestiaAddressBook_UNIT_TESTING "Enable unit testing" OFF) + +if(APPLE) + set(SFML_FRAMEWORKS_LOCATION "" CACHE PATH "Location for the SFML framework dependencies.") + + if(NOT EXISTS ${SFML_FRAMEWORKS_LOCATION}) + message(FATAL_ERROR "The location given by SFML_FRAMEWORKS_LOCATION does not exist.") + endif() +endif() diff --git a/source/CMakeFunctions/Packages.cmake b/source/CMakeFunctions/Packages.cmake index 4678364..c42d5b5 100644 --- a/source/CMakeFunctions/Packages.cmake +++ b/source/CMakeFunctions/Packages.cmake @@ -7,12 +7,24 @@ include(${wxWidgets_USE_FILE}) find_package(LibXml2 REQUIRED) include_directories(${LIBXML2_INCLUDE_DIRS}) +if (APPLE) + if (LIBXML2_LIBRARY MATCHES "^/usr/lib/.*") + message(FATAL_ERROR "Use of macOS's internal libxml2 dynamic library is not allowed.") + endif() +endif() -find_package(Iconv REQUIRED) -include_directories(${Iconv_INCLUDE_DIR}) +if(!APPLE) + find_package(Iconv REQUIRED) + include_directories(${Iconv_INCLUDE_DIR}) +endif() find_package(CURL REQUIRED) include_directories(${CURL_INCLUDE_DIRS}) +if (APPLE) + if (LIBXML2_LIBRARY MATCHES "^/usr/lib/.*") + message(FATAL_ERROR "Use of macOS's internal libcurl dynamic library is not allowed.") + endif() +endif() find_package(SFML COMPONENTS audio REQUIRED) include_directories(${SFML_DIR}/../include) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 097c584..814b433 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -7,6 +7,10 @@ set(CMAKE_CXX_STANDARD 11) include(Options) include(Packages) +if (APPLE) + include(MacOSSupport) +endif() + if (XestiaAddressBook_UNIT_TESTING) enable_testing() find_package(GTest REQUIRED) diff --git a/source/actmgr/CMakeLists.txt b/source/actmgr/CMakeLists.txt index 0f69875..9e87ae0 100644 --- a/source/actmgr/CMakeLists.txt +++ b/source/actmgr/CMakeLists.txt @@ -4,8 +4,8 @@ set(FILE_LIST frmActivityMgr.cpp frmActivityMgr.h frmActivityMgr-tasks.cpp) -if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - list(APPEND ${FILE_LIST} frmActivityMgr.mm) +if(APPLE) + list(APPEND FILE_LIST frmActivityMgr.mm) endif() add_library(${TARGET_NAME} diff --git a/source/convert.cpp b/source/convert.cpp index 89227cb..d734519 100644 --- a/source/convert.cpp +++ b/source/convert.cpp @@ -193,10 +193,10 @@ ConvertResult ConvertContact(wxString InputFormat, wxString OutputFormat, // Write out the data to the console. FinalData.Trim(); - std::cout << FinalData << std::endl; + std::cout << FinalData.ToStdString() << std::endl; } return CONVERTRESULT_OK; -} \ No newline at end of file +} diff --git a/source/frmMain.h b/source/frmMain.h index dcc18bb..4a2313c 100644 --- a/source/frmMain.h +++ b/source/frmMain.h @@ -125,7 +125,7 @@ class frmMain : public frmMainADT std::map AccountAccDirList; #if defined(__APPLE__) std::map AccountTrustData; - NSRunningApplication *helpBrowserProcess; + NSRunningApplication *helpBrowserProcess = nil; #elif defined(__WIN32__) std::map AccountCertificateData; #else diff --git a/source/frmMain.mm b/source/frmMain.mm index 7e6b563..39200a7 100644 --- a/source/frmMain.mm +++ b/source/frmMain.mm @@ -83,7 +83,7 @@ void frmMain::DisplayHelpBrowser() helpBrowserDocumentationPath = [[NSBundle mainBundle] pathForResource:@"Documentation (en_GB)" ofType:@"fodt"]; } - NSURL *helpBrowserExecutableURL = [[NSBundle mainBundle] URLForResource:@"ODTHelpBrowser" withExtension:@"app"]; + NSURL *helpBrowserExecutableURL = [[NSBundle mainBundle] URLForResource:@"odthelpbrowser" withExtension:@"app"]; NSArray *args = [NSArray arrayWithObjects:@"-d", helpBrowserDocumentationPath, nil]; NSDictionary *helpBrowserArguments = [NSDictionary dictionaryWithObject:args diff --git a/source/main.cpp b/source/main.cpp index 3de7a64..2140dfd 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -63,7 +63,7 @@ bool XestiaABApp::OnInit() // Setup the locale. wxLocale locale; - locale.Init(wxLANGUAGE_DEFAULT, wxLOCALE_LOAD_DEFAULT); + locale.Init(wxLANGUAGE_DEFAULT, wxLOCALE_LOAD_DEFAULT); static const wxCmdLineEntryDesc g_cmdLineDesc [] = { @@ -367,4 +367,4 @@ bool XestiaABApp::OnInit() return true; -} \ No newline at end of file +} diff --git a/projects/osx/ODTHelpBrowser/Info.plist b/source/os/osx/Info.plist similarity index 55% rename from projects/osx/ODTHelpBrowser/Info.plist rename to source/os/osx/Info.plist index 17ba4a4..dc5cfd0 100644 --- a/projects/osx/ODTHelpBrowser/Info.plist +++ b/source/os/osx/Info.plist @@ -3,32 +3,32 @@ CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) + English CFBundleExecutable $(EXECUTABLE_NAME) - CFBundleIconFile + CFBundleGetInfoString + CFBundleIconFile + XestiaAddressBook CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) + uk.co.xestia.addressbook CFBundleInfoDictionaryVersion 6.0 CFBundleLongVersionString - $(PRODUCT_VERSION) (c) 2013 - 2018 Xestia Software Development + CFBundleName - $(PRODUCT_NAME) + CFBundlePackageType - XSD + APPL CFBundleShortVersionString - 1.0.0 + + CFBundleSignature + ???? CFBundleVersion - 1.0.0 - LSApplicationCategoryType - public.app-category.productivity - LSMinimumSystemVersion - $(MACOSX_DEPLOYMENT_TARGET) + 0.24 + CSResourcesFileMapped + NSHumanReadableCopyright - Copyright © 2018 Xestia Software Development. All rights reserved. - NSPrincipalClass - wxNSApplication + (c) 2012-2020 Xestia Software Development diff --git a/source/os/osx/XestiaAddressBook.icns b/source/os/osx/XestiaAddressBook.icns new file mode 100644 index 0000000..4ff0067 Binary files /dev/null and b/source/os/osx/XestiaAddressBook.icns differ diff --git a/source/tools/CMakeLists.txt b/source/tools/CMakeLists.txt index a34ec67..8f1e901 100644 --- a/source/tools/CMakeLists.txt +++ b/source/tools/CMakeLists.txt @@ -1,6 +1,6 @@ add_executable(bitmapcode bitmapcode.cpp) - + if (MSVC) add_custom_command( TARGET bitmapcode @@ -10,6 +10,7 @@ endif() target_link_libraries(bitmapcode LINK_PUBLIC + c++ ${wxWidgets_LIBRARIES}) set (sources @@ -26,6 +27,8 @@ set (sources if (WIN32) add_executable(odthelpbrowser WIN32 ${sources}) +elseif (APPLE) + add_executable(odthelpbrowser MACOSX_BUNDLE ${sources}) else() add_executable(odthelpbrowser ${sources}) endif() diff --git a/source/tools/bitmapcode.cpp b/source/tools/bitmapcode.cpp index b054104..4425062 100644 --- a/source/tools/bitmapcode.cpp +++ b/source/tools/bitmapcode.cpp @@ -100,8 +100,8 @@ void CreateCPPFile(wxString dirfilename, wxString PNGFilename, int* counter) // Setup the inclusion guard. cppfile << "#include " << endl << endl; - cppfile << "#ifndef " << outname.c_str() << "_CPP" << endl; - cppfile << "#define " << outname.c_str() << "_CPP" << endl << endl; + cppfile << "#ifndef " << outname.ToStdString() << "_CPP" << endl; + cppfile << "#define " << outname.ToStdString() << "_CPP" << endl << endl; outname.Clear(); outname.Append(wxString::FromUTF8(DirFilenameOnly.c_str())); @@ -113,7 +113,7 @@ void CreateCPPFile(wxString dirfilename, wxString PNGFilename, int* counter) // Convert the PNG file into an unsigned char array. - cppfile << "static unsigned char " << outname.c_str() << + cppfile << "static unsigned char " << outname.ToStdString() << "[] = {" << endl; while (pngfile){ @@ -148,10 +148,9 @@ void CreateCPPFile(wxString dirfilename, wxString PNGFilename, int* counter) cppfile << "#endif" << endl << endl; cppfile.close(); - cout << "CPP\t" << CPPFilename.c_str() << endl; + cout << "CPP\t" << CPPFilename.ToStdString() << endl; ++*counter; - } void CreateHPPFileDir(wxString dirfilename, wxArrayString filelist, @@ -171,7 +170,7 @@ void CreateHPPFileDir(wxString dirfilename, wxArrayString filelist, bool fmatch = FALSE; wxString finaldirname; - wxString HPPFilename = dirfilename.c_str(); + wxString HPPFilename = dirfilename.ToStdString(); wxString DirFilenameOnly; wxString HPPFilenameOnly; @@ -224,8 +223,8 @@ void CreateHPPFileDir(wxString dirfilename, wxArrayString filelist, #endif hppfile << "#include " << endl << endl; - hppfile << "#ifndef " << finaldirname.c_str() << "_H" << endl; - hppfile << "#define " << finaldirname.c_str() << "_H" << endl << endl; + hppfile << "#ifndef " << finaldirname.ToStdString() << "_H" << endl; + hppfile << "#define " << finaldirname.ToStdString() << "_H" << endl << endl; hppfile << "// List all CPP files in the directory." << endl << endl; // Write each CPP file into the header file. @@ -255,8 +254,8 @@ void CreateHPPFileDir(wxString dirfilename, wxArrayString filelist, CPPFileOnly.RemoveLast(4); CPPFileOnly.Append(wxT(".cpp")); - hppfile << "#include \"" << DirFilenameOnly.c_str() << - "/" << CPPFileOnly.c_str() << "\"" << endl; + hppfile << "#include \"" << DirFilenameOnly.ToStdString() << + "/" << CPPFileOnly.ToStdString() << "\"" << endl; } @@ -267,7 +266,7 @@ void CreateHPPFileDir(wxString dirfilename, wxArrayString filelist, // Increment the HPP file counter. - cout << "HPPDIR\t" << HPPFilename.c_str() << endl; + cout << "HPPDIR\t" << HPPFilename.ToStdString() << endl; ++*counter; } @@ -386,7 +385,7 @@ int main(int argc, char *argv[]) DirFilenameWxS.Empty(); - std::cout << BitmapHeaderFilename.c_str() << std::endl; + std::cout << BitmapHeaderFilename.ToStdString() << std::endl; #if defined(__WIN32__) @@ -448,7 +447,7 @@ int main(int argc, char *argv[]) for (int fi = 0; fi < filelist.GetCount(); fi++) { - CreateCPPFile(dirlist[bi].wc_str(), filelist[fi].wc_str(), &cppg); + CreateCPPFile(dirlist[bi].ToStdString(), filelist[fi].ToStdString(), &cppg); fp++; } @@ -487,12 +486,12 @@ int main(int argc, char *argv[]) #elif defined(__WIN32__) - finalhppfile << "#include \"bitmaps\\" << DirNameSplit.c_str() << + finalhppfile << "#include \"bitmaps\\" << DirNameSplit.ToStdString() << ".h\"" << endl; #else - finalhppfile << "#include \"bitmaps/" << DirNameSplit.c_str() << + finalhppfile << "#include \"bitmaps/" << DirNameSplit.ToStdString() << ".h\"" << endl; #endif diff --git a/source/tools/generateicnsfile.sh b/source/tools/generateicnsfile.sh new file mode 100755 index 0000000..50091c5 --- /dev/null +++ b/source/tools/generateicnsfile.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +if [ -z $1 ]; then + echo "Usage: $0 " + exit +fi + +IMAGELOCATION=$1 +IMAGEFILENAME=${IMAGELOCATION##*/} +IMAGENAME="${IMAGEFILENAME%.*}" + +mkdir $IMAGENAME.iconset +sips $IMAGELOCATION -z 16 16 --out $IMAGENAME.iconset/icon_16x16.png +sips $IMAGELOCATION -z 32 32 --out $IMAGENAME.iconset/icon_16x16@2x.png +sips $IMAGELOCATION -z 32 32 --out $IMAGENAME.iconset/icon_32x32.png +sips $IMAGELOCATION -z 64 64 --out $IMAGENAME.iconset/icon_32x32@2x.png +sips $IMAGELOCATION -z 128 128 --out $IMAGENAME.iconset/icon_128x128.png +sips $IMAGELOCATION -z 256 256 --out $IMAGENAME.iconset/icon_128x128@2x.png +sips $IMAGELOCATION -z 256 256 --out $IMAGENAME.iconset/icon_256x256.png +sips $IMAGELOCATION -z 512 512 --out $IMAGENAME.iconset/icon_256x256@2x.png +sips $IMAGELOCATION -z 512 512 --out $IMAGENAME.iconset/icon_512x512.png +cp $IMAGELOCATION $IMAGENAME.iconset/icon_512x512@2x.png +iconutil -c icns $IMAGENAME.iconset +rm $IMAGENAME.iconset/* +rmdir $IMAGENAME.iconset