From c5960accae4b7c31fcc69440b078c990c9c31c38 Mon Sep 17 00:00:00 2001 From: jcangas Date: Wed, 23 Dec 2015 00:48:02 +0100 Subject: [PATCH 1/3] vendor:tree MAX_LEVEL. prj:reset. vendor:import fetch optimizado --- ChangeLog.txt | 23 +++++++++++++++-- lib/delphivm/dsl.rb | 54 ++++++++++++++++++++++++++++++---------- lib/delphivm/version.rb | 2 +- lib/dvm/project.thor | 9 +++++++ lib/dvm/vendor.thor | 16 ++++++------ spec/testPrj/imports.dvm | 2 -- 6 files changed, 81 insertions(+), 25 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 1251358..152f38d 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -2,12 +2,31 @@ == v3.6.0 -== vendor:import +== Nueva opción prj:reset + +Borra el out del proyecto + +== Nueva opción vendor:tree MAX_LEVEL + +Muestra el árbol de dependencias solo hasta un nivel máximo de profundidad. -Copia todo el contenido del .zip al directorio vendor, inlcuido el out si el zip lo contiene. +Util para revisar las dependencias directas (MAX_LEVEL = 0) o depurar las dependencias en general +== vendor:import + +* Copia todo el contenido del .zip al directorio vendor, inlcuido el out si el zip lo contiene. Ahora solo se envia salida al prj out durante vendor:make o vendor:build. +* fetch: optimizado: +** En lugar de descargar el import entero a memoria y luego crear el fichero +local en disco, la descarga se produce en bloques, lo que permite descargar ficheros grandes +con menos consumo de memoria. + +** optimizada la opción -f. Esta opción borra la copia local del import en el cache, par forzar una +descarga fresca. Si el import aparecia varias veces en el árbol, se borraba cada vez, ahora solo se +borra la primera vez que aparece en el árbol, las siguientes apariciones, reusan la copia recien +descargada. + === "build_as_copy" feature para vendor:build/make Si el zip contiene un out, en lugar de invocar MSBuild, se copia la versión ya compilada en vendor al diff --git a/lib/delphivm/dsl.rb b/lib/delphivm/dsl.rb index 755ec34..daf920d 100644 --- a/lib/delphivm/dsl.rb +++ b/lib/delphivm/dsl.rb @@ -54,8 +54,8 @@ def level protected - def tree - foreach_do :tree, true + def tree(max_level) + foreach_do :tree, max_level, true end def proccess @@ -78,13 +78,24 @@ def collect_dependences @imports = sorted_imports end - def foreach_do(method, owned = false) + def foreach_do(method, args = [], owned = false) return unless method imports.values.each do |importdef| next if owned && importdef.script != self - importdef.send method + importdef.send method, *args end end + + def satisfied(lib_tag) + lib_tag = lib_tag.to_sym + result = false + parent_result = false + result = true if @imports.has_key?(lib_tag) && @imports[lib_tag].satisfied? + parent_result = true if required_by && required_by.script.satisfied(lib_tag) + result ||= parent_result + #say "check #{level} satisfied #{lib_tag} = #{result};" + result + end end # Each import statement @@ -114,6 +125,7 @@ def initialize(script, libname, libver, liboptions = {}, &block) @source_uri = libopts[:uri] || Pathname(source) + lib_file @ide_pkgs = [] @dependences_scriptname = Pathname(PRJ_IMPORTS + lib_tag + 'imports.dvm') + @satisfied = false instance_eval(&block) if block end @@ -140,6 +152,10 @@ def dependences_script @dependences_script end + def satisfied? + @satisfied + end + private def ide_install(*packages) @@ -181,7 +197,8 @@ def proccess destination = DVM_IMPORTS + idever cache_folder = destination + lib_tag exist = cache_folder.exist? - if exist && script.options.force? + already_in_tree = script.send(:satisfied, lib_tag) + if exist && script.options.force? && !already_in_tree exist = false FileUtils.remove_dir(cache_folder.win, true) end @@ -191,9 +208,11 @@ def proccess say_status status, "#{destination.win}", :green zip_file = download(source_uri, lib_file) unless exist + exist ||= zip_file + exist ? @satisfied = true : @satisfied = false return if defined? Ocra + unzip(zip_file, destination) if zip_file - exist ||= zip_file return unless exist vendorize ensure_dependences_script @@ -207,7 +226,6 @@ def show_ide_install_report(report) say_status :IDE, 'missing packages:', :red say report[:fail].join("\n") end - #say "[#{script.level}] Import #{lib_file} done!", [:blue, :bold] end def get_vendor_files @@ -244,7 +262,7 @@ def install_vendor(link, target) end end - def tree + def tree(max_level) if script.level == 0 indent = '' else @@ -263,7 +281,7 @@ def tree say "#{idever} ", [ide_color, :bold] end say - dependences_script.send :tree + dependences_script.send(:tree, max_level) if (max_level > script.level) end def register(idever, pkg) @@ -275,11 +293,21 @@ def download(source_uri, file_name) to_here = DVM_TEMP + file_name to_here.delete if to_here.exist? pb = nil - start = lambda { |length| pb = ProgressBar.create(total: length, title: ' %9s ->' % 'download', format: '%t %J%% %E %B')} - progress = lambda { |s| pb.progress = s; pb.refresh } + start = lambda do |length| + pb = ProgressBar.create(total: length, title: ' %9s ->' % 'download', format: '%t %J%% %E %B') + end + progress = lambda do |s| + pb.progress = s + #pb.refresh + end begin - content = open(source_uri, 'rb', content_length_proc: start, progress_proc: progress).read - File.open(to_here, 'wb') { |wfile| wfile.write(content)} unless defined? Ocra + open(source_uri, 'rb', content_length_proc: start, progress_proc: progress) do |reader| + File.open(to_here, 'wb') do |wfile| + while chunk = reader.read(1024) + wfile.write(chunk) unless defined? Ocra + end + end + end rescue Exception => e say_status :ERROR, e, :red return nil diff --git a/lib/delphivm/version.rb b/lib/delphivm/version.rb index 63b9670..ed43ef0 100644 --- a/lib/delphivm/version.rb +++ b/lib/delphivm/version.rb @@ -1,5 +1,5 @@ class Delphivm include VersionInfo - self.VERSION = "3.5.6" + self.VERSION = "3.6.0" self.VERSION.file_name = __FILE__ end diff --git a/lib/dvm/project.thor b/lib/dvm/project.thor index 24045fd..c107062 100644 --- a/lib/dvm/project.thor +++ b/lib/dvm/project.thor @@ -10,8 +10,17 @@ class Project < BuildTarget method_option :group, type: :string, aliases: '-g', default: self.configuration.build_args, desc: "Use BuildGroup", for: :make method_option :group, type: :string, aliases: '-g', default: self.configuration.build_args, desc: "Use BuildGroup", for: :build + desc 'reset', 'erase prj out' + def reset + do_reset + end + protected + def do_reset + remove_dir(root_out_path) + end + def do_clean(idetag, cfg) do_build_action(idetag, cfg, 'Clean') end diff --git a/lib/dvm/vendor.thor b/lib/dvm/vendor.thor index 6c0201e..76dfbe9 100644 --- a/lib/dvm/vendor.thor +++ b/lib/dvm/vendor.thor @@ -72,10 +72,10 @@ prepare end - desc 'tree', 'show dependencs tree. Use after import' - def tree + desc 'tree MAX_LEVEL', 'show dependencs tree. defaul MAX_LEVEL = 100' + def tree(max_level = 100) silence_warnings do - DSL.load_dvm_script(PRJ_IMPORTS_FILE).send :tree + DSL.load_dvm_script(PRJ_IMPORTS_FILE).send(:tree, max_level.to_i) end end @@ -149,17 +149,19 @@ def build_as_copy(lib_tag, ide_tag, action) import_out_path = PRJ_IMPORTS + lib_tag + 'out' + ide_tag - return unless import_out_path.exist? - say_status(:WARN, "#{action} using #{import_out_path.relative_path_from PRJ_IMPORTS}", :yellow) + return false unless import_out_path.exist? + say_status(action.to_sym, "using imported #{import_out_path.relative_path_from PRJ_IMPORTS}", :yellow) Pathname(import_out_path).glob('**/*.*').each do |file| rel_route = file.relative_path_from(import_out_path) dest_route = PRJ_ROOT + 'out' + ide_tag + rel_route if action == 'Clean' remove_file(dest_route, verbose: false) + elsif action == 'Make' + copy_file(file, dest_route, verbose: false, force: true) else - copy_file(file, dest_route, verbose: false) + copy_file(file, dest_route, verbose: false, force: true) end end - true + return true end end diff --git a/spec/testPrj/imports.dvm b/spec/testPrj/imports.dvm index 40991fe..f571395 100644 --- a/spec/testPrj/imports.dvm +++ b/spec/testPrj/imports.dvm @@ -5,8 +5,6 @@ uses 'D210' do import 'Summer', '1.2.1', uri: 'https://github.com/jcangas/SummerFW4D/releases/download/v1.2.1/Summer-1.2.1-D210.zip' import "Dido", "0.9.4" import "Lord", "0.9.4" - # using uri fails for security issues - import 'ics', '3.2.0', uri: 'http://git-lab.rido.es/infomedvendors/ics/repository/archive.zip?ref=v3.2.0' end uses 'D200' do From 8458fa26de0510a94a04634a1724380a43d8eaf6 Mon Sep 17 00:00:00 2001 From: jcangas Date: Wed, 23 Dec 2015 00:53:56 +0100 Subject: [PATCH 2/3] bump version --- lib/delphivm/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/delphivm/version.rb b/lib/delphivm/version.rb index ed43ef0..a21dde1 100644 --- a/lib/delphivm/version.rb +++ b/lib/delphivm/version.rb @@ -1,5 +1,5 @@ class Delphivm include VersionInfo - self.VERSION = "3.6.0" + self.VERSION = "3.6.1" self.VERSION.file_name = __FILE__ end From 7cd348d942f8dce781356655cfb7293e1be20fbb Mon Sep 17 00:00:00 2001 From: jcangas Date: Wed, 23 Dec 2015 00:55:41 +0100 Subject: [PATCH 3/3] update installer --- installer/delphivm.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/delphivm.iss b/installer/delphivm.iss index e34ee9b..7f98987 100644 --- a/installer/delphivm.iss +++ b/installer/delphivm.iss @@ -1,4 +1,4 @@ -# define VERSION "3.5.6" +# define VERSION "3.6.1" [Setup] AppName=DelphiVM AppVersion={#VERSION}