annotate scripts/ti/make_cmd.pl @ 356:984df0753560

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