| 218 | |
| 219 | # GCC-specific pch generator. |
| 220 | class GccPchGenerator(pch.PchGenerator): |
| 221 | |
| 222 | # Inherit the __init__ method |
| 223 | |
| 224 | def run_pch(self, project, name, prop_set, sources): |
| 225 | # Find the header in sources. Ignore any CPP sources. |
| 226 | header = None |
| 227 | for s in sources: |
| 228 | if type.is_derived(s.type(), 'H'): |
| 229 | header = s |
| 230 | |
| 231 | # Error handling: Base header file name should be the same as the base |
| 232 | # precompiled header name. |
| 233 | header_name = header.name() |
| 234 | header_basename = os.path.basename(header_name).rsplit('.', 1)[0] |
| 235 | if header_basename != name: |
| 236 | location = project.project_module |
| 237 | ###FIXME: |
| 238 | raise Exception() |
| 239 | ### errors.user-error "in" $(location)": pch target name `"$(name)"' should be the same as the base name of header file `"$(header-name)"'" ; |
| 240 | |
| 241 | pch_file = Generator.run(self, project, name, prop_set, [header]) |
| 242 | |
| 243 | # return result of base class and pch-file property as usage-requirements |
| 244 | # FIXME: what about multiple results from generator.run? |
| 245 | return (property_set.create([Property('pch-file', pch_file[0]), |
| 246 | Property('cflags', '-Winvalid-pch')]), |
| 247 | pch_file) |
| 248 | |
| 249 | # Calls the base version specifying source's name as the name of the created |
| 250 | # target. As result, the PCH will be named whatever.hpp.gch, and not |
| 251 | # whatever.gch. |
| 252 | def generated_targets(self, sources, prop_set, project, name = None): |
| 253 | name = sources[0].name() |
| 254 | return Generator.generated_targets(self, sources, |
| 255 | prop_set, project, name) |
| 256 | |
| 257 | # Note: the 'H' source type will catch both '.h' header and '.hpp' header. The |
| 258 | # latter have HPP type, but HPP type is derived from H. The type of compilation |