diff --git a/source/dub/generators/build.d b/source/dub/generators/build.d index 56a72a6..0ca456d 100644 --- a/source/dub/generators/build.d +++ b/source/dub/generators/build.d @@ -307,7 +307,7 @@ logDiagnostic("Copying target from %s to %s", src.toNativeString(), buildsettings.targetPath); if (!existsFile(Path(buildsettings.targetPath))) mkdirRecurse(buildsettings.targetPath); - copyFile(src, Path(buildsettings.targetPath) ~ filename, true); + symlinkFile(src, Path(buildsettings.targetPath) ~ filename, true); } private bool isUpToDate(Path target_path, BuildSettings buildsettings, BuildPlatform platform, in Package main_pack, in Package[] packages, in Path[] additional_dep_files) diff --git a/source/dub/internal/vibecompat/core/file.d b/source/dub/internal/vibecompat/core/file.d index 5a806a3..e6849fe 100644 --- a/source/dub/internal/vibecompat/core/file.d +++ b/source/dub/internal/vibecompat/core/file.d @@ -134,6 +134,31 @@ } /** + Creates a symlink. +*/ +version (Windows) + alias symlinkFile = copyFile; // TODO: symlinks on Windows +else version (Posix) +{ + void symlinkFile(Path from, Path to, bool overwrite = false) + { + if (existsFile(to)) { + enforce(overwrite, "Destination file already exists."); + // remove file before copy to allow "overwriting" files that are in + // use on Linux + removeFile(to); + } + + .symlink(from.toNativeString(), to.toNativeString()); + } +} + +void symlinkFile(string from, string to) +{ + symlinkFile(Path(from), Path(to)); +} + +/** Removes a file */ void removeFile(Path path) @@ -288,4 +313,3 @@ } return ret; } -