specs/stx-jv.rbspec
changeset 236 5a4e789cdd40
parent 155 31e32b21a711
parent 219 c96964104b1a
child 237 69ab924b97bf
--- a/specs/stx-jv.rbspec	Fri May 11 12:10:26 2018 +0100
+++ b/specs/stx-jv.rbspec	Tue Jun 12 21:27:24 2018 +0000
@@ -1,22 +1,22 @@
-def build_platform_id()
-  return "#{ARCH}-#{win32? ? 'win32' : RbConfig::CONFIG['host_os']}"
-end
-
 # A helper function to download and unpack pre-built stc and librun
 # for those who are not lucky enough to have an access to sources
-def download_blob_matching(pattern, directory)
+def download_binary_component(component, directory)
   plat = nil
   blob = nil
   sha256 = nil
-  if win32? then
-      plat = 'Windows'
-  elsif linux?
-    plat = 'Linux'
-  else
-    error_unsupported_platform()
+  pattern = /prebuilt-#{Regexp.quote(component)}/
+
+  build_url = %Q{https://swing.fit.cvut.cz/jenkins/job/stx_jv/lastStableBuild}
+
+  origin_forest_url = HG::Repository.new(BUILD_DIR / '..').paths['default'].slice(0.. - 'stx-goodies-builder-rake'.size - 2) #/
+  # When building using Jan's staging repositories, use pre-built stc and librun
+  # from there too. 
+  if (origin_forest_url =~ /192.168.27.250/) then
+    build_url = %Q{http://192.168.27.253:8080/job/stx_jv/lastStableBuild/}
   end
-  build = Jenkins::Build.new(%Q{https://swing.fit.cvut.cz/jenkins/job/stx_jv/lastStableBuild})
-  platform = build_platform_id()
+
+  build = Jenkins::Build.new(build_url)
+  platform = BUILD_TARGET
   build.artifacts.each do | artifact |
     if (pattern =~ artifact.name) and (artifact.name.include? platform) then
       if artifact.name.end_with? '.sha256' then
@@ -27,19 +27,34 @@
     end
   end
   if not blob then
-    error "No artifact matching given pattern found"
+    error "No binary component \"'#{component}\" found: #{build_url}/artifact/artifacts/"
   end
-  puts "Downloading binary component #{blob.name}"
+  if sha256 then
+    info "Downloading binary component SHA265 checksum #{sha256.name}"
+    sha256.download_to(directory)
+    if File.exist? directory / "#{component}" and File.exist? directory / "#{component}.sha256" then
+      # Compare a "current" checksum and the (possibly) "new" checkum.
+      # if same, skip the download (assuming that version has been
+      # downloaded already)
+      sha256_current = File.read(directory / ".#{component}.sha256")
+      sha256_new     = File.read(directory / sha256.name)
+      if sha256_new == sha256_current then
+        return
+      end
+    end
+  end
+  info "Downloading binary component #{blob.name}"
   blob.download_to(directory)
-  if sha256 then
-    sha256.download_to(directory)
+  info "Extracting binary component #{blob.name}"
+  if File.exist? directory / component then
+    rm_rf directory / component
   end
   unzip directory / blob.name, remove: true
-  rm_f directory / sha256.name
+  if sha256 then
+    mv directory / sha256.name, directory / ".#{component}.sha256"
+  end
 end
 
-
-
 project :'stx:jv-branch-core' do
   # Core Smalltalk/X - does contain only standard libraries,
   # and development tools. Does not contain any other 'features'
@@ -48,58 +63,58 @@
   import :'stx:baseline'
 
   # FORKED STC and librun
-  package "stx:stc", :repository => :'swing:private:hg', :branch => 'jv',
+  package "stx:stc", :repository => :'jv-branch:private', :branch => 'jv',
     :checkout => (Proc.new do | pkg |
-    # Download pre-compiled binary if user has no access to source code
-    if Rake::Stx::Configuration::Repository::find(pkg.repository) then
-          checkout pkg.repository, 'stx/stc', :branch => pkg.branch, :revision => pkg.revision
-    else
-        download_blob_matching(/prebuilt-stc/, BUILD_DIR / 'stx')
+      # Download pre-compiled binary if user has no access to source code
+      if Rake::Stx::Configuration::Repository::find(pkg.repository) then
+        checkout pkg.repository, 'stx/stc', :branch => pkg.branch, :revision => pkg.revision
+      else
+        download_binary_component('stc', BUILD_DIR / 'stx')
       end
     end),
     :update => (Proc.new do | pkg |
       if (File.exists? BUILD_DIR / 'stx' / 'stc' / '.hg' / 'hgrc') then
         update pkg.repository, 'stx/stc', :branch => pkg.branch, :revision => pkg.revision
       else
-        warn "Not updating #{pkg.name} as no HG repository found in #{BUILD_DIR / 'stx' / 'stc'}"
+        download_binary_component('stc', BUILD_DIR / 'stx')
     end
   end)
 
-  package "stx:librun", :repository => :'swing:private:hg', :branch => 'jv',
+  package "stx:librun", :repository => :'jv-branch:private', :branch => 'jv',
     :checkout => (Proc.new do | pkg |
-    # Download pre-compiled binary if user has no access to source code
-    if Rake::Stx::Configuration::Repository::find(pkg.repository) then
+      # Download pre-compiled binary if user has no access to source code
+      if Rake::Stx::Configuration::Repository::find(pkg.repository) then
           checkout pkg.repository, 'stx/librun', :branch => pkg.branch, :revision => pkg.revision
-    else
-        download_blob_matching(/prebuilt-librun/, BUILD_DIR / 'stx')
+      else
+        download_binary_component('librun', BUILD_DIR / 'stx')
       end
     end),
     :update => (Proc.new do | pkg |
       if (File.exists? BUILD_DIR / 'stx' / 'librun' / '.hg' / 'hgrc') then
         update pkg.repository, 'stx/stc', :branch => pkg.branch, :revision => pkg.revision
       else
-        warn "Not updating #{pkg.name} as no HG repository found in #{BUILD_DIR / 'stx' / 'librun'}"
+        download_binary_component('librun', BUILD_DIR / 'stx')
     end
   end)
 
   # FORKED libraries
   # ======================================================================
-  package "stx:libbasic", :repository => :'bitbucket:janvrany', :branch => 'jv'
-  package "stx:libbasic2", :repository => :'bitbucket:janvrany', :branch => 'jv'
-  package "stx:libbasic3", :repository => :'bitbucket:janvrany', :branch => 'jv'
-  package "stx:libcomp", :repository => :'bitbucket:janvrany', :branch => 'jv'
-  package "stx:libtool", :repository => :'bitbucket:janvrany', :branch => 'jv'
-  package "stx:libtool2",:repository => :'bitbucket:janvrany', :branch => 'jv'
+  package "stx:libbasic", :repository => :'jv-branch:public', :branch => 'jv'
+  package "stx:libbasic2", :repository => :'jv-branch:public', :branch => 'jv'
+  package "stx:libbasic3", :repository => :'jv-branch:public', :branch => 'jv'
+  package "stx:libcomp", :repository => :'jv-branch:public', :branch => 'jv'
+  package "stx:libtool", :repository => :'jv-branch:public', :branch => 'jv'
+  package "stx:libtool2",:repository => :'jv-branch:public', :branch => 'jv'
 
-  package "stx:libview", :repository => :'bitbucket:janvrany', :branch => 'jv'
-  package "stx:libview2", :repository => :'bitbucket:janvrany', :branch => 'jv'
-  package "stx:libwidg", :repository => :'bitbucket:janvrany', :branch => 'jv'
-  package "stx:libwidg2", :repository => :'bitbucket:janvrany', :branch => 'jv'
+  package "stx:libview", :repository => :'jv-branch:public', :branch => 'jv'
+  package "stx:libview2", :repository => :'jv-branch:public', :branch => 'jv'
+  package "stx:libwidg", :repository => :'jv-branch:public', :branch => 'jv'
+  package "stx:libwidg2", :repository => :'jv-branch:public', :branch => 'jv'
 
-  package "stx:goodies/sunit", :repository => :'bitbucket:janvrany', :branch => 'jv'
-  package "stx:goodies/monticello", :repository => :'bitbucket:janvrany', :branch => 'jv'
-  package "stx:goodies/refactoryBrowser", :repository => :'bitbucket:janvrany', :branch => 'jv'
-  package "stx:libsvn", :repository => :'bitbucket:janvrany', :branch => 'jv'
+  package "stx:goodies/sunit", :repository => :'jv-branch:public', :branch => 'jv'
+  package "stx:goodies/monticello", :repository => :'jv-branch:public', :branch => 'jv'
+  package "stx:goodies/refactoryBrowser", :repository => :'jv-branch:public', :branch => 'jv'
+  package "stx:libsvn", :repository => :'jv-branch:public', :branch => 'jv'
 
   # Some more development tools to build and preload
   # ======================================================================
@@ -108,7 +123,7 @@
 
   # SmallSense
   package "stx:goodies/regex", :repository => :'exept:public'
-  package "stx:goodies/smallsense", :repository => :'bitbucket:janvrany'
+  package "stx:goodies/smallsense", :repository => :'jv-branch:public'
   package "stx:goodies/smallsense/refactoring_custom"
 
 
@@ -128,49 +143,9 @@
       if PROJECT == 'stx:jv-branch' then
         chdir BUILD_DIR / 'stx' / 'projects' / 'smalltalk' do
           if win32?
-            cmd = "smalltalk.bat --abortOnSEGV -I --quick --eval \"Stdout nextPutLine:'OKay, VM runs'. Smalltalk exit: 0\""
+            sh "smalltalk.bat --abortOnSEGV -I --quick --eval \"Stdout nextPutLine:'OKay, VM runs'. Smalltalk exit: 0\""
           else
-            cmd = "./smalltalk --abortOnSEGV -I --quick --eval \"Stdout nextPutLine:'OKay, VM runs'. Smalltalk exit: 0\""
-          end
-          if not system cmd
-            raise Exception.new("Cannot run smalltalk!")
-          end
-        end
-      end
-    end
-
-    if win32_wine?
-      task :'stx:projects/smalltalk:pre' do
-        chdir (BUILD_DIR / 'stx' / 'projects' / 'smalltalk') do
-          make "buildDate.h"
-        end
-      end
-
-    end
-
-    # Hack for badly-named files in libtool
-    task :'stx:libtool:post' do
-      chdir (BUILD_DIR / 'stx' / 'libtool') do
-        # Windows does not support symlinks, copy the file
-        if win32?
-          if not File.exist? 'Tools_BrowserList.STH'
-            cp 'Tools__BrowserList.STH', 'Tools_BrowserList.STH'
-          end
-          if not File.exist? 'Tools_NavigatorModel.STH'
-            cp 'Tools__NavigatorModel.STH', 'Tools_NavigatorModel.STH'
-          end
-          if not File.exist? 'Tools_NavigationState.STH'
-            cp 'Tools__NavigationState.STH', 'Tools_NavigationState.STH'
-          end
-        else
-          if not File.exist? 'Tools_BrowserList.H'
-            ln_s 'Tools__BrowserList.H', 'Tools_BrowserList.H'
-          end
-          if not File.exist? 'Tools_NavigatorModel.H'
-            ln_s 'Tools__NavigatorModel.H', 'Tools_NavigatorModel.H'
-          end
-          if not File.exist? 'Tools_NavigationState.H'
-            ln_s 'Tools__NavigationState.H', 'Tools_NavigationState.H'
+            sh "./smalltalk --abortOnSEGV -I --quick --eval \"Stdout nextPutLine:'OKay, VM runs'. Smalltalk exit: 0\""
           end
         end
       end
@@ -188,10 +163,10 @@
 
 
   app_name "smalltalkx-jv-branch"
-  app_version "6.2.6_#{BUILD_ID}"
+  app_version "8.0.0_#{BUILD_ID}"
 
   # Forked PetitParser
-  package "stx:goodies/petitparser", :repository => :'bitbucket:janvrany', :link => false
+  package "stx:goodies/petitparser", :repository => :'jv-branch:public', :link => false
   package "stx:goodies/petitparser/tests", :link => false
   package "stx:goodies/petitparser/analyzer",  :link => false
   package "stx:goodies/petitparser/analyzer/tests",  :link => false
@@ -201,35 +176,46 @@
   package "stx:goodies/communication", :repository => :'exept:public'
 
   # Java support
-  package "stx:libjava", :repository => :'bitbucket:janvrany'
+  package "stx:libjava", :repository => :'jv-branch:public'
   package "stx:libjava/tools"
   package "stx:libjava/experiments"
   #package "stx:libjava/examples" :link => false
 
+  # VDB
+  package 'stx:goodies/magritte', :repository => :'exept:public', :link => false
+  package 'stx:goodies/announcements', :repository => :'exept:public'
+  package 'jv:libgdbs', :repository => :'jv-branch:public', :link => false
+  package 'jv:libgdbs/tests', :repository => :'jv-branch:public', :link => false
+  package 'jv:vdb', :repository => :'jv-branch:public', :link => false
+
+
   # Smalltalk/X IDE
-  application 'stx:projects/smalltalk', :repository => :'bitbucket:janvrany', :branch => 'jv'
+  application 'stx:projects/smalltalk', :repository => :'jv-branch:public', :branch => 'jv'
 
-  package 'stx:libscm', :repository => :'bitbucket:janvrany'
-  package 'stx:libscm/common', :repository => :'bitbucket:janvrany'
-  package 'stx:libscm/mercurial', :repository => :'bitbucket:janvrany'
-  package 'stx:libscm/mercurial/monticello', :repository => :'bitbucket:janvrany'
-  package 'stx:goodies/ring', :repository => :'bitbucket:janvrany', :link => false
-  package 'stx:goodies/libcairo', :repository => :'bitbucket:janvrany', :link => false
-  package 'stx:goodies/cypress', :repository => :'bitbucket:janvrany'
-  package "stx:goodies/xmlsuite", :repository => :'bitbucket:janvrany'
+  package 'stx:libscm', :repository => :'jv-branch:public'
+  package 'stx:libscm/common', :repository => :'jv-branch:public'
+  package 'stx:libscm/mercurial', :repository => :'jv-branch:public'
+  package 'stx:libscm/mercurial/monticello', :repository => :'jv-branch:public'
+  package 'stx:goodies/ring', :repository => :'jv-branch:public', :link => false
+  package 'stx:goodies/libcairo', :repository => :'jv-branch:public', :link => false
+  package 'stx:goodies/cypress', :repository => :'jv-branch:public'
+  package "stx:goodies/xmlsuite", :repository => :'jv-branch:public'
   package "stx:goodies/loggia", :repository => :'exept:public', :link => false
-  package 'stx:goodies/smaCC',:repository => :'bitbucket:janvrany'
-  package 'stx:goodies/regression',:repository => :'bitbucket:janvrany', :branch => 'jv', :link => false
-  package "stx:goodies/builder", :repository => :'bitbucket:janvrany',:branch => 'jv', :link => false
+  package 'stx:goodies/smaCC',:repository => :'jv-branch:public'
+  package 'stx:goodies/regression',:repository => :'jv-branch:public', :branch => 'jv', :link => false
+  package "stx:goodies/builder", :repository => :'jv-branch:public',:branch => 'jv', :link => false
   package "stx:goodies/builder/reports"
 
   # Define a "default" test suite, i.e., a set of tests that are run when
   # user does `rake test`.
   package 'stx:libview/tests', :test => true;
+  package 'stx:libwidg/tests', :test => true;
+  package 'stx:libtool/tests', :test => true;
   package 'stx:libjava', :test => true;
   package 'stx:libjava/tools', :test => true;
   package 'stx:goodies/regression', :test => true;
   package 'stx:libscm/mercurial', :test => true;
+  package 'jv:libgdbs/tests', :test => true;
 
   tasks do
     # We need to checkout CharacterEncoderCodeGenerator from stx:goodies
@@ -274,8 +260,15 @@
       end
     end
 
-
-
+    # Normally the test package is not compiled but we have to
+    # compile programs used in tests before running the tests
+    # themselves. Sigh...
+    task "test:package:jv:libgdbs/tests:pre" do
+      chdir BUILD_DIR / 'jv' / 'libgdbs' / 'tests' do
+        sh "make -f Makefile.init mf" if unix?
+        make "testprograms"
+      end
+    end
 
     task :'install:main' => :'dist:jv-branch'
 
@@ -291,7 +284,7 @@
 
 
     	cairo_dlls = nil
-    	if ARCH == 'i386'
+    	if /i686/ =~ BUILD_TARGET
 	      cairo_dlls =  [
 	      	'libcairo-2.dll' ,
 					'libfontconfig-1.dll' ,
@@ -319,7 +312,7 @@
     		task :'dist:jv:post' => [ bin_dir / dll ]
 				file bin_dir / dll do
 					mkdir_p bin_dir
-					cp BUILD_DIR / 'stx' / 'goodies' / 'libcairo' / 'support' / 'win32' / (ARCH == 'i386' ? 'i586' : ARCH) / dll , bin_dir / dll
+					cp BUILD_DIR / 'stx' / 'goodies' / 'libcairo' / 'support' / 'win32' / (/i686/ =~ BUILD_TARGET ? 'i586' : 'x86_64') / dll , bin_dir / dll
 				end
     	end
     end
@@ -329,25 +322,13 @@
 
     task :'install:main' => [:'stx:jv-branch:extractver']
     task :'artifacts:main' => [:'stx:jv-branch:extractver']
-    task :'artifacts:post' => [:'stx:jv-branch:extractver'] do
-      # Just to be sure, refuse to create stc and librun archives
-      # if the directory contain sources. This is to prevent accidental
-      # leak of non-disclosed sources. Better safe than sorry!
-      if core_developer? || (File.exist? BUILD_DIR / 'stx' / 'stc' / '.hg') || (File.exist? BUILD_DIR / 'stx' / 'stc' / 'CVS') then
-        puts "WARNING: NOT CREATING stc archive since directory contains sources!!!"
-      else
-        # Be paranoid, do cleanup here. Should have been done, but who knows...
-        cleanup_stc()
-    	  zip BUILD_DIR / 'stx' / 'stc' , archive: ARTIFACTS_DIR / "#{project.app_name}-#{project.app_version}_#{build_platform_id()}_prebuilt-stc"
-      end
-      if core_developer? || (File.exist? BUILD_DIR / 'stx' / 'librun' / '.hg') || (File.exist? BUILD_DIR / 'stx' / 'librun' / 'CVS') then
-        puts  "WARNING: NOT CREATING librun archive since directory contains sources!!!"
-      else
-        # Be paranoid, do cleanup here. Should have been done, but who knows...
-        cleanup_librun()
-    	  zip BUILD_DIR / 'stx' / 'librun' , archive: ARTIFACTS_DIR / "#{project.app_name}-#{project.app_version}_#{build_platform_id()}_prebuilt-librun"
-      end
-    end
+    task :'artifacts:post' => [:'artifacts:prebuilt-stc', :'artifacts:prebuilt-librun' ]
+
+    # Add dependency of stc and librun archive tasks on :'stx:jv-branch:extractver' so
+    # they create archives with up-to-date version.
+    task :'artifacts:prebuilt-stc' => :'stx:jv-branch:extractver'
+    task :'artifacts:prebuilt-librun' => :'stx:jv-branch:extractver'
+
   end
 end
 
@@ -367,7 +348,7 @@
   ver = (ver.split(".")[0..2]).join(".")
   project.app_version "#{ver}_#{BUILD_ID}"
   # This is really ugly. We need to clean that up...
-  BUILD_NAME.replace "#{project.app_name}-#{project.app_version}_#{build_platform_id()}"
+  BUILD_NAME.replace "#{project.app_name}-#{project.app_version}_#{BUILD_TARGET}"
 end