Skip to content
This repository was archived by the owner on Feb 14, 2025. It is now read-only.

Commit 72f7676

Browse files
bryanoltmanfelangel
authored andcommitted
fix: update how we generate analyze_snapshot (#92)
* fix: update how we generate analyze_snapshot * formatting
1 parent d055509 commit 72f7676

File tree

1 file changed

+67
-25
lines changed

1 file changed

+67
-25
lines changed

lib/snapshot/BUILD.gn

Lines changed: 67 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,15 @@ group("generate_snapshot_bins") {
3434
# For macOS target builds: needed for both target CPUs (arm64, x64).
3535
# For iOS, Android target builds: all AOT target CPUs are arm/arm64.
3636
if (host_os == "mac" && (target_os == "mac" || target_os == "ios")) {
37-
deps += [ ":create_macos_gen_snapshots" ]
37+
deps += [
38+
":create_macos_analyze_snapshots",
39+
":create_macos_gen_snapshots",
40+
]
3841
} else if (host_os == "mac" &&
3942
(target_cpu == "arm" || target_cpu == "arm64")) {
4043
deps += [ ":create_arm_gen_snapshot" ]
4144
}
4245

43-
if (host_os == "mac" && target_os != "mac" &&
44-
(target_cpu == "arm" || target_cpu == "arm64")) {
45-
deps += [ ":create_arm_analyze_snapshot" ]
46-
}
47-
4846
# Build analyze_snapshot for 64-bit target CPUs.
4947
if (target_cpu == "arm64") {
5048
deps += [ "$dart_src/runtime/bin:analyze_snapshot($host_toolchain)" ]
@@ -181,25 +179,6 @@ if (host_os == "mac" && target_os != "mac" &&
181179
deps = [ "$dart_src/runtime/bin:gen_snapshot($host_toolchain)" ]
182180
visibility = [ ":*" ]
183181
}
184-
185-
copy("create_arm_analyze_snapshot") {
186-
# The toolchain-specific output directory. For cross-compiles, this is a
187-
# clang-x64 or clang-arm64 subdirectory of the top-level build directory.
188-
host_output_dir = get_label_info(
189-
"$dart_src/runtime/bin:analyze_snapshot($host_toolchain)",
190-
"root_out_dir")
191-
192-
# Determine suffixed output gen_snapshot name.
193-
target_cpu_suffix = target_cpu
194-
if (target_cpu == "arm") {
195-
target_cpu_suffix = "armv7"
196-
}
197-
198-
sources = [ "${host_output_dir}/analyze_snapshot" ]
199-
outputs = [ "${host_output_dir}/analyze_snapshot_${target_cpu_suffix}" ]
200-
deps = [ "$dart_src/runtime/bin:analyze_snapshot($host_toolchain)" ]
201-
visibility = [ ":*" ]
202-
}
203182
}
204183

205184
# Creates a `gen_snapshot` binary suffixed with the target CPU architecture.
@@ -258,6 +237,69 @@ if (host_os == "mac" && (target_os == "mac" || target_os == "ios")) {
258237
":create_macos_gen_snapshot_x64_${target_cpu}",
259238
]
260239
}
240+
241+
# Added by shorebird.
242+
# analyze_snapshot targets below were copied from the gen_snapshot targets
243+
# above to allow us to include analyze_snapshot in the artifacts generated
244+
# for create_ios_framework.py.
245+
template("build_mac_analyze_snapshot") {
246+
assert(defined(invoker.host_arch))
247+
host_cpu = invoker.host_arch
248+
249+
build_toolchain = "//build/toolchain/mac:clang_$host_cpu"
250+
analyze_snapshot_target_name = "analyze_snapshot"
251+
252+
# At this point, the gen_snapshot equivalent changes
253+
# gen_ snapshot_target_name to "gen_snapshot_host_targeting_host". There is
254+
# no equivalent for analyze_snapshot, so we don't do that here.
255+
#
256+
# It's unclear whether we need to do so now, but we didn't previously, so
257+
# we're not doing it now until we have a reason to.
258+
259+
analyze_snapshot_target =
260+
"$dart_src/runtime/bin:$analyze_snapshot_target_name($build_toolchain)"
261+
262+
copy(target_name) {
263+
# The toolchain-specific output directory. For cross-compiles, this is a
264+
# clang-x64 or clang-arm64 subdirectory of the top-level build directory.
265+
output_dir = get_label_info(analyze_snapshot_target, "root_out_dir")
266+
267+
sources = [ "${output_dir}/${analyze_snapshot_target_name}" ]
268+
outputs = [
269+
"${root_out_dir}/artifacts_$host_cpu/analyze_snapshot_${target_cpu}",
270+
]
271+
deps = [ analyze_snapshot_target ]
272+
}
273+
}
274+
275+
build_mac_analyze_snapshot(
276+
"create_macos_analyze_snapshot_arm64_${target_cpu}") {
277+
host_arch = "arm64"
278+
}
279+
280+
build_mac_analyze_snapshot(
281+
"create_macos_analyze_snapshot_x64_${target_cpu}") {
282+
host_arch = "x64"
283+
}
284+
285+
action("create_macos_analyze_snapshots") {
286+
script = "//flutter/sky/tools/create_macos_binary.py"
287+
outputs = [ "${root_out_dir}/analyze_snapshot_${target_cpu}" ]
288+
args = [
289+
"--in-arm64",
290+
rebase_path(
291+
"${root_out_dir}/artifacts_arm64/analyze_snapshot_${target_cpu}"),
292+
"--in-x64",
293+
rebase_path(
294+
"${root_out_dir}/artifacts_x64/analyze_snapshot_${target_cpu}"),
295+
"--out",
296+
rebase_path("${root_out_dir}/analyze_snapshot_${target_cpu}"),
297+
]
298+
deps = [
299+
":create_macos_analyze_snapshot_arm64_${target_cpu}",
300+
":create_macos_analyze_snapshot_x64_${target_cpu}",
301+
]
302+
}
261303
}
262304

263305
source_set("snapshot") {

0 commit comments

Comments
 (0)