From d447edc5edfbbece15785eed39cc94cc66dbcc76 Mon Sep 17 00:00:00 2001 From: Tadeu Zagallo Date: Thu, 1 Oct 2015 12:48:37 -0700 Subject: [PATCH] Fix profiler setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: @​public Update packager entry and profiler pre-built dylib + Update makefile to make it easier to use different versions of Xcode and shortcircuit when using the wrong version. Reviewed By: @jspahrsummers Differential Revision: D2498157 --- JSCLegacyProfiler/Makefile | 10 ++++++---- packager/packager.js | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/JSCLegacyProfiler/Makefile b/JSCLegacyProfiler/Makefile index 01503073526aa2..921ea75beb37d1 100644 --- a/JSCLegacyProfiler/Makefile +++ b/JSCLegacyProfiler/Makefile @@ -1,6 +1,7 @@ HEADER_PATHS := `find download/JavaScriptCore -name '*.h' | xargs -I{} dirname {} | uniq | xargs -I{} echo "-I {}"` -SDK_PATH = /Applications/Xcode.app/Contents/Developer/Platforms/$1.platform/Developer/SDKs/$1.sdk +XCODE_PATH ?= $(shell xcode-select -p) +SDK_PATH = $(XCODE_PATH)/Platforms/$1.platform/Developer/SDKs/$1.sdk SDK_VERSION = $(shell plutil -convert json -o - $(call SDK_PATH,iPhoneOS)/SDKSettings.plist | awk -f parseSDKVersion.awk) @@ -19,13 +20,14 @@ SYSROOT = -isysroot $(call SDK_PATH,$${PLATFORM}) IOS8_LIBS = download/WebCore/WebCore-7600.1.25 download/WTF/WTF-7600.1.24 download/JavaScriptCore/JavaScriptCore-7600.1.17 download/JavaScriptCore/JavaScriptCore-7600.1.17/Bytecodes.h -ios8: RCTJSCProfiler.ios8.dylib /tmp/RCTJSCProfiler ifneq ($(SDK_VERSION), 8) +all: $(error "Expected to be compiled with iOS SDK version 8, found $(SDK_VERSION)") -else - cp $^ endif +ios8: RCTJSCProfiler.ios8.dylib /tmp/RCTJSCProfiler + cp $^ + /tmp/RCTJSCProfiler: mkdir -p $@ diff --git a/packager/packager.js b/packager/packager.js index 9f0fd6c14d1ca1..fd040595d09113 100644 --- a/packager/packager.js +++ b/packager/packager.js @@ -233,14 +233,14 @@ function systraceProfileMiddleware(req, res, next) { childProcess.exec(cmd, function(error) { if (error) { if (error.code === 127) { - res.end( - '\n** Failed executing `' + cmd + '` **\n\n' + + var response = '\n** Failed executing `' + cmd + '` **\n\n' + 'Google trace-viewer is required to visualize the data, You can install it with `brew install trace2html`\n\n' + 'NOTE: Your profile data was kept at:\n' + dumpName - ); + console.log(response); + res.end(response); } else { console.error(error); - res.end('Unknown error %s', error.message); + res.end('Unknown error: ' + error.message); } return; } else { @@ -267,16 +267,16 @@ function cpuProfileMiddleware(req, res, next) { var dumpName = '/tmp/cpu-profile_' + Date.now(); fs.writeFileSync(dumpName + '.json', req.rawBody); - var cmd = path.join(__dirname, '..', 'JSCLegacyProfiler', 'json2trace') + ' -cpuprofiler ' + dumpName + '.cpuprofile ' + dumpName + '.json'; + var cmd = path.join(__dirname, '..', 'react-native-github', 'JSCLegacyProfiler', 'json2trace') + ' -cpuprofiler ' + dumpName + '.cpuprofile ' + dumpName + '.json'; childProcess.exec(cmd, function(error) { if (error) { console.error(error); - res.end('Unknown error: %s', error.message); + res.end('Unknown error: ' + error.message); } else { - res.end( - 'Your profile was generated at\n\n' + dumpName + '.cpuprofile\n\n' + - 'Open `Chrome Dev Tools > Profiles > Load` and select the profile to visualize it.' - ); + var response = 'Your profile was generated at\n\n' + dumpName + '.cpuprofile\n\n' + + 'Open `Chrome Dev Tools > Profiles > Load` and select the profile to visualize it.'; + console.log(response); + res.end(response); } }); }