| # Copyright 2021 The Cobalt Authors. All Rights Reserved. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| import("//starboard/build/config/os_definitions.gni") |
| |
| _elf_loader_sources = [ |
| "dynamic_section.cc", |
| "dynamic_section.h", |
| "elf_hash_table.cc", |
| "elf_hash_table.h", |
| "elf_header.cc", |
| "elf_header.h", |
| "elf_loader.cc", |
| "elf_loader.h", |
| "exported_symbols.cc", |
| "file.h", |
| "file_impl.cc", |
| "file_impl.h", |
| "gnu_hash_table.cc", |
| "gnu_hash_table.h", |
| "lz4_file_impl.cc", |
| "lz4_file_impl.h", |
| "program_table.cc", |
| "program_table.h", |
| "relocations.cc", |
| "relocations.h", |
| ] |
| |
| config("elf_loader_config") { |
| include_dirs = [ |
| "src/include", |
| "src/src", |
| ] |
| } |
| |
| static_library("elf_loader") { |
| sources = _elf_loader_sources + [ |
| "elf_loader_impl.cc", |
| "elf_loader_impl.h", |
| ] |
| |
| configs += [ ":elf_loader_config" ] |
| |
| deps = [ |
| ":constants", |
| ":evergreen_config", |
| ":evergreen_info", |
| "//starboard:starboard_group", |
| "//starboard/common", |
| "//third_party/lz4_lib:lz4", |
| ] |
| } |
| |
| if (sb_is_evergreen_compatible) { |
| static_library("elf_loader_sys") { |
| # System loader based on dlopen/dlsym. |
| # Should be used only for debugging/troubleshooting. |
| sources = _elf_loader_sources + [ |
| "elf_loader_impl.h", |
| "elf_loader_sys_impl.cc", |
| "elf_loader_sys_impl.h", |
| ] |
| |
| configs += [ ":elf_loader_config" ] |
| |
| deps = [ |
| ":constants", |
| ":evergreen_config", |
| ":evergreen_info", |
| "//starboard:starboard_group", |
| "//starboard/common", |
| ] |
| |
| if (sb_is_evergreen_compatible) { |
| deps += [ "//third_party/crashpad/wrapper" ] |
| } else { |
| deps += [ "//third_party/crashpad/wrapper:wrapper_stub" ] |
| } |
| } |
| } |
| |
| # TODO: b/309493306 - Stop building evergreen targets for all non-evergreen platforms. |
| if (current_toolchain == starboard_toolchain && !is_host_win) { |
| target(starboard_level_final_executable_type, "elf_loader_sandbox") { |
| data_deps = [ "//third_party/icu:icudata" ] |
| if (cobalt_font_package == "empty") { |
| data_deps += [ "//cobalt/content/fonts:copy_font_data" ] |
| } else { |
| data_deps += [ |
| "//cobalt/content/fonts:copy_fonts", |
| "//cobalt/content/fonts:fonts_xml", |
| ] |
| } |
| |
| sources = [ "elf_loader_sandbox.cc" ] |
| configs += [ ":elf_loader_config" ] |
| |
| deps = [ |
| ":constants", |
| ":elf_loader", |
| ":evergreen_info", |
| ":sabi_string", |
| "//cobalt/content/fonts:copy_font_data", |
| "//starboard:starboard_group", |
| ] |
| |
| if (!sb_is_evergreen_compatible) { |
| deps += [ "//third_party/crashpad/wrapper:wrapper_stub" ] |
| } |
| if (sb_is_evergreen_compatible && sb_evergreen_compatible_package) { |
| deps += [ "//starboard/loader_app:copy_crashpad_handler_named_as_so" ] |
| } |
| } |
| } |
| |
| if (sb_is_evergreen_compatible) { |
| target(final_executable_type, "elf_loader_sys_sandbox") { |
| # To properly function the system loader requires the starboard |
| # symbols to be exported from the binary. |
| # To allow symbols to be exported remove the '-fvisibility=hidden' flag |
| # from your BUILD.gn. For Linux this would be: |
| # starboard/linux/shared/platform_configuration/BUILD.gn |
| # Example run: |
| # export LD_LIBRARY_PATH=. |
| # ./elf_loader_sys_sandbox --evergreen_library=app/cobalt/lib/libcobalt.so --evergreen_content=app/cobalt/content |
| sources = [ "elf_loader_sandbox.cc" ] |
| configs += [ ":elf_loader_config" ] |
| |
| starboard_syms_path = |
| rebase_path("//starboard/starboard.syms", root_build_dir) |
| ldflags = [ |
| "-Wl,--dynamic-list=$starboard_syms_path", |
| "-ldl", |
| ] |
| |
| deps = [ |
| ":constants", |
| ":elf_loader_sys", |
| ":evergreen_info", |
| ":sabi_string", |
| "//starboard:starboard_group", |
| ] |
| |
| if (!sb_is_evergreen_compatible) { |
| deps += [ "//third_party/crashpad/wrapper:wrapper_stub" ] |
| } |
| } |
| } |
| |
| # TODO: b/309493306 - Stop building evergreen targets for all non-evergreen platforms. |
| if (!is_host_win) { |
| target(gtest_target_type, "elf_loader_test") { |
| testonly = true |
| sources = [ "//starboard/common/test_main.cc" ] |
| deps = [ |
| "//starboard:starboard_group", |
| "//testing/gmock", |
| "//testing/gtest", |
| ] |
| |
| if (target_cpu == "x86" || target_cpu == "x64" || target_cpu == "arm" || |
| target_cpu == "arm64") { |
| sources += [ |
| "dynamic_section_test.cc", |
| "elf_header_test.cc", |
| "elf_loader_test.cc", |
| "lz4_file_impl_test.cc", |
| "program_table_test.cc", |
| "relocations_test.cc", |
| ] |
| deps += [ |
| ":copy_elf_loader_testdata", |
| ":elf_loader", |
| ] |
| |
| data_deps = [ ":copy_elf_loader_testdata" ] |
| } |
| } |
| } |
| |
| copy("copy_elf_loader_testdata") { |
| install_content = true |
| sources = [ |
| "testdata/compressed.lz4", |
| "testdata/compressed_no_content_size.lz4", |
| "testdata/uncompressed", |
| ] |
| subdir = "starboard/elf_loader" |
| outputs = [ "$sb_static_contents_output_data_dir/test/$subdir/{{source_target_relative}}" ] |
| } |
| |
| static_library("constants") { |
| sources = [ |
| "elf_loader_constants.cc", |
| "elf_loader_constants.h", |
| ] |
| deps = [ "//starboard:starboard_headers_only" ] |
| } |
| |
| static_library("evergreen_info") { |
| sources = [ |
| "evergreen_info.cc", |
| "evergreen_info.h", |
| ] |
| |
| public_deps = [ "//starboard/common" ] |
| } |
| |
| static_library("evergreen_config") { |
| sources = [ |
| "evergreen_config.cc", |
| "evergreen_config.h", |
| ] |
| |
| public_deps = [ "//starboard/common" ] |
| } |
| |
| static_library("sabi_string") { |
| sources = [ |
| "sabi_string.cc", |
| "sabi_string.h", |
| ] |
| |
| deps = [ "//starboard/common" ] |
| } |