microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/debugger/ios/compiler.ts
37lines · modeblame
488f1908Jimmy Thomson10 years ago | 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT license. See LICENSE file in the project root for details. | |
| 3 | | |
| 4 | import * as path from "path"; | |
| 5 | import * as Q from "q"; | |
| 6 | | |
b0061ac6Meena Kunnathur Balakrishnan10 years ago | 7 | import {CommandExecutor} from "../../common/commandExecutor"; |
a9d96b7cdigeff10 years ago | 8 | import {Xcodeproj} from "../../common/ios/xcodeproj"; |
488f1908Jimmy Thomson10 years ago | 9 | |
| 10 | export class Compiler { | |
| 11 | private projectRoot: string; | |
| 12 | | |
bc96b26bJimmy Thomson10 years ago | 13 | constructor(projectRoot: string) { |
488f1908Jimmy Thomson10 years ago | 14 | this.projectRoot = projectRoot; |
| 15 | } | |
| 16 | | |
| 17 | public compile(): Q.Promise<void> { | |
| 18 | return this.xcodeBuildArguments().then((xcodeArguments: string[]) => { | |
45944d15Meena Kunnathur Balakrishnan10 years ago | 19 | return new CommandExecutor(this.projectRoot).spawnAndWaitForCompletion("xcodebuild", xcodeArguments); |
488f1908Jimmy Thomson10 years ago | 20 | }); |
| 21 | } | |
| 22 | | |
| 23 | /* | |
| 24 | Return the appropriate arguments for compiling a react native project | |
| 25 | */ | |
| 26 | private xcodeBuildArguments(): Q.Promise<string[]> { | |
afc46a73Jimmy Thomson10 years ago | 27 | return new Xcodeproj().findXcodeprojFile(this.projectRoot).then((projectFile: string) => { |
| 28 | const projectName = path.basename(projectFile, path.extname(projectFile)); | |
488f1908Jimmy Thomson10 years ago | 29 | return [ |
| 30 | "-project", path.join(this.projectRoot, "ios", projectFile), | |
| 31 | "-scheme", projectName, | |
| 32 | "-destination", "generic/platform=iOS", // Build for a generic iOS device | |
| 33 | "-derivedDataPath", path.join(this.projectRoot, "ios", "build") | |
| 34 | ]; | |
| 35 | }); | |
| 36 | } | |
| 37 | } |