prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  case.build --clean-build will remove the CASEDIR contents if EXEDIR points to the CASEDIR
  I'm reporting this from @dmleung. He setup some cases where EXEDIR was set to be the same as CASEDIR (so NOT a bld subdirectory of the CASEDIR).  If he then runs "./case.build --clean-build" it then erases the contents of the CASEDIR. Outside of that it actually functions fine, but if you clean your build it will cause problems. Note, that he did this with older cime versions and it seemed to work OK, but with cime6.0.45 it will remove the case directory contents.
  
  The important thing to note is that this is something you should NOT do! So we can either close this as a WONTFIX as a degenerate case that you shouldn't do. Or a simple thing to do would be to add a simple check that EXEDIR should not be the same as CASEDIR, or there should be an error reported.
  
  </issue>
  <code>
  [start of CIME/XML/env_build.py]
  1 """
  2 Interface to the env_build.xml file.  This class inherits from EnvBase
  3 """
  4 from CIME.XML.standard_module_setup import *
  5 
  6 from CIME import utils
  7 from CIME.XML.env_base import EnvBase
  8 
  9 logger = logging.getLogger(__name__)
  10 
  11 
  12 class EnvBuild(EnvBase):
  13     # pylint: disable=unused-argument
  14     def __init__(
  15         self, case_root=None, infile="env_build.xml", components=None, read_only=False
  16     ):
  17         """
  18         initialize an object interface to file env_build.xml in the case directory
  19         """
  20         schema = os.path.join(utils.get_schema_path(), "env_entry_id.xsd")
  21         EnvBase.__init__(self, case_root, infile, schema=schema, read_only=read_only)
  22
  [end of CIME/XML/env_build.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/CIME/XML/env_build.py b/CIME/XML/env_build.py
  --- a/CIME/XML/env_build.py
  +++ b/CIME/XML/env_build.py
  @@ -18,4 +18,19 @@
           initialize an object interface to file env_build.xml in the case directory
           """
           schema = os.path.join(utils.get_schema_path(), "env_entry_id.xsd")
  +        self._caseroot = case_root
           EnvBase.__init__(self, case_root, infile, schema=schema, read_only=read_only)
  +
  +    def set_value(self, vid, value, subgroup=None, ignore_type=False):
  +        """
  +        Set the value of an entry-id field to value
  +        Returns the value or None if not found
  +        subgroup is ignored in the general routine and applied in specific methods
  +        """
  +        # Do not allow any of these to be the same as CASEROOT
  +        if vid in ("EXEROOT", "OBJDIR", "LIBROOT"):
  +            utils.expect(value != self._caseroot, f"Cannot set {vid} to CASEROOT")
  +
  +        return super(EnvBuild, self).set_value(
  +            vid, value, subgroup=subgroup, ignore_type=ignore_type
  +        )
  
verification_info: {"golden_diff": "diff --git a/CIME/XML/env_build.py b/CIME/XML/env_build.py\n--- a/CIME/XML/env_build.py\n+++ b/CIME/XML/env_build.py\n@@ -18,4 +18,19 @@\n         initialize an object interface to file env_build.xml in the case directory\n         \"\"\"\n         schema = os.path.join(utils.get_schema_path(), \"env_entry_id.xsd\")\n+        self._caseroot = case_root\n         EnvBase.__init__(self, case_root, infile, schema=schema, read_only=read_only)\n+\n+    def set_value(self, vid, value, subgroup=None, ignore_type=False):\n+        \"\"\"\n+        Set the value of an entry-id field to value\n+        Returns the value or None if not found\n+        subgroup is ignored in the general routine and applied in specific methods\n+        \"\"\"\n+        # Do not allow any of these to be the same as CASEROOT\n+        if vid in (\"EXEROOT\", \"OBJDIR\", \"LIBROOT\"):\n+            utils.expect(value != self._caseroot, f\"Cannot set {vid} to CASEROOT\")\n+\n+        return super(EnvBuild, self).set_value(\n+            vid, value, subgroup=subgroup, ignore_type=ignore_type\n+        )\n", "issue": "case.build --clean-build will remove the CASEDIR contents if EXEDIR points to the CASEDIR\nI'm reporting this from @dmleung. He setup some cases where EXEDIR was set to be the same as CASEDIR (so NOT a bld subdirectory of the CASEDIR).  If he then runs \"./case.build --clean-build\" it then erases the contents of the CASEDIR. Outside of that it actually functions fine, but if you clean your build it will cause problems. Note, that he did this with older cime versions and it seemed to work OK, but with cime6.0.45 it will remove the case directory contents.\r\n\r\nThe important thing to note is that this is something you should NOT do! So we can either close this as a WONTFIX as a degenerate case that you shouldn't do. Or a simple thing to do would be to add a simple check that EXEDIR should not be the same as CASEDIR, or there should be an error reported.\n", "before_files": [{"content": "\"\"\"\nInterface to the env_build.xml file.  This class inherits from EnvBase\n\"\"\"\nfrom CIME.XML.standard_module_setup import *\n\nfrom CIME import utils\nfrom CIME.XML.env_base import EnvBase\n\nlogger = logging.getLogger(__name__)\n\n\nclass EnvBuild(EnvBase):\n    # pylint: disable=unused-argument\n    def __init__(\n        self, case_root=None, infile=\"env_build.xml\", components=None, read_only=False\n    ):\n        \"\"\"\n        initialize an object interface to file env_build.xml in the case directory\n        \"\"\"\n        schema = os.path.join(utils.get_schema_path(), \"env_entry_id.xsd\")\n        EnvBase.__init__(self, case_root, infile, schema=schema, read_only=read_only)\n", "path": "CIME/XML/env_build.py"}]}