From a55d9646d1e86b8ef04a65cd042c0b30e08981ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Tue, 23 Jun 2015 11:06:41 +0200 Subject: [PATCH] Make .crystal directory location configurable --- .travis.yml | 1 + src/compiler/crystal/command.cr | 4 ++-- src/compiler/crystal/compiler.cr | 2 +- src/compiler/crystal/config.cr | 5 +++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index f15b23785469..67ad39a1029f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,7 @@ install: | esac export PATH=/tmp/llvm-3.5.0-1/bin:$PATH export CRYSTAL_CONFIG_VERSION=ci + export CRYSTAL_CACHE_DIR=/tmp/crystal script: - make crystal spec - find samples -name "*.cr" | xargs -L 1 ./bin/crystal build --no-build diff --git a/src/compiler/crystal/command.cr b/src/compiler/crystal/command.cr index 6c1b0e8f75e3..d49e2f56c171 100644 --- a/src/compiler/crystal/command.cr +++ b/src/compiler/crystal/command.cr @@ -1,7 +1,7 @@ module Crystal def self.tempfile(basename) - Dir.mkdir_p ".crystal" - ".crystal/crystal-run-#{basename}.tmp" + Dir.mkdir_p Config.cache_dir + File.join(Config.cache_dir, "crystal-run-#{basename}.tmp") end end diff --git a/src/compiler/crystal/compiler.cr b/src/compiler/crystal/compiler.cr index 60b212b60e77..ca575db42320 100644 --- a/src/compiler/crystal/compiler.cr +++ b/src/compiler/crystal/compiler.cr @@ -143,7 +143,7 @@ module Crystal if @cross_compile_flags output_dir = "." else - output_dir = ".crystal/#{sources.first.filename}" + output_dir = File.join(Config.cache_dir, sources.first.filename) end Dir.mkdir_p(output_dir) diff --git a/src/compiler/crystal/config.cr b/src/compiler/crystal/config.cr index 64a5b0843ad9..9b9e6b155e23 100644 --- a/src/compiler/crystal/config.cr +++ b/src/compiler/crystal/config.cr @@ -2,5 +2,10 @@ module Crystal module Config PATH = {{ env("CRYSTAL_CONFIG_PATH") || "" }} VERSION = {{ env("CRYSTAL_CONFIG_VERSION") || `(git describe --tags --long 2>/dev/null)`.stringify.chomp }} + CACHE_DIR = ENV["CRYSTAL_CACHE_DIR"]? || ".crystal" + + def self.cache_dir + @@cache_dir ||= File.expand_path(CACHE_DIR) + end end end