Waf copy file from source tree to build tree

I have the following snippet to copy the file as is to the build directory:

for m in std_mibs:
    print("Copying", m)
    bld(name       = 'cpstdmib',
        rule       = 'cp -f ${SRC} ${TGT}',
        #source     =  m + '.mib',
        source     =  bld.path.make_node(m + '.mib'), # <-- section 5.3.3 of the waf book
        target     =  bld.path.get_bld().make_node(m + '.mib')
        )

      

I see this rule, although horrible (from print), no copy seems to happen! I also changed the source to use make_node

as shown in the example in section 5.3.3 of the waf book, still no luck! Am I missing something obvious here?

Also, after this I have some rules that rely on the copied files and I tried to add an intermediate

bld.add_group()

      

I hope the sequence will work if this copy succeeds

+3


source to share


3 answers


If you run the rule once, it will not run again until the source has been updated. This is true even if the target is removed, for example (which was probably the way you tested).



If you want to reconfigure, if the target is removed, you will need always=True

it or you will need to check for availability and install target.sig = None

.

+1


source


Two alternatives:

  • features="subst"

    with is_copy=True

    :

     bld(features='subst', source='wscript', target='wscript', is_copy=True)
    
          

  • waflib.extras.buildcopy

    in the following way:

    from waflib.extras import buildcopy
    #...
    def build(bld):
        bld(features='buildcopy',buildcopy_source=['file'])
    
          



cp

platform independent.

Object is created

A task_gen

that will later become Task

, which will be executed before process_sources

. Don't expect immediate effects.

+1


source


Look at your directory out

, there will be out/${TGT}

(not exactly, but the ${TGT}

path is relative to your directory top

)


This is completely expected behavior, since you don't want to modify the original tree on creation.

0


source







All Articles