home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / clean.e < prev    next >
Text File  |  1999-06-05  |  4KB  |  118 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr
  4. --                       http://SmallEiffel.loria.fr
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License
  11. -- for  more  details.  You  should  have  received a copy of the GNU General
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class CLEAN
  17.    --
  18.    -- The `clean' command.
  19.    --
  20.  
  21. inherit COMMAND_FLAGS;
  22.  
  23. creation make
  24.  
  25. feature {NONE}
  26.  
  27.    command_name: STRING is
  28.       do
  29.          Result := Command_clean;
  30.       end;
  31.  
  32.    make is
  33.       local
  34.          argc, argi: INTEGER;
  35.          arg, make_suffix: STRING;
  36.       do
  37.          argc := argument_count;
  38.          if argc < 1 then
  39.             system_tools.bad_use_exit(command_name);
  40.          end;
  41.          search_for_verbose_flag;
  42.          search_for_cc_flag(argc);
  43.          from
  44.             make_suffix := system_tools.make_suffix;
  45.             argi := 1;
  46.          until
  47.             argi > argc
  48.          loop
  49.             arg := argument(argi);
  50.             if is_flag_verbose(arg) then
  51.                argi := argi + 1;
  52.             elseif is_flag_version(arg) then
  53.                argi := argi + 1;
  54.             elseif arg.item(1) = '-' then
  55.                unknown_flag_exit(arg);
  56.             else
  57.                if arg.has_suffix(eiffel_suffix) then
  58.                   arg.remove_suffix(eiffel_suffix);
  59.                elseif arg.has_suffix(make_suffix) then
  60.                   arg.remove_suffix(make_suffix);
  61.                end;
  62.                run_control.compute_root_class(arg);
  63.                try_to_remove(arg);
  64.                arg.to_upper;
  65.                try_to_remove(arg);
  66.                arg.to_lower;
  67.                try_to_remove(arg);
  68.                arg := system_tools.remove_make_script;
  69.                arg := run_control.root_class.twin;
  70.                try_to_remove(arg);
  71.                arg.to_lower;
  72.                try_to_remove(arg);
  73.                argi := argi + 1;
  74.             end;
  75.          end;
  76.       end;
  77.  
  78.    try_to_remove(prefix_name: STRING) is
  79.       require
  80.          prefix_name.count > 0
  81.       local
  82.          i: INTEGER;
  83.       do
  84.          from
  85.             i := 1;
  86.          until
  87.             i = 0
  88.          loop
  89.             tmp_path.copy(prefix_name);
  90.             i.append_in(tmp_path);
  91.             tmp_path.extend('.');
  92.             tmp_path.extend('c');
  93.             if file_exists(tmp_path) then
  94.                echo.file_removing(tmp_path);
  95.                tmp_path.put('d',tmp_path.count);
  96.                echo.file_removing(tmp_path);
  97.                tmp_path.remove_last(2);
  98.                tmp_path.append(system_tools.object_suffix);
  99.                echo.file_removing(tmp_path);
  100.                i := i + 1;
  101.             else
  102.                i := 0;
  103.             end;
  104.          end;
  105.          tmp_path.copy(prefix_name);
  106.          tmp_path.extend('.');
  107.          tmp_path.extend('h');
  108.          echo.file_removing(tmp_path);
  109.          tmp_path.put('c',tmp_path.count);
  110.          echo.file_removing(tmp_path);
  111.          tmp_path.put('d',tmp_path.count);
  112.          echo.file_removing(tmp_path);
  113.       end;
  114.  
  115. end -- CLEAN
  116.  
  117.  
  118.