Skip to content

Commit 2abf669

Browse files
authored
Merge pull request #1023 from NativeScript/bektchiev/framework-linking-optimizations
NativeScript.framework linking optimizations
2 parents b1e0c16 + db45156 commit 2abf669

8 files changed

+40
-15
lines changed

CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ set(INFO_PLIST_TEMPLATE "${CMAKE_SOURCE_DIR}/cmake/Info.plist")
4949
#WTF uses char16_t for UCHAR_TYPE and we need to match it
5050
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14 -stdlib=libc++ -DUCHAR_TYPE=char16_t")
5151

52+
# Override RelWithDebInfo configuration's default optimization O2 to O3
53+
# because we've started releasing NativeScript.framework from it
54+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3")
55+
5256
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG=1")
5357
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1")
5458

build/scripts/build-livesync-static-lib.sh

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ xcodebuild \
3333
-quiet
3434

3535
checkpoint "Packaging TKLiveSync.framework"
36+
rm -rf "$WORKSPACE/dist/TKLiveSync"
3637
mkdir -p "$WORKSPACE/dist/TKLiveSync/"
3738
cp -r "build/Release-iphoneos/TKLiveSync.framework/Headers" "$WORKSPACE/dist/TKLiveSync"
3839
mv "$WORKSPACE/dist/TKLiveSync/Headers" "$WORKSPACE/dist/TKLiveSync/include"

build/scripts/build-nativescript-framework.sh

+19-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ set -e
44

55
source "$(dirname "$0")/common.sh"
66

7+
CONFIGURATION=$NATIVESCRIPT_XCODE_CONFIGURATION
8+
79
checkpoint "Building NativeScript.framework"
810

911
mkdir -p "$WORKSPACE/cmake-build" && pushd "$_"
@@ -12,26 +14,34 @@ rm -f "CMakeCache.txt"
1214
cmake .. -G"Xcode" -D"BUILD_SHARED_LIBS=ON"
1315
# TODO: fix build when iphoneos build is started first
1416
checkpoint "Building NativeScript.framework - iphonesimulator SDK"
15-
xcodebuild -configuration "RelWithDebInfo" -sdk "iphonesimulator" -target "NativeScript" -quiet
17+
xcodebuild -configuration $CONFIGURATION -sdk "iphonesimulator" -target "NativeScript" -quiet
1618
checkpoint "Building NativeScript.framework - iphoneos SDK"
17-
xcodebuild -configuration "RelWithDebInfo" -sdk "iphoneos" -target "NativeScript" -quiet
19+
xcodebuild -configuration $CONFIGURATION -sdk "iphoneos" -target "NativeScript" -quiet
1820
popd
1921

2022
checkpoint "Packaging NativeScript.framework"
2123
mkdir -p "$DIST_DIR" && pushd "$_"
22-
cp -r "$WORKSPACE/cmake-build/src/NativeScript/RelWithDebInfo-iphoneos/NativeScript.framework" "."
24+
cp -r "$WORKSPACE/cmake-build/src/NativeScript/$CONFIGURATION-iphoneos/NativeScript.framework" "."
2325
rm "NativeScript.framework/NativeScript"
26+
27+
# Strip debug information, dSYM package must be used for debugging and symbolicating
28+
strip -S "$WORKSPACE/cmake-build/src/NativeScript/$CONFIGURATION-iphonesimulator/NativeScript.framework/NativeScript" \
29+
"$WORKSPACE/cmake-build/src/NativeScript/$CONFIGURATION-iphoneos/NativeScript.framework/NativeScript"
30+
echo "CodeSign $WORKSPACE/cmake-build/src/NativeScript/$CONFIGURATION-iphonesimulator/NativeScript.framework/NativeScript"
31+
32+
/usr/bin/codesign --force --sign - --timestamp=none "$WORKSPACE/cmake-build/src/NativeScript/$CONFIGURATION-iphonesimulator/NativeScript.framework/NativeScript"
33+
2434
lipo -create -output "NativeScript.framework/NativeScript" \
25-
"$WORKSPACE/cmake-build/src/NativeScript/RelWithDebInfo-iphonesimulator/NativeScript.framework/NativeScript" \
26-
"$WORKSPACE/cmake-build/src/NativeScript/RelWithDebInfo-iphoneos/NativeScript.framework/NativeScript"
35+
"$WORKSPACE/cmake-build/src/NativeScript/$CONFIGURATION-iphonesimulator/NativeScript.framework/NativeScript" \
36+
"$WORKSPACE/cmake-build/src/NativeScript/$CONFIGURATION-iphoneos/NativeScript.framework/NativeScript"
2737

28-
cp -r "$WORKSPACE/cmake-build/src/NativeScript/RelWithDebInfo-iphoneos/NativeScript.framework.dSYM" "."
38+
cp -r "$WORKSPACE/cmake-build/src/NativeScript/$CONFIGURATION-iphoneos/NativeScript.framework.dSYM" "."
2939
rm "NativeScript.framework.dSYM/Contents/Resources/DWARF/NativeScript"
3040
lipo -create -output "NativeScript.framework.dSYM/Contents/Resources/DWARF/NativeScript" \
31-
"$WORKSPACE/cmake-build/src/NativeScript/RelWithDebInfo-iphonesimulator/NativeScript.framework.dSYM/Contents/Resources/DWARF/NativeScript" \
32-
"$WORKSPACE/cmake-build/src/NativeScript/RelWithDebInfo-iphoneos/NativeScript.framework.dSYM/Contents/Resources/DWARF/NativeScript"
41+
"$WORKSPACE/cmake-build/src/NativeScript/$CONFIGURATION-iphonesimulator/NativeScript.framework.dSYM/Contents/Resources/DWARF/NativeScript" \
42+
"$WORKSPACE/cmake-build/src/NativeScript/$CONFIGURATION-iphoneos/NativeScript.framework.dSYM/Contents/Resources/DWARF/NativeScript"
3343

34-
tar -zcf NativeScript.framework.dSYM.tgz NativeScript.framework.dSYM
44+
zip -qr NativeScript.framework.dSYM.zip NativeScript.framework.dSYM
3545
rm -rf NativeScript.framework.dSYM
3646

3747
popd

build/scripts/build-testrunner-application.sh

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
set -e
44
set -o pipefail
55

6-
CONFIGURATION="Release"
7-
86
source "$(dirname "$0")/common.sh"
97

8+
CONFIGURATION=$NATIVESCRIPT_XCODE_CONFIGURATION
9+
1010
checkpoint "Building TestRunner application"
1111

1212
mkdir -p "$WORKSPACE/cmake-build" && pushd "$_"
@@ -25,12 +25,14 @@ xcodebuild \
2525
-scheme "TestRunner" \
2626
ARCHS="armv7 arm64" \
2727
ONLY_ACTIVE_ARCH="NO" \
28+
-quiet \
2829

2930
xcodebuild archive \
3031
-archivePath "$WORKSPACE/cmake-build/tests/TestRunner/$CONFIGURATION-iphoneos/TestRunner.xcarchive" \
3132
-configuration "$CONFIGURATION" \
3233
-sdk "iphoneos" \
33-
-scheme "TestRunner"
34+
-scheme "TestRunner" \
35+
-quiet \
3436

3537
popd
3638

@@ -39,7 +41,8 @@ xcodebuild \
3941
-exportArchive \
4042
-archivePath "$WORKSPACE/cmake-build/tests/TestRunner/$CONFIGURATION-iphoneos/TestRunner.xcarchive" \
4143
-exportPath "$WORKSPACE/cmake-build/tests/TestRunner/$CONFIGURATION-iphoneos" \
42-
-exportOptionsPlist "$WORKSPACE/cmake/ExportOptions.plist"
44+
-exportOptionsPlist "$WORKSPACE/cmake/ExportOptions.plist" \
45+
-quiet \
4346

4447
cp "$WORKSPACE/cmake-build/tests/TestRunner/$CONFIGURATION-iphoneos/TestRunner.ipa" "$DIST_DIR"
4548

build/scripts/common.sh

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function checkpoint {
1212

1313
WORKSPACE=$(pwd)
1414
DIST_DIR="$WORKSPACE/dist"
15+
NATIVESCRIPT_XCODE_CONFIGURATION="RelWithDebInfo"
1516

1617
if [ ! -d "$WORKSPACE/build/scripts" ]; then
1718
echo "This script must be run from the root of the repository."

build/scripts/package-tns-ios.sh

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ PACKAGE_DIR="$DIST_DIR/package"
1010
FRAMEWORK_DIR="$PACKAGE_DIR/framework"
1111
INTERNAL_DIR="$FRAMEWORK_DIR/internal"
1212

13+
# Start with a clean package directory
14+
rm -rf $PACKAGE_DIR
1315
mkdir -p "$INTERNAL_DIR"
1416

1517
"$WORKSPACE/build/scripts/build-livesync-static-lib.sh"

build/scripts/run-tests.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ testrun.stdout.on('data', function(chunks) {
9393

9494
chunks = leftover + chunks;
9595
chunks = chunks.replace(/\(lldb\)\s/g, '');
96-
var lines = chunks.split('\n');
96+
var lines = chunks.split(/\r?\n/);
9797
for(var i = 0; i < lines.length - 1; i++) {
9898
var line = lines[i];
9999

@@ -106,7 +106,8 @@ testrun.stdout.on('data', function(chunks) {
106106
// if line.indexOf('App Start') reset the timeout function
107107
var index = line.indexOf(term);
108108
if (index <= 0) {
109-
process.stdout.write(line + '\n');
109+
if (line)
110+
process.stdout.write(line + '\n');
110111
} else {
111112
if (line.indexOf("CONSOLE LOG") !== 0) {
112113
// Each line is logged by the debugger twice (to console and to logs)

src/WebKit.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ set(WEBKIT_CMAKE_ARGS
3333
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
3434
-DCMAKE_CXX_STANDARD=14
3535
-DCMAKE_CXX_STANDARD_REQUIRED=ON
36+
# Override RelWithDebInfo configuration's defaults to the ones from NativeScript
37+
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=${CMAKE_CXX_FLAGS_RELWITHDEBINFO}
38+
3639
)
3740

3841
include(ExternalProject)

0 commit comments

Comments
 (0)