Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Add a message to explain no property violation is found
[simgrid.git] / tools / stack-cleaner / as
1 #!/usr/bin/ruby
2 # Wrapper around the real `as` which adds filtering capabilities.
3
4 require "tempfile"
5 require "fileutils"
6
7 def wrapped_as(argv)
8
9   args=[]
10   input=nil
11
12   i = 0
13   while i<argv.size
14     case argv[i]
15     when "-o", "-I"
16       args.push(argv[i])
17       args.push(argv[i+1])
18       i = i + 1
19     when /^-/
20       args.push(argv[i])
21     else
22       if input
23         exit 1
24       else
25         input = argv[i]
26       end
27     end
28     i = i + 1
29   end
30
31   if input==nil
32     # We dont handle pipe yet:
33     exit 1
34   end
35
36   # Generate temp file
37   tempfile = Tempfile.new("as-filter")
38   tempfile.close
39   script = File.dirname($0) + "/clean-stack-filter"
40   unless system([script, script], 0 => input, 1 => tempfile.path)
41     status=$?.exitstatus
42     FileUtils.rm tempfile
43     exit status
44   end
45   args.push(tempfile.path)
46
47   # Call the real assembler:
48   res = system("as", *args)
49   status = if res != nil
50              $?.exitstatus
51            else
52              1
53            end
54   FileUtils.rm tempfile
55   exit status
56
57 end
58
59 wrapped_as(ARGV)