From c8f896e512be5e426c2aacff476dd115e4fd2b1f Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Mon, 17 Oct 2005 14:49:20 +0300 Subject: [PATCH] blead@25775 Symbian update Message-ID: p4raw-id: //depot/perl@25776 --- MANIFEST | 3 ++ README.symbian | 4 +- symbian/PerlBase.pod | 2 +- symbian/PerlUtil.cpp | 116 ++++++++++++++++++++++++++++++++++++++++++++++++ symbian/PerlUtil.h | 36 +++++++++++++++ symbian/PerlUtil.pod | 41 +++++++++++++++++ symbian/TODO | 5 ++- symbian/config.pl | 29 +++++++++--- symbian/sdk.pl | 86 +++++++++++++++++++++++++++++++++++ symbian/sisify.pl | 75 ++++++++++++++++++++----------- symbian/symbian_proto.h | 2 +- symbian/xsbuild.pl | 25 +++++++---- 12 files changed, 379 insertions(+), 45 deletions(-) create mode 100644 symbian/PerlUtil.cpp create mode 100644 symbian/PerlUtil.h create mode 100644 symbian/PerlUtil.pod diff --git a/MANIFEST b/MANIFEST index efaa36c..700b1c5 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2656,6 +2656,9 @@ symbian/PerlBase.h Symbian Perl base class header symbian/PerlBase.pod Symbian Perl base class documentation symbian/PerlRecog.cpp Symbian recognizer code symbian/PerlRecog.mmp Symbian recognizer build +symbian/PerlUtil.cpp Symbian Perl utility class +symbian/PerlUtil.h Symbian Perl utility class header +symbian/PerlUtil.pod Symbian Perl utility class documentation symbian/port.pl Helper code for config.pl symbian/README ReadMe for the Symbian files symbian/sanity.pl Helper code for config.pl diff --git a/README.symbian b/README.symbian index 19ce115..f3e565b 100644 --- a/README.symbian +++ b/README.symbian @@ -129,7 +129,7 @@ mainly as demonstrations. the messages. Since the total size of all Perl SIS files once installed is - over 1.9 MB, it is recommended to do the installation into a + over 2 MB, it is recommended to do the installation into a memory card (drive E:) instead of the C: drive. The size of the perlXYZ.SIS is about 370 kB but once it is in the @@ -150,7 +150,7 @@ mainly as demonstrations. make perlext.sis - which will create perlXYZext.sis (210 kB -> 470 kB). + which will create perlXYZext.sis (290 kB -> 770 kB). To compile the demonstration application PerlApp you need first to install the Perl headers under the SDK. diff --git a/symbian/PerlBase.pod b/symbian/PerlBase.pod index 2203b96..af70e5d 100644 --- a/symbian/PerlBase.pod +++ b/symbian/PerlBase.pod @@ -1,6 +1,6 @@ =head1 NAME -CPerlBase - a base class encapsulating a Perl interpreter +CPerlBase - a C++ base class encapsulating a Perl interpreter in Symbian =head1 SYNOPSIS diff --git a/symbian/PerlUtil.cpp b/symbian/PerlUtil.cpp new file mode 100644 index 0000000..75c2cff --- /dev/null +++ b/symbian/PerlUtil.cpp @@ -0,0 +1,116 @@ +/* Copyright (c) 2004-2005 Nokia. All rights reserved. */ + +/* The PerlUtil class is licensed under the same terms as Perl itself. */ + +/* See PerlUtil.pod for documentation. */ + +#define PERLUTIL_CPP + +#include "PerlUtil.h" + +#include + +#undef Copy + +EXPORT_C SV* PerlUtil::newSvPVfromTDesC8(const TDesC8& aDesC8) { + dTHX; + return newSVpvn((const char *)aDesC8.Ptr(), aDesC8.Size()); +} + +EXPORT_C void PerlUtil::setSvPVfromTDesC8(SV* sv, const TDesC8& aDesC8) { + dTHX; + sv_setpvn(sv, (const char *)aDesC8.Ptr(), aDesC8.Size()); +} + +EXPORT_C HBufC8* PerlUtil::newHBufC8fromSvPV(SV* sv) { + dTHX; + return PerlUtil::newHBufC8fromPVn((const U8 *)SvPV_nolen(sv), SvLEN(sv)); +} + +EXPORT_C void PerlUtil::setTDes8fromSvPV(TDes8& aDes8, SV* sv) { + dTHX; + PerlUtil::setTDes8fromPVn(aDes8, (const U8 *)SvPV_nolen(sv), SvLEN(sv)); +} + +EXPORT_C SV* PerlUtil::newSvPVfromTDesC16(const TDesC16& aDesC16) { + dTHX; + SV* sv = NULL; + HBufC8* hBuf8 = HBufC8::New(aDesC16.Length() * 3); + + if (hBuf8) { + TPtr8 aPtr8(hBuf8->Des()); + CnvUtfConverter::ConvertFromUnicodeToUtf8(aPtr8, aDesC16); + sv = newSVpvn((const char *)(hBuf8->Ptr()), hBuf8->Size()); + delete hBuf8; + hBuf8 = NULL; + SvUTF8_on(sv); + } + + return sv; +} + +EXPORT_C void PerlUtil::setSvPVfromTDesC16(SV* sv, const TDesC16& aDesC16) { + dTHX; + HBufC8* hBuf8 = HBufC8::New(aDesC16.Length() * 3); + + if (hBuf8) { + TPtr8 aPtr8(hBuf8->Des()); + CnvUtfConverter::ConvertFromUnicodeToUtf8(aPtr8, aDesC16); + sv_setpvn(sv, (const char *)(hBuf8->Ptr()), hBuf8->Size()); + delete hBuf8; + hBuf8 = NULL; + SvUTF8_on(sv); + } +} + +EXPORT_C HBufC16* PerlUtil::newHBufC16fromSvPV(SV* sv) { + dTHX; + return PerlUtil::newHBufC16fromPVn((const U8 *)SvPV_nolen(sv), SvLEN(sv), SvUTF8(sv)); +} + +void PerlUtil::setTDes16fromSvPV(TDes16& aDes16, SV* sv) { + dTHX; + PerlUtil::setTDes16fromPVn(aDes16, (const U8 *)SvPV_nolen(sv), SvLEN(sv), SvUTF8(sv)); +} + +EXPORT_C HBufC8* PerlUtil::newHBufC8fromPVn(const U8* s, STRLEN n) { + HBufC8* aBuf8 = HBufC8::New(n); + if (aBuf8) { + TPtr8 ptr8 = aBuf8->Des(); + ptr8.Copy(s, n); + } + return aBuf8; +} + +EXPORT_C void PerlUtil::setTDes8fromPVn(TDes8& aDes8, const U8* s, STRLEN n) { + // TODO: grow aDes8 if needed + aDes8.Copy(s, n); +} + +EXPORT_C HBufC16* PerlUtil::newHBufC16fromPVn(const U8 *s, STRLEN n, bool utf8) { + HBufC16 *hBuf16 = HBufC16::New(n); // overallocate + + if (hBuf16) { + if (utf8) { + TPtr16 aPtr16(hBuf16->Des()); + TPtrC8 aPtrC8(s, n); + CnvUtfConverter::ConvertToUnicodeFromUtf8(aPtr16, aPtrC8); + } else { + TPtrC8 aPtrC8(s, n); + hBuf16->Des().Copy(aPtrC8); + } + } + + return hBuf16; +} + +EXPORT_C void PerlUtil::setTDes16fromPVn(TDes16& aDes16, const U8 *s, STRLEN n, bool utf8) { + // TODO: grow aDes16 if needed + if (utf8) { + TPtrC8 aPtrC8(s, n); + CnvUtfConverter::ConvertToUnicodeFromUtf8(aDes16, aPtrC8); + } else { + TPtrC8 aPtrC8(s, n); + aDes16.Copy(aPtrC8); + } +} diff --git a/symbian/PerlUtil.h b/symbian/PerlUtil.h new file mode 100644 index 0000000..1e7d292 --- /dev/null +++ b/symbian/PerlUtil.h @@ -0,0 +1,36 @@ +/* Copyright (c) 2004-2005 Nokia. All rights reserved. */ + +/* The PerlUtil class is licensed under the same terms as Perl itself. */ + +/* See PerlUtil.pod for documentation. */ + +#ifndef __PerlUtil_h__ +#define __PerlUtil_h__ + +#include + +#include "EXTERN.h" +#include "perl.h" + +class PerlUtil { + public: + + IMPORT_C static SV* newSvPVfromTDesC8(const TDesC8& aDes); + IMPORT_C static void setSvPVfromTDesC8(SV* sv, const TDesC8& aDes); + IMPORT_C static HBufC8* newHBufC8fromSvPV(SV* sv); + IMPORT_C static void setTDes8fromSvPV(TDes8& aDes8, SV* sv); + + IMPORT_C static SV* newSvPVfromTDesC16(const TDesC16& aDes); + IMPORT_C static void setSvPVfromTDesC16(SV* sv, const TDesC16& aDes); + IMPORT_C static HBufC16* newHBufC16fromSvPV(SV* sv); + IMPORT_C static void setTDes16fromSvPV(TDes16& aDes16, SV* sv); + + IMPORT_C static HBufC8* newHBufC8fromPVn(const U8* s, STRLEN n); + IMPORT_C static void setTDes8fromPVn(TDes8& aDes8, const U8* s, STRLEN n); + IMPORT_C static HBufC16* newHBufC16fromPVn(const U8* s, STRLEN n, bool utf8); + IMPORT_C static void setTDes16fromPVn(TDes16& aDes16, const U8* s, STRLEN n, bool utf8); +}; + +#endif /* #ifndef __PerlUtil_h__ */ + + diff --git a/symbian/PerlUtil.pod b/symbian/PerlUtil.pod new file mode 100644 index 0000000..095d592 --- /dev/null +++ b/symbian/PerlUtil.pod @@ -0,0 +1,41 @@ +=head1 NAME + +PerlUtil - a C++ utility class for Perl/Symbian + +=head1 SYNOPSIS + + // in your App.mmp + USERINCLUDE \symbian\perl\x.y.z\include + LIBRARY perlXYZ.lib + + // in your App + #include "PerlUtil.h" // includes also EXTERN.h and perl.h + + // Static methods for moving between Perl strings (SvPV) + // and Symbian strings (HBufC and TDes). + + static SV* newSvPVfromTDesC8(const TDesC8& aDes); + static void setSvPVfromTDesC8(SV* sv, const TDesC8& aDes); + static HBufC8* newHBufC8fromSvPV(SV* sv); + static void setTDes8fromSvPV(TDes8* aDes8, SV* sv); + + static SV* newSvPVfromTDesC16(const TDesC16& aDes); + static void setSvPVfromTDesC16(SV* sv, const TDesC16& aDes); + static HBufC16* newHBufC16fromSvPV(SV* sv); + static void setTDes16fromSvPV(TDes16* aDes16, SV* sv); + + static HBufC8* newHBufC8fromPVn(const U8* s, STRLEN n); + static void setTDes8fromPVn(TDes8* aDes8, const U8* s, STRLEN n); + static HBufC16* newHBufC16fromPVn(const U8* s, STRLEN n, bool utf8); + static void setTDes16fromPVn(TDes16* aDes16, const U8* s, STRLEN n); + // An example + + const U8* s = (const U8 *)"foo"; + HBufC16* b = PerlUtil::newHBufC16fromPVn(s, 3, 0); + someCallWithConstTDesCRefArgument(*b); + delete b; + +=cut + + + diff --git a/symbian/TODO b/symbian/TODO index 96b81a6..e8586d2 100644 --- a/symbian/TODO +++ b/symbian/TODO @@ -27,14 +27,16 @@ - system("app arg1 arg2 &") but remember that a Symbian process does get only argv[0] and argv[1]: all the arguments of the application are passed - in as a single argument ("arg1 arg2" in the above) + in as a single argument, the second one ("arg1 arg2" in the above) What does not work: + - I/O redirection - piped open, in either direction - qx/backtick/` - fork/wait (these unlikely to ever work as in POSIX) - IO redirection or filename globbing in system() (since there is no POSIX shell beneath) What might work in future: + - some I/O redirection - exec() might be made to work - Symbian::spawn("cmd args") returning a process id (what does Win32 do?) - Symbian::waitpid($spawned_pid) @@ -70,7 +72,6 @@ =head1 PACKAGING -- @INC manipulation for sisify.pl - subdivide perlext.sis? - pm-stripper: strip pod and comments, while inserting the appropriate #line commands to keep linenumbers in sync. Shaves off easily 50% diff --git a/symbian/config.pl b/symbian/config.pl index cb14771..d37a49e 100644 --- a/symbian/config.pl +++ b/symbian/config.pl @@ -313,12 +313,15 @@ print "Creating...\n"; create_mmp( 'miniperl', 'exe', 'miniperlmain.c', 'symbian\symbian_stubs.c', - 'symbian\PerlBase.cpp', 'symbian\symbian_utils.cpp', + 'symbian\PerlBase.cpp', + 'symbian\PerlUtil.cpp', + 'symbian\symbian_utils.cpp', ); create_mmp( "perl", 'exe', 'perlmain.c', 'symbian\symbian_stubs.c', 'symbian\symbian_utils.cpp', 'symbian\PerlBase.cpp', + 'symbian\PerlUtil.cpp', 'ext\DynaLoader\DynaLoader.cpp', ); @@ -326,6 +329,7 @@ create_mmp( "perl$VERSION", 'dll', 'symbian\symbian_dll.cpp', 'symbian\symbian_stubs.c', 'symbian\symbian_utils.cpp', 'symbian\PerlBase.cpp', + 'symbian\PerlUtil.cpp', 'ext\DynaLoader\DynaLoader.cpp', ); @@ -548,10 +552,10 @@ allsis: all miniperlexe.sis perlexe.sis perldll.sis perllib.sis perlext.sis perl perldll.sis perl$VERSION.sis: perldll_arm pm symbian\\makesis.pl perl \$(XLIB) symbian\\makesis.pl perl${VERSION}dll -perllib.sis: \$(PM) +perl${VERSION}lib.sis perllib.sis: \$(PM) perl \$(XLIB) symbian\\makesis.pl perl${VERSION}lib -perlext.sis: perldll_arm buildext_sis +perl${VERSION}ext.sis perlext.sis: perldll_arm buildext_sis perl symbian\\makesis.pl perl${VERSION}ext EXT = Compress::Zlib Cwd Data::Dumper Devel::Peek Digest::MD5 Errno Fcntl File::Glob Filter::Util::Call IO List::Util MIME::Base64 PerlIO::scalar PerlIO::via SDBM_File Socket Storable Time::HiRes XSLoader attrs @@ -587,19 +591,34 @@ sdkinstall: - copy /y *.inc \$(APIDIR)\\include copy /y lib\\ExtUtils\\xsubpp \$(APIDIR)\\lib\\ExtUtils copy /y lib\\ExtUtils\\typemap \$(APIDIR)\\lib\\ExtUtils + copy /y lib\\ExtUtils\\ParseXS.pm \$(APIDIR)\\lib\\ExtUtils copy /y symbian\\xsbuild.pl \$(APIDIR)\\bin + copy /y symbian\\sisify.pl \$(APIDIR)\\bin copy /y symbian\\PerlBase.h \$(APIDIR)\\include + copy /y symbian\\PerlUtil.h \$(APIDIR)\\include copy /y symbian\\symbian*.h \$(APIDIR)\\include\\symbian copy /y symbian\\PerlBase.pod \$(APIDIR)\\pod + copy /y symbian\\PerlUtil.pod \$(APIDIR)\\pod RELDIR = $SDK\\epoc32\\release RELWIN = \$(RELDIR)\\\$(WIN)\\udeb RELARM = \$(RELDIR)\\\$(ARM)\\$UARM +SDKZIP = perl${VERSION}sdk.zip -perlsdk.zip: perldll sdkinstall + +\$(SDKZIP) perlsdk.zip: perldll sdkinstall + -del /f perl${VERSION}sdk.zip zip -r perl${VERSION}sdk.zip \$(RELWIN)\\perl$VERSION.* \$(RELARM)\\perl$VERSION.* \$(APIDIR) \@echo perl${VERSION}sdk.zip created. +PERLSIS = perl${VERSION}.SIS perl${VERSION}lib.SIS perl${VERSION}ext.SIS +ALLSIS = \$(PERLSIS) perlapp.sis +ETC = README.symbian symbian\\PerlBase.pod symbian\\PerlUtil.pod symbian\\sisify.pl symbian\\TODO + +perl${VERSION}dist.zip perldist.zip: \$(ALLSIS) \$(SDKZIP) \$(ETC) + -del /f perl${VERSION}dist.zip + zip -r perl${VERSION}dist.zip \$(ALLSIS) \$(SDKZIP) \$(ETC) + perlapp: sdkinstall perlapp_win perlapp_arm perlapp_win: config.h @@ -615,7 +634,7 @@ perlapp.sis: perlapp_arm cd symbian; make perlapp.sis perlapp.zip: - cd symbian; zip perlapp.zip PerlApp.* PerlRecog.* PerlBase.* demo_pl + cd symbian; zip perlapp.zip PerlApp.* PerlRecog.* PerlBase.* PerlUtil.* demo_pl zip: perlsdk.zip perlapp.zip diff --git a/symbian/sdk.pl b/symbian/sdk.pl index 1dc4d2f..8054c50 100644 --- a/symbian/sdk.pl +++ b/symbian/sdk.pl @@ -46,3 +46,89 @@ $ENV{UARM} = $UARM; die "$0: failed to locate the Symbian SDK\n" unless defined $SDK; $SDK; + +# The following is a cheat sheet for the right S60/S80 SDK settings. +# +# set EPOC_BIN=%EPOCROOT%Epoc32\gcc\bin;%EPOCROOT%Epoc32\Tools +# set MWCW=C:\Program Files\Metrowerks\CodeWarrior for Symbian OEM v2.8 +# set MSVC=C:\Program Files\Microsoft Visual Studio +# set MSVC_BIN=%MSVC%\VC98\Bin;%MSVC%\Common\MSDev98\Bin +# set MSVC_INC=%MSVC%\VC98\atl\include;%MSVC%\mfc\include;%MSVC%\include +# set MSVC_LIB=%MSVC%\mfc\lib;%MSVC%\lib +# +# s60-1.2-cw: +# +# set EPOCROOT=\Symbian\Series60_1_2_CW\ +# set PATH=%EPOC_BIN%;%MSVC_BIN%;%MWCW%\Bin;%MWCW%\Symbian_Tools\Command_Line_Tools;%PATH% +# set USERDEFS=%USERDEFS% -D__SERIES60_12__ -D__SERIES60_MAJOR__=1 -D__SERIES60_MINOR__=2 -D__SERIES60_1X__ +# +# s60-1.2-vc: +# +# set EPOCROOT=\Symbian\6.1\Series60\ +# set PATH=\Symbian\6.1\Shared\Epoc32\gcc\bin;\Symbian\6.1\Shared\Epoc32\Tools;%MSVC_BIN%;%PATH% +# set INCLUDE=%MSVC_INC% +# set LIB=%MSVC_LIB% +# set USERDEFS=%USERDEFS% -D__SERIES60_12__ -D__SERIES60_MAJOR__=1 -D__SERIES60_MINOR__=2 -D__SERIES60_1X__ +# +# s60-2.0-cw: +# +# set EPOCROOT=\Symbian\7.0s\Series60_v20_CW\ +# set EPOCDEVICE=Series60_2_0_CW:com.Nokia.Series60_2_0_CW +# set PATH=%EPOC_BIN%;%MWCW%\Bin;%MWCW%\Symbian_Tools\Command_Line_Tools;%PATH% +# set USERDEFS=%USERDEFS% -D__SERIES60_20__ -D__SERIES60_MAJOR__=2 -D__SERIES60_MINOR__=0 -D__SERIES60_2X__ +# +# s60-2.0-vc: +# +# set EPOCROOT=\Symbian\7.0s\Series60_v20\ +# set EPOCDEVICE=Series60_v20:com.nokia.series60 +# set PATH=%EPOC_BIN%;%MSVC_BIN%;%PATH% +# set INCLUDE=%MSVC_INC% +# set LIB=%MSVC_LIB% +# set USERDEFS=%USERDEFS% -D__SERIES60_20__ -D__SERIES60_MAJOR__=2 -D__SERIES60_MINOR__=0 -D__SERIES60_2X__ +# +# s60-2.1-cw: +# +# set EPOCROOT=\Symbian\7.0s\Series60_v21_CW\ +# set EPOCDEVICE=Series60_v21_CW:com.Nokia.series60 +# set PATH=%EPOC_BIN%;%MWCW%\Bin;%MWCW%\Symbian_Tools\Command_Line_Tools;%PATH% +# set USERDEFS=%USERDEFS% -D__SERIES60_21__ -D__SERIES60_MAJOR__=2 -D__SERIES60_MINOR__=1 -D__SERIES60_2X__ +# +# s60-2.6-cw: +# +# set EPOCROOT=\Symbian\8.0a\S60_2nd_FP2_CW\ +# set EPOCDEVICE=S60_2nd_FP2_CW:com.nokia.series60 +# set PATH=%EPOC_BIN%;%MWCW%\Bin;%MWCW%\Symbian_Tools\Command_Line_Tools;%PATH% +# set USERDEFS=%USERDEFS% -D__SERIES60_26__ -D__SERIES60_MAJOR__=2 -D__SERIES60_MINOR__=6 -D__SERIES60_2X__ -D__BLUETOOTH_API_V2__ +# +# s60-2.6-vc: +# +# set EPOCROOT=\Symbian\8.0a\S60_2nd_FP2\ +# set EPOCDEVICE=S60_2nd_FP2:com.nokia.Series60 +# set PATH=%EPOC_BIN%;%MSVC_BIN%;%PATH% +# set INCLUDE=%MSVC_INC% +# set LIB=%MSVC_LIB% +# set USERDEFS=%USERDEFS% -D__SERIES60_26__ -D__SERIES60_MAJOR__=2 -D__SERIES60_MINOR__=6 -D__SERIES60_2X__ -D__BLUETOOTH_API_V2__ +# +# s60-2.8-cw: +# +# set EPOCROOT=\Symbian\8.1a\S60_2nd_FP3\ +# set EPOCDEVICE=S60_2nd_FP3:com.nokia.series60 +# set PATH=%EPOC_BIN%;%MWCW%\Bin;%MWCW%\Symbian_Tools\Command_Line_Tools;%PATH% +# set USERDEFS=%USERDEFS% -D__SERIES60_28__ -D__SERIES60_MAJOR__=2 -D__SERIES60_MINOR__=8 -D__SERIES60_2X__ -D__BLUETOOTH_API_V2__ +# +# s80-2.0-cw: +# +# set EPOCROOT=\Symbian\7.0s\S80_DP2_0_SDK_CW\ +# set EPOCDEVICE=Series80_DP2_0_SDK_CW:com.nokia.Series80 +# set PATH=%EPOC_BIN%;%MWCW%\Bin;%MWCW%\Symbian_Tools\Command_Line_Tools;%PATH% +# set USERDEFS=%USERDEFS% -D__SERIES80_20__ -D__SERIES80_MAJOR__=2 -D__SERIES80_MINOR__=0 -D__SERIES80_2X__ +# +# s80-2.0-vc: +# +# set EPOCROOT=\Symbian\7.0s\S80_DP2_0_SDK\ +# set EPOCDEVICE=Series80_DP2_0_SDK:com.nokia.Series80 +# set PATH=%EPOC_BIN%;%MWCW%\Bin;%MWCW%\Symbian_Tools\Command_Line_Tools;%PATH% +# set USERDEFS=%USERDEFS% -D__SERIES80_20__ -D__SERIES80_MAJOR__=2 -D__SERIES80_MINOR__=0 -D__SERIES80_2X__ +# +# EOF + diff --git a/symbian/sisify.pl b/symbian/sisify.pl index 1cf2065..6edce4b 100644 --- a/symbian/sisify.pl +++ b/symbian/sisify.pl @@ -14,7 +14,7 @@ use strict; use vars qw($VERSION); -$VERSION = '0.1'; +$VERSION = '0.2'; use Getopt::Long; use File::Temp qw/tempdir/; @@ -22,24 +22,14 @@ use File::Find; use File::Basename qw/basename dirname/; use Cwd qw/getcwd/; -# TODO: -# - prepend the \system\app\$AppName{,\lib} somehow to the @INC - BEGIN { - my $warn; - # This utility has been developed under Cygwin in Windows with - # the Series 60 2.6 SDK installed, but for the makesis utility in - # UNIX/Linux, try e.g. one of the following: + # This utility has been developed in Windows under cmd.exe with + # the Series 60 2.6 SDK installed, but for the makesis utility + # in UNIX/Linux, try e.g. one of the following: # http://gnupoc.sourceforge.net/ # http://symbianos.org/~andreh/ You # will also need the 'uidcrc' utility. - for my $exe (qw(/bin/cp /bin/tar)) { - unless( -f $exe) { # Sorry, Win32ers. - warn "$0: Need $exe\n"; - $warn++; - } - } - die "$0: Cannot continue, aborting.\n" if $warn; + die "$0: Looks like Cygwin, aborting.\n" if exists $ENV{'!C:'}; } sub die_with_usage { @@ -52,7 +42,7 @@ $0 [ --uid=hhhhhhhh ] [ --version=a.b.c ] [ --library=x.y.z ] [ some.pl | Some.p The uid is the Symbian app uid for the SIS. The version is the version of the SIS. The library is the version of Perl under which to install. If using this, -only specify directories to package. +only specify directories for packaging. __USAGE__ } @@ -156,15 +146,16 @@ for my $file (@SisPl, @SisPm, @SisOther) { print "[copying file '$file']\n" if $Debug; die_with_usage("$0: File '$file': $!") unless -f $file; my $dir = dirname($file); - do_system("mkdir $tempdir/$dir") unless $dir eq '.'; - do_system("cp $file $tempdir"); + do_system("mkdir $tempdir\\$dir") unless $dir eq '.'; + do_system("copy $file $tempdir"); } if (@SisPl) { - do_system("cp $SisPl[0] $tempdir/default.pl") unless $SisPl[0] eq "default.pl"; + do_system("copy $SisPl[0] $tempdir\\default.pl") + unless $SisPl[0] eq "default.pl"; } for my $dir (@SisDir) { print "[copying directory '$dir']\n" if $Debug; - do_system("tar cf - $dir | (cd $tempdir && tar xf -)"); + do_system("copy $dir $tempdir"); } my $SisVersionCommas = $SisVersion; @@ -173,13 +164,43 @@ $SisVersionCommas =~ s/\./\,/g; my @pkg; -push @pkg, qq[&EN]; +push @pkg, qq[&EN;]; push @pkg, qq[#{"$AppName"},($SisUid),$SisVersionCommas]; push @pkg, qq[(0x101F6F88), 0, 0, 0, {"Series60ProductID"}]; my $OWD = getcwd(); +$OWD =~ s!/!\\!g; + chdir($tempdir) or die "$0: chdir('$tempdir')\n"; + +if (@SisPl) { + if (open(my $fi, "default.pl")) { + my $fn = "default.pl.new"; + if (open(my $fo, ">$fn")) { + while (<$fi>) { + last unless /^\#/; + print $fo $_; + } + print $fo "use lib qw(\\system\\apps\\$AppName \\system\\apps\\$AppName\\lib);\n"; + printf $fo qq[# %d "$SisPl[0]"\n], $.; + print $fo $_; + while (<$fi>) { + print $fo $_; + } + close($fo); + } else { + die "$0: open '>$fn': $!\n"; + } + close($fi); + rename($fn, "default.pl") or die "$0: rename $fn default.pl: $!\n"; + # system("cat -nvet default.pl"); + } else { + die "$0: open 'default.pl': $!\n"; + } +} + + my @c; find( sub { @@ -290,15 +311,15 @@ if ($ShowPkg) { } my $sis = "$AppName.SIS"; unlink($sis); + do_system("dir"); do_system("makesis $fn"); unless (-f $sis) { die qq[$0: failed to create "$sis"\n]; } - do_system("ls -l"); - do_system("cat -vet $fn"); - do_system("cp $AppName.sis $OWD"); + do_system("copy $AppName.sis $OWD"); + chdir($OWD); + system("dir $sis"); print "\n=== Now transfer $sis to your device ===\n"; - system("ls -l $sis"); } exit(0); @@ -307,6 +328,8 @@ sub init_hex { # This is Symbian application executable skeleton. # You can create the ...\epoc32\release\thumb\urel\foo.app # by compiling the PerlApp.cpp with PerlMinSample defined in PerlApp.h. + # The following executable has been compiled using the Series 60 SDK 2.6 + # for Visual C. $APPHEX = <<__APP__; 7900 0010 ce39 0010 f615 2010 8581 1076 4550 4f43 0020 0000 05fc d15d 0000 0000 @@ -691,6 +714,8 @@ __APP__ # This is Symbian application resource skeleton. # You can create the ...\epoc32\data\z\system\apps\PerlApp\PerlApp.rsc # by compiling the PerlApp.cpp. + # The following resource has been compiled using the Series 60 SDK 2.6 + # for Visual C. $RSCHEX = <<__RSC__; 6b4a 1f10 0000 0000 5fde 0400 1ca3 60de 01b8 0010 0004 0000 0001 f0e5 4d00 0000 diff --git a/symbian/symbian_proto.h b/symbian/symbian_proto.h index f50de34..2a51f3a 100644 --- a/symbian/symbian_proto.h +++ b/symbian/symbian_proto.h @@ -41,7 +41,7 @@ extern char* strncpy(char *dst, const char *src, size_t n); #endif /* PERL_CORE || PERL_EXT */ -#if defined(SYMBIAN_DLL_CPP) || defined(SYMBIAN_UTILS_CPP) || defined(PERLBASE_CPP) +#if defined(SYMBIAN_DLL_CPP) || defined(SYMBIAN_UTILS_CPP) || defined(PERLBASE_CPP) || defined(PERLUTIL_CPP) # define PERL_SYMBIAN_START_EXTERN_C extern "C" { # define PERL_SYMBIAN_EXPORT_C EXPORT_C # define PERL_SYMBIAN_END_EXTERN_C } diff --git a/symbian/xsbuild.pl b/symbian/xsbuild.pl index f4140a9..556db70 100644 --- a/symbian/xsbuild.pl +++ b/symbian/xsbuild.pl @@ -34,8 +34,8 @@ my $SDK; my $VERSION; my $R_V_SV; my $PERLSDK; -my $WIN; -my $ARM; +my $WIN = 'wins'; +my $ARM = 'thumb'; my $BUILDROOT = getcwd(); if ( !defined $PerlVersion && $0 =~ m:\\symbian\\perl\\(.+)\\bin\\xsbuild.pl:i ) @@ -101,15 +101,22 @@ $PERLSDK = "\\Symbian\\Perl\\$PerlVersion"; $R_V_SV = $PerlVersion; -$VERSION =~ tr/.//d; +$VERSION = $PerlVersion unless defined $VERSION; + +$VERSION =~ tr/.//d if defined $VERSION; $ENV{SDK} = $SDK; # For the Errno extension $ENV{CROSS} = 1; # For the Encode extension -my $UREL = $ENV{UREL}; # from sdk.pl -$UREL =~ s/-ARM-/$ARM/; -my $UARM = $ENV{UARM}; # from sdk.pl -my $SRCDBG = $UARM eq 'udeb' ? "SRCDBG" : ""; +my $UARM = 'urel'; +my $UREL = "$SDK\\epoc32\\release\\-ARM-\\$UARM"; +my $SRCDBG; +if (exists $ENV{UREL}) { + $UREL = $ENV{UREL}; # from sdk.pl + $UREL =~ s/-ARM-/$ARM/; + $UARM = $ENV{UARM}; # from sdk.pl + $SRCDBG = $UARM eq 'udeb' ? "SRCDBG" : ""; +} my %CONF; my %EXTCFG; @@ -379,7 +386,7 @@ sub update_dir { sub xsconfig { my ( $ext, $dir ) = @_; - print "Configuring for $ext, directory $dir...\n"; + print "Configuring for $ext, directory '$dir'...\n"; my $extu = $CoreBuild ? "$BUILDROOT\\lib\\ExtUtils" : "$PERLSDK\\lib\\ExtUtils"; update_dir($dir) or die "$0: chdir '$dir': $!\n"; my $build = dirname($ext); @@ -743,7 +750,7 @@ for my $ext (@ARGV) { # (3) With an updated _init.c that carries the symbols from step (2). system_echo("make clean"); - system_echo("make defrost") == 0 or die "$0: make defrost failed\n"; + system_echo("make defrost") == 0 or warn "$0: make defrost failed\n"; my @TARGET; -- 2.7.4