specs/stx-jv.rbspec
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 10 Sep 2019 22:02:16 +0100
changeset 322 7ed1f5ec59c5
parent 317 70c505f690bf
permissions -rw-r--r--
Use forked `stx:libjavascript`

...since the one from eXept's repositories is broken for
too long...
     1 # A helper function to download and unpack pre-built stc and librun
     2 # for those who are not lucky enough to have an access to sources
     3 def download_binary_component(component, directory)
     4   plat = nil
     5   blob = nil
     6   sha256 = nil
     7   pattern = /prebuilt-#{Regexp.quote(component)}/
     8 
     9   build_url = %Q{https://swing.fit.cvut.cz/jenkins/job/stx_jv/lastStableBuild}
    10 
    11   origin_forest_url = HG::Repository.new(BUILD_DIR / '..').paths['default'].slice(0.. - 'stx-goodies-builder-rake'.size - 2) #/
    12   # When building using Jan's staging repositories, use pre-built stc and librun
    13   # from there too. 
    14   if (origin_forest_url =~ /192.168.27.250/) then
    15     build_url = %Q{http://192.168.27.253:8080/job/stx_jv/lastStableBuild/}
    16   end
    17 
    18   build = Jenkins::Build.new(build_url)
    19   platform = BUILD_TARGET
    20   build.artifacts.each do | artifact |
    21     if (pattern =~ artifact.name) and (artifact.name.include? platform) then
    22       if artifact.name.end_with? '.sha256' then
    23         sha256 = artifact
    24       else
    25         blob = artifact
    26       end
    27     end
    28   end
    29   if not blob then
    30     error "No binary component \"'#{component}\" found: #{build_url}/artifact/artifacts/"
    31   end
    32   if sha256 then
    33     info "Downloading binary component SHA265 checksum #{sha256.name}"
    34     sha256.download_to(directory)
    35     if File.exist? directory / "#{component}" and File.exist? directory / "#{component}.sha256" then
    36       # Compare a "current" checksum and the (possibly) "new" checkum.
    37       # if same, skip the download (assuming that version has been
    38       # downloaded already)
    39       sha256_current = File.read(directory / ".#{component}.sha256")
    40       sha256_new     = File.read(directory / sha256.name)
    41       if sha256_new == sha256_current then
    42         return
    43       end
    44     end
    45   end
    46   info "Downloading binary component #{blob.name}"
    47   blob.download_to(directory)
    48   info "Extracting binary component #{blob.name}"
    49   if File.exist? directory / component then
    50     rm_rf directory / component
    51   end
    52   unzip directory / blob.name, remove: true
    53   if sha256 then
    54     mv directory / sha256.name, directory / ".#{component}.sha256"
    55   end
    56 end
    57 
    58 project :'stx:jv-branch-core' do
    59   # Core Smalltalk/X - does contain only standard libraries,
    60   # and development tools. Does not contain any other 'features'
    61   # like XML suite, Java support. Usable as a basis for standalone
    62   # applications that needs some JV-branch features.
    63   import :'stx:baseline'
    64 
    65   # FORKED STC and librun
    66   package "stx:stc", :repository => :'jv-branch:public', :branch => 'jv',
    67     :checkout => (Proc.new do | pkg |
    68       # Download pre-compiled binary if user has no access to source code
    69       begin
    70         checkout pkg.repository, 'stx/stc', :branch => pkg.branch, :revision => pkg.revision
    71       rescue Exception
    72         download_binary_component('stc', BUILD_DIR / 'stx')
    73       end
    74     end),
    75     :update => (Proc.new do | pkg |
    76       if (File.exists? BUILD_DIR / 'stx' / 'stc' / '.hg' / 'hgrc') then
    77         update pkg.repository, 'stx/stc', :branch => pkg.branch, :revision => pkg.revision
    78       elsif not jenkins?
    79         download_binary_component('stc', BUILD_DIR / 'stx')
    80       end
    81     end)
    82 
    83   package "stx:librun", :repository => :'jv-branch:public', :branch => 'jv',
    84     :checkout => (Proc.new do | pkg |
    85       # Download pre-compiled binary if user has no access to source code
    86       begin
    87         checkout pkg.repository, 'stx/librun', :branch => pkg.branch, :revision => pkg.revision
    88       rescue Exception
    89         download_binary_component('librun', BUILD_DIR / 'stx')
    90       end
    91     end),
    92     :update => (Proc.new do | pkg |
    93       if (File.exists? BUILD_DIR / 'stx' / 'librun' / '.hg' / 'hgrc') then
    94         update pkg.repository, 'stx/stc', :branch => pkg.branch, :revision => pkg.revision
    95       elsif not jenkins?
    96         download_binary_component('librun', BUILD_DIR / 'stx')
    97       end
    98     end)
    99 
   100   # FORKED libraries
   101   # ======================================================================
   102   package "stx:libbasic", :repository => :'jv-branch:public', :branch => 'jv'
   103   package "stx:libbasic2", :repository => :'jv-branch:public', :branch => 'jv'
   104   package "stx:libbasic3", :repository => :'jv-branch:public', :branch => 'jv'
   105   package "stx:libcomp", :repository => :'jv-branch:public', :branch => 'jv'
   106   package "stx:libtool", :repository => :'jv-branch:public', :branch => 'jv'
   107   package "stx:libtool2",:repository => :'jv-branch:public', :branch => 'jv'
   108 
   109   package "stx:libview", :repository => :'jv-branch:public', :branch => 'jv'
   110   package "stx:libview2", :repository => :'jv-branch:public', :branch => 'jv'
   111   package "stx:libwidg", :repository => :'jv-branch:public', :branch => 'jv'
   112   package "stx:libwidg2", :repository => :'jv-branch:public', :branch => 'jv'
   113 
   114   package "stx:goodies/sunit", :repository => :'jv-branch:public', :branch => 'jv'
   115   package "stx:goodies/monticello", :repository => :'jv-branch:public', :branch => 'jv'
   116   package "stx:goodies/refactoryBrowser", :repository => :'jv-branch:public', :branch => 'jv'
   117   package "stx:libsvn", :repository => :'jv-branch:public', :branch => 'jv'
   118   package "stx:libjavascript", :repository => :'jv-branch:public', :branch => 'jv'
   119 
   120 
   121   # Some more development tools to build and preload
   122   # ======================================================================
   123   package "stx:goodies/xml/vw", :repository => :'exept:public'
   124   package "stx:goodies/xml/stx", :repository => :'exept:public'
   125 
   126   # SmallSense
   127   package "stx:goodies/regex", :repository => :'exept:public'
   128   package "stx:goodies/smallsense", :repository => :'jv-branch:public'
   129   package "stx:goodies/smallsense/refactoring_custom"
   130 
   131 
   132   tasks do
   133     # Build and install documentation for stx:libjava and stx:libscm/mercurial
   134     task "install:pre" do
   135       chdir BUILD_DIR / 'stx' / 'libjava' do
   136         make "doc-install"
   137       end
   138       chdir BUILD_DIR / 'stx' / 'libscm' / 'mercurial' do
   139         make "doc-install"
   140       end
   141     end
   142 
   143     # Try execute run the VM if it starts up
   144     task :'compile:post' do
   145       if PROJECT == 'stx:jv-branch' then
   146         chdir BUILD_DIR / 'stx' / 'projects' / 'smalltalk' do
   147           if win32?
   148             sh "smalltalk.bat --abortOnSEGV -I --quick --eval \"Stdout nextPutLine:'OKay, VM runs'. Smalltalk exit: 0\""
   149           else
   150             sh "./smalltalk --abortOnSEGV -I --quick --eval \"Stdout nextPutLine:'OKay, VM runs'. Smalltalk exit: 0\""
   151           end
   152         end
   153       end
   154     end
   155   end
   156 
   157 end
   158 
   159 
   160 
   161 project :'stx:jv-branch' do
   162   # Standard Smalltalk/X IDE with some nice libraries preloaded
   163 
   164   import :'stx:jv-branch-core'
   165 
   166 
   167   app_name "smalltalkx-jv-branch"
   168   app_version "8.0.0_#{BUILD_ID}"
   169 
   170   # Forked PetitParser
   171   package "stx:goodies/petitparser", :repository => :'jv-branch:public', :link => false
   172   package "stx:goodies/petitparser/tests", :link => false
   173   package "stx:goodies/petitparser/analyzer",  :link => false
   174   package "stx:goodies/petitparser/analyzer/tests",  :link => false
   175 
   176   # Monticello
   177   package "stx:libcompat", :repository => :'exept:public'
   178   package "stx:goodies/communication", :repository => :'exept:public'
   179 
   180   # Java support
   181   package "stx:libjava", :repository => :'jv-branch:public'
   182   package "stx:libjava/tools"
   183   package "stx:libjava/experiments"
   184   #package "stx:libjava/examples" :link => false
   185 
   186   # VDB
   187   package 'stx:goodies/magritte', :repository => :'exept:public', :link => false
   188   package 'stx:goodies/announcements', :repository => :'exept:public'
   189   package 'jv:libgdbs', :repository => :'jv-branch:public', :link => false
   190   package 'jv:libgdbs/tests', :repository => :'jv-branch:public', :link => false
   191   package 'jv:vdb', :repository => :'jv-branch:public', :link => false
   192   package 'jv:vdb/plugins/bee', :repository => :'jv-branch:public', :link => false
   193 
   194 
   195   # Smalltalk/X IDE
   196   application 'stx:projects/smalltalk', :repository => :'jv-branch:public', :branch => 'jv'
   197 
   198   package 'stx:libscm', :repository => :'jv-branch:public'
   199   package 'stx:libscm/common', :repository => :'jv-branch:public'
   200   package 'stx:libscm/mercurial', :repository => :'jv-branch:public'
   201   package 'stx:libscm/mercurial/monticello', :repository => :'jv-branch:public'
   202   package 'stx:goodies/ring', :repository => :'jv-branch:public', :link => false
   203   package 'stx:goodies/libcairo', :repository => :'jv-branch:public', :link => false
   204   package 'stx:goodies/cypress', :repository => :'jv-branch:public'
   205   package "stx:goodies/xmlsuite", :repository => :'jv-branch:public'
   206   package "stx:goodies/loggia", :repository => :'exept:public', :link => false
   207   package 'stx:goodies/smaCC',:repository => :'jv-branch:public'
   208   package 'stx:goodies/regression',:repository => :'jv-branch:public', :branch => 'jv', :link => false
   209   package "stx:goodies/builder", :repository => :'jv-branch:public',:branch => 'jv', :link => false
   210   package "stx:goodies/builder/reports"
   211 
   212   # Define a "default" test suite, i.e., a set of tests that are run when
   213   # user does `rake test`.
   214   package 'stx:libview/tests', :test => true;
   215   package 'stx:libwidg/tests', :test => true;
   216   package 'stx:libtool/tests', :test => true;
   217   package 'stx:libjava', :test => true;
   218   package 'stx:libjava/tools', :test => true;
   219   package 'stx:goodies/regression', :test => true;
   220   package 'stx:libscm/mercurial', :test => true;
   221   package 'jv:libgdbs/tests', :test => true;
   222   package 'jv:vdb/tests', :test => true;
   223 
   224   tasks do
   225     # We need to checkout CharacterEncoderCodeGenerator from stx:goodies
   226     # because RegressionTests::CharacterTests>>test01_CaseTesting needs that.
   227     task 'checkout:post' => BUILD_DIR / 'stx' / 'goodies' / 'CharacterEncoderCodeGenerator.st'
   228     file (BUILD_DIR / 'stx' / 'goodies' / 'CharacterEncoderCodeGenerator.st') do
   229       checkout(:'exept:public', 'stx/goodies/CharacterEncoderCodeGenerator.st')
   230     end
   231 
   232     # Checkout & install demos. Too bad that demos are not in a package itself but
   233     # rather a set of scaterred files here and there. So we have to checkout
   234     # and install them manually
   235     task 'checkout:post' => 'checkout:demos'
   236     task 'checkout:demos' => [ BUILD_DIR / 'stx' / 'doc' / 'coding' ,
   237                                BUILD_DIR / 'stx' / 'goodies'  / 'demos' ,
   238                                BUILD_DIR / 'stx' / 'clients' ]
   239     file BUILD_DIR / 'stx' / 'doc' / 'coding' do
   240       checkout(:'exept:public', 'stx/doc/coding')
   241     end
   242     file BUILD_DIR / 'stx' / 'goodies'  / 'demos' do
   243       checkout(:'exept:public', 'stx/goodies/demos')
   244     end
   245     file BUILD_DIR / 'stx' / 'clients' do
   246       checkout(:'exept:public', 'stx/clients')
   247     end
   248 
   249     task 'dist:jv:post' => 'dist:jv:demos'
   250     task 'dist:jv:demos' do
   251       cp_rx BUILD_DIR / 'stx' / 'doc' / 'coding', $install_jv_dirs[:pkg_dir] / 'stx' / 'doc' do |fname|
   252         # fname is full path!!!
   253         /\.svn|CVS|\.cvsignore|tests/.match(fname).nil?
   254       end
   255 
   256       cp_rx BUILD_DIR / 'stx' / 'goodies' / 'demos', $install_jv_dirs[:pkg_dir] / 'stx' / 'goodies'  do |fname|
   257         # fname is full path!!!
   258         /\.svn|CVS|\.cvsignore|tests/.match(fname).nil?
   259       end
   260 
   261       cp_rx BUILD_DIR / 'stx' / 'clients', $install_jv_dirs[:pkg_dir] / 'stx' do |fname|
   262         # fname is full path!!!
   263         /\.svn|CVS|\.cvsignore|tests/.match(fname).nil?
   264       end
   265     end
   266 
   267     # Normally the test package is not compiled but we have to
   268     # compile programs used in tests before running the tests
   269     # themselves. Sigh...
   270     task "test:package:jv:libgdbs/tests:pre" do
   271       chdir BUILD_DIR / 'jv' / 'libgdbs' / 'tests' do
   272         sh "make -f Makefile.init mf" if unix?
   273         make "testprograms"
   274       end
   275     end
   276     # VDB tests are reusing libgdbs test programs
   277     task "test:package:jv:vdb/tests:pre" => "test:package:jv:libgdbs/tests:pre"
   278 
   279     task :'install:main' => :'dist:jv-branch'
   280 
   281     task :'dist:jv:pre' => :'stx:jv-branch:extractver'
   282 
   283     if win32?
   284       app_name    = project.app_name      || (raise Exception.new("No app_name property specified"))
   285 	    app_version = project.app_version   || (raise Exception.new("No app_version property specified"))
   286 	    version = app_version.split('_').first
   287 
   288 	    install_dir = ARTIFACTS_DIR / BUILD_NAME
   289 	    bin_dir = install_dir / 'bin'
   290 
   291 
   292     	cairo_dlls = nil
   293     	if /i686/ =~ BUILD_TARGET
   294 	      cairo_dlls =  [
   295 	      	'libcairo-2.dll' ,
   296 					'libfontconfig-1.dll' ,
   297 					'libfreetype-6.dll' ,
   298 					'liblzma-5.dll' ,
   299 					'libpixman-1-0.dll' ,
   300 					'libpng15-15.dll' ,
   301 					'libxml2-2.dll' ,
   302 					'zlib1.dll'
   303 					]
   304 			else
   305 				cairo_dlls =  [
   306 	      	'fontconfig.dll' ,
   307 	      	'iconv.dll' ,
   308 	      	'libcairo-2.dll' ,
   309 	      	'libpng16.dll' ,
   310 	      	'libxml2.dll' ,
   311 	      	'pixman-1.dll' ,
   312 	      	'zlib1.dll'
   313 	      ]
   314 			end
   315 
   316     	task :'dist:jv:post' => [ :'stx:jv-branch:extractver' , :'dist:jv:variables' ]
   317     	cairo_dlls.each do | dll |
   318     		task :'dist:jv:post' => [ bin_dir / dll ]
   319 				file bin_dir / dll do
   320 					mkdir_p bin_dir
   321 					cp BUILD_DIR / 'stx' / 'goodies' / 'libcairo' / 'support' / 'win32' / (/i686/ =~ BUILD_TARGET ? 'i586' : 'x86_64') / dll , bin_dir / dll
   322 				end
   323     	end
   324     end
   325 
   326     task :'dist:jv-branch' => [ :'dist:jv:all',
   327                                 :'dist:jv:doc' ]
   328 
   329     task :'install:main' => [:'stx:jv-branch:extractver']
   330     task :'artifacts:main' => [:'stx:jv-branch:extractver']
   331     task :'artifacts:post' => [:'artifacts:prebuilt-stc', :'artifacts:prebuilt-librun' ]
   332 
   333     # Add dependency of stc and librun archive tasks on :'stx:jv-branch:extractver' so
   334     # they create archives with up-to-date version.
   335     task :'artifacts:prebuilt-stc' => :'stx:jv-branch:extractver'
   336     task :'artifacts:prebuilt-librun' => :'stx:jv-branch:extractver'
   337 
   338   end
   339 end
   340 
   341 task :'stx:jv-branch:extractver' => :'setup' do
   342   ver = nil
   343   if win32?
   344     stx_exe = 'stx.com'
   345   else
   346     stx_exe = './stx'
   347   end
   348   chdir BUILD_DIR / 'stx' / 'projects' / 'smalltalk' do
   349     ver = %x(#{stx_exe} --eval "Stdout nextPutAll: Smalltalk versionString")
   350     if $?.exitstatus != 0
   351       raise Exception.new("Failed extract version from stx")
   352     end
   353   end
   354   ver = (ver.split(".")[0..2]).join(".")
   355   project.app_version "#{ver}_#{BUILD_ID}"
   356   # This is really ugly. We need to clean that up...
   357   BUILD_NAME.replace "#{project.app_name}-#{project.app_version}_#{BUILD_TARGET}"
   358 end
   359 
   360 
   361 project :'stx:jv-branch:for-reports-only' do
   362   import :'stx:jv-branch'
   363 
   364   # Sigh, if we're about to run tests only, we don't want to
   365   # run standard tests so we need to clean test flag.
   366   package 'stx:libview/tests', :test => false;
   367   package 'stx:libjava', :test => false;
   368   package 'stx:libjava/tools', :test => false;
   369   package 'stx:goodies/regression', :test => false;
   370   package 'stx:libscm/mercurial', :test => false;
   371 
   372   tasks do
   373     task :'stx:projects/smalltalk:pre' do
   374       chdir BUILD_DIR / 'stx' / 'projects' / 'smalltalk' do
   375          if win32?
   376            system "bmake clobber"
   377          else
   378            system "make clobber"
   379          end
   380       end
   381     end
   382 
   383     clear :'dist:install' => :'dist:jv-branch'
   384   end
   385 end
   386