119 build_dir, final_output_dir = opts.build_dir, opts.final_output_dir
120
121 assert os.path.exists('bin/gn')
122
123 for d in [build_dir, final_output_dir]:
125
126 apps_dir = 'platform_tools/android/apps'
127 app = 'skqp'
128 lib = 'lib%s_jni.so' % app
129
130
131
132 remove(build_dir +
'/libs')
133 build_paths = [apps_dir + '/.gradle',
134 apps_dir + '/' + app + '/build',
135 apps_dir + '/' + app + '/src/main/libs']
136 for path in build_paths:
138 try:
140 except OSError:
141 sys.stderr.write('failed to create symlink "%s"\n' % path)
142
143 lib_dir = '%s/%s/src/main/libs' % (apps_dir, app)
144 apk_build_dir = '%s/%s/build/outputs/apk' % (apps_dir, app)
145 for d in [lib_dir, apk_build_dir]:
146 shutil.rmtree(d, True)
147
148 with RemoveFiles(*build_paths):
149 for arch in opts.architectures:
150 build = os.path.join(build_dir, arch)
151 gn_args = opts.gn_args(arch)
152 args =
' '.
join(
'%s=%s' % (k, v)
for k, v
in gn_args.items())
153 check_call([
'bin/gn',
'gen', build,
'--args=' + args])
154 try:
156 except subprocess.CalledProcessError:
157 check_call([
'ninja',
'-C', build,
'-t',
'clean'])
159 dst = '%s/%s' % (lib_dir, skia_to_android_arch_name_map[arch])
161 shutil.copy(os.path.join(build, lib), dst)
162
164 env_copy = os.environ.copy()
165 env_copy['ANDROID_HOME'] = opts.android_home
166 env_copy['ANDROID_NDK_HOME'] = opts.android_ndk
167
168 check_call([
'apps/gradlew',
'-p' 'apps/' + app,
169 '-P', 'suppressNativeBuild',
170 ':%s:assembleUniversalDebug' % app],
171 env=env_copy, cwd='platform_tools/android')
172
173 apk_name = app + "-universal-debug.apk"
174
175 apk_list = list(
find_name(apk_build_dir, apk_name))
176 assert len(apk_list) == 1
177
178 out = os.path.join(final_output_dir, apk_name)
179 shutil.move(apk_list[0], out)
180 sys.stdout.write(out + '\n')
181
182 arches =
'_'.
join(sorted(opts.architectures))
183 copy = os.path.join(final_output_dir, "%s-%s-debug.apk" % (app, arches))
184 shutil.copyfile(out, copy)
185 sys.stdout.write(copy + '\n')
186
187 sys.stdout.write('* * * COMPLETE * * *\n\n')
188
189
def find_name(searchpath, filename)
def make_symlinked_subdir(target, working_dir)
static SkString join(const CommandLineFlags::StringArray &)