Przeglądaj źródła

add 'snapshot' target

Vladislav Folts 11 lat temu
rodzic
commit
41a20a92ef
2 zmienionych plików z 21 dodań i 10 usunięć
  1. 21 2
      build.py
  2. 0 8
      test/make_snapshot.cmd

+ 21 - 2
build.py

@@ -87,6 +87,7 @@ def run(cmd, env=None, cwd=None, print_output=False):
     return result
 
 root = os.path.dirname(os.path.abspath(__file__))
+snapshot_root = os.path.join(root, 'snapshot')
 
 def make_js_search_dirs(bin):
     return [os.path.join(root, 'test'), 
@@ -141,7 +142,6 @@ def recompile(bin):
     return result
 
 def compile_using_snapshot(src):
-    snapshot_root = os.path.join(root, 'snapshot')
     out = os.path.join(root, 'bin', 'js')
     compiler = os.path.join(snapshot_root, 'oc_nodejs.js')
     js_search_dirs = [snapshot_root]
@@ -253,7 +253,26 @@ class pre_commit_target(object):
     def __init__(self, options):
         pre_commit_check(options)
 
-targets = [compile_target, html_target, tests_target, pre_commit_target]
+class snapshot_target(object):
+    name = 'snapshot'
+    description = 'make snapshot - current compiled compiler (set of *.js) to use for compiling oberon sources'
+
+    @staticmethod
+    def setup_options(parser):
+        pass
+        
+    def __init__(self, options):
+        new_dir = snapshot_root + '.new'
+        cleanup(new_dir)
+        shutil.copytree(os.path.join(root, 'src'), new_dir)
+        shutil.copytree(os.path.join(root, 'bin', 'js'), os.path.join(new_dir, 'js'))
+        if os.path.exists(snapshot_root):
+            old_dir = snapshot_root + '.bak'
+            cleanup(old_dir)
+            os.rename(snapshot_root, old_dir)
+        os.rename(new_dir, snapshot_root)
+
+targets = [compile_target, html_target, tests_target, pre_commit_target, snapshot_target]
 
 def build(target, options):
     targets[target](options)

+ 0 - 8
test/make_snapshot.cmd

@@ -1,8 +0,0 @@
-del /S /Q ..\snapshot
-mkdir ..\snapshot\js
-mkdir ..\snapshot\eberon
-mkdir ..\snapshot\oberon
-copy ..\src\*.js ..\snapshot
-copy ..\src\eberon\*.js ..\snapshot\eberon
-copy ..\src\oberon\*.js ..\snapshot\oberon
-copy ..\bin\js\*.js ..\snapshot\js