win-build: Fixes a kconfig incompatibility for Windows

In windows systems the rename() function fails if the new name
of the original file corresponds to a file that already exists.

The fix removes the new file before renaming the original one.

Jira: ZEP-980

Change-Id: Ib3a43db86c0dd3fabb592f53ea7619eb5738bb65
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@intel.com>
This commit is contained in:
Juan Manuel Cruz 2016-11-15 15:35:07 -06:00 committed by Anas Nashif
commit 7f1c76f2bf
2 changed files with 6 additions and 0 deletions

View file

@ -824,7 +824,9 @@ next:
if (*tmpname) {
strcat(dirname, basename);
strcat(dirname, ".old");
remove(dirname);
rename(newname, dirname);
remove(newname);
if (rename(tmpname, newname))
return 1;
}
@ -1004,11 +1006,13 @@ int conf_write_autoconf(void)
name = getenv("KCONFIG_AUTOHEADER");
if (!name)
name = "include/generated/autoconf.h";
remove(name);
if (rename(".tmpconfig.h", name))
return 1;
name = getenv("KCONFIG_TRISTATE");
if (!name)
name = "include/config/tristate.conf";
remove(name);
if (rename(".tmpconfig_tristate", name))
return 1;
name = conf_get_autoconfig_name();
@ -1016,6 +1020,7 @@ int conf_write_autoconf(void)
* This must be the last step, kbuild has a dependency on auto.conf
* and this marks the successful completion of the previous steps.
*/
remove(name);
if (rename(".tmpconfig", name))
return 1;

View file

@ -72,6 +72,7 @@ int file_write_dep(const char *name)
fprintf(out, "\n$(deps_config): ;\n");
fclose(out);
remove(name);
rename("..config.tmp", name);
return 0;
}