rakelib/compile.rake
branchstx-8.0.0
changeset 176 84363aa38ff4
parent 169 f9f519bb10b6
child 181 3aaf65a5541c
--- a/rakelib/compile.rake	Thu Aug 24 10:11:14 2017 +0100
+++ b/rakelib/compile.rake	Thu Aug 24 17:04:58 2017 +0100
@@ -25,128 +25,75 @@
   !(core_developer? or ENV['RETAIN_STX_AND_LIBRUN_SOURCE'] == 'yespleaseretain!')
 end
 
-def rm_rf_all_in_except(directory, exceptions = [])
-  if File.directory?(directory)
-    Dir.foreach(directory) {|each| rm_rf File.join(directory, each) if (each != '.' and each != '..' and !exceptions.include?(each))}
-  else
-    rm_f directory
-  end
-end
+STC_BINARY_FILES = [        
+    'cpu_arm.h',        
+    'cpu_i386.h',
+    'cpu_x86_64.h',
+    'cpu_ia64.h',
+    'stc.h',
+    'stcIntern.h',
+    'stcVMdata.h',
+    'stcVMoffsets.h',
+    'stxAsmMacros.h',
+    'stxNames.h',
+    'stxOSDefs.h',
+    'stxTypeMacros.h',
+    'symbols.stc.seed',
+    'version.h',
+    'sha1.h',
+    'sha1.c',
+    'README',
 
-case
-  when unix?
-    STC_BINARY_FILES = [
-        'cpu_alpha.h',
-        'cpu_arm.h',
-        'cpu_hppa.h',
-        'cpu_i386.h',
-        'cpu_x86_64.h',
-        'cpu_ia64.h',
-        'cpu_mc68k.h',
-        'cpu_mc88k.h',
-        'cpu_mips.h',
-        'cpu_ns32k.h',
-        'cpu_power.h',
-        'cpu_s390.h',
-        'cpu_sparc.h',
-        'cpu_vax.h',
-        'stc.h',
-        'stcIntern.h',
-        'stcVMdata.h',
-        'stcVMoffsets.h',
-        'stxAsmMacros.h',
-        'stxNames.h',
-        'stxOSDefs.h',
-        'stxTypeMacros.h',
-        'symbols.stc.seed',
-        'version.h',
-        'README',
+    # UNIX specific
+    'stx-config.sh',
+    'linuxIntern.h',
+    'freeBSDIntern.h',
+    'macIntern.h',
+    'Make.proto',
+    'stc',
+    'stc.1',
 
-        #unix specific
-        'stx-config.sh',
-        'linuxIntern.h',
-        'macIntern.h',
-        'Make.proto',
-        'stc',
-        'stc.1',
-    ]
-    LIBRUN_BINARY_FILES1 = %w(
-        libffi-3.2.1
-        md5.h
-        mcompiler.h
-        main.c
-        librun.so
-        librun.a
-        symlist.c
-        Make.proto
-        makefile
-        hmm.h
-        hmm.c
-    )
-    LIBRUN_BINARY_FILES2 = []
+    # Windows specific
+    'stx-config.bat',
+    'mingwmake.bat',
+    'ntIntern.h',
+    'nt.h',
+    'Make.proto',
+    'stc.exe',
+]
+    
+LIBRUN_BINARY_FILES = [
+    'libffi-3.2.1',
+    'md5.h',
+    'mcompiler.h',
+    'main.c',
+    'hmm.h',
+    'hmm.c',
 
-  when win32?
-    STC_BINARY_FILES = [
-        'cpu_alpha.h',
-        'cpu_arm.h',
-        'cpu_hppa.h',
-        'cpu_i386.h',
-        'cpu_x86_64.h',
-        'cpu_ia64.h',
-        'cpu_mc68k.h',
-        'cpu_mc88k.h',
-        'cpu_mips.h',
-        'cpu_ns32k.h',
-        'cpu_power.h',
-        'cpu_s390.h',
-        'cpu_sparc.h',
-        'cpu_vax.h',
-        'stc.h',
-        'stcIntern.h',
-        'stcVMdata.h',
-        'stcVMoffsets.h',
-        'stxAsmMacros.h',
-        'stxNames.h',
-        'stxOSDefs.h',
-        'stxTypeMacros.h',
-        'symbols.stc.seed',
-        'version.h',
-        'README',
+    # UNIX specific
+    'librun.so',
+    'librun.a',
+    'symlist.c',
+    'Make.proto',
+    'makefile',
 
-        #windows specific
-        'stx-config.bat',
-        'mingwmake.bat',
-        'ntIntern.h',
-        'nt.h',
-        'Make.proto',
-        'stc.exe',
-    ]
-    LIBRUN_BINARY_FILES1 = %w(
-        libffi-3.2.1
-        md5.h
-        mcompiler.h
-        main.c
-        objmingw
-        bc.mak
-        mingwmake.bat
-        buildDate.h
-        genDate.com
-    )
-
-    LIBRUN_BINARY_FILES2 = %w(librun.dll librun.lib)
-
-  else
-    raise Exception.new('Unsupported platform')
-end
+    # Windows specific
+    'bc.mak',
+    'mingwmake.bat',
+    'buildDate.h',
+    'genDate.com',
+    File.join('objmingw' , 'librun.dll'),
+    File.join('objmingw' , 'librun.lib'),
+]        
 
 def cleanup_stc
   if should_remove_librun_and_stc_sources
     puts 'Cleaning up stc...'
     begin
-      rm_rf_all_in_except(STX_TOP_DIR / 'stc', STC_BINARY_FILES)
+      rm_rf_ex STX_TOP_DIR / 'stc', exceptions: STC_BINARY_FILES
     rescue
-      # When something goes wrong, be safe and remove whole directory
-      rm_rf STX_TOP_DIR / 'stc'
+      # When something goes wrong, be safe and remove whole directory...
+      rm_rf    STX_TOP_DIR / 'stc'
     end
   end
 end
@@ -155,11 +102,10 @@
   if should_remove_librun_and_stc_sources
     puts 'Cleaning up librun...'
     begin
-      rm_rf_all_in_except(STX_TOP_DIR / 'librun', LIBRUN_BINARY_FILES1)
-      rm_rf_all_in_except(STX_TOP_DIR / 'librun' / 'objmingw', LIBRUN_BINARY_FILES2) if win32?
+      rm_rf_ex STX_TOP_DIR / 'stc', exceptions: LIBRUN_BINARY_FILES
     rescue
-      # When something goes wrong, be safe and remove whole directory
-      rm_rf STX_TOP_DIR / 'librun'
+      # When something goes wrong, be safe and remove whole directory...
+      rm_rf    STX_TOP_DIR / 'librun'
     end
   end
 end