Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion build/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,18 @@ function(extract_sources sources_file)
set(executorch_root ${CMAKE_CURRENT_SOURCE_DIR})
endif()

if(ANDROID_ABI)
if("${ANDROID_ABI}" STREQUAL "arm64-v8a")
set(target_platforms_arg "--target-platforms=shim//:android-arm64")
else()
message(FATAL_ERROR "Unsupported ANDROID_ABI setting ${ANDROID_ABI}. Please add it here!")
endif()
endif()
execute_process(
COMMAND
${PYTHON_EXECUTABLE} ${executorch_root}/build/extract_sources.py
--config=${executorch_root}/build/cmake_deps.toml --out=${sources_file}
--buck2=${BUCK2}
--buck2=${BUCK2} ${target_platforms_arg}
OUTPUT_VARIABLE gen_srcs_output
ERROR_VARIABLE gen_srcs_error
RESULT_VARIABLE gen_srcs_exit_code
Expand Down
24 changes: 19 additions & 5 deletions build/extract_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import re

from enum import Enum
from typing import Any, Optional, Sequence
from typing import Any, List, Optional, Sequence

from buck_util import Buck2Runner

Expand Down Expand Up @@ -96,7 +96,12 @@ def __init__(
else:
self._config[k] = v

def get_sources(self, graph: "Graph", runner: Buck2Runner) -> frozenset[str]:
def get_sources(
self, graph: "Graph", runner: Buck2Runner, buck_args: Optional[List[str]]
) -> frozenset[str]:
if buck_args is None:
buck_args = []

if self._state == Target._InitState.READY:
return self._sources
# Detect cycles.
Expand All @@ -113,7 +118,7 @@ def get_sources(self, graph: "Graph", runner: Buck2Runner) -> frozenset[str]:
)

# Get the complete list of source files that this target depends on.
sources: set[str] = set(runner.run(["cquery", query]))
sources: set[str] = set(runner.run(["cquery", query] + buck_args))

# Keep entries that match all of the filters.
filters = [re.compile(p) for p in self._config.get("filters", [])]
Expand All @@ -128,7 +133,9 @@ def get_sources(self, graph: "Graph", runner: Buck2Runner) -> frozenset[str]:
# its deps. Remove entries that are already covered by the transitive
# set of dependencies.
for dep in self._config.get("deps", []):
sources.difference_update(graph.by_name[dep].get_sources(graph, runner))
sources.difference_update(
graph.by_name[dep].get_sources(graph, runner, buck_args)
)

self._sources = frozenset(sources)
self._state = Target._InitState.READY
Expand Down Expand Up @@ -173,6 +180,9 @@ def parse_args() -> argparse.Namespace:
metavar="file",
help="Path to the file to generate.",
)
parser.add_argument(
"--target-platforms", help="--target-platforms to pass to buck cquery, if any."
)
return parser.parse_args()


Expand All @@ -199,8 +209,12 @@ def main():
# Run the queries and get the lists of source files.
target_to_srcs: dict[str, list[str]] = {}
runner: Buck2Runner = Buck2Runner(args.buck2)
buck_args = []
if args.target_platforms:
buck_args = ["--target-platforms"]
buck_args.append(args.target_platforms)
for name, target in graph.by_name.items():
target_to_srcs[name] = sorted(target.get_sources(graph, runner))
target_to_srcs[name] = sorted(target.get_sources(graph, runner, buck_args))

# Generate the requested format.
output: bytes
Expand Down
10 changes: 10 additions & 0 deletions shim/BUCK
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@prelude//platforms:defs.bzl", "execution_platform")
load("@prelude//toolchains:cxx.bzl", "system_cxx_toolchain")
load("@prelude//toolchains:genrule.bzl", "system_genrule_toolchain")
load("@prelude//toolchains:go.bzl", "system_go_toolchain")
Expand Down Expand Up @@ -55,3 +56,12 @@ remote_test_execution_toolchain(
name = "remote_test_execution",
visibility = ["PUBLIC"],
)

execution_platform(
name = "android-arm64",
cpu_configuration = "prelude//cpu:arm64",
os_configuration = "prelude//os:android",
# REVIEW: not sure if this is correct
use_windows_path_separators = host_info().os.is_windows,
visibility = ["PUBLIC"],
)
Loading