Skip to content

Commit

Permalink
Fix profiler setup
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tadeuzagallo authored and facebook-github-bot-3 committed Oct 1, 2015
1 parent 2c0da0f commit d447edc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
10 changes: 6 additions & 4 deletions JSCLegacyProfiler/Makefile
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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 $@

Expand Down
20 changes: 10 additions & 10 deletions packager/packager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
});
}
Expand Down

0 comments on commit d447edc

Please sign in to comment.