FreeCalypso > hg > fc-tourmaline
annotate scripts/ti/make_cmd.pl @ 46:09cdd5bf04e4
Condat display driver fix for 96x64 BW framebuffer
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 17 Oct 2020 22:50:15 +0000 |
parents | 021ac9f5a765 |
children |
rev | line source |
---|---|
17
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 #!perl |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 # generate a dynamic Linker command file |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 # PARAMETER ARE: |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 # 0 : Name of the file with the parameters |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 # 1 : Name of the Linker command file (output) |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 # 2 : value of the TOOL_CHOICE variable |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 # 3 : Name of the Linker command file template |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 # 4 - (n-1) : Name of the libraries |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #$argcount = @ARGV; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 my $lnk_opt_file=$ARGV[0]; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 my $cmd_file=$ARGV[1]; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 my $toolchoice_type = $ARGV[2]; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 my $cmd_file_temp=$ARGV[3]; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 my %section; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 open (TMP,$lnk_opt_file)||die "can't open file\n"; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 # parse the parameter file and construct replacement strings |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 # |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 # the file contains entries of the following form |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 # (BSS_LIBS (.bss)) |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 # or |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 # (BSS_LIBS (.bss) CONST_LIBS (.text, .const)) |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 # or |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 # (BSS_LIBS (.bss)) (BSS_LIBS (.bss) CONST_LIBS (.text, .const)) |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 # |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 # the syntax is as follows, white space and line breaks are not significant |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 # <ENTRY> := <lp> <PAIR><lp> |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 # <PAIR> := <name> <SECTION> |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 # <SECTION> := <lp><free_text><lp> |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 # <lp> := ( |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 # <rp> := ) |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 # <name> := [A-Za-z_]+ |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 # <free_text> := [^()]+ |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 # |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 # each entry will be linked with one library passed on the command line |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 my $line; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 my $count; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 while ($line=<TMP>) { |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 # find <ENTRY> |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 while ($line =~ /\((\s*\w+\s*\([^\(\)]+\))+\)/) { |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 $line = $'; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 $match = $&; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 # find <PAIR> |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 while ($match =~ /\s*(\w+)\s*(\([^\(\)]+\))/ ) { |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 $match = $'; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 $section{"$1"} .= "$ARGV[$count+4] $2\n"; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 } |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 $count++; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 } |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 } |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 open (TMP1, ">$cmd_file"); |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 open (TMP,$cmd_file_temp); |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 while ($line=<TMP>) { |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 my $replaced = 0; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 foreach $key (keys(%section)) { |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 if ($line =~ /\($key\)/g) { |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 # insert the Libs |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 $line = $section{$key}; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 $replaced = 1; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 } |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 } |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 # NEW COMPILER MANAGEMENT |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 # If use of VISUAL LINKER, needs to manage trampoline download. |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 # Case of: |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 # - TOOL_CHOICE == 0 => compiler v1.22e with vlinker v1.9902 |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 # - TOOL_CHOICE == 3 => compiler & linker v2.54 |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 if ($toolchoice_type == 0) { |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 $line =~ s(COMMENT1START)(/*); |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 $line =~ s(COMMENT1END)(*/); |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 $line =~ s(COMMENT2START)(); |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 $line =~ s(COMMENT2END)(); |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 } else { |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 $line =~ s(COMMENT1START)(); |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 $line =~ s(COMMENT1END)(); |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 $line =~ s(COMMENT2START)(/*); |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 $line =~ s(COMMENT2END)(*/); |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 } |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 if ($replaced || !($line =~ /^\s*\$\(\s*\w+\s*\)\s*$/ )) { |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 print TMP1 $line; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 } |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 } |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 close TMP; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 close TMP1; |
021ac9f5a765
scripts/ti/make_cmd.pl: import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 unlink $tmp_file; |