Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tutorial: Targeting multiple platforms #1075

Closed
wants to merge 16 commits into from

Conversation

@jonnyzzz jonnyzzz self-assigned this Jul 10, 2018
@jonnyzzz jonnyzzz requested a review from olonho Jul 10, 2018
```bash
kotlinc -target ios_arm64 -output bin/ios_arm64 main.kt
```
to create a binary for fresh iPhone supporting arm64.

This comment has been minimized.

Copy link
@olonho

olonho Jul 13, 2018

Add something like:

Native executable bin/ios_x64.kexe will be produced, check that with file bin/ios_x64.kexe.

This comment has been minimized.

Copy link
@jonnyzzz

jonnyzzz Jul 16, 2018

Author Member

👍

for those OSes. So on each of the operation systems we call the compiler:

```bash
kotlinc main.kt

This comment has been minimized.

Copy link
@olonho

olonho Jul 13, 2018

Better specify -o, otheriwse it's pretty hard to guess where output will go.

This comment has been minimized.

Copy link
@jonnyzzz

jonnyzzz Jul 16, 2018

Author Member

fixed

kotlinc main.kt
```

There is no need to specify `-target` parameter explicitly, because

This comment has been minimized.

Copy link
@olonho

olonho Jul 13, 2018

Replace with smth like: "If no -target option specified, native executable for host platform where compiler was executed is produced, which matches behavior of other native compilers".

This comment has been minimized.

Copy link
@jonnyzzz

jonnyzzz Jul 16, 2018

Author Member

Done. Simplified a bit

The -target parameter is optional. If it is not included, the binary will be produced for the system, where the compiler is executed. It matches the behavior of other native compilers.

@jonnyzzz jonnyzzz force-pushed the tutorial-kn-mp branch from a036730 to bc7771e Jul 16, 2018
@jonnyzzz jonnyzzz requested a review from B1ggDave Jul 16, 2018
@jonnyzzz

This comment has been minimized.

Copy link
Member Author

commented Jul 16, 2018

Including @B1ggDave to help us to check the language

issue: EVAN-5121
---

With Kotlin/Native can compile a native binary for

This comment has been minimized.

Copy link
@B1ggDave

B1ggDave Jul 16, 2018

Collaborator

"With Kotlin/Native can compile a native binary for"

either of these works:
With Kotlin/Native, you can compile a native binary for
With Kotlin/Native, it is possible to compile a native binary for


* [Specify a Target Platform](#specifying-target-platform)
* [Build for a Specific Platform](#building-for-a-specific-platform)
* [Build a Console Utility for several OSes](#building-a-console-utility)

This comment has been minimized.

Copy link
@B1ggDave

B1ggDave Jul 16, 2018

Collaborator

"OSes"

consider:
OS's
Operating Systems

* [Build for a Specific Platform](#building-for-a-specific-platform)
* [Build a Console Utility for several OSes](#building-a-console-utility)

We need to have Kotlin/Native compiler on our machines.

This comment has been minimized.

Copy link
@B1ggDave

B1ggDave Jul 16, 2018

Collaborator

+We need to have a Kotlin/Native compiler on our machines.

We need to have Kotlin/Native compiler on our machines.
You may have a look at the
[A Basic Kotlin/Native Application](basic-kotlin-native-app.html#obtaining-the-compiler)
tutorial for more information in that step.

This comment has been minimized.

Copy link
@B1ggDave

B1ggDave Jul 16, 2018

Collaborator

+tutorial for more information on performing this step.

zephyr_stm32f4_disco:
```

The set of targets of Kotlin/Native compiler depends on the host operating system.

This comment has been minimized.

Copy link
@B1ggDave

B1ggDave Jul 16, 2018

Collaborator

The set of targets for the Kotlin/Native compiler depends on the host operating system.

```

The set of targets of Kotlin/Native compiler depends on the host operating system.
We may specify target explicitly with `-target <name>` argument. The default target

This comment has been minimized.

Copy link
@B1ggDave

B1ggDave Jul 16, 2018

Collaborator

We may specify a target explicitly with a '-target ' argument.

tutorial for more information in that step.
Let's assume we have a console, where `kotlinc` (or the older `konanc`) command is available.

## Specifying Target Platform

This comment has been minimized.

Copy link
@B1ggDave

B1ggDave Jul 16, 2018

Collaborator

Specifying a Target Platform


## Building for a Specific Platform

Let's create a sample Kotlin/Native program and save it as `main.kt`. You may see the previous tutorial

This comment has been minimized.

Copy link
@B1ggDave

B1ggDave Jul 16, 2018

Collaborator

You may want to have a look at the tutorial A Basic Kotlin/Native Application for more details.

You can see the previous tutorial A Basic Kotlin/Native Application for more details.

}
```

We use `-target` argument of the `kotlinc` to specify the platform. It is also

This comment has been minimized.

Copy link
@B1ggDave

B1ggDave Jul 16, 2018

Collaborator

We use the -target argument from the kotlinc to specify the platform.


We use `-target` argument of the `kotlinc` to specify the platform. It is also
helpful to use `-output` to explicitly instruct
the compiler on where to create the compiled binary, e.g., to build for the iOS emulator on macOS we use:

This comment has been minimized.

Copy link
@B1ggDave

B1ggDave Jul 16, 2018

Collaborator

the compiler on where to create the compiled binary, for example, to build for the iOS emulator on macOS we use:

you use for example throughout the page, this e.g. seemed out of place.

```bash
kotlinc -target ios_arm64 -output bin/ios_arm64 main.kt
```
to create a binary for fresh iPhone supporting arm64.

This comment has been minimized.

Copy link
@B1ggDave

B1ggDave Jul 16, 2018

Collaborator

to create a binary for the fresh iPhone supporting arm64.

This comment has been minimized.

Copy link
@jonnyzzz

jonnyzzz Jul 18, 2018

Author Member

Used

to create a binary for an iPhone supporting arm64.


## Building a Console Utility

We saw above that the set of supported target platforms depends on the host operating system.

This comment has been minimized.

Copy link
@B1ggDave

B1ggDave Jul 16, 2018

Collaborator

+Running the compiler on Windows, macOS, and Linux is required to create a console application
+for these Operating Systems. On each of the operating system we call the compiler:

may be used to automate and simplify the process.

## Next Steps

This comment has been minimized.

Copy link
@B1ggDave

B1ggDave Jul 16, 2018

Collaborator

+Build tools help to deal with compiler arguments. You might want to consider
+using Gradle build system for your project.
+Gradle with the Kotlin/Native plugin simplifies the setup for each operating system, just download and run the
+Kotlin/Native compiler and it will be even more pleasant for you.

This comment has been minimized.

Copy link
@jonnyzzz

jonnyzzz Jul 18, 2018

Author Member

I was intended to mean a bit different: Gradle ... downloads and runs ...
Fixed it in the other way

Copy link
Collaborator

left a comment

added in some suggestions for the text to consider. :)

@jonnyzzz

This comment has been minimized.

Copy link
Member Author

commented Jul 18, 2018

@B1ggDave I've included fixed your comments

@jonnyzzz jonnyzzz closed this Jul 18, 2018
@jonnyzzz jonnyzzz deleted the tutorial-kn-mp branch Jul 18, 2018
@jonnyzzz

This comment has been minimized.

Copy link
Member Author

commented Jul 18, 2018

I've squashed and merged the branch into master to follow commit message guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.