diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 2ce43cde00..51f0ce3e7d 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,23 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-07-04 10:15 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * utils/hbmk2/hbmk2.prg + + Added app bundle generation for OS X targets in -gui mode. + It's experimental yet. (f.e. clean will not clean it f.e.) + Thanks to Teo Fonrouge for the hints. + * Using escapting function (instead of manual escaping) when + launching Windows apps on NT. + ; TOFIX: hb_FCopy() + + * source/rtl/fscopy.c + + Now it will copy flags on *nix systems (just like __COPYFILE()). + + * source/rtl/copyfile.c + * Minor formatting. + + ; TODO: Add generic app icon support. Possible? + 2009-07-04 09:13 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * utils/hbmk2/hbmk2.prg * commandResult() merged into hbmk_run(). @@ -312,7 +329,7 @@ * source/vm/task.c ! Minor text sync in debug calls. - ; TOFIX: + ; TOFIX: [DONE] ../../filesys.c(1698) : error C2065: 'Flags' : undeclared identifier ../../filesys.c(1792) : error C2065: 'Flags' : undeclared identifier diff --git a/harbour/source/rtl/copyfile.c b/harbour/source/rtl/copyfile.c index 04916a3826..dc2b585857 100644 --- a/harbour/source/rtl/copyfile.c +++ b/harbour/source/rtl/copyfile.c @@ -55,7 +55,7 @@ #include "hbapiitm.h" #include "hbapifs.h" -#if defined(HB_OS_UNIX_COMPATIBLE) +#if defined( HB_OS_UNIX_COMPATIBLE ) #include #include #endif @@ -105,7 +105,7 @@ static BOOL hb_copyfile( const char * szSource, const char * szDest ) if( fhndDest != FS_ERROR ) { -#if defined(HB_OS_UNIX_COMPATIBLE) +#if defined( HB_OS_UNIX_COMPATIBLE ) struct stat struFileInfo; int iSuccess = fstat( fhndSource, &struFileInfo ); #endif @@ -131,7 +131,7 @@ static BOOL hb_copyfile( const char * szSource, const char * szDest ) hb_xfree( buffer ); -#if defined(HB_OS_UNIX_COMPATIBLE) +#if defined( HB_OS_UNIX_COMPATIBLE ) if( iSuccess == 0 ) fchmod( fhndDest, struFileInfo.st_mode ); #endif diff --git a/harbour/source/rtl/fscopy.c b/harbour/source/rtl/fscopy.c index 3f587a9937..a088c2ddd2 100644 --- a/harbour/source/rtl/fscopy.c +++ b/harbour/source/rtl/fscopy.c @@ -53,6 +53,11 @@ #include "hbapi.h" #include "hbapifs.h" +#if defined( HB_OS_UNIX_COMPATIBLE ) + #include + #include +#endif + #define HB_FSCOPY_BUFFERSIZE 16384 BOOL hb_fsCopy( const char * pszSource, const char * pszDest ) @@ -65,6 +70,10 @@ BOOL hb_fsCopy( const char * pszSource, const char * pszDest ) { if( ( fhndDest = hb_fsCreate( pszDest, FC_NORMAL ) ) != FS_ERROR ) { +#if defined( HB_OS_UNIX_COMPATIBLE ) + struct stat struFileInfo; + int iSuccess = fstat( fhndSource, &struFileInfo ); +#endif USHORT nBytesRead; void * pbyBuffer = hb_xgrab( HB_FSCOPY_BUFFERSIZE ); @@ -79,6 +88,11 @@ BOOL hb_fsCopy( const char * pszSource, const char * pszDest ) hb_xfree( pbyBuffer ); +#if defined( HB_OS_UNIX_COMPATIBLE ) + if( iSuccess == 0 ) + fchmod( fhndDest, struFileInfo.st_mode ); +#endif + hb_fsClose( fhndDest ); } else diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index 613bc096b5..59369c5d32 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -3859,6 +3859,25 @@ FUNCTION hbmk( aArgs, /* @ */ lPause, /* @ */ lUTF8 ) FErase( cScriptFile ) ENDIF + IF nErrorLevel == 0 .AND. hbmk[ _HBMK_lGUI ] .AND. hbmk[ _HBMK_cARCH ] == "darwin" + /* Build app bundle for OS X GUI apps. (experimental) */ + tmp := FN_DirGet( l_cPROGNAME ) + IF ! Empty( tmp ) + tmp += hb_osPathSeparator() + ENDIF + tmp += FN_NameGet( l_cPROGNAME ) + ".app" + hb_osPathSeparator() + "Contents" + IF DirBuild( tmp + hb_osPathSeparator() + "MacOS" ) + FErase( tmp + hb_osPathSeparator() + "MacOS" + hb_osPathSeparator() + FN_NameGet( l_cPROGNAME ) ) + FRename( l_cPROGNAME, tmp + hb_osPathSeparator() + "MacOS" + hb_osPathSeparator() + FN_NameGet( l_cPROGNAME ) ) + IF ! hb_FileExists( tmp + hb_osPathSeparator() + "Info.plist" ) + hb_MemoWrit( tmp + hb_osPathSeparator() + "Info.plist", MacOSXFiles( hbmk, 1, FN_NameGet( l_cPROGNAME ) ) ) + ENDIF + IF ! hb_FileExists( tmp + hb_osPathSeparator() + "PkgInfo" ) + hb_MemoWrit( tmp + hb_osPathSeparator() + "PkgInfo", MacOSXFiles( hbmk, 2, FN_NameGet( l_cPROGNAME ) ) ) + ENDIF + ENDIF + ENDIF + CASE lStopAfterCComp .AND. lCreateLib .AND. ! Empty( cBin_Lib ) IF hbmk[ _HBMK_lINC ] .AND. ! hbmk[ _HBMK_lQuiet ] @@ -4123,20 +4142,25 @@ FUNCTION hbmk( aArgs, /* @ */ lPause, /* @ */ lUTF8 ) IF ! lStopAfterHarbour .AND. ! lStopAfterCComp .AND. ; ! lCreateLib .AND. ! lCreateDyn .AND. ; nErrorLevel == 0 .AND. ! l_lCLEAN .AND. hbmk[ _HBMK_lRUN ] + cCommand := l_cPROGNAME #if defined( __PLATFORM__UNIX ) IF Empty( FN_DirGet( l_cPROGNAME ) ) - l_cPROGNAME := "." + hb_osPathSeparator() + l_cPROGNAME + cCommand := "." + hb_osPathSeparator() + l_cPROGNAME ENDIF #endif - cCommand := PathSepToTarget( hbmk, l_cPROGNAME ) + cCommand := PathSepToTarget( hbmk, cCommand ) #if defined( __PLATFORM__WINDOWS ) - IF hbmk[ _HBMK_lGUI ] - IF hb_osIsWinNT() - cCommand := 'start "" "' + cCommand + '"' - ELSE - cCommand := 'start ' + cCommand + IF hbmk[ _HBMK_lGUI ] + IF hb_osIsWinNT() + cCommand := 'start "" ' + FN_Escape( cCommand, _ESC_DBLQUOTE ) + ELSE + cCommand := "start " + cCommand + ENDIF + ENDIF + #elif defined( __PLATFORM__DARWIN ) + IF hbmk[ _HBMK_lGUI ] + cCommand := "open " + FN_Escape( cCommand + ".app", _ESC_NIX ) ENDIF - ENDIF #endif cCommand := AllTrim( cCommand + " " + ArrayToList( l_aOPTRUN ) ) IF hbmk[ _HBMK_lTRACE ] @@ -6523,6 +6547,62 @@ FUNCTION hbmk_KEYW( hbmk, cKeyword ) RETURN .F. +STATIC FUNCTION MacOSXFiles( hbmk, nType, cPROGNAME ) + LOCAL cString + + HB_SYMBOL_UNUSED( hbmk ) + + SWITCH nType + CASE 1 + + #pragma __cstream|cString:=%s + + + + +%TAB%CFBundleInfoDictionaryVersion +%TAB%6.0 +%TAB%CFBundleIdentifier +%TAB%%__APPID__% +%TAB%CFBundleDevelopmentRegion +%TAB%English +%TAB%CFBundleExecutable +%TAB%%__APPNAME__% +%TAB%CFBundleIconFile +%TAB%%__APPICON__% +%TAB%CFBundleName +%TAB%%__APPNAME__% +%TAB%CFBundlePackageType +%TAB%%__APPTYPE__% +%TAB%CFBundleSignature +%TAB%%__APPSIGN__% +%TAB%CFBundleGetInfoString +%TAB%%__APPNAME__% version %__APPVERSION__%, %__APPCOPYRIGHT__% +%TAB%CFBundleLongVersionString +%TAB%%__APPVERSION__%, %__APPCOPYRIGHT__% +%TAB%NSHumanReadableCopyright +%TAB%%__APPCOPYRIGHT__% +%TAB%LSRequiresCarbon +%TAB% +%TAB%CSResourcesFileMapped +%TAB% + + + ENDTEXT + EXIT + CASE 2 + cString := "%__APPTYPE__%%__APPSIGN__%" + EXIT + ENDSWITCH + + cString := StrTran( cString, "%TAB%", Chr( 9 ) ) + + cString := StrTran( cString, "%__APPNAME__%", cPROGNAME ) + cString := StrTran( cString, "%__APPTYPE__%", "APPL" ) + cString := StrTran( cString, "%__APPSIGN__%", PadR( cPROGNAME, 4, "?" ) ) + + RETURN cString + STATIC PROCEDURE GetUILangCDP( /* @ */ cLNG, /* @ */ cCDP ) IF Empty( cLNG := GetEnv( "HB_LANG" ) )