diff --git a/maintainers/flake-module.nix b/maintainers/flake-module.nix index 419994bdb..a42828208 100644 --- a/maintainers/flake-module.nix +++ b/maintainers/flake-module.nix @@ -125,8 +125,8 @@ ''^src/libfetchers/registry\.hh$'' ''^src/libfetchers/tarball\.cc$'' ''^src/libfetchers/tarball\.hh$'' - ''^src/libfetchers/unix/git\.cc$'' - ''^src/libfetchers/unix/mercurial\.cc$'' + ''^src/libfetchers/git\.cc$'' + ''^src/libfetchers/mercurial\.cc$'' ''^src/libmain/common-args\.cc$'' ''^src/libmain/common-args\.hh$'' ''^src/libmain/loggers\.cc$'' @@ -237,11 +237,11 @@ ''^src/libstore/build/substitution-goal\.hh$'' ''^src/libstore/build/worker\.cc$'' ''^src/libstore/build/worker\.hh$'' - ''^src/libstore/unix/builtins/fetchurl\.cc$'' - ''^src/libstore/unix/builtins/unpack-channel\.cc$'' + ''^src/libstore/builtins/fetchurl\.cc$'' + ''^src/libstore/builtins/unpack-channel\.cc$'' ''^src/libstore/gc\.cc$'' - ''^src/libstore/unix/local-overlay-store\.cc$'' - ''^src/libstore/unix/local-overlay-store\.hh$'' + ''^src/libstore/local-overlay-store\.cc$'' + ''^src/libstore/local-overlay-store\.hh$'' ''^src/libstore/local-store\.cc$'' ''^src/libstore/local-store\.hh$'' ''^src/libstore/unix/user-lock\.cc$'' diff --git a/src/libfetchers/unix/git.cc b/src/libfetchers/git.cc similarity index 98% rename from src/libfetchers/unix/git.cc rename to src/libfetchers/git.cc index fa7ef3621..ce80932f6 100644 --- a/src/libfetchers/unix/git.cc +++ b/src/libfetchers/git.cc @@ -19,7 +19,10 @@ #include #include #include -#include + +#ifndef _WIN32 +# include +#endif using namespace std::string_literals; @@ -40,6 +43,7 @@ bool isCacheFileWithinTtl(time_t now, const struct stat & st) bool touchCacheFile(const Path & path, time_t touch_time) { +#ifndef _WIN32 // TODO implement struct timeval times[2]; times[0].tv_sec = touch_time; times[0].tv_usec = 0; @@ -47,6 +51,9 @@ bool touchCacheFile(const Path & path, time_t touch_time) times[1].tv_usec = 0; return lutimes(path.c_str(), times) == 0; +#else + return false; +#endif } Path getCachePath(std::string_view key, bool shallow) @@ -98,7 +105,15 @@ bool storeCachedHead(const std::string & actualUrl, const std::string & headRef) try { runProgram("git", true, { "-C", cacheDir, "--git-dir", ".", "symbolic-ref", "--", "HEAD", headRef }); } catch (ExecError &e) { - if (!WIFEXITED(e.status)) throw; + if ( +#ifndef WIN32 // TODO abstract over exit status handling on Windows + !WIFEXITED(e.status) +#else + e.status != 0 +#endif + ) + throw; + return false; } /* No need to touch refs/HEAD, because `git symbolic-ref` updates the mtime. */ @@ -329,7 +344,13 @@ struct GitInputScheme : InputScheme .program = "git", .args = {"-C", repoInfo.url, "--git-dir", repoInfo.gitDir, "check-ignore", "--quiet", std::string(path.rel())}, }); - auto exitCode = WEXITSTATUS(result.first); + auto exitCode = +#ifndef WIN32 // TODO abstract over exit status handling on Windows + WEXITSTATUS(result.first) +#else + result.first +#endif + ; if (exitCode != 0) { // The path is not `.gitignore`d, we can add the file. diff --git a/src/libfetchers/local.mk b/src/libfetchers/local.mk index 0fef1466b..e229a0993 100644 --- a/src/libfetchers/local.mk +++ b/src/libfetchers/local.mk @@ -5,16 +5,10 @@ libfetchers_NAME = libnixfetchers libfetchers_DIR := $(d) libfetchers_SOURCES := $(wildcard $(d)/*.cc) -ifdef HOST_UNIX - libfetchers_SOURCES += $(wildcard $(d)/unix/*.cc) -endif # Not just for this library itself, but also for downstream libraries using this library INCLUDE_libfetchers := -I $(d) -ifdef HOST_UNIX - INCLUDE_libfetchers += -I $(d)/unix -endif libfetchers_CXXFLAGS += $(INCLUDE_libutil) $(INCLUDE_libstore) $(INCLUDE_libfetchers) diff --git a/src/libfetchers/unix/mercurial.cc b/src/libfetchers/mercurial.cc similarity index 100% rename from src/libfetchers/unix/mercurial.cc rename to src/libfetchers/mercurial.cc diff --git a/src/libstore/unix/builtins/fetchurl.cc b/src/libstore/builtins/fetchurl.cc similarity index 100% rename from src/libstore/unix/builtins/fetchurl.cc rename to src/libstore/builtins/fetchurl.cc diff --git a/src/libstore/unix/builtins/unpack-channel.cc b/src/libstore/builtins/unpack-channel.cc similarity index 100% rename from src/libstore/unix/builtins/unpack-channel.cc rename to src/libstore/builtins/unpack-channel.cc diff --git a/src/libstore/legacy-ssh-store.hh b/src/libstore/legacy-ssh-store.hh index 6c3c95080..b683ed580 100644 --- a/src/libstore/legacy-ssh-store.hh +++ b/src/libstore/legacy-ssh-store.hh @@ -26,10 +26,14 @@ struct LegacySSHStoreConfig : virtual CommonSSHStoreConfig struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Store { +#ifndef _WIN32 // Hack for getting remote build log output. // Intentionally not in `LegacySSHStoreConfig` so that it doesn't appear in // the documentation - const Setting logFD{this, -1, "log-fd", "file descriptor to which SSH's stderr is connected"}; + const Setting logFD{this, INVALID_DESCRIPTOR, "log-fd", "file descriptor to which SSH's stderr is connected"}; +#else + Descriptor logFD = INVALID_DESCRIPTOR; +#endif struct Connection; diff --git a/src/libstore/unix/local-overlay-store.cc b/src/libstore/local-overlay-store.cc similarity index 100% rename from src/libstore/unix/local-overlay-store.cc rename to src/libstore/local-overlay-store.cc diff --git a/src/libstore/unix/local-overlay-store.hh b/src/libstore/local-overlay-store.hh similarity index 100% rename from src/libstore/unix/local-overlay-store.hh rename to src/libstore/local-overlay-store.hh diff --git a/src/libstore/unix/local-overlay-store.md b/src/libstore/local-overlay-store.md similarity index 100% rename from src/libstore/unix/local-overlay-store.md rename to src/libstore/local-overlay-store.md diff --git a/src/libstore/local.mk b/src/libstore/local.mk index 60174d009..5dc8f3370 100644 --- a/src/libstore/local.mk +++ b/src/libstore/local.mk @@ -6,7 +6,7 @@ libstore_DIR := $(d) libstore_SOURCES := $(wildcard $(d)/*.cc $(d)/builtins/*.cc $(d)/build/*.cc) ifdef HOST_UNIX - libstore_SOURCES += $(wildcard $(d)/unix/*.cc $(d)/unix/builtins/*.cc $(d)/unix/build/*.cc) + libstore_SOURCES += $(wildcard $(d)/unix/*.cc $(d)/unix/build/*.cc) endif ifdef HOST_LINUX libstore_SOURCES += $(wildcard $(d)/linux/*.cc)