From 144df3cc33785d7502c15d1bae0a36a5524a7adf Mon Sep 17 00:00:00 2001 From: Ali <> Date: Thu, 21 Nov 2019 14:22:33 +0400 Subject: [PATCH] Fix ipadiff [skip ci] --- tools/ipadiff.py | 5 ---- tools/main.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/tools/ipadiff.py b/tools/ipadiff.py index b62b5accab..532e0ea363 100644 --- a/tools/ipadiff.py +++ b/tools/ipadiff.py @@ -181,11 +181,6 @@ def diff_plists(file1, file2): if data1 == data2: return 'equal' else: - with open('lhs.plist', 'wb') as f: - f.write(str.encode(data1)) - with open('rhs.plist', 'wb') as f: - f.write(str.encode(data2)) - sys.exit(1) return 'not_equal' diff --git a/tools/main.cpp b/tools/main.cpp index 99c513eda5..540eee9687 100644 --- a/tools/main.cpp +++ b/tools/main.cpp @@ -175,16 +175,54 @@ static void writeDataToFile(std::vector const &data, std::string const static std::vector stripSwiftSymbols(std::string const &file) { std::string command; - command += "xcrun strip -ST -o /dev/stdout \""; + + command += "xcrun bitcode_strip \""; command += file; - command += "\" 2> /dev/null"; - + command += "\" -r -o \""; + command += file; + command += ".stripped\""; + uint8_t buffer[128]; - std::vector result; + FILE *pipe = popen(command.c_str(), "r"); if (!pipe) { throw std::runtime_error("popen() failed!"); } + while (true) { + size_t readBytes = fread(buffer, 1, 128, pipe); + if (readBytes <= 0) { + break; + } + } + pclose(pipe); + + command = ""; + command += "codesign --remove-signature \""; + command += file; + command += ".stripped\""; + + pipe = popen(command.c_str(), "r"); + if (!pipe) { + throw std::runtime_error("popen() failed!"); + } + while (true) { + size_t readBytes = fread(buffer, 1, 128, pipe); + if (readBytes <= 0) { + break; + } + } + pclose(pipe); + + command = ""; + command += "xcrun strip -ST -o /dev/stdout \""; + command += file; + command += ".stripped\" 2> /dev/null"; + + std::vector result; + pipe = popen(command.c_str(), "r"); + if (!pipe) { + throw std::runtime_error("popen() failed!"); + } while (true) { size_t readBytes = fread(buffer, 1, 128, pipe); if (readBytes <= 0) { @@ -193,6 +231,23 @@ static std::vector stripSwiftSymbols(std::string const &file) { result.insert(result.end(), buffer, buffer + readBytes); } pclose(pipe); + + command = ""; + command += "rm \""; + command += file; + command += ".stripped\""; + + pipe = popen(command.c_str(), "r"); + if (!pipe) { + throw std::runtime_error("popen() failed!"); + } + while (true) { + size_t readBytes = fread(buffer, 1, 128, pipe); + if (readBytes <= 0) { + break; + } + } + pclose(pipe); return result; }