Search code examples
pythonscons

How SCons hardlinks sources in variant directory?


I tested SCons default hardlink behavior.

I am expecting that a modification in the hardlinked file in the variant dir is reflected also in the original file. But this doesn't happen.

Is hardlinking really a default behavior as stated in SCons doc or it is just copying the files in the variant directory ?

EDIT:

Details about my implementations/configurations:

I am using VariantDir with one SConscript in the root of the project

Duplicate option is on in VariantDir

No duplicate option in cmd line (default).

I am using my own custom tools. I am using only the program builder from the builders available by default in SCons.

I tried the following flags: hard-soft-copy (the default), soft-hard-copy, hard-copy, soft-copy or copy.

None of them will provide me a real hard link copy.

I expect the following:

When I change a source file in variant dir the change will be reflected in the original file (at the original location) since the file in variant dir is a hard link.

Instead a change in the source file in the variant dir won't be reflected in the original file.

EDIT 2:

After running --debug=duplicate I got for each file considered in the dependency cycle a message similar to this:

dup: relinking variant 'relative_path_to_file' from 'absolute_path'

Solution

  • As stated in the corresponding Python reference docs, the underlying os.link method, that SCons tries to find and use internally to create hard links, is not available under Windows. The same holds true for os.symlink (symbolic/soft links), so the only remaining option for SCons under Windows is to actually copy the files.