[Laszlo-user] Build Info

Rich Christiansen warproof at warproof.com
Thu Nov 1 17:31:19 PDT 2007


For anyone following this thread, I thought I'd report on my solution here.

To include the build data in my app, I used 'Rake', the build tool of 
the ever-so-shiny Ruby language.  Every time I run rake, an XML file is 
generated (compilationData.xml) that contains the time at which the 
build was produced.

Since I was already introducing a fairly heavyweight build tool like 
Rake, I thought I'd automate the building of several different 'flavors' 
of my app as well - something I had previously done manually.  (These 
'flavors' are the various binary combinations of 'Debug' and 'Pro'.)  
Compilation is provided via the ropenlaszlo ruby gem, and 
distribution-ready packages are prepared with a variety of shell 
commands (cp, zip, etc.)

If you're intrigued by what this 'Featurific' thing might be, feel free 
to check out http://featurific.com .

Hope this helps someone else! :)

-Rich


<begin Rakefile>
# Written by Rich following the instructions at 
http://weblog.openlaszlo.org/archives/2006/01/deploying-openlaszlo-applications-with-rake/
# Also used http://sishen.lifegoo.com/?p=41 as a guide

# Before running 'rake' you'll need to ensure you've run the following 
commands to properly set your env vars
# export OPENLASZLO_HOME=/Applications/OpenLaszlo\ Server\ 
4.0.2/Server/lps-4.0.2   # location of the OpenLaszlo SDK on the file system
# export 
OPENLASZLO_URL=http://localhost:8080/lps-4.0.2                             
# URL of the OpenLaszlo server


require 'rubygems'
require 'ropenlaszlo'
require 'rake/clean'

@@time = Time.new

BUILD_DIR = "build"
ARCHIVE_DIR = File.join(BUILD_DIR, 'archives')
F_FREE_DIR = File.join(ARCHIVE_DIR, 'Featurific')
F_PRO_DIR = File.join(ARCHIVE_DIR, 'FeaturificPro')

directory(BUILD_DIR)
directory(ARCHIVE_DIR)
directory(F_FREE_DIR)
directory(F_PRO_DIR)

CLEAN.include(File.join(BUILD_DIR, '*.swf'))  # Remove all SWFs (leave 
archives dir intact)
CLOBBER.include(BUILD_DIR)                    # Remove all build files

##### Compile main.lzx to .swf
# NOTE: Since we :clean before every compilation, we don't need to 
include all lzx files as dependencies.  This means the app will be
# re-built from scratch on *every* 'rake' (otherwise, the app would only 
be rebuilt if main.lzx had been changed)
file File.join(BUILD_DIR, 'main.swf') => ['main.lzx', :clean, BUILD_DIR, 
F_FREE_DIR, F_PRO_DIR] do
  #       in          out                                     rt      
debug   pro
  compile('main.lzx', 'featurific.swf',                       'swf8', 
false,  false)
  compile('main.lzx', 'featurificDebug.swf',                  'swf8', 
true,   false)
  compile('main.lzx', 'featurificPro.swf',                    'swf8', 
false,  true)
  compile('main.lzx', 'featurificProDebug.swf',               'swf8', 
true,   true)
end

def compile(infile, outfile, runtime, debug, pro_version)
  puts "\nCompiling #{infile} to #{outfile} 
(runtime:#{runtime},\tdebug:#{debug},\tpro_version:#{pro_version})" if 
verbose
  prepare_compilation_data(pro_version)
  puts "Compiling..."
  OpenLaszlo::compile infile, {:output => File.join(BUILD_DIR, outfile), 
:runtime => runtime, :debug => debug}
 
  if pro_version
    cp File.join(BUILD_DIR, outfile), File.join(F_PRO_DIR, outfile)
  else
    cp File.join(BUILD_DIR, outfile), File.join(F_FREE_DIR, outfile)
  end
end

def prepare_compilation_data(pro_version)
  puts "Preparing compilation data" if verbose
  open("compilationData.xml",'w') do |outfile|
    outfile.puts "<data>"
    outfile.puts "\t<buildTime value='#{@@time}'/>"
    outfile.puts "\t<proVersion value='#{pro_version}'/>"
    outfile.puts "</data>"
  end
end


##### Create archives
desc "Build the app and create distro archives"
task :create_archives => [:clobber, ARCHIVE_DIR, File.join(BUILD_DIR, 
'main.swf')] do
  puts "\nCreating archives" if verbose

  # Common files
  cp_r File.join('buildResources', 'common', '.'), F_FREE_DIR
  cp_r File.join('buildResources', 'common', '.'), F_PRO_DIR

  # FREE
  cp_r File.join('buildResources', 'FREE', '.'), F_FREE_DIR
 
  # Pro
  cp_r File.join('buildResources', 'Pro', '.'), F_PRO_DIR
 
  sh "cd #{F_FREE_DIR} && zip -qr -9 ../featurific.zip *"
  sh "cd #{F_PRO_DIR} && zip -qr -9 ../featurificPro.zip *"
end


##### Default - Compile
task :default => File.join(BUILD_DIR, 'main.swf')
<end Rakefile>





<begin output>
Fuji:/Applications/OpenLaszlo Server 4.0.2/Server/lps-4.0.2/gallery3 
rich$ rake create_archives
(in /Applications/OpenLaszlo Server 4.0.2/Server/lps-4.0.2/gallery3)
rm -r build/featurific.swf
rm -r build/featurificDebug.swf
rm -r build/featurificPro.swf
rm -r build/featurificProDebug.swf
rm -r build
mkdir -p build/archives
mkdir -p build/archives/Featurific
mkdir -p build/archives/FeaturificPro

Compiling main.lzx to featurific.swf (runtime:swf8,     debug:false,    
pro_version:false)
Preparing compilation data
Compiling...
cp build/featurific.swf build/archives/Featurific/featurific.swf

Compiling main.lzx to featurificDebug.swf (runtime:swf8,        
debug:true,    pro_version:false)
Preparing compilation data
Compiling...
cp build/featurificDebug.swf build/archives/Featurific/featurificDebug.swf

Compiling main.lzx to featurificPro.swf (runtime:swf8,  debug:false,    
pro_version:true)
Preparing compilation data
Compiling...
cp build/featurificPro.swf build/archives/FeaturificPro/featurificPro.swf

Compiling main.lzx to featurificProDebug.swf (runtime:swf8,     
debug:true,    pro_version:true)
Preparing compilation data
Compiling...
cp build/featurificProDebug.swf 
build/archives/FeaturificPro/featurificProDebug.swf

Creating archives
cp -r buildResources/common/. build/archives/Featurific
cp -r buildResources/common/. build/archives/FeaturificPro
cp -r buildResources/FREE/. build/archives/Featurific
cp -r buildResources/Pro/. build/archives/FeaturificPro
cd build/archives/Featurific && zip -qr -9 ../featurific.zip *
cd build/archives/FeaturificPro && zip -qr -9 ../featurificPro.zip *
<end output>

P T Withington wrote:
> The debug version is formatted to the debug console (and only 
> available in debug).  The canvas version is available in all apps and 
> returns a string that can be displayed by your application.
>
> Maybe file an improvement request to add the app compile timestamp to 
> that info...
>
> On 2007-10-30, at 13:22 EDT, Henry Minsky wrote:
>
>> The actual call to get the info as a string is
>>
>> LzCanvas.versionInfoString()
>>
>>
>>
>> On 10/30/07, Henry Minsky <henry.minsky at gmail.com> wrote:
>>>
>>> Hmm, that's a good idea, I don't think the compiler bakes the  date 
>>> that
>>> the app was compiled into the app anyplace. It does bake in the 
>>> information
>>> on the version of LPS that is running though:
>>>
>>> Debug.versionInfo ()
>>>
>>> will return a string like this
>>> Debug.versionInfo
>>>
>>> lzx> Debug.versionInfo
>>> ()
>>> URL:
>>>
>>> http://127.0.0.1:8080/trunk/test/forum2/main.lzx?lzt=object&lzt=object&lzr=dhtml&debug=true&lzbacktrace=true 
>>>
>>>
>>> Version: 4.1.x.0
>>> Release: Latest
>>> Build: 7031 C:\users\hqm\openlaszlo\trunk
>>> Date: 2007-10-28T20:54:17-0400
>>> Target: dhtml
>>> Runtime: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: 1.8.1.8)
>>> Gecko/20071008 Firefox/2.0.0.8
>>> lzx>
>>>
>>> On 10/30/07, Rich Christiansen <warproof at warproof.com> wrote:
>>>>
>>>> I'm currently dealing with the unpleasant headache of tracking various
>>>> installations of different versions of my SOLO app.  I've added
>>>> functionality to display the version number of the app, but I'd also
>>>> like to include a build number.  In fact, I'd prefer to just use the
>>>> time at which the app was built if that's possible.
>>>>
>>>> How could I go about doing this?  Some sort of preprocessing 
>>>> directive?
>>>>
>>>> Thanks in advance! :)
>>>> -Rich
>>>>
>>>
>>>
>>>
>>> -- 
>>> Henry Minsky
>>> Software Architect
>>> hminsky at laszlosystems.com
>>>
>>>
>>
>>
>> -- 
>> Henry Minsky
>> Software Architect
>> hminsky at laszlosystems.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.openlaszlo.org/pipermail/laszlo-user/attachments/20071101/c0967293/attachment-0001.html


More information about the Laszlo-user mailing list