70
71
72
73
74 prebuilt_sdk = os.path.abspath(args.dart_sdk)
75
76 dart_binary = os.path.join(prebuilt_sdk, "bin", "dart")
77 if not os.path.isfile(dart_binary):
78 print(
"Binary not found: " + dart_binary)
79 return 1
80
81 dartaotruntime_binary = os.path.join(prebuilt_sdk, "bin", "dartaotruntime")
82 if not os.path.isfile(dartaotruntime_binary):
83 print(
"Binary not found: " + dartaotruntime_binary)
84 return 1
85
86 gen_kernel_snapshot = os.path.join(prebuilt_sdk, "bin", "snapshots",
87 "gen_kernel_aot.dart.snapshot")
88 if not os.path.isfile(gen_kernel_snapshot):
89 print(
"Binary not found: " + gen_kernel_snapshot)
90 return 1
91
92 platform_dill = os.path.join(prebuilt_sdk, "lib", "_internal",
93 "vm_platform_strong.dill")
94 if not os.path.isfile(platform_dill):
95 print(
"Binary not found: " + platform_dill)
96 return 1
97
98
100 dart_binary,
101 "compile",
102 "exe",
103 "--packages",
104 args.packages,
105 f"-Dsdk_hash={args.sdk_hash}",
106 "-o",
107 args.output,
108 args.entry_point,
109 ])
110 if not ok:
111 return 1
112
113
114 with TemporaryDirectory() as tmpdir:
115 output_dill = os.path.join(tmpdir, "output.dill")
117 dartaotruntime_binary,
118 gen_kernel_snapshot,
119 "--platform",
120 platform_dill,
121 "--packages",
122 args.packages,
123 "--depfile",
124 args.depfile,
125 "-o",
126 output_dill,
127 args.entry_point,
128 ])
129 if not ok:
130 return 1
131
132
133
134 with open(args.depfile, "r") as f:
135 content = f.read()
136 (target_name, deps) = content.split(": ", 1)
137 if target_name != output_dill:
139 "ERROR: Something is wrong with generated depfile: expected {output_dill} as target, but got {target_name}"
140 )
141 return 1
142 with open(args.depfile, "w") as f:
143 f.write(args.output)
144 f.write(": ")
145 f.write(deps)
146
147 return 0
148
149
def print(*args, **kwargs)
static void parse_args(int argc, char *argv[], Args *args)