Compile one or more dispatch-able sources and generates object files, also generates abstract C config headers and macros that used later for the final runtime dispatching process. The mechanism behind it is to takes each source file that specified in 'sourc
(self, sources, src_dir=None, ccompiler=None, **kwargs)
| 2267 | return self.parse_dispatch_names |
| 2268 | |
| 2269 | def try_dispatch(self, sources, src_dir=None, ccompiler=None, **kwargs): |
| 2270 | """ |
| 2271 | Compile one or more dispatch-able sources and generates object files, |
| 2272 | also generates abstract C config headers and macros that |
| 2273 | used later for the final runtime dispatching process. |
| 2274 | |
| 2275 | The mechanism behind it is to takes each source file that specified |
| 2276 | in 'sources' and branching it into several files depend on |
| 2277 | special configuration statements that must be declared in the |
| 2278 | top of each source which contains targeted CPU features, |
| 2279 | then it compiles every branched source with the proper compiler flags. |
| 2280 | |
| 2281 | Parameters |
| 2282 | ---------- |
| 2283 | sources : list |
| 2284 | Must be a list of dispatch-able sources file paths, |
| 2285 | and configuration statements must be declared inside |
| 2286 | each file. |
| 2287 | |
| 2288 | src_dir : str |
| 2289 | Path of parent directory for the generated headers and wrapped sources. |
| 2290 | If None(default) the files will generated in-place. |
| 2291 | |
| 2292 | ccompiler : CCompiler |
| 2293 | Distutils `CCompiler` instance to be used for compilation. |
| 2294 | If None (default), the provided instance during the initialization |
| 2295 | will be used instead. |
| 2296 | |
| 2297 | **kwargs : any |
| 2298 | Arguments to pass on to the `CCompiler.compile()` |
| 2299 | |
| 2300 | Returns |
| 2301 | ------- |
| 2302 | list : generated object files |
| 2303 | |
| 2304 | Raises |
| 2305 | ------ |
| 2306 | CompileError |
| 2307 | Raises by `CCompiler.compile()` on compiling failure. |
| 2308 | DistutilsError |
| 2309 | Some errors during checking the sanity of configuration statements. |
| 2310 | |
| 2311 | See Also |
| 2312 | -------- |
| 2313 | parse_targets : |
| 2314 | Parsing the configuration statements of dispatch-able sources. |
| 2315 | """ |
| 2316 | to_compile = {} |
| 2317 | baseline_flags = self.cpu_baseline_flags() |
| 2318 | include_dirs = kwargs.setdefault("include_dirs", []) |
| 2319 | |
| 2320 | for src in sources: |
| 2321 | output_dir = os.path.dirname(src) |
| 2322 | if src_dir: |
| 2323 | if not output_dir.startswith(src_dir): |
| 2324 | output_dir = os.path.join(src_dir, output_dir) |
| 2325 | if output_dir not in include_dirs: |
| 2326 | # To allow including the generated config header(*.dispatch.h) |