diff --git a/repos/base/mk/generic.mk b/repos/base/mk/generic.mk index d41d09302..d1de60f98 100644 --- a/repos/base/mk/generic.mk +++ b/repos/base/mk/generic.mk @@ -94,11 +94,16 @@ ifeq ($(NIM_CPU),) $(warning NIM_CPU not defined for any of the following SPECS: $(SPECS)) else +ifeq ($(wildcard $(NIM)),) +$(error Nim compiler not found at $(NIM), see the 'tool/tool_chain_nim' script) +endif + NIM_MAKEFILES := $(foreach X,$(SRC_NIM),$(X).mk) + NIM_ARGS = --compileOnly --os:genode --cpu:$(NIM_CPU) NIM_ARGS += --verbosity:0 --hint[Processing]:off --nimcache:. NIM_ARGS += --noCppExceptions -NIM_ARGS += $(foreach X,$(call select_from_repositories,include/nim),--path:$(X)) +NIM_ARGS += $(foreach DIR,$(foreach REP,$(REPOSITORIES),$(wildcard $(REP)/include/nim)), --path:$(DIR)) NIM_ARGS += $(NIM_OPT) # Generate the C++ sources and compilation info diff --git a/repos/base/mk/global.mk b/repos/base/mk/global.mk index f65a93647..8270ee621 100644 --- a/repos/base/mk/global.mk +++ b/repos/base/mk/global.mk @@ -55,7 +55,7 @@ HOST_CC = $(CUSTOM_HOST_CC) # # Nim toolchain # -NIM ?= nim +NIM ?= /usr/local/genode-nim/bin/nim # # JSON parsing utility diff --git a/repos/libports/ports/nim-csources.hash b/repos/libports/ports/nim-csources.hash new file mode 100644 index 000000000..44056728f --- /dev/null +++ b/repos/libports/ports/nim-csources.hash @@ -0,0 +1 @@ +83abcf5efae001cbe80d473b18d8e5314f1e1500 diff --git a/repos/libports/ports/nim-csources.port b/repos/libports/ports/nim-csources.port new file mode 100644 index 000000000..dd9573c93 --- /dev/null +++ b/repos/libports/ports/nim-csources.port @@ -0,0 +1,11 @@ +LICENSE := MIT +VERSION := 0.17.2 +DOWNLOADS := nim-csources.archive + +OWNER = nim-lang +REPO = csources +REV = 08c310bb8277611711ca06619526ec08f1feffaf + +URL(nim-csources) := https://github.com/$(OWNER)/$(REPO)/archive/$(REV).tar.gz +SHA(nim-csources) := 659cbaf6081ede035342dbb05c70fd9184d1446b +DIR(nim-csources) := . diff --git a/repos/libports/ports/nim.hash b/repos/libports/ports/nim.hash new file mode 100644 index 000000000..d38282f0c --- /dev/null +++ b/repos/libports/ports/nim.hash @@ -0,0 +1 @@ +11b0318a9b77aacfb46ec52a5d4df36bce2fd954 diff --git a/repos/libports/ports/nim.port b/repos/libports/ports/nim.port new file mode 100644 index 000000000..aa735166a --- /dev/null +++ b/repos/libports/ports/nim.port @@ -0,0 +1,11 @@ +LICENSE := MIT +VERSION := 0.17.2 +DOWNLOADS := nim.archive + +OWNER := ehmry +REPO := nim +REV := c129528e8eff8ec8b84664d0b64e8ca89745df2a + +URL(nim) := https://github.com/$(OWNER)/$(REPO)/archive/$(REV).tar.gz +SHA(nim) := 5350686dfb42a871f6bdbbd634e30b68b39b9d46 +DIR(nim) := . diff --git a/repos/libports/run/nim.run b/repos/libports/run/nim.run index 172699a9f..63ba464c7 100644 --- a/repos/libports/run/nim.run +++ b/repos/libports/run/nim.run @@ -32,7 +32,7 @@ set config { - + diff --git a/repos/libports/src/test/nim/main.nim b/repos/libports/src/test/nim/main.nim index 8a15a299f..0a79a12fc 100644 --- a/repos/libports/src/test/nim/main.nim +++ b/repos/libports/src/test/nim/main.nim @@ -110,3 +110,4 @@ suite "garbage collector": echo GC_getStatistics() echo "done" +quit 0 diff --git a/tool/tool_chain_nim b/tool/tool_chain_nim new file mode 100755 index 000000000..7f7b8e782 --- /dev/null +++ b/tool/tool_chain_nim @@ -0,0 +1,73 @@ +#!/usr/bin/make -f +# +# \brief Tool for preparing the Nim tool-chain for the Genode OS Framework +# \author Emery Hemingway +# \date 2017-07-04 +# + +help: + @$(ECHO) + @$(ECHO) "Build Nim compiler for the Genode OS Framework tool chain" + @$(ECHO) + @$(ECHO) "--- available commands ---" + @$(ECHO) "build - build Nim compiler" + @$(ECHO) "clean - clean everything except contrib sources" + @$(ECHO) "install - copy Nim compiler and standard library to '$(INSTALL_LOCATION)'" + @$(ECHO) + +.PHONY: build help install + +GENODE_DIR ?= $(realpath $(dir $(firstword $(MAKEFILE_LIST)))/..) +include $(GENODE_DIR)/tool/ports/mk/common.inc + +LOCAL_INSTALL_LOCATION ?= /usr/local +INSTALL_LOCATION := $(LOCAL_INSTALL_LOCATION)/genode-nim + +NIM_CONTRIB_DIR = $(shell $(GENODE_DIR)/tool/ports/current nim) +NIM_CSOURCES_CONTRIB_DIR = $(shell $(GENODE_DIR)/tool/ports/current nim-csources) + +BUILD_DIR = build/nim + +build: $(BUILD_DIR)/bin/nim $(BUILD_DIR)/koch + +$(BUILD_DIR)/bin/nim: $(BUILD_DIR)/koch + @$(ECHO) "$(BRIGHT_COL)building Nim compiler...$(DEFAULT_COL)" + $(VERBOSE)cd $(BUILD_DIR) && ./koch boot -d:release --verbosity:0 --hint[Processing]:off + +$(BUILD_DIR)/koch: $(BUILD_DIR)/koch.nim $(BUILD_DIR)/.bootstrap.tag + @$(ECHO) "$(BRIGHT_COL)building Koch...$(DEFAULT_COL)" + $(VERBOSE)cd $(BUILD_DIR) && ./bin/nim c koch + +$(BUILD_DIR)/.bootstrap.tag: $(BUILD_DIR)/csources + @$(ECHO) "$(BRIGHT_COL)building bootstrap compiler...$(DEFAULT_COL)" + $(VERBOSE)cd $(BUILD_DIR)/csources && sh build.sh + @touch $@ + +$(BUILD_DIR)/csources: $(NIM_CSOURCES_CONTRIB_DIR) $(BUILD_DIR)/koch.nim + @$(ECHO) "$(BRIGHT_COL)copying Nim C sources...$(DEFAULT_COL)" + $(VERBOSE)mkdir -p $@ + $(VERBOSE)cp -a $