Skip to content

Commit d447edc

Browse files
tadeuzagallofacebook-github-bot-3
authored andcommitted
Fix profiler setup
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
1 parent 2c0da0f commit d447edc

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

JSCLegacyProfiler/Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
HEADER_PATHS := `find download/JavaScriptCore -name '*.h' | xargs -I{} dirname {} | uniq | xargs -I{} echo "-I {}"`
22

3-
SDK_PATH = /Applications/Xcode.app/Contents/Developer/Platforms/$1.platform/Developer/SDKs/$1.sdk
3+
XCODE_PATH ?= $(shell xcode-select -p)
4+
SDK_PATH = $(XCODE_PATH)/Platforms/$1.platform/Developer/SDKs/$1.sdk
45

56
SDK_VERSION = $(shell plutil -convert json -o - $(call SDK_PATH,iPhoneOS)/SDKSettings.plist | awk -f parseSDKVersion.awk)
67

@@ -19,13 +20,14 @@ SYSROOT = -isysroot $(call SDK_PATH,$${PLATFORM})
1920

2021
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
2122

22-
ios8: RCTJSCProfiler.ios8.dylib /tmp/RCTJSCProfiler
2323
ifneq ($(SDK_VERSION), 8)
24+
all:
2425
$(error "Expected to be compiled with iOS SDK version 8, found $(SDK_VERSION)")
25-
else
26-
cp $^
2726
endif
2827

28+
ios8: RCTJSCProfiler.ios8.dylib /tmp/RCTJSCProfiler
29+
cp $^
30+
2931
/tmp/RCTJSCProfiler:
3032
mkdir -p $@
3133

packager/packager.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,14 @@ function systraceProfileMiddleware(req, res, next) {
233233
childProcess.exec(cmd, function(error) {
234234
if (error) {
235235
if (error.code === 127) {
236-
res.end(
237-
'\n** Failed executing `' + cmd + '` **\n\n' +
236+
var response = '\n** Failed executing `' + cmd + '` **\n\n' +
238237
'Google trace-viewer is required to visualize the data, You can install it with `brew install trace2html`\n\n' +
239238
'NOTE: Your profile data was kept at:\n' + dumpName
240-
);
239+
console.log(response);
240+
res.end(response);
241241
} else {
242242
console.error(error);
243-
res.end('Unknown error %s', error.message);
243+
res.end('Unknown error: ' + error.message);
244244
}
245245
return;
246246
} else {
@@ -267,16 +267,16 @@ function cpuProfileMiddleware(req, res, next) {
267267
var dumpName = '/tmp/cpu-profile_' + Date.now();
268268
fs.writeFileSync(dumpName + '.json', req.rawBody);
269269

270-
var cmd = path.join(__dirname, '..', 'JSCLegacyProfiler', 'json2trace') + ' -cpuprofiler ' + dumpName + '.cpuprofile ' + dumpName + '.json';
270+
var cmd = path.join(__dirname, '..', 'react-native-github', 'JSCLegacyProfiler', 'json2trace') + ' -cpuprofiler ' + dumpName + '.cpuprofile ' + dumpName + '.json';
271271
childProcess.exec(cmd, function(error) {
272272
if (error) {
273273
console.error(error);
274-
res.end('Unknown error: %s', error.message);
274+
res.end('Unknown error: ' + error.message);
275275
} else {
276-
res.end(
277-
'Your profile was generated at\n\n' + dumpName + '.cpuprofile\n\n' +
278-
'Open `Chrome Dev Tools > Profiles > Load` and select the profile to visualize it.'
279-
);
276+
var response = 'Your profile was generated at\n\n' + dumpName + '.cpuprofile\n\n' +
277+
'Open `Chrome Dev Tools > Profiles > Load` and select the profile to visualize it.';
278+
console.log(response);
279+
res.end(response);
280280
}
281281
});
282282
}

0 commit comments

Comments
 (0)