Run jobserver.start() to build this object's target file.
(self)
| 147 | self._start_deps_unlocked(dirty) |
| 148 | |
| 149 | def _start_self(self): |
| 150 | """Run jobserver.start() to build this object's target file.""" |
| 151 | assert self.lock.owned |
| 152 | t = self.t |
| 153 | sf = self.sf |
| 154 | newstamp = sf.read_stamp() |
| 155 | if (sf.is_generated and |
| 156 | newstamp != state.STAMP_MISSING and |
| 157 | (sf.is_override or state.detect_override(sf.stamp, newstamp))): |
| 158 | state.warn_override(_nice(t)) |
| 159 | if not sf.is_override: |
| 160 | warn('%s - old: %r\n' % (_nice(t), sf.stamp)) |
| 161 | warn('%s - new: %r\n' % (_nice(t), newstamp)) |
| 162 | sf.set_override() |
| 163 | sf.save() |
| 164 | # fall through and treat it the same as a static file |
| 165 | if (os.path.exists(t) and not os.path.isdir(t + '/.') |
| 166 | and (sf.is_override or not sf.is_generated)): |
| 167 | # an existing source file that was not generated by us. |
| 168 | # This step is mentioned by djb in his notes. |
| 169 | # For example, a rule called default.c.do could be used to try |
| 170 | # to produce hello.c, but we don't want that to happen if |
| 171 | # hello.c was created by the end user. |
| 172 | debug2("-- static (%r)\n" % t) |
| 173 | if not sf.is_override: |
| 174 | sf.set_static() |
| 175 | sf.save() |
| 176 | return self._finalize(0) |
| 177 | sf.zap_deps1() |
| 178 | (dodir, dofile, _, basename, ext) = paths.find_do_file(sf) |
| 179 | if not dofile: |
| 180 | if os.path.exists(t): |
| 181 | sf.set_static() |
| 182 | sf.save() |
| 183 | return self._finalize(0) |
| 184 | else: |
| 185 | err('no rule to redo %r\n' % t) |
| 186 | sf.set_failed() |
| 187 | sf.save() |
| 188 | return self._finalize(1) |
| 189 | # There is no good place for us to pre-create a temp file for |
| 190 | # stdout. The target dir might not exist yet, or it might currently |
| 191 | # exist but get wiped by the .do script. Other dirs, like the one |
| 192 | # containing the .do file, might be mounted readonly. We can put it |
| 193 | # in the system temp dir, but then we can't necessarily rename it to |
| 194 | # the target filename because it might cross filesystem boundaries. |
| 195 | # Also, if redo is interrupted, it would leave a temp file lying |
| 196 | # around. To avoid all this, use mkstemp() to create a temp file |
| 197 | # wherever it wants to, and immediately unlink it, but keep a file |
| 198 | # handle open. When the .do script finishes, we can copy the |
| 199 | # content out of that nameless file handle into a file in the same |
| 200 | # dir as the target (which by definition must now exist, if you |
| 201 | # wanted the target to exist). |
| 202 | # |
| 203 | # On the other hand, the $3 temp filename can be hardcoded to be in |
| 204 | # the target directory, even if that directory does not exist. |
| 205 | # It's not *redo*'s job to create that file. The .do file will |
| 206 | # create it, if it wants, and it's the .do file's job to first ensure |
no test coverage detected