how to use msvs_postbuild to copy diffrent files to OutDir

49 views
Skip to first unread message

alenn...@gmail.com

unread,
Nov 13, 2018, 10:46:44 AM11/13/18
to gyp-developer
'configurations':
                {
                    'Debug':
                    {
                           'msvs_postbuild': 
                            [
                                        r'copy "<(QTDIR)\bin\Qt5Cored.dll" "$(OutDir)"',
                                        r'copy "..\3rd\opencv\bin\Debug\opencv_world331d.dll" "$(OutDir)" ',
                            ],#msvs_postbuild
                    },
                    'Release':
                    {
                           'msvs_postbuild': 
                            [
                                        r'copy "<(QTDIR)\bin\Qt5Core.dll" "$(OutDir)"',
                                        r'copy "..\3rd\opencv\bin\Release\opencv_world331.dll" "$(OutDir)" ',
                            ],#msvs_postbuild
                    },
               }


This is what I want to do, but i found this is wrong , so i want to konw how to achieve the goal, or are there other ways to do 

alan

unread,
Nov 14, 2018, 5:48:53 AM11/14/18
to gyp-developer
Try:

           'msbuild_settings':{
              'PostBuildEvent':{'Command':r'copy ...'},
            },

Refael Ackermann

unread,
Nov 14, 2018, 12:41:08 PM11/14/18
to gyp-developer
It's an interesting feature request (post-build-action).
A common pattern that results in portable builds is to add a dependent `none` type wrapper `target` with an `action` that does the copy.

Alan Birtles

unread,
Nov 16, 2018, 4:19:07 AM11/16/18
to Alen Ning, gyp-de...@googlegroups.com

Try this patch to MSVSSettings.py

--- /private/var/folders/h4/_5_dh0d52mndz_97wvnmqd3w0000gn/T/Y3JnJa_MSVSSettings.py    2018-11-16 09:15:06.000000000
+++ /private/var/folders/h4/_5_dh0d52mndz_97wvnmqd3w0000gn/T/IVFhHa_MSVSSettings.py    2018-11-16 09:15:06.000000000
@@ -536,21 +536,23 @@
 _link = _Tool('VCLinkerTool', 'Link')
 _midl = _Tool('VCMIDLTool', 'Midl')
 _rc = _Tool('VCResourceCompilerTool', 'ResourceCompile')
 _lib = _Tool('VCLibrarianTool', 'Lib')
 _manifest = _Tool('VCManifestTool', 'Manifest')
 _masm = _Tool('MASM', 'MASM')
+_postbuild = _Tool('', 'PostBuildEvent')
 
 
 _AddTool(_compile)
 _AddTool(_link)
 _AddTool(_midl)
 _AddTool(_rc)
 _AddTool(_lib)
 _AddTool(_manifest)
 _AddTool(_masm)
+_AddTool(_postbuild)
 # Add sections only found in the MSBuild settings.
 _msbuild_validators[''] = {}
 _msbuild_validators['ProjectReference'] = {}
 _msbuild_validators['ManifestResourceCompile'] = {}
 
 # Descriptions of the compiler options, i.e. VCCLCompilerTool in MSVS and
@@ -717,12 +719,15 @@
 _MSBuildOnly(_compile, 'PreprocessOutputPath', _string)  # /Fi
 _MSBuildOnly(_compile, 'ProcessorNumber', _integer)  # the number of processors
 _MSBuildOnly(_compile, 'TrackerLogDirectory', _folder_name)
 _MSBuildOnly(_compile, 'TreatSpecificWarningsAsErrors', _string_list)  # /we
 _MSBuildOnly(_compile, 'UseUnicodeForAssemblerListing', _boolean)  # /FAu
 
+_MSBuildOnly(_postbuild, 'Message', _string)
+_MSBuildOnly(_postbuild, 'Command', _string)
+
 # Defines a setting that needs very customized processing
 _CustomGeneratePreprocessedFile(_compile, 'GeneratePreprocessedFile')
 
 
 # Directives for converting MSVS VCLinkerTool to MSBuild Link.
 # See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\link.xml" for


Quoting Alen Ning <alenn...@gmail.com>:

 I tried to do it, but i got some errors 
 
Warning: unrecognized tool PostBuildEvent
Traceback (most recent call last):
  File "E:\gyp\gyp_main.py", line 16, in <module>
    sys.exit(gyp.script_main())
  File "E:\gyp\pylib\gyp\__init__.py", line 545, in script_main
    return main(sys.argv[1:])
  File "E:\gyp\pylib\gyp\__init__.py", line 538, in main
    return gyp_main(args)
  File "E:\gyp\pylib\gyp\__init__.py", line 523, in gyp_main
    generator.GenerateOutput(flat_list, targets, data, params)
  File "E:\gyp\pylib\gyp\generator\msvs.py", line 2045, in GenerateOutput
    generator_flags))
  File "E:\gyp\pylib\gyp\generator\msvs.py", line 963, in _GenerateProject
    return _GenerateMSBuildProject(project, options, version, generator_flags)
  File "E:\gyp\pylib\gyp\generator\msvs.py", line 3364, in _GenerateMSBuildProject
    _FinalizeMSBuildSettings(spec, configuration)
  File "E:\gyp\pylib\gyp\generator\msvs.py", line 3147, in _FinalizeMSBuildSettings
    _ToolAppend(msbuild_settings, 'PostBuildEvent', 'Command', postbuild)
  File "E:\gyp\pylib\gyp\generator\msvs.py", line 249, in _ToolAppend
    _ToolSetOrAppend(tools, tool_name, setting, value, only_if_unset)
  File "E:\gyp\pylib\gyp\generator\msvs.py", line 272, in _ToolSetOrAppend
    value, setting, tool_name, str(tool[setting])))
TypeError: Appending "['copy "..\\3rd\\orangefilter\\bin\\debug\\" "$(OutDir)" ']" to a non-list setting "Command" for t
ool "PostBuildEvent" is not allowed, previous value: copy "..\3rd\orangefilter\bin\debug\" "$(OutDir)"

gyp don't support PostBuildEvent key word

alan <apbi...@gmail.com> 于2018年11月14日周三 下午6:48写道:

--

---
You received this message because you are subscribed to the Google Groups "gyp-developer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gyp-develope...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


 
--
Alen NIng


Refael Ackermann

unread,
Nov 16, 2018, 9:21:34 AM11/16/18
to al...@birtles.org.uk, alenn...@gmail.com, gyp-de...@googlegroups.com
I'd be happy to merge it to https://github.com/refack/GYP (soon to be https://github.com/nodejs/GYP)
Reply all
Reply to author
Forward
0 new messages