qsfdeps.pl 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. if ($name =~ /\.cof$/i) {
  24. $cof_list{$name}++;
  25. } elsif ($type =~ /^(mif|hex)_file$/i) {
  26. $asm_deps{$name}++;
  27. } else {
  28. $map_deps{$name}++;
  29. }
  30. }
  31. close($in);
  32. sub print_deps($%) {
  33. my($target,%deps) = @_;
  34. print "\n", $target, " :";
  35. foreach my $dep (sort keys(%deps)) {
  36. print " \\\n\t", $dep;
  37. }
  38. print "\n";
  39. }
  40. my $map_target = "$output_dir/$project.map.rpt";
  41. print_deps($map_target, %map_deps);
  42. my $asm_target = "$output_dir/$project.mif_update.rpt";
  43. print_deps($asm_target, %asm_deps);
  44. exit 0;