From 25cff7c321e70b17a919b301634e21424f9dee17 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Thu, 20 Aug 2015 15:06:43 -0700 Subject: [PATCH] Enable launching iOS applications using Xcode for profiling and tracing --- build/config/ios/XcodeHarness/.gitignore | 18 ++ .../Harness.xcodeproj/project.pbxproj | 272 ++++++++++++++++++ build/config/ios/XcodeHarness/main.m | 10 + build/config/ios/rules.gni | 49 +++- 4 files changed, 348 insertions(+), 1 deletion(-) create mode 100644 build/config/ios/XcodeHarness/.gitignore create mode 100644 build/config/ios/XcodeHarness/Harness.xcodeproj/project.pbxproj create mode 100644 build/config/ios/XcodeHarness/main.m diff --git a/build/config/ios/XcodeHarness/.gitignore b/build/config/ios/XcodeHarness/.gitignore new file mode 100644 index 00000000000..89c499e451e --- /dev/null +++ b/build/config/ios/XcodeHarness/.gitignore @@ -0,0 +1,18 @@ +# Xcode +.DS_Store +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +*.xcworkspace +!default.xcworkspace +xcuserdata +profile +*.moved-aside +DerivedData +.idea/ diff --git a/build/config/ios/XcodeHarness/Harness.xcodeproj/project.pbxproj b/build/config/ios/XcodeHarness/Harness.xcodeproj/project.pbxproj new file mode 100644 index 00000000000..33c21867061 --- /dev/null +++ b/build/config/ios/XcodeHarness/Harness.xcodeproj/project.pbxproj @@ -0,0 +1,272 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 9E16D11C1B8684E900402ACB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E16D11B1B8684E900402ACB /* main.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 9E16D11B1B8684E900402ACB /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 9E842F101B866F0F00C84ECC /* Harness.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Harness.app; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 9E842EDD1B864EA100C84ECC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9E16D11D1B8684F000402ACB /* Source */ = { + isa = PBXGroup; + children = ( + 9E16D11B1B8684E900402ACB /* main.m */, + ); + name = Source; + sourceTree = ""; + }; + 9E16D11E1B8684F900402ACB /* Products */ = { + isa = PBXGroup; + children = ( + 9E842F101B866F0F00C84ECC /* Harness.app */, + ); + name = Products; + sourceTree = ""; + }; + 9E842ED71B864EA100C84ECC = { + isa = PBXGroup; + children = ( + 9E16D11D1B8684F000402ACB /* Source */, + 9E16D11E1B8684F900402ACB /* Products */, + ); + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 9E842EDF1B864EA100C84ECC /* Harness */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9E842F031B864EA100C84ECC /* Build configuration list for PBXNativeTarget "Harness" */; + buildPhases = ( + 9E842EDC1B864EA100C84ECC /* Sources */, + 9E842EDD1B864EA100C84ECC /* Frameworks */, + 9EA9970A1B867E74007B8C62 /* Copy GN Built Contents */, + 9E842EDE1B864EA100C84ECC /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Harness; + productName = SkyDebug; + productReference = 9E842F101B866F0F00C84ECC /* Harness.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 9E842ED81B864EA100C84ECC /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0640; + ORGANIZATIONNAME = Domokit; + TargetAttributes = { + 9E842EDF1B864EA100C84ECC = { + CreatedOnToolsVersion = 6.4; + }; + }; + }; + buildConfigurationList = 9E842EDB1B864EA100C84ECC /* Build configuration list for PBXProject "Harness" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 9E842ED71B864EA100C84ECC; + productRefGroup = 9E842ED71B864EA100C84ECC; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 9E842EDF1B864EA100C84ECC /* Harness */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 9E842EDE1B864EA100C84ECC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 9EA9970A1B867E74007B8C62 /* Copy GN Built Contents */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy GN Built Contents"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "cp -R ${SOURCE_ROOT}/Sideload/ ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 9E842EDC1B864EA100C84ECC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9E16D11C1B8684E900402ACB /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 9E842F011B864EA100C84ECC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.4; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 9E842F021B864EA100C84ECC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.4; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 9E842F041B864EA100C84ECC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = "$(SRCROOT)/Sideload/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 9E842F051B864EA100C84ECC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = "$(SRCROOT)/Sideload/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 9E842EDB1B864EA100C84ECC /* Build configuration list for PBXProject "Harness" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9E842F011B864EA100C84ECC /* Debug */, + 9E842F021B864EA100C84ECC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 9E842F031B864EA100C84ECC /* Build configuration list for PBXNativeTarget "Harness" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9E842F041B864EA100C84ECC /* Debug */, + 9E842F051B864EA100C84ECC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 9E842ED81B864EA100C84ECC /* Project object */; +} diff --git a/build/config/ios/XcodeHarness/main.m b/build/config/ios/XcodeHarness/main.m new file mode 100644 index 00000000000..5ddbd34dc18 --- /dev/null +++ b/build/config/ios/XcodeHarness/main.m @@ -0,0 +1,10 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import + +int main(int argc, char* argv[]) { + NSCAssert(NO, @"Placeholder for Xcode. Should never be run"); + return EXIT_FAILURE; +} diff --git a/build/config/ios/rules.gni b/build/config/ios/rules.gni index caf8eb2df4e..cf65af427db 100644 --- a/build/config/ios/rules.gni +++ b/build/config/ios/rules.gni @@ -40,6 +40,46 @@ template("code_sign_ios") { } } +template("xcode_harness_ios") { + assert(defined(invoker.deps), + "The dependencies must be specified") + assert(defined(invoker.app_bundle), + "The app bundle must be defined") + assert(defined(invoker.app_name), + "The application name must be defined") + app_name = invoker.app_name + + xcode_project_gen_target_name = app_name + "_xcode" + copy(xcode_project_gen_target_name) { + sources = [ + "//build/config/ios/XcodeHarness" + ] + outputs = [ + "$root_build_dir/$xcode_project_gen_target_name", + ] + } + + bundle_copy_gen_target_name = app_name + "_bundle_copy" + copy(bundle_copy_gen_target_name) { + sources = [ + invoker.app_bundle + ] + outputs = [ + "$root_build_dir/$xcode_project_gen_target_name/Sideload", + ] + + deps = invoker.deps + [ + ":$xcode_project_gen_target_name" + ] + } + + group(target_name) { + deps = [ + ":$bundle_copy_gen_target_name" + ] + } +} + template("resource_copy_ios") { assert(defined(invoker.resources), "The source list of resources to copy over") @@ -150,6 +190,13 @@ template("ios_app") { ] } + # Generate the Xcode Harness for Profiling + xcode_harness_gen_target_name = app_name + "_harness" + xcode_harness_ios(xcode_harness_gen_target_name) { + app_bundle = "$root_build_dir/$app_name.app" + deps = [ ":$copy_gen_target_name" ] + } + # Perform Code Signing code_sign_gen_target_name = target_name + "_codesign" @@ -165,7 +212,7 @@ template("ios_app") { group(target_name) { # Skip code signing if no identity is provided. This is useful for simulator # builds - deps = [] + deps = [ ":$xcode_harness_gen_target_name" ] if (invoker.code_signing_identity == "") { deps += [ ":$copy_gen_target_name" ] } else {