2
0

qsfdeps.pl 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/perl
  2. #
  3. # Extract dependency files from a Quartus .qsf file
  4. #
  5. use strict;
  6. my($infile,$project) = @ARGV;
  7. my %map_deps = ($infile);
  8. my %asm_deps = ();
  9. my %cof_list = ();
  10. my $output_dir = 'output_files';
  11. open(my $in, '<', $infile) or die;
  12. while (defined(my $l = <$in>)) {
  13. chomp $l;
  14. next unless ($l =~ /^\s*set_global_assignment\s+\-name\s+(\w+)\s+\"?(.*?)\"?\s*$/);
  15. my $type = $1;
  16. my $name = $2;
  17. if ($type =~ /^project_output_directory$/i) {
  18. $output_dir = $name;
  19. next;
  20. }
  21. next if ($type !~ /_file$/i || $type =~ /^generate_/i);
  22. $name =~ s/^quartus_\w+://;
  23. $name =~ s/\s-.*$//;
  24. if ($name =~ /\.cof$/i) {
  25. $cof_list{$name}++;
  26. } elsif ($type =~ /^(mif|hex)_file$/i) {
  27. $asm_deps{$name}++;
  28. } else {
  29. $map_deps{$name}++;
  30. }
  31. }
  32. close($in);
  33. sub print_deps($%) {
  34. my($target,%deps) = @_;
  35. print "\n", $target, " :";
  36. foreach my $dep (sort keys(%deps)) {
  37. print " \\\n\t", $dep;
  38. }
  39. print "\n";
  40. }
  41. my $map_target = "$output_dir/$project.map.rpt";
  42. print_deps($map_target, %map_deps);
  43. my $asm_target = "$output_dir/$project.mif_update.rpt";
  44. print_deps($asm_target, %asm_deps);
  45. exit 0;