dlang / dub

Package and build management system for D
MIT License
673 stars 230 forks source link

Cannot cache build in the presence of `__FILE_FULL_PATH__` #2840

Closed Geod24 closed 7 months ago

Geod24 commented 7 months ago

Reported by @kinke .

#!/usr/bin/env dub
/++ dub.json:
   {
       "name": "build"
   }
+/

import std.format;

immutable FullPath = __FILE_FULL_PATH__;

void main (string[] args)
{
    assert(args.length == 2, "Expected a single argument");
    assert(args[1] == FullPath, format("%s != %s -- %s", args[1], FullPath, args[0]));
}
echo "$CODE" > build.d && chmod +x build.d
./build.d $(pwd)/build.d
mkdir nested && cp build.d nested/ && cd nested
./build.d $(pwd)/build.d

Results in:

core.exception.AssertError@build.d(15): /home/mlang/projects/dlang/dub/foo/nested/build.d != /home/mlang/projects/dlang/dub/foo/build.d -- /tmp/.dub/build/build-~master/application-debug-zjWJHxauIHQN4hH1LrZ2uA/build
----------------
??:? [0x563be84e1f06]
??:? [0x563be84e1b82]
??:? [0x563be85080d6]
??:? [0x563be84e96ef]
??:? [0x563be84e0bd3]
build.d:15 [0x563be84a7b4f]
??:? [0x563be84e93bc]
??:? [0x563be84e92b6]
??:? [0x563be84e910d]
/home/mlang/dlang/ldc-1.35.0/bin/../import/core/internal/entrypoint.d:42 [0x563be84a7d41]
??:? [0x7faca72c3d8f]
??:? __libc_start_main [0x7faca72c3e3f]
??:? [0x563be84a7984]
Error Program exited with code 1

Because the program does not get rebuilt.

kinke commented 7 months ago

Just for the record, rdmd uses a global cache too (in /tmp), but the cache key is different for identical files in different directories.