Cleanup: treat stx:stc & stx:librun as normal packages
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 13 Dec 2016 13:33:24 +0000
changeset 102 fc572bd895f2
parent 101 32f9287b419a
child 103 fda494c2564b
Cleanup: treat stx:stc & stx:librun as normal packages ...so `rake update`, `rake workflow:push-upstream` and so work with them as well.
rakelib/checkout.rake
rakelib/compile.rake
rakelib/dsl.rb
rakelib/rbspec.rb
rakelib/scm.rb
rakelib/setup.rake
rakelib/support.rb
specs/baseline.rbspec
specs/stx-jv.rbspec
--- a/rakelib/checkout.rake	Mon Dec 12 22:43:48 2016 +0000
+++ b/rakelib/checkout.rake	Tue Dec 13 13:33:24 2016 +0000
@@ -59,8 +59,7 @@
         doit = true
       elsif (pkg.property_defined? :repository) and (pkg.repository != pkg.parent_package.repository)
         # doit = true        
-      end 
-      
+      end      
     end
 
     if doit
--- a/rakelib/compile.rake	Mon Dec 12 22:43:48 2016 +0000
+++ b/rakelib/compile.rake	Tue Dec 13 13:33:24 2016 +0000
@@ -304,7 +304,7 @@
 
   rule 'makefile' do | t |
     if File.exist?(File.dirname(t.name) / 'GNUmakefile')
-  rm (File.dirname(t.name) / 'GNUmakefile')
+      rm (File.dirname(t.name) / 'GNUmakefile')
     end
 
     chdir File.dirname(t.name) do
--- a/rakelib/dsl.rb	Mon Dec 12 22:43:48 2016 +0000
+++ b/rakelib/dsl.rb	Tue Dec 13 13:33:24 2016 +0000
@@ -50,7 +50,7 @@
     def self.property(name, properties = {})      
       @property_definitions ||= {}
       if @property_definitions.include? name
-        raise Exception.new("Property #{name} already defined in class #{self.name}")
+        raise Exception.new("Property #{name} already defined for this kind of object")
       else
         prop_def_class = properties[:property_definition_class] || PropertyDefinition
         @property_definitions[name] = prop_def_class.new(name, self, properties)
--- a/rakelib/rbspec.rb	Mon Dec 12 22:43:48 2016 +0000
+++ b/rakelib/rbspec.rb	Tue Dec 13 13:33:24 2016 +0000
@@ -432,11 +432,16 @@
       if not (mandatory or referenced) then
         raise Exception.new("Nor mandator nor referenced prereqs asked. Must specify either `mandatoryy: true` or `referenced: true` or both")
       end
+
       # Special hack for stx:stc and stx:librun which are actually 
       # not a smalltalk packages. 
-      if @name == 'stx:stc' or @name == 'stx:librun' then
+      if @name == 'stx:stc'      
         return []
       end
+      if @name == 'stx:librun'
+        # stx:librun depends on STC
+        return ['stx:stc']
+      end
 
       root = BUILD_DIR if (not root && defined? BUILD_DIR)
       if not root then
@@ -452,7 +457,8 @@
         source << line
       end      
       source.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
-      prereqs = []      
+      # All packaged depends on STC - one cannot compile them without it!
+      prereqs = ['stx:stc']       
       if mandatory then        
         prereqs += source.scan(/^mandatoryPreRequisites(.*?)!$/m).flatten.to_s.scan(/#'([^']+)'/).flatten
       end
--- a/rakelib/scm.rb	Mon Dec 12 22:43:48 2016 +0000
+++ b/rakelib/scm.rb	Tue Dec 13 13:33:24 2016 +0000
@@ -158,10 +158,7 @@
         paths['canonical'] = "#{repository.canonical}/#{directory.gsub('/', separator)}"
         hg.paths = paths
       end
-      hg.pull('default')
-      if paths['default'] != paths['canonical'] then
-        hg.pull('canonical')
-      end
+      hg.pull('canonical')
       # If revision is not specified, then look for an active bookmark
       # and update to it. If no bookmark is active, then look for bookmark
       # `master`. If it exist, then update to `master`. If it 
@@ -258,7 +255,12 @@
     separator = kwargs[:separator] || '.'
     revision =  kwargs[:revision] 
     
-    paths = { 'canonical' => "#{repository.canonical}/#{directory.gsub('/', separator)}" }            
+    paths = {}
+    if repository.canonical then
+      paths['canonical'] = "#{repository.canonical}/#{directory.gsub('/', separator)}"
+    else
+      raise Exception.new("Repository named #{repository.name} does not define mandatory canonical repository URL")
+    end
     if repository.upstream then
       paths['upstream'] = "#{repository.upstream}/#{directory.gsub('/', separator)}"
     end
@@ -266,7 +268,6 @@
       paths['staging'] = "#{repository.staging}/#{directory.gsub('/', separator)}"
     end
 
-    
     begin
       if repository.staging then
         paths['default'] = paths['staging']
@@ -280,6 +281,7 @@
         hg.paths = paths
         hg.pull('canonical')
       else
+        paths['default'] = paths['canonical']
         hg = HG::Repository.clone(paths['canonical'], root / directory, noupdate: true)
         hg.paths = paths
       end
--- a/rakelib/setup.rake	Mon Dec 12 22:43:48 2016 +0000
+++ b/rakelib/setup.rake	Tue Dec 13 13:33:24 2016 +0000
@@ -150,9 +150,9 @@
 end
 
 task :'setup:dependencies' => :'checkout' do
-  project.packages.each do | pkg |        
-    if File.exist? (BUILD_DIR / pkg.directory() / pkg.project_definition_file_name()) then
-	  if not pkg.test_package? then
+  project.packages.each do | pkg |          
+    if pkg.name == 'stx:stc' or pkg.name == 'stx:librun' or File.exist? (BUILD_DIR / pkg.directory() / pkg.project_definition_file_name()) then
+	    if not pkg.test_package? then
         task "#{project.application.name}:dependencies" => pkg.name
         task "#{pkg.name}:dependencies" => pkg.prereqs(mandatory: true)
       end
@@ -260,12 +260,27 @@
         if pkg.application? and win32?
           make 'exe'
           make 'RESOURCEFILES'
-        else
-          # Somewhat stupid detection whether we run recent St/X or not...
-          if File.exist? BUILD_DIR / 'stx' / 'libbasic2' / 'Makefile.init'
-            make "#{make_vars} full"
+        else          
+          if pkg.name == 'stx:stc' 
+            # Sigh, on UNIX makefile is generated. So if we're using
+            # binary stc, we have to recreate it first.
+            if unix? then
+              if not File.exist? 'makefile'
+                sh "'#{STX_TOP_DIR / 'rules' / 'stmkmf'}'"
+              end
+            end
+            make
+          elsif pkg.name == 'stx:librun'
+            make
           else
-            make "#{make_vars}"
+            # Somewhat stupid detection whether we run recent St/X or not
+            # ('recent' mean more recent than 3 years or so)
+            # TODO: Remove this hack
+            if File.exist? BUILD_DIR / 'stx' / 'libbasic2' / 'Makefile.init'
+              make "#{make_vars} full"
+            else
+              make "#{make_vars}"
+            end
           end
         end
       end
--- a/rakelib/support.rb	Mon Dec 12 22:43:48 2016 +0000
+++ b/rakelib/support.rb	Tue Dec 13 13:33:24 2016 +0000
@@ -41,10 +41,8 @@
 # stc and librun repository so the build will fail. 
 def core_developer?
   # JV's box: jv@..., vranyj1@...
-  if (ENV['USER'] == 'jv') or (ENV['USER'] == 'vranyj1')
-    return true
-  end
-  if (ENV['USERNAME'] == 'jv') or (ENV['USERNAME'] == 'vranyj1')
+  user = ENV['USER'] || ENV['USERNAME']
+  if (user == 'jv') or (user == 'vranyj1')
     return true
   end
   return false
--- a/specs/baseline.rbspec	Mon Dec 12 22:43:48 2016 +0000
+++ b/specs/baseline.rbspec	Tue Dec 13 13:33:24 2016 +0000
@@ -1,6 +1,8 @@
 project :'stx:baseline' do
 
   repository :'exept:public'
+  package "stx:stc"
+  package "stx:librun"
   package "stx:libbasic"
   package "stx:goodies/refactoryBrowser/helpers"
   package "stx:goodies/refactoryBrowser/parser"
@@ -36,8 +38,6 @@
     task :'checkout:buildtools' => [ BUILD_DIR / 'stx' / "rules",
 				     BUILD_DIR / 'stx' / "configurations",
 				     BUILD_DIR / 'stx' / "support",
-				     BUILD_DIR / 'stx' / "stc",
-				     BUILD_DIR / 'stx' / "librun",
 				     BUILD_DIR / 'stx' / "RELEASE",
 				     # needed by applications for *.rc stuff
                                      BUILD_DIR / 'stx' / 'projects' / 'smalltalk',
@@ -96,18 +96,7 @@
       # the clear is here to avoid multiple checkouts
       t.clear()
     end
-
-    file BUILD_DIR / 'stx' / 'stc' => BUILD_DIR do | t |
-      checkout :'swing:private', 'stx/stc'
-      # the clear is here to avoid multiple checkouts
-      t.clear()
-    end
-
-    file BUILD_DIR / 'stx' / 'librun' => BUILD_DIR do | t |
-      checkout :'swing:private', 'stx/librun'
-      # the clear is here to avoid multiple checkouts
-      t.clear()
-    end
+    
 
     file BUILD_DIR / 'stx' / 'projects' / 'smalltalk' do | t |
       app = project.application
--- a/specs/stx-jv.rbspec	Mon Dec 12 22:43:48 2016 +0000
+++ b/specs/stx-jv.rbspec	Tue Dec 13 13:33:24 2016 +0000
@@ -42,6 +42,25 @@
   # applications that needs some JV-branch features.
   import :'stx:baseline'
 
+  # FORKED STC and librun
+  package "stx:stc", :repository => :'swing:private:hg', :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
+    else
+        download_blob_matching(/prebuilt-stc/, BUILD_DIR / 'stx')
+    end
+  end)
+
+  package "stx:librun", :repository => :'swing:private:hg', :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/librun', :branch => pkg.branch
+    else
+        download_blob_matching(/prebuilt-librun/, BUILD_DIR / 'stx')
+    end
+  end)
+
   # FORKED libraries
   # ======================================================================
   package "stx:libbasic", :repository => :'bitbucket:janvrany', :branch => 'jv'
@@ -82,22 +101,6 @@
       end
     end
 
-    redefine BUILD_DIR / 'stx' / 'stc' => BUILD_DIR do
-      if Rake::Stx::Configuration::Repository::find(:'swing:private:hg') then
-        checkout :'swing:private:hg', 'stx/stc', :branch => 'jv'
-      else
-        download_blob_matching(/prebuilt-stc/, BUILD_DIR / 'stx')
-      end
-    end
-
-    redefine BUILD_DIR / 'stx' / 'librun' => BUILD_DIR do      
-      if Rake::Stx::Configuration::Repository::find(:'swing:private:hg') then
-        checkout :'swing:private:hg', 'stx/librun', :branch => 'jv'
-      else        
-        download_blob_matching(/prebuilt-librun/, BUILD_DIR / 'stx')
-      end
-    end
-
     # Try execute run the VM if it starts up
     task :'compile:post' do
       if PROJECT == 'stx:jv-branch' then