Add more context to quit_if_file_exists in configure.py

Currently, having a dirty `obj/` directory is sufficient to abort CI
tests. This results in errors like the following:

```
...
== end clock drift check ==
sccache: Starting the server...
configure: error: Existing 'config.toml' detected.
== clock drift check ==
...
```

This is subtle and doesn't give a good idea as to what causes the issue.
With this patch, the error becomes more prominent and a resolution is
suggested:

```
== end clock drift check ==
sccache: Starting the server...

configure: ERROR: Existing 'config.toml' detected. Exiting
Is objdir '/home/tmgross/projects/rust/obj' clean?

== clock drift check ==
```
This commit is contained in:
Trevor Gross
2023-07-01 22:02:55 -04:00
parent 7a5d2d0138
commit 8a2022b108
4 changed files with 15 additions and 3 deletions

View File

@@ -180,7 +180,7 @@ def p(msg):
def err(msg):
print("configure: error: " + msg)
print("\nconfigure: ERROR: " + msg + "\n")
sys.exit(1)
def is_value_list(key):
@@ -544,7 +544,14 @@ def write_config_toml(writer, section_order, targets, sections):
def quit_if_file_exists(file):
if os.path.isfile(file):
err("Existing '" + file + "' detected.")
msg = "Existing '{}' detected. Exiting".format(file)
# If the output object directory isn't empty, we can get these errors
host_objdir = os.environ.get("OBJDIR_ON_HOST")
if host_objdir is not None:
msg += "\nIs objdir '{}' clean?".format(host_objdir)
err(msg)
if __name__ == "__main__":
# If 'config.toml' already exists, exit the script at this point