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
Closed

Conversation

jonnyzzz
Copy link
Member

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add something like:

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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

```bash
kotlinc main.kt
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

kotlinc main.kt
```

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member Author

Including @B1ggDave to help us to check the language

issue: EVAN-5121
---

With Kotlin/Native can compile a native binary for
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

@B1ggDave B1ggDave Jul 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to create a binary for the fresh iPhone supporting arm64.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Collaborator

@B1ggDave B1ggDave Jul 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Collaborator

@B1ggDave B1ggDave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@jonnyzzz
Copy link
Member Author

@B1ggDave I've included fixed your comments

@jonnyzzz jonnyzzz closed this Jul 18, 2018
@jonnyzzz jonnyzzz deleted the tutorial-kn-mp branch July 18, 2018 12:00
@jonnyzzz
Copy link
Member Author

jonnyzzz 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
Labels
None yet
Projects
None yet
3 participants