module L::Util

General purpose build tools.

Public Class Methods

install(what, where, mode: nil, require: []) click to toggle source

Install a file

Installs what into the directory where. Source files are added to the +=all+ tag and installed files are added to the +=install+ tag.

@param what [Set<Pathname,String>,Array<Pathname,String>,Pathname,String]

The files to install.

@param where [Pathname,String] The directory to install them to. If not

absolute it is relative to +D:prefix+

@param mode [Numeric] The permissions (specified in base ten) for the

file.  If nil the current permissions are kept.

@param require [Set<Pathname,String>,Array<Pathname,String>,Pathname,String]

Files that must be present before installing the file.

@return [Array<Pathname>] The installed files.

@example

exe = L::C.program(srcs, ['pthread'], 'bitmonitor-test')
L::Util.install exe, 'bin/', mode: 755
# File lib/rub/l/util.rb, line 150
def self.install(what, where, mode: nil, require: [])
        what = R::Tool.make_set_paths what
        where = Pathname.new(where)
        require = R::Tool.make_set_paths require
        
        what.map do |f|
                if f.directory?
                        install(f.children, where+f.basename)
                else
                        install_to(f, where+f.basename)
                end
        end.flatten.to_set
end
install_to(from, to, mode: nil, require: []) click to toggle source

Install a file to a specific location.

@see install

Similar to {#install} but the basename is not used as the name in the new location. If from is a dirtectory it is installed and renamed but it’s contents are preserved with the same names.

@param from [Set<Pathname,String>,Array<Pathname,String>,Pathname,String]

The files to install.

@param to [Pathname,String] Where to install them. If not

absolute it is relative to +D:prefix+

@param mode [Numeric] The permissions (specified in base ten) for the

file.  If nil the current permissions are kept.

@param require [Set<Pathname,String>,Array<Pathname,String>,Pathname,String]

Files that must be present before installing the file.

@return [Array<Pathname>] The installed files.

# File lib/rub/l/util.rb, line 109
def self.install_to(from, to, mode: nil, require: [])
        from = C.path(from)
        to   = Pathname.new(to).expand_path(D :prefix)
        
        if from.directory?
                return install(from.children, to)
        end
        
        C.generator(
                Set[from].merge(require),
                ['install', "-D#{mode!=nil ? "m#{mode}" : "" }", from, to],
                to,
                desc: 'Installing'
        ).each do |o|
                C.tag(:all    ).require(from)
                C.tag(:install).require(to)
        end
        uninstall to
        
        Set[from]
end
uninstall(what) click to toggle source

Uninstall a file.

Adds the file to the :uninstall tag.

@param what [Set<Pathname,String>,Array<Pathname,String>,Pathname,String]

The files to remove.

@return [void]

# File lib/rub/l/util.rb, line 62
def self.uninstall(what)
        what = R::Tool.make_set_paths what
        
        what.each do |f|
                TargetUninstall.instance.add f
        end
end