|
19 | 19 | Version, // Program version information, generated by version.sh |
20 | 20 | PasExt, BinTree, // A couple basic MPLA units. |
21 | 21 | GloDat, // Global types, variables, data, etc. |
22 | | - CfgOpts; // Command Line option processing. |
23 | | - |
| 22 | + CfgOpts, // Command Line option processing. |
| 23 | + CfgMap; // Reading and processing of _Mapping.txt file. |
24 | 24 |
|
25 | 25 | // Saves Filename of an Entry with a problem, error, etc to a file when the |
26 | 26 | // "IssueFileName" file name is set. |
@@ -889,156 +889,6 @@ procedure Build; |
889 | 889 | SectionTree.Free; |
890 | 890 | end; |
891 | 891 |
|
892 | | -{ ---------------------------------------------------------------------------- } |
893 | | - |
894 | | -function KindFromText(S : String) : TSectionKind; |
895 | | -begin |
896 | | - case LowerCase(Trim(S)) of |
897 | | - 'none' : Result:=skNone; |
898 | | - 'standard' : Result:=skStandard; |
899 | | - 'interrupt' : Result:=skInterrupt; |
900 | | - 'cmos' : Result:=skCMOS; |
901 | | - 'farcall' : Result:=skFarCall; |
902 | | - 'i2c' : Result:=skI2C; |
903 | | - 'memory' : Result:=skMemory; |
904 | | - 'msr' : Result:=skMSR; |
905 | | - 'port' : Result:=skPort; |
906 | | - 'glossary' : Result:=skGlossary; |
907 | | - 'table' : Result:=skTable; |
908 | | - 'smm' : Result:=skSMM; |
909 | | - 'link' : Result:=skLink; |
910 | | - 'faq' : Result:=skFAQ; |
911 | | - else |
912 | | - Result:=skNone; |
913 | | - raise Exception.Create('Section Type "'+Trim(S)+'" was not recognized.'); |
914 | | - end; |
915 | | -end; |
916 | | - |
917 | | -procedure ReadFileMap; |
918 | | -{ TODO 2 -cDevel Remove a lot of duplicate and similar code } |
919 | | -var |
920 | | - INI : TIniFile; |
921 | | - Strs : TStringList; |
922 | | - K, S : String; |
923 | | - I, J : Integer; |
924 | | - |
925 | | - procedure ReadSection(SectName : String); |
926 | | - var |
927 | | - X : Integer; |
928 | | - begin |
929 | | - INI.ReadSectionRaw(SectName, Strs); |
930 | | - // Blanks are already removed. Remove Comments. |
931 | | - for X := Strs.Count - 1 downto 0 do |
932 | | - if HasLeading(Strs[X], ';', false) then |
933 | | - Strs.Delete(X); |
934 | | - end; |
935 | | - |
936 | | -begin |
937 | | - if not FileExists(DirSource + MapFile) then Exit; |
938 | | - INI:=nil; |
939 | | - Strs:=nil; |
940 | | - try |
941 | | - Strs:=TStringList.Create; |
942 | | - INI := TIniFile.Create(DirSource + MapFile); |
943 | | - // Replace Miscellaneous Directory when defined |
944 | | - S:= ExcludeTrailing(INI.ReadString('MISC', 'Directory', MiscFileDir), PathDelimiter); |
945 | | - if not DirectoryExists(DirSource + S) then begin |
946 | | - LogMessage(vbMinimal, 'Invalid directory for miscellaneous files: ' + S); |
947 | | - Halt(1); |
948 | | - end else |
949 | | - MiscFileDir:=S; |
950 | | - // Replace INTERRUPT_1ST sections, replaces internal table |
951 | | - ReadSection('1ST'); |
952 | | - if Strs.Count > 0 then begin |
953 | | - SetLength(INTERRUPT_1ST, Strs.Count); |
954 | | - for I := 0 to Strs.Count - 1 do begin |
955 | | - S:=Strs[I]; |
956 | | - PopDelim(S, EQUAL); |
957 | | - S:=Trim(S); |
958 | | - INTERRUPT_1ST[I]:=Trim(S); |
959 | | - end; |
960 | | - end; |
961 | | - // Replace SECTION_ORDER sections, replaces internal table |
962 | | - ReadSection('ORDER'); |
963 | | - if Strs.Count > 0 then begin |
964 | | - SetLength(SECTION_ORDER, Strs.Count); |
965 | | - for I := 0 to Strs.Count - 1 do begin |
966 | | - S:=Strs[I]; |
967 | | - PopDelim(S, EQUAL); |
968 | | - S:=Trim(S); |
969 | | - SECTION_ORDER[I]:=Trim(S); |
970 | | - end; |
971 | | - end; |
972 | | - // Update File/Path Name mappings, updates and appends internal table |
973 | | - ReadSection('NAMES'); |
974 | | - if Strs.Count > 0 then begin |
975 | | - for I := 0 to Strs.Count - 1 do begin |
976 | | - S:=Strs[I]; |
977 | | - K:=Trim(PopDelim(S, EQUAL)); |
978 | | - S:=Trim(S); |
979 | | - if S = '' then Continue; |
980 | | - for J := 0 to High(DOSNAMES) do |
981 | | - if UpperCase(DOSNAMES[J].DOS) = UpperCase(K) then begin |
982 | | - if Uppercase(K) = FILE_1ST then |
983 | | - IntFirstDir:=S; |
984 | | - DOSNAMES[J].Name:=S; |
985 | | - K:=''; |
986 | | - Break; |
987 | | - end; |
988 | | - if K = '' then Continue; |
989 | | - SetLength(DOSNAMES, Length(DOSNAMES) + 1); |
990 | | - DOSNAMES[High(DOSNAMES)].DOS:=K; |
991 | | - DOSNAMES[High(DOSNAMES)].Name:=S; |
992 | | - DOSNAMES[High(DOSNAMES)].Kind:=skNone; |
993 | | - end; |
994 | | - end; |
995 | | - // Update File/Path Name TYPE, updates and appends internal table |
996 | | - ReadSection('TYPE'); |
997 | | - if Strs.Count > 0 then begin |
998 | | - for I := 0 to Strs.Count - 1 do begin |
999 | | - S:=Strs[I]; |
1000 | | - K:=Trim(PopDelim(S, EQUAL)); |
1001 | | - S:=Trim(S); |
1002 | | - if S = '' then Continue; |
1003 | | - for J := 0 to High(DOSNAMES) do |
1004 | | - if UpperCase(DOSNAMES[J].DOS) = UpperCase(K) then begin |
1005 | | - DOSNAMES[J].Kind:=KindFromText(S); |
1006 | | - Break; |
1007 | | - end; |
1008 | | - end; |
1009 | | - end; |
1010 | | - // Update File Description Information for FILELIST, , updates and appends |
1011 | | - // internal table |
1012 | | - ReadSection('INFO'); |
1013 | | - if Strs.Count > 0 then begin |
1014 | | - for I := 0 to Strs.Count - 1 do begin |
1015 | | - S:=Strs[I]; |
1016 | | - K:=Trim(PopDelim(S, EQUAL)); |
1017 | | - S:=Trim(S); |
1018 | | - if S = '' then Continue; |
1019 | | - for J := 0 to High(DOSINFO) do |
1020 | | - if UpperCase(DOSINFO[J].Name) = UpperCase(K) then begin |
1021 | | - DOSINFO[J].Text:=S; |
1022 | | - K:=''; |
1023 | | - Break; |
1024 | | - end; |
1025 | | - if K = '' then Continue; |
1026 | | - SetLength(DOSINFO, Length(DOSINFO) + 1); |
1027 | | - DOSINFO[High(DOSINFO)].Name:=K; |
1028 | | - DOSINFO[High(DOSINFO)].Text:=S; |
1029 | | - end; |
1030 | | - end; |
1031 | | - |
1032 | | - except |
1033 | | - on E : Exception do begin |
1034 | | - LogMessage(vbCritical, 'Mapping file exception: ' + E.Message); |
1035 | | - Halt(1); |
1036 | | - end; |
1037 | | - end; |
1038 | | - if Assigned(INI) then INI.Free; |
1039 | | - if Assigned(Strs) then Strs.Free; |
1040 | | -end; |
1041 | | - |
1042 | 892 | // We do not really need to include the Lazarus Resourse in the executable. |
1043 | 893 | // But, Lazarus keeps sticking it back in here. So, whatever, its only a couple |
1044 | 894 | // of bytes. |
|
0 commit comments