Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add separate C and C++ compiler in Daedalus

This way we compile C++ files with the compiler specified by CXX and C
files with CC. This makes it possible to also pass in C++ compiler
options in the future.
  • Loading branch information...
commit 98016e9e0851b1e43fd876b950d1db40f3c1b720 1 parent 1c51253
@dbussink dbussink authored
Showing with 22 additions and 5 deletions.
  1. +22 −5 projects/daedalus/daedalus.rb
View
27 projects/daedalus/daedalus.rb
@@ -139,10 +139,12 @@ def stop
end
class Compiler
- def initialize(compiler, linker, logger, blueprint)
- @compiler = compiler
+ def initialize(c_compiler, cxx_compiler, linker, logger, blueprint)
+ @c_compiler = c_compiler
+ @cxx_compiler = cxx_compiler
@linker = linker
@cflags = []
+ @cxxflags = []
@ldflags = []
@libraries = []
@log = logger
@@ -194,7 +196,7 @@ def set_ldshared
if $CC == "cc" and `cc -flags 2>&1` =~ /Sun/ # detect SUNWspro compiler
# SUN CHAIN
@cflags << "-DCC_SUNWspro" << "-KPIC"
- @ldshared = "#{@compiler} -G -KPIC -lCstd"
+ @ldshared = "#{@linker} -G -KPIC -lCstd"
else
# GNU CHAIN
# on Unix we need a g++ link, not gcc.
@@ -236,7 +238,7 @@ def header_directories
dirs
end
- attr_reader :path, :cflags, :ldflags, :log
+ attr_reader :path, :cflags, :cxxflags, :ldflags, :log
def add_library(lib)
if f = lib.cflags
@@ -263,8 +265,21 @@ def sha1(path)
end
def compile(source, object)
+ if source =~ /\.cpp$/
+ cxx_compile(source, object)
+ else
+ c_compile(source, object)
+ end
+ end
+
+ def c_compile(source, object)
@log.show "CC", source
- @log.command "#{@compiler} #{@cflags.join(' ')} -c -o #{object} #{source}"
+ @log.command "#{@c_compiler} #{@cflags.join(' ')} -c -o #{object} #{source}"
+ end
+
+ def cxx_compile(source, object)
+ @log.show "CXX", source
+ @log.command "#{@cxx_compiler} #{@cflags.join(' ')} #{@cxxflags.join(' ')} -c -o #{object} #{source}"
end
def link(path, files)
@@ -691,6 +706,7 @@ def initialize(base, compiler)
@shared_libraries = []
@compiler = Compiler.new(ENV['CC'] || "gcc",
ENV['CXX'] || "g++",
+ ENV['CXX'] || "g++",
compiler.log, nil)
yield self
@@ -963,6 +979,7 @@ def library_group(path, &block)
def gcc!
@compiler = Compiler.new(ENV['CC'] || "gcc",
ENV['CXX'] || "g++",
+ ENV['CXX'] || "g++",
Logger.new, self)
end
Please sign in to comment.
Something went wrong with that request. Please try again.