Skip to content

Commit

Permalink
Use local symlinks to provide cc, c++ on PATH.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed May 19, 2016
1 parent 98adcd1 commit 68e07cd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -54,6 +54,8 @@ tmtags
/work
/staging
/bootstrap
/build/bin/cc
/build/bin/c++
Gemfile.installed.lock

# .revision tracks configure and code revision consistency
Expand Down
4 changes: 4 additions & 0 deletions Rakefile
Expand Up @@ -60,6 +60,10 @@ unless RedCard.check :ruby, :rubinius
exit 1
end

if BUILD_CONFIG[:build_bin]
ENV["PATH"] = "#{BUILD_CONFIG[:build_bin]}:#{ENV["PATH"]}"
end

def libprefixdir
if BUILD_CONFIG[:stagingdir]
"#{BUILD_CONFIG[:stagingdir]}#{BUILD_CONFIG[:libdir]}"
Expand Down
25 changes: 23 additions & 2 deletions configure
Expand Up @@ -165,6 +165,8 @@ class Configure
@ruby_version = "2.2.2"
@ruby_libversion = @ruby_version.split(/\./)[0..1].join.to_i

@build_bin = "#{@sourcedir}/build/bin"

# Configure settings
@release_build = !in_git?
end
Expand Down Expand Up @@ -325,11 +327,11 @@ class Configure

o.doc "\n Compiler settings"

o.on "--cc", "COMPILER", "Compiler to use for C code (eg gcc, clang)" do |cc|
o.on "--cc", "COMPILER", "Compiler to use for C code (eg clang)" do |cc|
@cc = cc
end

o.on "--cxx", "COMPILER", "Compiler to use for C++ code (eg g++, clang++)" do |cxx|
o.on "--cxx", "COMPILER", "Compiler to use for C++ code (eg clang++)" do |cxx|
@cxx = cxx
end

Expand Down Expand Up @@ -712,6 +714,24 @@ please notify us.
EOM
end

if File.exist? @build_bin
if !File.directory? @build_bin
fail "#{@build_bin} already exists and is not a directory"
end
else
FileUtils.mkdir_p @build_bin
end

if @cc != "cc"
cc = "#{@build_bin}/cc"
File.symlink `which #{@cc}`.chomp, cc unless File.exist? cc
end

if @cxx != "c++"
cxx = "#{@build_bin}/c++"
File.symlink `which #{@cxx}`.chomp, cxx unless File.exist? cxx
end

@make ||= ENV['MAKE'] || 'make'
@rake ||= ENV['RAKE'] || 'rake'
@tar ||= ENV['TAR'] || (@windows ? 'bsdtar' : 'tar')
Expand Down Expand Up @@ -1572,6 +1592,7 @@ int main() { return tgetnum(""); }
:bootstrap_gems_dir => @bootstrap_gems_dir,
:capi_includedir => @capi_includedir,
:build_exe => "#{@build_prefix}#{@bindir}/#{@program_name}",
:build_bin => @build_bin,
:prefixdir => @prefixdir,
:bindir => @bindir,
:libdir => @libdir,
Expand Down

0 comments on commit 68e07cd

Please sign in to comment.