Author: tkreuzer Date: Mon Mar 30 22:31:43 2015 New Revision: 66989
URL: http://svn.reactos.org/svn/reactos?rev=66989&view=rev Log: [CMAKE] Use native OS tools for concatenating files. Remove cat from host tools.
Removed: trunk/reactos/tools/cat.c Modified: trunk/reactos/CMakeLists.txt trunk/reactos/cmake/CMakeMacros.cmake trunk/reactos/tools/CMakeLists.txt
Modified: trunk/reactos/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/reactos/CMakeLists.txt?rev=66989&am... ============================================================================== --- trunk/reactos/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/CMakeLists.txt [iso-8859-1] Mon Mar 30 22:31:43 2015 @@ -85,9 +85,9 @@ add_subdirectory(lib)
if(NOT MSVC) - export(TARGETS bin2c cat widl gendib cabman cdmake mkhive obj2bin spec2def geninc rsym mkshelllink utf16le FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- ) - else() - export(TARGETS bin2c cat widl gendib cabman cdmake mkhive obj2bin spec2def geninc mkshelllink utf16le FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- ) + export(TARGETS bin2c widl gendib cabman cdmake mkhive obj2bin spec2def geninc rsym mkshelllink utf16le FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- ) + else() + export(TARGETS bin2c widl gendib cabman cdmake mkhive obj2bin spec2def geninc mkshelllink utf16le FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- ) endif()
else()
Modified: trunk/reactos/cmake/CMakeMacros.cmake URL: http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/CMakeMacros.cmake?rev... ============================================================================== --- trunk/reactos/cmake/CMakeMacros.cmake [iso-8859-1] (original) +++ trunk/reactos/cmake/CMakeMacros.cmake [iso-8859-1] Mon Mar 30 22:31:43 2015 @@ -504,12 +504,27 @@ endfunction() endif()
-macro(concatenate_files _output) - add_custom_command( - OUTPUT ${_output} - COMMAND native-cat ${ARGN} > ${_output} - DEPENDS ${ARGN} native-cat) -endmacro() +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + function(concatenate_files _output _file1) + file(TO_NATIVE_PATH "${_output}" _real_output) + file(TO_NATIVE_PATH "${_file1}" _file_list) + foreach(_file ${ARGN}) + file(TO_NATIVE_PATH "${_file}" _real_file) + set(_file_list "${_file_list} + ${_real_file}") + endforeach() + add_custom_command( + OUTPUT ${_output} + COMMAND cmd.exe /C "copy /Y /B ${_file_list} ${_real_output} > nul" + DEPENDS ${_file1} ${ARGN}) + endfunction() +else() + macro(concatenate_files _output) + add_custom_command( + OUTPUT ${_output} + COMMAND cat ${ARGN} > ${_output} + DEPENDS ${ARGN}) + endmacro() +endif()
function(add_importlibs _module) add_dependency_node(${_module})
Modified: trunk/reactos/tools/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/CMakeLists.txt?rev=66... ============================================================================== --- trunk/reactos/tools/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/tools/CMakeLists.txt [iso-8859-1] Mon Mar 30 22:31:43 2015 @@ -6,7 +6,6 @@ endif()
add_executable(bin2c bin2c.c) -add_executable(cat cat.c) add_executable(gendib gendib/gendib.c) add_executable(geninc geninc/geninc.c) add_executable(mkshelllink mkshelllink/mkshelllink.c)
Removed: trunk/reactos/tools/cat.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cat.c?rev=66988 ============================================================================== --- trunk/reactos/tools/cat.c [iso-8859-1] (original) +++ trunk/reactos/tools/cat.c (removed) @@ -1,128 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS conCATenation tool - * FILE: tools/cat.c - * PURPOSE: Concatenates STDIN or an arbitrary number of files to STDOUT - * PROGRAMMERS: David Welch - * Semyon Novikov (tappak) - * Hermès Bélusca - Maïto - */ - -#include <stdio.h> - -#ifdef _WIN32 -#include <fcntl.h> -#else -#define O_TEXT 0x4000 -#define O_BINARY 0x8000 -#define setmode(fd, mode) // This function is useless in *nix world. -#define stricmp strcasecmp -#endif - -#define ARRAYSIZE(a) (sizeof(a) / sizeof((a)[0])) - -void help(void) -{ - fprintf(stdout, - "\n" - "ReactOS File Concatenation Tool\n" - "\n" - "Usage: cat [options] [file [...]]\n" - "options - Currently ignored\n"); -} - -int main(int argc, char* argv[]) -{ - int i; - FILE* in; - unsigned char buff[512]; - size_t cnt, readcnt; - - if (argc >= 2) - { - if (stricmp(argv[1], "-h" ) == 0 || - stricmp(argv[1], "--help") == 0 || - stricmp(argv[1], "/?" ) == 0 || - stricmp(argv[1], "/help" ) == 0) - { - help(); - return 0; - } - } - - /* Set STDOUT to binary */ - setmode(fileno(stdout), O_BINARY); - - /* Special case where we run 'cat' without any argument: we use STDIN */ - if (argc <= 1) - { - unsigned int ch; - - /* Set STDIN to binary */ - setmode(fileno(stdin), O_BINARY); - -#if 0 // Version using feof() - ch = fgetc(stdin); - while (!feof(stdin)) - { - putchar(ch); - ch = fgetc(stdin); - } -#else - while ((ch = fgetc(stdin)) != EOF) - { - putchar(ch); - } -#endif - - return 0; - } - - /* We have files: read them and output them to STDOUT */ - for (i = 1; i < argc; i++) - { - /* Open the file in binary read mode */ - in = fopen(argv[i], "rb"); - if (in == NULL) - { - fprintf(stderr, "Failed to open file '%s'\n", argv[i]); - return -1; - } - - /* Dump the file to STDOUT */ - cnt = 0; readcnt = 0; - while (readcnt == cnt) - { - /* Read data from the input file */ - cnt = ARRAYSIZE(buff); - readcnt = fread(&buff, sizeof(buff[0]), cnt, in); - if (readcnt != cnt) - { - /* - * The real number of read bytes differs from the number of bytes - * we wanted to read, so either a reading error occurred, or EOF - * was reached while reading. Bail out if it is a reading error. - */ - if (!feof(in)) - { - fprintf(stderr, "Error while reading file '%s'\n", argv[i]); - fclose(in); - return -1; - } - } - - /* Nothing to be read anymore, so we can gracefully break */ - if (readcnt == 0) break; - - /* Write data to STDOUT */ - fwrite(&buff, sizeof(buff[0]), readcnt, stdout); - } - - /* Finally close the file */ - fclose(in); - } - - return 0; -} - -/* EOF */