Add suport for JSC profiling on iOS 9

Summary: public

Make the makefile more flexible and add support for iOS9

Reviewed By: jspahrsummers

Differential Revision: D2656510

fb-gh-sync-id: 0a8a6f137e68b50afedbc6d32266618ad79381e0
This commit is contained in:
Tadeu Zagallo 2015-11-16 03:34:39 -08:00 committed by facebook-github-bot-5
parent 905a8a4ce0
commit 02b2e23663
3 changed files with 100 additions and 70 deletions

View File

@ -211,7 +211,11 @@ static json_gen_status append_node_json(json_gen gen, const JSC::ProfileNode *no
static json_gen_status append_root_json(json_gen gen, const JSC::Profile *profile) {
GEN_AND_CHECK(json_gen_map_open(gen, json_entry_key));
GEN_AND_CHECK(json_gen_key_cstring(gen, "rootNodes"));
#if IOS8
GEN_AND_CHECK(append_children_array_json(gen, profile->head()));
#else
GEN_AND_CHECK(append_children_array_json(gen, profile->rootNode()));
#endif
GEN_AND_CHECK(json_gen_map_close(gen));
return json_gen_status_ok;
@ -246,7 +250,11 @@ static json_gen_status append_node_json(json_gen gen, const JSC::ProfileNode *no
for (const JSC::ProfileNode::Call &call : node->calls()) {
GEN_AND_CHECK(json_gen_map_open(gen, json_entry_key));
GEN_AND_CHECK(json_gen_keyvalue_double(gen, "startTime", call.startTime()));
#if IOS8
GEN_AND_CHECK(json_gen_keyvalue_double(gen, "totalTime", call.totalTime()));
#else
GEN_AND_CHECK(json_gen_keyvalue_double(gen, "totalTime", call.elapsedTime()));
#endif
GEN_AND_CHECK(json_gen_map_close(gen));
}
GEN_AND_CHECK(json_gen_array_close(gen));

View File

@ -1,76 +1,18 @@
HEADER_PATHS := `find download/JavaScriptCore -name '*.h' | xargs -I{} dirname {} | uniq | xargs -I{} echo "-I {}"`
ios9:
IOS_VERSION=9 \
JSC_VERSION=7601.1.46.3 \
WEB_CORE_VERSION=7601.1.46.10 \
WTF_VERSION=7601.1.46.3 \
make -f Makefile.base
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)
CERT ?= iPhone Developer
ARCHS = x86_64 arm64 armv7 i386
PLATFORM = \
if [[ "$*" = "x86_64" || "$*" = "i386" ]]; then \
PLATFORM=iPhoneSimulator; \
else \
PLATFORM=iPhoneOS; \
fi;
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
ifneq ($(SDK_VERSION), 8)
all:
$(error "Expected to be compiled with iOS SDK version 8, found $(SDK_VERSION)")
endif
ios8: RCTJSCProfiler.ios8.dylib /tmp/RCTJSCProfiler
cp $^
/tmp/RCTJSCProfiler:
mkdir -p $@
RCTJSCProfiler.ios8.dylib: RCTJSCProfiler_unsigned.ios8.dylib
cp $< $@
codesign -f -s "${CERT}" $@
.PRECIOUS: RCTJSCProfiler_unsigned.ios8.dylib
RCTJSCProfiler_unsigned.ios8.dylib: $(patsubst %,RCTJSCProfiler_%.ios8.dylib,$(ARCHS))
lipo -create -output $@ $^
.PRECIOUS: RCTJSCProfiler_%.ios8.dylib
RCTJSCProfiler_%.ios8.dylib: $(IOS8_LIBS)
$(PLATFORM) \
clang -w -dynamiclib -o RCTJSCProfiler_$*.ios8.dylib -std=c++11 \
-arch $* \
-install_name RCTJSCProfiler.ios8.dylib \
-include ./download/JavaScriptCore/JavaScriptCore-7600.1.17/config.h \
-I download \
-I download/WebCore/WebCore-7600.1.25/icu \
-I download/WTF/WTF-7600.1.24 \
-DNDEBUG=1\
-miphoneos-version-min=8.0 \
$(SYSROOT) \
$(HEADER_PATHS) \
-undefined dynamic_lookup \
JSCLegacyProfiler.mm
.PRECIOUS: %/Bytecodes.h
%/Bytecodes.h:
python $*/generate-bytecode-files --bytecodes_h $@ $*/bytecode/BytecodeList.json
.PRECIOUS: download/%
download/%: download/%.tar.gz
tar -zxvf $< -C `dirname $@` > /dev/null
.PRECIOUS: %.tar.gz
%.tar.gz:
mkdir -p `dirname $@`
curl -o $@ http://www.opensource.apple.com/tarballs/$(patsubst download/%,%,$@)
ios8:
IOS_VERSION=8 \
JSC_VERSION=7600.1.17 \
WEB_CORE_VERSION=7600.1.25 \
WTF_VERSION=7600.1.24 \
make -f Makefile.base
.PHONY: clean
clean:
-rm -rf $(wildcard *.dylib)
-rm -rf $(wildcard *.a)
-rm -rf download

View File

@ -0,0 +1,80 @@
HEADER_PATHS := `find download/JavaScriptCore/JavaScriptCore-$(JSC_VERSION) -name '*.h' | xargs -I{} dirname {} | uniq | xargs -I{} echo "-I {}"`
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)
CERT ?= iPhone Developer
ARCHS = x86_64 arm64 armv7 i386
PLATFORM = \
if [[ "$*" = "x86_64" || "$*" = "i386" ]]; then \
PLATFORM=iPhoneSimulator; \
else \
PLATFORM=iPhoneOS; \
fi;
SYSROOT = -isysroot $(call SDK_PATH,$${PLATFORM})
IOS_LIBS = \
download/JavaScriptCore/JavaScriptCore-$(JSC_VERSION) \
download/WebCore/WebCore-$(WEB_CORE_VERSION) \
download/WTF/WTF-$(WTF_VERSION) \
download/JavaScriptCore/JavaScriptCore-$(JSC_VERSION)/Bytecodes.h
IOS_EXT=ios$(IOS_VERSION)
ifneq ($(SDK_VERSION), $(IOS_VERSION))
all:
$(error "Expected to be compiled with iOS SDK version 8, found $(SDK_VERSION)")
else
all: RCTJSCProfiler.$(IOS_EXT).dylib /tmp/RCTJSCProfiler
cp $^
endif
/tmp/RCTJSCProfiler:
mkdir -p $@
RCTJSCProfiler.$(IOS_EXT).dylib: RCTJSCProfiler_unsigned.$(IOS_EXT).dylib
cp $< $@
codesign -f -s "${CERT}" $@
.PRECIOUS: RCTJSCProfiler_unsigned.$(IOS_EXT).dylib
RCTJSCProfiler_unsigned.$(IOS_EXT).dylib: $(patsubst %,RCTJSCProfiler_%.$(IOS_EXT).dylib,$(ARCHS))
lipo -create -output $@ $^
.PRECIOUS: RCTJSCProfiler_%.$(IOS_EXT).dylib
RCTJSCProfiler_%.$(IOS_EXT).dylib: $(IOS_LIBS)
$(PLATFORM) \
clang -w -dynamiclib -o RCTJSCProfiler_$*.$(IOS_EXT).dylib -std=c++11 \
-arch $* \
-install_name RCTJSCProfiler.$(IOS_EXT).dylib \
-include ./download/JavaScriptCore/JavaScriptCore-$(JSC_VERSION)/config.h \
-I download \
-I download/WebCore/WebCore-$(WEB_CORE_VERSION)/icu \
-I download/WTF/WTF-$(WTF_VERSION) \
-DNDEBUG=1 \
-DIOS$(IOS_VERSION)=1 \
-miphoneos-version-min=8.0 \
$(SYSROOT) \
$(HEADER_PATHS) \
-undefined dynamic_lookup \
JSCLegacyProfiler.mm
.PRECIOUS: %/Bytecodes.h
%/Bytecodes.h:
python $*/generate-bytecode-files --bytecodes_h $@ $*/bytecode/BytecodeList.json
.PRECIOUS: download/%
download/%: download/%.tar.gz
tar -zxvf $< -C `dirname $@` > /dev/null
.PRECIOUS: %.tar.gz
%.tar.gz:
mkdir -p `dirname $@`
curl -o $@ http://www.opensource.apple.com/tarballs/$(patsubst download/%,%,$@)