Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: build/android/rezip/rezip.cc

Issue 595933003: Re-invent page aligning libraries in APK file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update for Ross' review Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // rezip is a tool which is used to modify zip files. It reads in a 5 // rezip is a tool which is used to modify zip files. It reads in a
6 // zip file and outputs a new zip file after applying various 6 // zip file and outputs a new zip file after applying various
7 // transforms. The tool is used in the Android Chromium build process 7 // transforms. The tool is used in the Android Chromium build process
8 // to modify an APK file (which are zip files). The main application 8 // to modify an APK file (which are zip files). The main application
9 // of this is to modify the APK so that the shared library is no 9 // of this is to modify the APK so that the shared library is no
10 // longer compressed. Ironically, this saves both transmission and 10 // longer compressed. Ironically, this saves both transmission and
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 LOG(ERROR) << " <action> is 'inflatealign', 'dropdescriptors' or 'rename'"; 483 LOG(ERROR) << " <action> is 'inflatealign', 'dropdescriptors' or 'rename'";
484 LOG(ERROR) << " 'inflatealign'"; 484 LOG(ERROR) << " 'inflatealign'";
485 LOG(ERROR) << " inflate and page aligns files of the form " 485 LOG(ERROR) << " inflate and page aligns files of the form "
486 "lib/*/crazy.lib*.so"; 486 "lib/*/crazy.lib*.so";
487 LOG(ERROR) << " 'dropdescriptors':"; 487 LOG(ERROR) << " 'dropdescriptors':";
488 LOG(ERROR) << " remove zip data descriptors from the zip file"; 488 LOG(ERROR) << " remove zip data descriptors from the zip file";
489 LOG(ERROR) << " 'rename':"; 489 LOG(ERROR) << " 'rename':";
490 LOG(ERROR) << " renames files of the form lib/*/lib*.so to " 490 LOG(ERROR) << " renames files of the form lib/*/lib*.so to "
491 "lib/*/crazy.lib*.so. Note libchromium_android_linker.so is " 491 "lib/*/crazy.lib*.so. Note libchromium_android_linker.so is "
492 "not renamed as the crazy linker can not load itself."; 492 "not renamed as the crazy linker can not load itself.";
493 LOG(ERROR) << " 'renameinflate':";
494 LOG(ERROR) << " combines rename and inflate steps in a single pass.";
493 exit(1); 495 exit(1);
494 } 496 }
495 497
496 const char* action = argv[1]; 498 const char* action = argv[1];
497 const char* in_zip_filename = argv[2]; 499 const char* in_zip_filename = argv[2];
498 const char* out_zip_filename = argv[3]; 500 const char* out_zip_filename = argv[3];
499 501
500 InflatePredicateFun inflate_predicate_fun = NULL; 502 InflatePredicateFun inflate_predicate_fun = NULL;
501 AlignFun align_fun = NULL; 503 AlignFun align_fun = NULL;
502 RenameFun rename_fun = NULL; 504 RenameFun rename_fun = NULL;
503 bool check_page_align = false; 505 bool check_page_align = false;
506 // Note although only "renameinflate" is used in the build process, the
507 // other steps are used in the LGPL compliance process.
504 if (strcmp("inflatealign", action) == 0) { 508 if (strcmp("inflatealign", action) == 0) {
505 inflate_predicate_fun = &IsCrazyLibraryFilename; 509 inflate_predicate_fun = &IsCrazyLibraryFilename;
506 align_fun = &PageAlignCrazyLibrary; 510 align_fun = &PageAlignCrazyLibrary;
507 check_page_align = true; 511 check_page_align = true;
508 } else if (strcmp("rename", action) == 0) { 512 } else if (strcmp("rename", action) == 0) {
509 rename_fun = &RenameLibraryForCrazyLinker; 513 rename_fun = &RenameLibraryForCrazyLinker;
514 } else if (strcmp("renameinflate", action) == 0) {
515 rename_fun = &RenameLibraryForCrazyLinker;
516 inflate_predicate_fun = &IsLibraryFilename;
510 } else if (strcmp("dropdescriptors", action) == 0) { 517 } else if (strcmp("dropdescriptors", action) == 0) {
511 // Minizip does not know about data descriptors, so the default 518 // Minizip does not know about data descriptors, so the default
512 // copying action will drop the descriptors. This should be fine 519 // copying action will drop the descriptors. This should be fine
513 // as data descriptors are redundant information. 520 // as data descriptors are redundant information.
514 // Note we need to explicitly drop the descriptors before trying to 521 // Note we need to explicitly drop the descriptors before trying to
515 // do alignment otherwise we will miscalculate the position because 522 // do alignment otherwise we will miscalculate the position because
516 // we don't know about the data descriptors. 523 // we don't know about the data descriptors.
517 } else { 524 } else {
518 LOG(ERROR) << "Usage: <action> should be 'inflatealign', " 525 LOG(ERROR) << "Usage: <action> should be 'inflatealign', "
519 "'dropdescriptors' or 'rename'"; 526 "'dropdescriptors' or 'rename'";
520 exit(1); 527 exit(1);
521 } 528 }
522 529
523 if (!Rezip(in_zip_filename, 530 if (!Rezip(in_zip_filename,
524 out_zip_filename, 531 out_zip_filename,
525 align_fun, 532 align_fun,
526 rename_fun, 533 rename_fun,
527 inflate_predicate_fun)) { 534 inflate_predicate_fun)) {
528 exit(1); 535 exit(1);
529 } 536 }
530 if (check_page_align && !CheckPageAlignAndOnlyOneLibrary(out_zip_filename)) { 537 if (check_page_align && !CheckPageAlignAndOnlyOneLibrary(out_zip_filename)) {
531 exit(1); 538 exit(1);
532 } 539 }
533 return 0; 540 return 0;
534 } 541 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698