tpr.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. ktigcc - TIGCC IDE for KDE
  3. tpr handling routines adapted from tprbuilder
  4. Copyright (C) 2002 Romain Liévin
  5. Copyright (C) 2002-2006 Kevin Kofler
  6. Copyright (C) 2006 Joey Adams
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software Foundation,
  17. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. */
  19. #pragma once
  20. class KURL;
  21. #include <qstring.h>
  22. #include <qstringlist.h>
  23. #include <qcstring.h>
  24. #include <qvaluevector.h>
  25. #include <qpair.h>
  26. /*Structure definitions from tprbuilder source; slightly modified
  27. to work under C++
  28. */
  29. typedef unsigned char Boolean;
  30. /* global enumerations */
  31. enum SectionType_ { SECTION_NONE, SECTION_SETTINGS, SECTION_LIBOPTS,
  32. SECTION_FILEEDIT, SECTION_FILES };
  33. typedef enum SectionType_ SectionType;
  34. /* definitions */
  35. typedef struct tprsettings tprSettings;
  36. struct tprsettings
  37. {
  38. tprsettings() : archive(0),pack(0),debug_info(0),std_lib(1),
  39. use_data_var(0),copy_data_var(1),copy_data_var_arc(1),
  40. optimize_nops(1),optimize_returns(1),optimize_branches(1),
  41. optimize_moves(1),optimize_tests(1),optimize_calcs(1),
  42. remove_unused(1),outputbin(0),fargo(0),flash_os(0),
  43. cut_ranges(1),reorder_sections(1),merge_constants(1),
  44. initialize_bss(1),
  45. cc_switches("-Os -Wall -W -Wwrite-strings -ffunction-sections -fdata-sections"),
  46. as_switches(""),
  47. a68k_switches("-g -t")
  48. {}
  49. Boolean archive; // we want to build an archive
  50. Boolean pack; // we want to pack the executable
  51. Boolean debug_info; // pass -g option to tigcc
  52. Boolean std_lib; // link against tigcc.a
  53. Boolean use_data_var;
  54. Boolean copy_data_var;
  55. Boolean copy_data_var_arc;
  56. Boolean optimize_nops;
  57. Boolean optimize_returns;
  58. Boolean optimize_branches;
  59. Boolean optimize_moves;
  60. Boolean optimize_tests;
  61. Boolean optimize_calcs;
  62. Boolean remove_unused;
  63. Boolean outputbin;
  64. Boolean fargo;
  65. Boolean flash_os;
  66. Boolean cut_ranges;
  67. Boolean reorder_sections;
  68. Boolean merge_constants;
  69. Boolean initialize_bss;
  70. QString pack_name;
  71. QString cc_switches;
  72. QString as_switches;
  73. QString a68k_switches;
  74. QString cmd_line;
  75. QString post_build;
  76. QString data_var;
  77. };
  78. enum tprreloctypes {
  79. RT_NONE, // None (BSS, data var)
  80. RT_DIRECT, // Direct (ROM_CALLs)
  81. RT_AMS, // AMS (relocs)
  82. RT_PRECOMP, // ROM_CALLs only: Precomputed (Optimized)
  83. RT_KERNEL, // Kernel
  84. RT_COMPRESSED, // Compressed
  85. RT_MLINK, // MLink
  86. RT_FLINE // ROM_CALLs only: F-Line
  87. };
  88. typedef enum tprreloctypes tprRelocType;
  89. typedef struct tprlibopts tprLibOpts;
  90. struct tprlibopts
  91. {
  92. tprlibopts() : use_ti89(1),use_ti92p(1),use_v200(1),opt_calc_consts(0),
  93. use_kernel(0),use_preos(0),use_minams(1),
  94. unofficial_os(0),use_fline_jumps(0),use_4b_fline_jumps(0),
  95. use_internal_fline_emu(0),use_return_value(0),
  96. enable_error_return(0),save_screen(1),opt_rom_calls(0),
  97. minams(100),reloc_format(RT_AMS),rom_call_format(RT_DIRECT),
  98. bss_ref_format(RT_KERNEL),data_ref_format(RT_KERNEL)
  99. {}
  100. Boolean use_ti89;
  101. Boolean use_ti92p;
  102. Boolean use_v200;
  103. Boolean opt_calc_consts;
  104. Boolean use_kernel;
  105. Boolean use_preos;
  106. Boolean use_minams;
  107. Boolean unofficial_os;
  108. Boolean use_fline_jumps;
  109. Boolean use_4b_fline_jumps;
  110. Boolean use_internal_fline_emu;
  111. Boolean use_return_value;
  112. Boolean enable_error_return;
  113. Boolean save_screen;
  114. Boolean opt_rom_calls;
  115. int minams;
  116. tprRelocType reloc_format;
  117. tprRelocType rom_call_format;
  118. tprRelocType bss_ref_format;
  119. tprRelocType data_ref_format;
  120. };
  121. typedef struct
  122. {
  123. QStringList path;
  124. QStringList folder;
  125. } TPRFileList;
  126. typedef struct
  127. {
  128. QString prj_name;
  129. QString open_file;
  130. tprSettings settings;
  131. tprLibOpts libopts;
  132. TPRFileList h_files;
  133. TPRFileList c_files;
  134. TPRFileList s_files;
  135. TPRFileList asm_files;
  136. TPRFileList o_files;
  137. TPRFileList a_files;
  138. TPRFileList txt_files;
  139. TPRFileList oth_files;
  140. TPRFileList quill_files;
  141. } TPRDataStruct;
  142. enum {PATH_ERROR,PATH_NOTFOUND,PATH_FILE,PATH_FOLDER}; //return types for getPathType
  143. typedef QValueVector<QPair<unsigned,unsigned> > LineStartList;
  144. const char *smartAscii(const QString &s);
  145. void newSettings(tprSettings *settings,tprLibOpts *libopts);
  146. int loadTPR(const QString &fileName,TPRDataStruct *dest);
  147. QString loadFileText(const char *fileName);
  148. int saveTPR(const QString &fileName,TPRDataStruct *src);
  149. void mkdir_multi(const char *fileName);
  150. int saveAndSplitFileText(const char *fileName, const QString &fileText,
  151. bool split, bool addCLineDirective,
  152. bool addASMLineDirective, const QString &origFileName,
  153. LineStartList *pLineStartList, bool addNewline=true);
  154. int saveFileText(const char *fileName,const QString &fileText);
  155. void kurlNewFileName(KURL &dir,const QString &newFileName);
  156. int checkFileName(const QString &fileName,const QStringList &fileNameList);
  157. int copyFile(const char *src, const char *dest);
  158. bool moveFile(const QString &src, const QString &dest);
  159. int insertName(const char *src, const char *dest, const char *name);
  160. int getPathType(const QString &thePath);
  161. QStringList process_libopts(void);
  162. QStringList process_settings(const QString &prjNameUnicode,
  163. QCString &projectName, QCString &dataVarName,
  164. QCString &packFolder, QCString &packName);