<commit_before>--!The Automatic Cross-platform Build Tool
-- 
-- XMake is free software; you can redistribute it and/or modify
-- it under the terms of the GNU Lesser General Public License as published by
-- the Free Software Foundation; either version 2.1 of the License, or
-- (at your option) any later version.
-- 
-- XMake is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU Lesser General Public License for more details.
-- 
-- You should have received a copy of the GNU Lesser General Public License
-- along with XMake; 
-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
-- 
-- Copyright (C) 2009 - 2015, ruki All rights reserved.
--
-- @author      ruki
-- @file        makefile.lua
--

-- define module: makefile
local makefile = makefile or {}

-- load modules
local io        = require("base/io")
local os        = require("base/os")
local rule      = require("base/rule")
local path      = require("base/path")
local utils     = require("base/utils")
local config    = require("base/config")
local project   = require("base/project")
local linker    = require("base/linker")
local compiler  = require("base/compiler")
local tools     = require("tools/tools")
local platform  = require("platform/platform")

-- make the object to the makefile
function makefile._make_object(file, target, srcfile, objfile, percent)
    
    -- check
    assert(file and target and srcfile and objfile)

    -- get the compiler 
    local c, errors = compiler.get(srcfile)
    if not c then
        -- error
        utils.error(errors)
        return false
    end

    -- get mode
    local mode = config.get("mode") or ""
    if mode == "release" then mode = ".r"
    elseif mode == "debug" then mode = ".d"
    elseif mode == "profile" then mode = ".p"
    else mode = "" end

    -- get ccache
    local ccache = platform.tool("ccache") 

    -- make command
    local cmd = compiler.make(c, target, srcfile, objfile, makefile._LOGFILE)
    if ccache then
        cmd = ccache:append(cmd, " ")
    end

    -- make head
    file:write(string.format("%s:", objfile))

    -- make dependence
    file:write(string.format(" %s\n", srcfile))

    -- make body
    file:write(string.format("\t@echo [%2d%%] %scompiling%s %s\n", percent, utils.ifelse(ccache, "ccache ", ""), mode, srcfile))
    file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:gsub("[%s=\"]", function (w) return string.format("%%%x", w:byte()) end)))
    file:write(string.format("\t@xmake l mkdir %s\n", path.directory(objfile)))
    file:write(string.format("\t@%s\n", cmd))

    -- make tail
    file:write("\n")

    -- ok
    return true
end

-- make all objects of the given target to the makefile
function makefile._make_objects(file, target, srcfiles, objfiles)

    -- check
    assert(file and target and srcfiles and objfiles)

    -- make all objects
    local i = 1
    local n = #objfiles
    for _, objfile in ipairs(objfiles) do

        -- make object
        if not makefile._make_object(file, target, srcfiles[i], objfile, (i - 1) * 100 / n) then
            return false
        end

        -- next
        i = i + 1
    end

    -- ok
    return true
end

-- make the given target to the makefile
function makefile._make_target(file, name, target)

    -- check
    assert(file and name and target and target.kind)<commit_msg>remove progress for makefile<commit_after>--!The Automatic Cross-platform Build Tool
-- 
-- XMake is free software; you can redistribute it and/or modify
-- it under the terms of the GNU Lesser General Public License as published by
-- the Free Software Foundation; either version 2.1 of the License, or
-- (at your option) any later version.
-- 
-- XMake is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU Lesser General Public License for more details.
-- 
-- You should have received a copy of the GNU Lesser General Public License
-- along with XMake; 
-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
-- 
-- Copyright (C) 2009 - 2015, ruki All rights reserved.
--
-- @author      ruki
-- @file        makefile.lua
--

-- define module: makefile
local makefile = makefile or {}

-- load modules
local io        = require("base/io")
local os        = require("base/os")
local rule      = require("base/rule")
local path      = require("base/path")
local utils     = require("base/utils")
local config    = require("base/config")
local project   = require("base/project")
local linker    = require("base/linker")
local compiler  = require("base/compiler")
local tools     = require("tools/tools")
local platform  = require("platform/platform")

-- make the object to the makefile
function makefile._make_object(file, target, srcfile, objfile)
    
    -- check
    assert(file and target and srcfile and objfile)

    -- get the compiler 
    local c, errors = compiler.get(srcfile)
    if not c then
        -- error
        utils.error(errors)
        return false
    end

    -- get mode
    local mode = config.get("mode") or ""
    if mode == "release" then mode = ".r"
    elseif mode == "debug" then mode = ".d"
    elseif mode == "profile" then mode = ".p"
    else mode = "" end

    -- get ccache
    local ccache = platform.tool("ccache") 

    -- make command
    local cmd = compiler.make(c, target, srcfile, objfile, makefile._LOGFILE)
    if ccache then
        cmd = ccache:append(cmd, " ")
    end

    -- make head
    file:write(string.format("%s:", objfile))

    -- make dependence
    file:write(string.format(" %s\n", srcfile))

    -- make body
    file:write(string.format("\t@echo %scompiling%s %s\n", utils.ifelse(ccache, "ccache ", ""), mode, srcfile))
    file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:gsub("[%s=\"]", function (w) return string.format("%%%x", w:byte()) end)))
    file:write(string.format("\t@xmake l mkdir %s\n", path.directory(objfile)))
    file:write(string.format("\t@%s\n", cmd))

    -- make tail
    file:write("\n")

    -- ok
    return true
end

-- make all objects of the given target to the makefile
function makefile._make_objects(file, target, srcfiles, objfiles)

    -- check
    assert(file and target and srcfiles and objfiles)

    -- make all objects
    local i = 1
    for _, objfile in ipairs(objfiles) do

        -- make object
        if not makefile._make_object(file, target, srcfiles[i], objfile) then
            return false
        end

        -- next
        i = i + 1
    end

    -- ok
    return true
end

-- make the given target to the makefile
function makefile._make_target(file, name, target)

    -- check
    assert(file and name and target and target.kind)
{'fraction_non_alphanumeric': 0.12772988505747127, 'fraction_numerical': 0.004166666666666667, 'mean_word_length': 2.7066027689030885, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5373148', 'n_tokens_mistral': 2119, 'n_tokens_neox': 2061, 'n_words': 732}