How_do_I_use_the_same_pkg_file_for_debug_and_release_builds(转)
2010-11-19 18:12
483 查看
Within Carbide there is a useful protocol whereby you can use three macros in your pkg file. To quote the SDK
“The following symbols are available for PKG files in order to make reuse of PKG files more efficient across build targets. These symbols are only supported within Carbide.c++. They are:
$(EPOCROOT) — the location of the epoc32 folder but not including the epoc32 folder
$(PLATFORM) — platform designator, for example: ARMI, WINSC (Emulator) , GCCE, THUMB, etc.
$(TARGET) — target designator UDEB (Debug) or UREL (Release)”
This is a good thing because you don’t need to have special pkg files for release and debug builds. Sadly this is not available in the vanilla SDKs.
Carbide is good, but there are often times we have to implement batch build systems and have to rely on the SDK. The good news is you can do a half-baked/home-baked version yourself. The steps are as follows
1. Use an Extension makefile file in your bld.inf. The line will look something like:
2. In sis.make (you can call it what you want, but it has to match the line above) you can call a Perl script. Something like:
To find out what the environment is when the build is going on you can call this function in the script:
So, this function:
The basic idea is that the environment variables are there to use as part of the build process. You could use another language; I just use Perl because it is already there in the SDK. You can also customize your build in all sorts of ways once you get the hang of it.
Hope this helps.
“The following symbols are available for PKG files in order to make reuse of PKG files more efficient across build targets. These symbols are only supported within Carbide.c++. They are:
$(EPOCROOT) — the location of the epoc32 folder but not including the epoc32 folder
$(PLATFORM) — platform designator, for example: ARMI, WINSC (Emulator) , GCCE, THUMB, etc.
$(TARGET) — target designator UDEB (Debug) or UREL (Release)”
This is a good thing because you don’t need to have special pkg files for release and debug builds. Sadly this is not available in the vanilla SDKs.
Carbide is good, but there are often times we have to implement batch build systems and have to rely on the SDK. The good news is you can do a half-baked/home-baked version yourself. The steps are as follows
1. Use an Extension makefile file in your bld.inf. The line will look something like:
makefile ..\sis\sis.makeThe details of Extension makefiles are in the SDK.
2. In sis.make (you can call it what you want, but it has to match the line above) you can call a Perl script. Something like:
pkgname= pkg1 FINAL : echo using EPOCROOT= echo $(EPOCROOT) echo Writing pkg createpkgfiles.pl echo make the sis file echo Build and sign using makesis $(pkgname).pkg signsis -v -s $(pkgname).SIS $(pkgname)signed.sis somecert.cer somekey.key del /q $(pkgname).SIS ren $(pkgname)signed.sis $(pkgname).sis3. Use “createpkgfiles.pl” to write the pkg files from templates.
@templates= ( ['template.pkg1.pkg', 'pkg1.pkg'], ['template.pkg2.pkg', 'pkg2.pkg'], ); sub replaceStrings { print "\nreplace strings\n"; local $/; #Move the template to the target file for $i( 0 .. $#templates) { print "\n\ncopy /Y $templates[$i][0] $templates[$i][1]\n\n"; system("copy /Y $templates[$i][0] $templates[$i][1]"); open(FILE, $filename) or open(FILE, "$templates[$i][1]") or die("could not find $filename"); $_=<FILE>; close (FILE); foreach $key (sort keys(%ENV)) { #print "\n$key = $ENV{$key}"; s/\$\($key\)/$ENV{$key}/gm; } open(FILE, ">$templates[$i][1]") or die("could not find $filename for writing"); print FILE "$_"; close (FILE); } } ######################## #Start here ######################## replaceStrings(); print "\nEnd";The script will take lines like in the template file
$(EPOCROOT)epoc32\release\$(PLATFORM)\$(CFG)\...and turn them into
C:\Symbian\9.1\S60_3rd_MR\epoc32\include\GCCE\UREL\...In the pkg file words conforming to the $(varname) syntax will be replaced with the value of the value of the environment variable.
To find out what the environment is when the build is going on you can call this function in the script:
sub printEnv { foreach $key (sort keys(%ENV)) { print "\n$key = $ENV{$key}"; } }The good thing is that you can use any environment variable, so you can set a few of your own and use them to vary the build and/or change the version in the pkg to match your app.
So, this function:
sub setVersion { my($versionInfoFile)=@_; open(VER_FILE, $versionInfoFile); print "Get versions from $versionInfoFile\n"; while($line=<VER_FILE>) { @words=split(/ +/, $line); if($words[1] eq 'VERSION_MAJOR') { $val=$words[2]; chomp($val); print "VERSION_MAJOR= $val, "; $ENV{'BLD_VER_MAJOR'}=$val; } if($words[1] eq 'VERSION_MINOR') { $val=$words[2]; chomp($val); print "VERSION_MINOR= $val, "; $ENV{'BLD_VER_MINOR'}=$val; } if($words[1] eq 'VERSION_BUILD') { $val=$words[2]; chomp($val); print "VERSION_BUILD= $val"; $ENV{'BLD_VER_BUILD'}=$val; } } close (VER_FILE); }Will read the version numbers out of a header that looks like this:
#define VERSION_MAJOR 4 #define VERSION_MINOR 0 #define VERSION_BUILD 49And set the environment so that the line in the pkg template:
#{"$( BLD_PKG_NAME)", "$(BLD_PKG_NAME)"},(0x20000xxx),$(BLD_VER_MAJOR),$(BLD_VER_MINOR),$(BLD_VER_BUILD)Will yield the hoped for result (If I had a penny for every time I forgot to update the pkg version and released something, I would have about 8p)
The basic idea is that the environment variables are there to use as part of the build process. You could use another language; I just use Perl because it is already there in the SDK. You can also customize your build in all sorts of ways once you get the hang of it.
Hope this helps.
相关文章推荐
- How to get the Diagnostic data and debug file of Sales Order pick release
- How to locate the log files and troubleshoot Rapid Install for Release 12.0.x and 12.1.x [ID 452120.1]
- How to create fully custom Role, User, Event, Resource classes for use with the Security and Scheduler modules
- How to Access and Use the Windows Hosts File in Windows 7 and Vista
- How do I get multiple process to log to the same file?
- How to Use JSONKit for iOS and the Rotten Tomatoes API
- How can I force Python's file.write() to use the same newline format in Windows as in Linux (“\r\n”
- How do we release the GDI object when we use selectobject choosing a brush?
- cannot use the same dataset for report.dataset and page.dataset
- [Android]Error:Application and test application id cannot be the same: both are '' for debugAndroid
- How to use the same thread function for multiple threads (safely)
- Error:Application and test application id cannot be the same: both are 'com.xxxxxxx' for debugAndroi
- Open debug mode for Tomcat and use Eclipse to remote debug the application
- How to Determine the Version of Oracle XML Publisher for Oracle E-Business Suite 11i and Release 12 (Doc ID 362496.1)
- How to Change the Icon for a File Type in Windows 7 and Vista(转)
- How to download Xcode 4 / 5 / 6 / 7 and get the DMG file?
- How do the Match Approval Level Option and Invoice Match Option work?
- how do I delete an Eclipse project when I've already deleted the folder and contents?
- use MyButton is simple,only add two file and then add some code just bellow in any dlg src declear the button control and will ok!
- How to Use the BASH "for" Loop in Shell Scripts