Write Makefile code for any 'sources' from the gyp input. These are source files necessary to build the current target. We need to handle shared_intermediate directory source files as a special case by copying them to the intermediate directory and treating them as a
(self, spec, configs, extra_sources)
| 551 | self.WriteLn("LOCAL_ASFLAGS := $(LOCAL_CFLAGS)") |
| 552 | |
| 553 | def WriteSources(self, spec, configs, extra_sources): |
| 554 | """Write Makefile code for any 'sources' from the gyp input. |
| 555 | These are source files necessary to build the current target. |
| 556 | We need to handle shared_intermediate directory source files as |
| 557 | a special case by copying them to the intermediate directory and |
| 558 | treating them as a generated sources. Otherwise the Android build |
| 559 | rules won't pick them up. |
| 560 | |
| 561 | Args: |
| 562 | spec, configs: input from gyp. |
| 563 | extra_sources: Sources generated from Actions or Rules. |
| 564 | """ |
| 565 | sources = filter(make.Compilable, spec.get("sources", [])) |
| 566 | generated_not_sources = [x for x in extra_sources if not make.Compilable(x)] |
| 567 | extra_sources = filter(make.Compilable, extra_sources) |
| 568 | |
| 569 | # Determine and output the C++ extension used by these sources. |
| 570 | # We simply find the first C++ file and use that extension. |
| 571 | all_sources = sources + extra_sources |
| 572 | local_cpp_extension = ".cpp" |
| 573 | for source in all_sources: |
| 574 | (root, ext) = os.path.splitext(source) |
| 575 | if IsCPPExtension(ext): |
| 576 | local_cpp_extension = ext |
| 577 | break |
| 578 | if local_cpp_extension != ".cpp": |
| 579 | self.WriteLn("LOCAL_CPP_EXTENSION := %s" % local_cpp_extension) |
| 580 | |
| 581 | # We need to move any non-generated sources that are coming from the |
| 582 | # shared intermediate directory out of LOCAL_SRC_FILES and put them |
| 583 | # into LOCAL_GENERATED_SOURCES. We also need to move over any C++ files |
| 584 | # that don't match our local_cpp_extension, since Android will only |
| 585 | # generate Makefile rules for a single LOCAL_CPP_EXTENSION. |
| 586 | local_files = [] |
| 587 | for source in sources: |
| 588 | (root, ext) = os.path.splitext(source) |
| 589 | if ( |
| 590 | "$(gyp_shared_intermediate_dir)" in source |
| 591 | or "$(gyp_intermediate_dir)" in source |
| 592 | or (IsCPPExtension(ext) and ext != local_cpp_extension) |
| 593 | ): |
| 594 | extra_sources.append(source) |
| 595 | else: |
| 596 | local_files.append(os.path.normpath(os.path.join(self.path, source))) |
| 597 | |
| 598 | # For any generated source, if it is coming from the shared intermediate |
| 599 | # directory then we add a Make rule to copy them to the local intermediate |
| 600 | # directory first. This is because the Android LOCAL_GENERATED_SOURCES |
| 601 | # must be in the local module intermediate directory for the compile rules |
| 602 | # to work properly. If the file has the wrong C++ extension, then we add |
| 603 | # a rule to copy that to intermediates and use the new version. |
| 604 | final_generated_sources = [] |
| 605 | # If a source file gets copied, we still need to add the original source |
| 606 | # directory as header search path, for GCC searches headers in the |
| 607 | # directory that contains the source file by default. |
| 608 | origin_src_dirs = [] |
| 609 | for source in extra_sources: |
| 610 | local_file = source |
no test coverage detected