Skip to content

Commit

Permalink
Merge pull request #10824 from nix-windows/misc-windows-fixes
Browse files Browse the repository at this point in the history
Misc Windows fixes
  • Loading branch information
Ericson2314 authored Jun 2, 2024
2 parents 802b4e4 + e0b1595 commit 8e9fc28
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 17 deletions.
12 changes: 6 additions & 6 deletions maintainers/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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$''
Expand Down Expand Up @@ -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$''
Expand Down
27 changes: 24 additions & 3 deletions src/libfetchers/unix/git.cc → src/libfetchers/git.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
#include <regex>
#include <string.h>
#include <sys/time.h>
#include <sys/wait.h>

#ifndef _WIN32
# include <sys/wait.h>
#endif

using namespace std::string_literals;

Expand All @@ -40,13 +43,17 @@ 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;
times[1].tv_sec = 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)
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 0 additions & 6 deletions src/libfetchers/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 5 additions & 1 deletion src/libstore/legacy-ssh-store.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> logFD{this, -1, "log-fd", "file descriptor to which SSH's stderr is connected"};
const Setting<int> logFD{this, INVALID_DESCRIPTOR, "log-fd", "file descriptor to which SSH's stderr is connected"};
#else
Descriptor logFD = INVALID_DESCRIPTOR;
#endif

struct Connection;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/libstore/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8e9fc28

Please sign in to comment.