cmdline.pas 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. {
  2. cmdline.pas
  3. Command line parsing methods
  4. Copyright (C) 2006-2007 Felipe Monteiro de Carvalho
  5. This file is part of MkSymbian build tool.
  6. MkSymbian is free software;
  7. you can redistribute it and/or modify it under the
  8. terms of the GNU General Public License version 2
  9. as published by the Free Software Foundation.
  10. MkSymbian is distributed in the hope
  11. that it will be useful, but WITHOUT ANY WARRANTY; without even
  12. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  13. PURPOSE. See the GNU General Public License for more details.
  14. Please note that the General Public License version 2 does not permit
  15. incorporating MkSymbian into proprietary programs.
  16. }
  17. unit cmdline;
  18. {$ifdef fpc}
  19. {$mode delphi}{$H+}
  20. {$endif}
  21. interface
  22. uses
  23. Classes, SysUtils,
  24. constants;
  25. type
  26. { TCmdLine }
  27. TCmdLine = class(TObject)
  28. public
  29. procedure Usage;
  30. procedure ShowPath;
  31. procedure ParseCmdLineOptions(var opts: TMkSymbianOptions);
  32. end;
  33. var
  34. vCmdLine: TCmdLine;
  35. implementation
  36. uses sdkutil, projectparser;
  37. { TCmdLine }
  38. {*******************************************************************
  39. * TCmdLine.Usage ()
  40. *
  41. * DESCRIPTION: Shows a usage message for the tool
  42. *
  43. * PARAMETERS: None
  44. *
  45. * RETURNS: Nothing
  46. *
  47. *******************************************************************}
  48. procedure TCmdLine.Usage;
  49. begin
  50. WriteLn('mksymbian - Build tool for Free Pascal for SymbianOS');
  51. WriteLn('');
  52. WriteLn('The parameters you specifyed are wrong.');
  53. WriteLn('');
  54. WriteLn('Usage: mksymbian [command] [project file]');
  55. WriteLn('');
  56. WriteLn('Possible commands: ');
  57. WriteLn('');
  58. WriteLn('build - Builds an application');
  59. WriteLn('bindings - Builds the c++ bindings for pascal');
  60. WriteLn('showpath - Show the paths the tool is using');
  61. WriteLn('');
  62. end;
  63. {*******************************************************************
  64. * TCmdLine.ShowPath ()
  65. *
  66. * DESCRIPTION: Shows in which paths (sdk, fpc, etc) mksymbian is using
  67. *
  68. * PARAMETERS: None
  69. *
  70. * RETURNS: Nothing
  71. *
  72. *******************************************************************}
  73. procedure TCmdLine.ShowPath;
  74. begin
  75. WriteLn('mksymbian - Build tool for Free Pascal for SymbianOS');
  76. WriteLn('');
  77. WriteLn('SDK Version: ' + vSDKUtil.StrSDKVersion);
  78. WriteLn('Location of SDK: ' + vSDKUtil.SDKFolder);
  79. WriteLn('Location of Free Pascal Compiler: ' + vProject.CompilerPath);
  80. WriteLn('');
  81. end;
  82. {*******************************************************************
  83. * TCmdLine.ParseCmdLineOptions ()
  84. *
  85. * DESCRIPTION: Parses the command line options utilized to call mksymbian
  86. *
  87. * PARAMETERS: None
  88. *
  89. * RETURNS: Nothing
  90. *
  91. *******************************************************************}
  92. procedure TCmdLine.ParseCmdLineOptions(var opts: TMkSymbianOptions);
  93. begin
  94. FillChar(opts, SizeOf(TMkSymbianOptions), #0);
  95. if (ParamCount = 0) then
  96. begin
  97. Usage;
  98. Exit;
  99. end;
  100. opts.ProjectFile := ParamStr(2);
  101. if CompareText(ParamStr(1), paramBuild) = 0 then opts.task := stBuildApp
  102. else if CompareText(ParamStr(1), paramBindings) = 0 then opts.task := stBuildBindings
  103. else if CompareText(ParamStr(1), paramShowPath) = 0 then
  104. begin
  105. opts.task := stNothing;
  106. vProject.ParseFile;
  107. ShowPath;
  108. end
  109. else
  110. begin
  111. opts.task := stNothing;
  112. Usage;
  113. end;
  114. end;
  115. end.