class Object

Public Instance Methods

clang_compiler_build_str(out_name, files, inc_dirs, lib_dirs, libs, config, ex_linker_flags, ex_build_flags) click to toggle source

Builds a command line string for clang++

# File lib/cpp_build.rb, line 3
def clang_compiler_build_str(out_name, files, inc_dirs, lib_dirs, libs, config, ex_linker_flags, ex_build_flags)

        # Compiler
        cc = "clang++"

        # Config
        if config == :debug
                config = "-g -O0"
        elsif config == :release
                config = "-O2"
        end

        # Files
        if files.class == Array then files = files.join(" ") end

        if files == :not_set
                return "echo \"No Files Given\""
        end

        # Inc Dirs
        if inc_dirs.class == Array then inc_dirs = inc_dirs.join(" -I") end
        if inc_dirs.class == String then inc_dirs = "-I" + inc_dirs end
        if inc_dirs == :not_set then inc_dirs = "" end

        # Lib Dirs
        if lib_dirs.class == Array then lib_dirs = lib_dirs.join(" -L") end
        if lib_dirs.class == String then lib_dirs = "-L" + lib_dirs end
        if lib_dirs == :not_set then lib_dirs = "" end

        # Libs
        if(lib_dirs != :not_set)
                if libs.class == Array then libs = libs.join(" -l") end
                if libs.class == String then libs = "-l" + libs end
        else
                libs = ""
        end


        #Extras
        if ex_linker_flags.class == Array then ex_linker_flags = ex_linker_flags.join(" ") end
        if ex_build_flags.class == Array then ex_build_flags = ex_build_flags.join(" ") end


        # Output
        build = "-o #{out_name}"

        # Other Stuff
        cpp_standard = "-std=c++11"

        framework_dir = "" #"-F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/"

        # Build cmd string
        cmd_string = "#{cc} #{files} #{inc_dirs} #{lib_dirs} #{framework_dir} #{libs} #{ex_linker_flags} #{ex_build_flags} #{config} #{cpp_standard} #{build}"

        return cmd_string
end