From 3dc93dc86ce5c01fd3ec7eeffbde900797f0cd64 Mon Sep 17 00:00:00 2001 From: Alexey Stepanov Date: Mon, 5 Sep 2016 20:50:12 +0300 Subject: [PATCH] translator: add fast build in executable file --- translator/Makefile | 17 +++++++++++++++-- translator/README.md | 12 ++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/translator/Makefile b/translator/Makefile index dee97cb2ef8..6f42191cad9 100644 --- a/translator/Makefile +++ b/translator/Makefile @@ -6,9 +6,11 @@ red = '\033[0;31m' lightRed = '\033[1;31m' orange = '\033[0;33m' nc = '\033[0m' +KOTSTD='../kotstd' +SOURCELIB=build/sources stdlib: - cd ../kotstd && make clean && make + cd $(KOTSTD) && make clean && make %.out: stdlib %.txt @./run_one_test.sh $(@:.out=.txt) @@ -25,6 +27,17 @@ all: build tests; clean: ./gradlew clean +compile: build + mkdir -p $(SOURCELIB) + rm -f $(SOURCELIB)/linked.ll + rm -f $(SOURCELIB)/linked.ll + java -jar build/libs/translator-1.0.jar -I $(KOTSTD)/kt $(files) -o $(SOURCELIB)/build.ll + llvm-link-3.6 -S $(KOTSTD)/build/stdlib_x86.ll $(SOURCELIB)/build.ll >> $(SOURCELIB)/linked.ll + clang-3.6 $(SOURCELIB)/linked.ll -o $(output) + rm $(SOURCELIB)/linked.ll + rm $(SOURCELIB)/build.ll + + .DEFAULT_GOAL := all .FORCE: build, all -.PHONY: tests, stdlib, build, all +.PHONY: tests, stdlib, build, all, compile diff --git a/translator/README.md b/translator/README.md index 1cd95f18e72..c18661729e9 100644 --- a/translator/README.md +++ b/translator/README.md @@ -1,5 +1,16 @@ # Translator from Kotlin to LLVM +## Fast build +If you want to use the translator without going into any technical details, this section is for you. Using following commands you will be able to compile your Kotlin files, the resulting executable file + + $ make compile files=$(KTFILES) output=$(OUTPUT) + +where + - $(KTFILES) - list of your Kotlin files separated by spaces + - $(OUTPUT) - the resulting file + + **NOTE:** when you use a fast build, the name of your your entry point function must be **main** and it should not receive arguments + ## Building For build translator into jar, you must run gradle target @@ -50,3 +61,4 @@ where $(COMPILED_LLVM_CODE) - code obtained in the step compiler $ lli-3.6 $(LINKED_CODE) where $(LINKED_CODE) - code obtained in the previous step +