2
0

qsfdeps.pl 1.2 KB

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