summaryrefslogtreecommitdiff
path: root/src/rebuild.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebuild.cc')
-rw-r--r--src/rebuild.cc114
1 files changed, 1 insertions, 113 deletions
diff --git a/src/rebuild.cc b/src/rebuild.cc
index 4b0c8e5..cfbe790 100644
--- a/src/rebuild.cc
+++ b/src/rebuild.cc
@@ -143,92 +143,6 @@ bool contains(const std::vector<Source>& sources, const std::string& file)
}
}
-#ifdef _WIN32
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-// From: http://www.catch22.net/tuts/win32/self-deleting-executables
-void DeleteSelf()
-{
-//#ifdef Windows NT/2000
-#if 1
- char buf[MAX_PATH];
- HMODULE module;
-
- module = GetModuleHandle(0);
- GetModuleFileName(module, buf, MAX_PATH);
- CloseHandle((HANDLE)4);
-
- __asm
- {
- lea eax, buf
- push 0
- push 0
- push eax
- push ExitProcess
- push module
- push DeleteFile
- push UnmapViewOfFile
- ret
- }
-#endif
-//#elif Windows 95/98
-#if 0
- char buf[MAX_PATH];
- HMODULE module;
-
- module = GetModuleHandle(0);
- GetModuleFileName(module, buf, MAX_PATH);
-
- __asm
- {
- lea eax, buf
- push 0
- push 0
- push eax
- push ExitProcess
- push module
- push DeleteFile
- push FreeLibrary
- ret
- }
-#endif
-//endif
-}
-#endif // _WIN32
-
-void copyAndRelaunch(bool dirty_tasks, bool delete_me,
- int argc, char* argv[],
- const std::string& copy_src,
- const std::string& copy_tar,
- const std::string& compilation_name)
-{
-#ifdef _WIN32
- if(dirty_tasks && !delete_me)
- {
- CopyFile(copy_src.data(), copy_tar.data(), false);
- SetFileAttributes(copy_tar.data(), FILE_ATTRIBUTE_HIDDEN);
- auto t = std::filesystem::last_write_time(copy_src);
- std::filesystem::last_write_time(copy_tar, t);
-
- STARTUPINFO si{};
- PROCESS_INFORMATION pi{};
- si.cb = sizeof(pi);
- std::string args = copy_tar;
- for(int i = 1; i < argc; ++i)
- {
- args += " ";
- args += argv[i];
- }
- args += " --name ";
- args += compilation_name;
-
- CreateProcess(nullptr, args.data(), 0,0,0,0,0,0,&si,&pi);
- exit(0);
- }
-#endif // _WIN32
-}
-
bool recompileCheck(const Settings& global_settings, int argc, char* argv[],
bool relaunch_allowed)
{
@@ -250,8 +164,6 @@ bool recompileCheck(const Settings& global_settings, int argc, char* argv[],
argv0_file = std::filesystem::current_path() / argv0_file;
}
- bool delete_me = settings_file.string() != argv0_file.string();
-
BuildConfiguration config;
config.type = TargetType::Executable;
@@ -335,7 +247,7 @@ bool recompileCheck(const Settings& global_settings, int argc, char* argv[],
}
}
- auto tasks = taskFactory({config}, settings, {});
+ auto tasks = taskFactory({config}, settings, {}, true);
for(auto task : tasks)
{
@@ -359,9 +271,6 @@ bool recompileCheck(const Settings& global_settings, int argc, char* argv[],
auto dirty_tasks = build(settings, "ctor", tasks, true); // dryrun
- copyAndRelaunch(dirty_tasks, delete_me, argc, argv,
- settings.name/*argv[0]*/, "ctor-rebuild-tmp.exe", settings.name);
-
bool was_rebuilt{false};
if(dirty_tasks)
{
@@ -369,10 +278,6 @@ bool recompileCheck(const Settings& global_settings, int argc, char* argv[],
auto ret = build(settings, "ctor", tasks); // run for real
if(ret != 0)
{
- if(delete_me)
- {
- DeleteSelf();
- }
return ret;
}
was_rebuilt = true;
@@ -380,19 +285,12 @@ bool recompileCheck(const Settings& global_settings, int argc, char* argv[],
if(reconfigure)
{
- copyAndRelaunch(true, delete_me, argc, argv,
- settings.name,
- "ctor-reconfigure-tmp.exe", settings.name);
std::vector<std::string> args;
args.push_back("reconfigure");
if(!relaunch_allowed)
{
args.push_back("--no-rerun");
}
- if(delete_me)
- {
- args.push_back("--name " + settings.name);
- }
for(int i = 1; i < argc; ++i)
{
args.push_back(argv[i]);
@@ -400,18 +298,8 @@ bool recompileCheck(const Settings& global_settings, int argc, char* argv[],
auto ret = execute(settings.name, args, {});
//if(ret != 0)
{
- if(delete_me)
- {
- DeleteSelf();
- }
exit(ret);
}
-
- }
-
- if(delete_me)
- {
- DeleteSelf();
}
return dirty_tasks;