[ros-dev] [ros-diffs] [hbelusca] 66946: [CMAKE] Improve the concatenate_files macro introduced by Timo in r52179 + r52182 and hackfixed in r53914 . Notice that now it can take an arbitrary number of files to be concaten...

Timo Kreuzer timo.kreuzer at web.de
Sun Mar 29 16:47:48 UTC 2015


The fun part is, your commit caused a conflict for me. The reason is 
that I had just changed it to support multiple files, but using the OS 
tools. And I don't see what is challenging there. It's not like you have 
to write this in ARM assembly.

Unless anyone objects, I'm going to replace the current solution with a 
solution using OS tools.

Timo


Am 29.03.2015 um 16:01 schrieb Hermès BÉLUSCA - MAÏTO:
> Being forced (for the windows system) to build the whole string "file1 +
> file2 + ... + fileN" to feed the 'copy' command would be quite challenging.
> OK on windows there is the 'type' command (that I didn't think of at first).
> It just have a tiny "problem", in that you need to do (for example): "type
> 1.txt 2.txt 3.txt 1> toto.txt 2> NUL" to concatenate the 3 files into
> toto.txt *and* redirecting STDERR to NUL, otherwise the names of the files
> being processed are displayed in STDERR (that is usually equivalent to
> STDOUT, and as result, you would have a lot of spam while compiling). But
> then, doing that, in case some file is missing (for example), you couldn't
> see the error because you've redirected STDERR to NUL ... And I haven't
> found any option to overcome this problem.
>
> -----Message d'origine-----
> De : Ros-dev [mailto:ros-dev-bounces at reactos.org] De la part de Pierre
> Schweitzer
> Envoyé : dimanche 29 mars 2015 13:14
> À : ReactOS Development List
> Objet : Re: [ros-dev] [ros-diffs] [hbelusca] 66946: [CMAKE] Improve the
> concatenate_files macro introduced by Timo in r52179 + r52182 and hackfixed
> in r53914 . Notice that now it can take an arbitrary number of files to be
> concaten...
>
> Seconding here...
> What's the whole purpose of this?
> You have cat on Linux/BSD systems and type on Windows systems (if you don't
> want to do the whole cmd copy stuff).
> So what's the point? Let's keep efficient local tools.
>
> On 29/03/2015 07:15, Thomas Faber wrote:
>> I don't see how creating a new host-tool is an improvement over using
>> OS builtins?
>>
>>
>> On 2015-03-29 03:53, hbelusca at svn.reactos.org wrote:
>>> Author: hbelusca
>>> Date: Sun Mar 29 01:53:10 2015
>>> New Revision: 66946
>>>
>>> URL: http://svn.reactos.org/svn/reactos?rev=66946&view=rev
>>> Log:
>>> [CMAKE]
>>> Improve the concatenate_files macro introduced by Timo in r52179 + r52182
> and hackfixed in r53914 . Notice that now it can take an arbitrary number of
> files to be concatenated. Hence you need to specify first the output file,
> and all the rest is the different files.
>>> [FREELDR]
>>> Use the improved concatenate_files macro.
>>>
>>> Modified:
>>>      trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt
>>>      trunk/reactos/cmake/CMakeMacros.cmake
>>>
>>> Modified: trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt
>>> URL:
>>> http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr
>>> /CMakeLists.txt?rev=66946&r1=66945&r2=66946&view=diff
>>>
> ============================================================================
> ==
>>> --- trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt	[iso-8859-1]
> (original)
>>> +++ trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt	[iso-8859-1]
> Sun Mar 29 01:53:10 2015
>>> @@ -226,10 +226,13 @@
>>>   add_dependencies(freeldr_pe asm)
>>>   add_dependencies(freeldr_pe_dbg asm)
>>>   
>>> +# Retrieve the full path to the generated file of the 'freeldr_pe'
>>> +target get_target_property(_freeldr_pe_output_file freeldr_pe
>>> +LOCATION)
>>> +
>>>   concatenate_files(
>>> +    ${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys
>>>       ${CMAKE_CURRENT_BINARY_DIR}/frldr16.bin
>>> -    freeldr_pe
>>> -    ${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys)
>>> +    ${_freeldr_pe_output_file})
>>>   
>>>   add_custom_target(freeldr ALL DEPENDS
>>> ${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys)
>>>   
>>> @@ -238,9 +241,9 @@
>>>   add_cd_file(TARGET freeldr FILE
>>> ${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys DESTINATION loader NO_CAB
>>> NOT_IN_HYBRIDCD FOR livecd hybridcd NAME_ON_CD setupldr.sys)
>>>   
>>>   concatenate_files(
>>> +    ${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys
>>>       ${CMAKE_CURRENT_BINARY_DIR}/frldr16.bin
>>> -    freeldr_pe
>>> -    ${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys)
>>> +    ${_freeldr_pe_output_file})
>>>   
>>>   add_custom_target(setupldr ALL DEPENDS
>>> ${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys)
>>>   add_cd_file(TARGET setupldr FILE
>>> ${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys DESTINATION loader NO_CAB
>>> FOR bootcd regtest)
>>>
>>> Modified: trunk/reactos/cmake/CMakeMacros.cmake
>>> URL:
>>> http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/CMakeMacros.cm
>>> ake?rev=66946&r1=66945&r2=66946&view=diff
>>>
> ============================================================================
> ==
>>> --- trunk/reactos/cmake/CMakeMacros.cmake	[iso-8859-1] (original)
>>> +++ trunk/reactos/cmake/CMakeMacros.cmake	[iso-8859-1] Sun Mar 29
> 01:53:10 2015
>>> @@ -504,33 +504,12 @@
>>>       endfunction()
>>>   endif()
>>>   
>>> -if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
>>> -    macro(to_win_path _cmake_path _native_path)
>>> -        string(REPLACE "/" "\\" ${_native_path} "${_cmake_path}")
>>> -    endmacro()
>>> -
>>> -    # yeah the parameter mess sucks, but thats what works...
>>> -    function(concatenate_files _file1 _target2 _output)
>>> -        get_target_property(_file2 ${_target2} LOCATION)
>>> -        to_win_path("${_file1}" _real_file1)
>>> -        to_win_path("${_file2}" _real_file2)
>>> -        to_win_path("${_output}" _real_output)
>>> -        add_custom_command(
>>> -            OUTPUT ${_output}
>>> -            COMMAND cmd.exe /C "copy /Y /B ${_real_file1} +
> ${_real_file2} ${_real_output} > nul"
>>> -            DEPENDS ${_file1}
>>> -            DEPENDS ${_target2})
>>> -    endfunction()
>>> -else()
>>> -    macro(concatenate_files _file1 _target2 _output)
>>> -        get_target_property(_file2 ${_target2} LOCATION)
>>> -        add_custom_command(
>>> -            OUTPUT ${_output}
>>> -            COMMAND cat ${_file1} ${_file2} > ${_output}
>>> -            DEPENDS ${_file1}
>>> -            DEPENDS ${_target2})
>>> -    endmacro()
>>> -endif()
>>> +macro(concatenate_files _output)
>>> +    add_custom_command(
>>> +        OUTPUT ${_output}
>>> +        COMMAND native-cat ${ARGN} > ${_output}
>>> +        DEPENDS ${ARGN} native-cat)
>>> +endmacro()
>>>   
>>>   function(add_importlibs _module)
>>>       add_dependency_node(${_module})
>>>
>>>
>>
>> _______________________________________________
>> Ros-dev mailing list
>> Ros-dev at reactos.org
>> http://www.reactos.org/mailman/listinfo/ros-dev
>>
>
> --
> Pierre Schweitzer <pierre at reactos.org> System & Network Administrator
> Senior Kernel Developer ReactOS Deutschland e.V.
>
>
> _______________________________________________
> Ros-dev mailing list
> Ros-dev at reactos.org
> http://www.reactos.org/mailman/listinfo/ros-dev
>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3683 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://www.reactos.org/pipermail/ros-dev/attachments/20150329/ccb47f4b/attachment.bin>


More information about the Ros-dev mailing list