Changeset 310

Show
Ignore:
Timestamp:
07/16/06 03:34:49 (4 years ago)
Author:
vasi
Message:

much faster AND shorter

Location:
gtk-osx/trunk/scripts/gtk-osx
Files:
1 removed
2 modified

Legend:

Unmodified
Added
Removed
  • gtk-osx/trunk/scripts/gtk-osx/build/package.rb

    r308 r310  
    1212                sub = realpath 
    1313                dir = Pathname.new(other).realpath.to_s 
    14                 sub[0, dir.length] == dir 
     14                sub.to_s[0, dir.length] == dir 
    1515        end 
    1616end 
     
    112112                                 
    113113                                if file.within?(@config.prefix) 
    114                                         files << file 
     114                                        files << file.to_s 
    115115                                else 
    116116                                        $stderr.puts "WARNING: File #{file} was placed outside " + 
  • gtk-osx/trunk/scripts/gtk-osx/ktrace.rb

    r308 r310  
    1 #!/usr/bin/ruby -w 
     1require 'pathname' 
    22require 'gtk-osx/script' 
    3 require 'gtk-osx/ktrace/kdump' 
     3require 'gtk-osx/shellquote' 
    44 
    55class KTrace 
    66        def initialize(tracefile = 'ktrace.out') 
    77                @tracefile = tracefile 
    8                 @initial_dir = Dir.pwd 
     8                @origdir = Dir.pwd 
    99        end 
    1010                 
    1111        def run_script(str, msg = Script::DEFAULT_MSG) 
    12                 raise "Already read results!" if defined? @kdump 
     12                raise "Already read results!" if defined? @files 
    1313                wrap = %w[ktrace -i -a -tcn -f] << @tracefile 
    1414                Script.run_script_file(str, msg, wrap) 
    1515        end 
    1616         
    17         def method_missing(sym, *args) 
    18                 unless defined? @kdump 
    19                         @kdump = KDump.new(@tracefile, @initial_dir) 
     17        # Get the files that were written to. 
     18        # Not the prettiest implementation, but the previous one was far too slow. 
     19        def write_paths 
     20                return @files if defined? @files                 
     21                 
     22                line_re = %r[\s(CALL|NAMI)\s*(.*)] 
     23                call_re = %r[(open|symlink)(.*)] 
     24                args_re = %r[,] 
     25                 
     26                files = {} 
     27                call = nil 
     28                dir = Pathname.new(@origdir) 
     29                 
     30                output = `kdump -d -n -f #{@tracefile.shellquote}` 
     31                output.scan(line_re) do |type, details| 
     32                        if (type == 'CALL') 
     33                                md = call_re.match(details) or next 
     34                                func, args = md.captures 
     35                                if func == 'open' 
     36                                        args = args[1, args.size - 2] 
     37                                        flags = args.split(args_re)[1] 
     38                                        next if (flags.to_i & 3).zero? 
     39                                end 
     40                                call = func 
     41                        elsif call # NAMI: applies to the previous call 
     42                                details = details[1, details.size - 2] 
     43                                path = (dir + details).cleanpath 
     44                                if call == 'chdir' 
     45                                        dir = path # make sure our paths are ok 
     46                                else 
     47                                        files[path] = true 
     48                                end 
     49                                call = nil 
     50                        end 
    2051                end 
    21                 @kdump.send(sym, *args) 
    22         end 
    23          
    24         def respond_to?(sym) 
    25                 super || (defined?(@kdump) && @kdump.respond_to?(sym)) 
     52                 
     53                return @files = files.keys 
    2654        end 
    2755end