From c8fa8a0974e9db3875319baeb472894398e61bfd Mon Sep 17 00:00:00 2001 From: chn Date: Sat, 24 May 2025 18:20:14 +0800 Subject: [PATCH] packages.winjob: remove --- flake/dev.nix | 8 --- packages/default.nix | 1 - packages/winjob/.clangd | 3 -- packages/winjob/.envrc | 1 - packages/winjob/CMakeLists.txt | 36 -------------- packages/winjob/default.nix | 11 ---- packages/winjob/include/winjob/windows.hpp | 8 --- packages/winjob/src/windows.cpp | 58 ---------------------- packages/winjob/src/winjob.cpp | 22 -------- packages/winjob/src/winjobd.cpp | 31 ------------ 10 files changed, 179 deletions(-) delete mode 100644 packages/winjob/.clangd delete mode 100644 packages/winjob/.envrc delete mode 100644 packages/winjob/CMakeLists.txt delete mode 100644 packages/winjob/default.nix delete mode 100644 packages/winjob/include/winjob/windows.hpp delete mode 100644 packages/winjob/src/windows.cpp delete mode 100644 packages/winjob/src/winjob.cpp delete mode 100644 packages/winjob/src/winjobd.cpp diff --git a/flake/dev.nix b/flake/dev.nix index 0f715511..584ee73e 100644 --- a/flake/dev.nix +++ b/flake/dev.nix @@ -34,14 +34,6 @@ packages = [ pkgs.clang-tools_18 ]; CMAKE_EXPORT_COMPILE_COMMANDS = "1"; }; - winjob = - let inherit (pkgs) clang-tools_18; in let inherit (inputs.self.packages.x86_64-w64-mingw32) pkgs winjob; - in pkgs.mkShell.override { stdenv = pkgs.gcc14Stdenv; } - { - inputsFrom = [ winjob ]; - packages = [ clang-tools_18 ]; - CMAKE_EXPORT_COMPILE_COMMANDS = "1"; - }; mirism = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; } { inputsFrom = [ pkgs.localPackages.mirism ]; diff --git a/packages/default.nix b/packages/default.nix index 1333f900..8aac7066 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -94,7 +94,6 @@ inputs: rec stdenv = inputs.pkgs.clang18Stdenv; }; chn-bsub = inputs.pkgs.callPackage ./chn-bsub { inherit biu; }; - winjob = inputs.pkgs.callPackage ./winjob { stdenv = inputs.pkgs.gcc14Stdenv; }; sockpp = inputs.pkgs.callPackage ./sockpp.nix { src = inputs.topInputs.sockpp; }; py4vasp = inputs.pkgs.python3Packages.callPackage ./py4vasp.nix { src = inputs.topInputs.py4vasp; }; pocketfft = inputs.pkgs.callPackage ./pocketfft.nix { src = inputs.topInputs.pocketfft; }; diff --git a/packages/winjob/.clangd b/packages/winjob/.clangd deleted file mode 100644 index 31d7203a..00000000 --- a/packages/winjob/.clangd +++ /dev/null @@ -1,3 +0,0 @@ -CompileFlags: - Add: [ -Wall, -Wextra, -std=c++26 ] - Compiler: g++ diff --git a/packages/winjob/.envrc b/packages/winjob/.envrc deleted file mode 100644 index fdd24a78..00000000 --- a/packages/winjob/.envrc +++ /dev/null @@ -1 +0,0 @@ -use flake .#winjob diff --git a/packages/winjob/CMakeLists.txt b/packages/winjob/CMakeLists.txt deleted file mode 100644 index 81a446e2..00000000 --- a/packages/winjob/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -# cmake_minimum_required(VERSION 3.30) -cmake_minimum_required(VERSION 3.29) -project(winjob VERSION 0.0.0 LANGUAGES CXX) -enable_testing() -include(GNUInstallDirs) - -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message("Setting build type to 'Release' as none was specified.") - set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") -endif() - -set(WINJOB_VERSION "unknown" CACHE STRING "Version of the winjob") - -find_package(Boost REQUIRED COMPONENTS headers filesystem) - -add_executable(winjob src/winjob.cpp src/windows.cpp) -# target_compile_features(winjob PRIVATE cxx_std_26) -target_compile_options(winjob PRIVATE "-std=c++26") -target_include_directories(winjob PRIVATE ${PROJECT_SOURCE_DIR}/include) -target_link_libraries(winjob PRIVATE Boost::headers Boost::filesystem ws2_32 wsock32) -target_compile_definitions(winjob PRIVATE winjob_VERSION="${winjob_VERSION}") - -add_executable(winjobd src/winjobd.cpp) -# target_compile_features(winjob PRIVATE cxx_std_26) -target_compile_options(winjobd PRIVATE "-std=c++26") -target_include_directories(winjobd PRIVATE ${PROJECT_SOURCE_DIR}/include) -target_link_libraries(winjobd PRIVATE Boost::headers Boost::filesystem ws2_32 wsock32) -target_compile_definitions(winjobd PRIVATE winjob_VERSION="${winjob_VERSION}") - -install(TARGETS winjob RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(TARGETS winjobd RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - -get_property(ImportedTargets DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS) -message("Imported targets: ${ImportedTargets}") -message("List of compile features: ${CMAKE_CXX_COMPILE_FEATURES}") diff --git a/packages/winjob/default.nix b/packages/winjob/default.nix deleted file mode 100644 index a511a805..00000000 --- a/packages/winjob/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ - stdenv, cmake, pkg-config, version ? null, lib, - boost -}: stdenv.mkDerivation -{ - name = "winjob"; - src = ./.; - buildInputs = [ boost ]; - nativeBuildInputs = [ cmake pkg-config ]; - cmakeFlags = lib.optionals (version != null) [ "-DWINJOB_VERSION=${version}" ]; -} diff --git a/packages/winjob/include/winjob/windows.hpp b/packages/winjob/include/winjob/windows.hpp deleted file mode 100644 index ccded104..00000000 --- a/packages/winjob/include/winjob/windows.hpp +++ /dev/null @@ -1,8 +0,0 @@ -# include -# include -# include - -namespace winjob -{ - std::optional> get_owner(const std::string& file_name); -} diff --git a/packages/winjob/src/windows.cpp b/packages/winjob/src/windows.cpp deleted file mode 100644 index 72724485..00000000 --- a/packages/winjob/src/windows.cpp +++ /dev/null @@ -1,58 +0,0 @@ -# include -# include -# include -# include -# include - -namespace winjob -{ - std::optional> get_owner(const std::string& file_name) - { - DWORD dwRtnCode = 0; - PSID pSidOwner = NULL; - BOOL bRtnBool = TRUE; - LPTSTR AcctName = NULL; - LPTSTR DomainName = NULL; - DWORD dwAcctName = 1, dwDomainName = 1; - SID_NAME_USE eUse = SidTypeUnknown; - HANDLE hFile; - PSECURITY_DESCRIPTOR pSD = NULL; - - // Get the handle of the file object. - hFile = CreateFile - (file_name.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - - // Check GetLastError for CreateFile error code. - if (hFile == INVALID_HANDLE_VALUE) return {}; - - // Get the owner SID of the file. - dwRtnCode = GetSecurityInfo(hFile, SE_FILE_OBJECT, OWNER_SECURITY_INFORMATION, &pSidOwner, NULL, NULL, NULL, &pSD); - - // Check GetLastError for GetSecurityInfo error condition. - if (dwRtnCode != ERROR_SUCCESS) return {}; - - // First call to LookupAccountSid to get the buffer sizes. - bRtnBool = LookupAccountSid - (NULL, pSidOwner, AcctName, (LPDWORD)&dwAcctName, DomainName, (LPDWORD)&dwDomainName, &eUse); - - // Reallocate memory for the buffers. - AcctName = (LPTSTR)GlobalAlloc(GMEM_FIXED, dwAcctName * sizeof(wchar_t)); - - // Check GetLastError for GlobalAlloc error condition. - if (AcctName == NULL) return {}; - - DomainName = (LPTSTR)GlobalAlloc(GMEM_FIXED, dwDomainName * sizeof(wchar_t)); - - // Check GetLastError for GlobalAlloc error condition. - if (DomainName == NULL) return {}; - - // Second call to LookupAccountSid to get the account name. - bRtnBool = LookupAccountSid - (NULL, pSidOwner, AcctName, (LPDWORD)&dwAcctName, DomainName, (LPDWORD)&dwDomainName, &eUse); - - // Check GetLastError for LookupAccountSid error condition. - if (bRtnBool == FALSE) return {}; - - return std::make_pair(std::string(DomainName), std::string(AcctName)); - } -} diff --git a/packages/winjob/src/winjob.cpp b/packages/winjob/src/winjob.cpp deleted file mode 100644 index 9a0da24c..00000000 --- a/packages/winjob/src/winjob.cpp +++ /dev/null @@ -1,22 +0,0 @@ -# include -# include - -int main() -{ - boost::asio::io_context io_context; - boost::asio::local::stream_protocol::endpoint ep("winjobd.sock"); - // send a message to the server - boost::asio::local::stream_protocol::socket socket(io_context); - socket.connect(ep); - std::string message; - std::getline(std::cin, message); - boost::asio::write(socket, boost::asio::buffer(message)); - // receive a message from the server - boost::asio::streambuf buf; - boost::asio::read_until(socket, buf, '\n'); - std::istream is(&buf); - std::string line; - std::getline(is, line); - std::cout << "Received: " << line << '\n'; - return 0; -} \ No newline at end of file diff --git a/packages/winjob/src/winjobd.cpp b/packages/winjob/src/winjobd.cpp deleted file mode 100644 index b51fbb24..00000000 --- a/packages/winjob/src/winjobd.cpp +++ /dev/null @@ -1,31 +0,0 @@ -# include -# include - -int main() -{ - boost::asio::io_context io_context; - boost::asio::local::stream_protocol::endpoint ep("winjobd.sock"); - boost::asio::local::stream_protocol::acceptor acceptor(io_context, ep, false); - std::function func = - [&](const boost::system::error_code& ec, boost::asio::local::stream_protocol::socket socket) - { - if (ec) - { - std::cerr << "Failed to accept connection\n"; - return; - } - std::cout << "Accepted connection\n"; - boost::asio::streambuf buf; - boost::asio::read_until(socket, buf, '\n'); - std::istream is(&buf); - std::string line; - std::getline(is, line); - std::cout << "Received: " << line << '\n'; - // write a message to the client - std::string message = "thanks for the message\n"; - boost::asio::write(socket, boost::asio::buffer(message)); - acceptor.async_accept(func); - }; - acceptor.async_accept(func); - io_context.run(); -}