<commit_before>--!A cross-platform build utility based on Lua
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
--     http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- 
-- Copyright (C) 2015 - 2019, TBOOX Open Source Group.
--
-- @author      ruki
-- @file        xmake.lua
--

-- define rule: environment
rule("cuda.env")

    before_load(function (target)

        -- imports
        import("detect.sdks.find_cuda")

        -- find cuda sdk first
        local cuda = assert(find_cuda(nil, {verbose = true}), "Cuda SDK not found!")
        if cuda then
            target:data_set("cuda", cuda)
        end
    end)

    after_load(function (target)

        -- imports
        import("core.platform.platform")

        -- get cuda sdk
        local cuda = assert(target:data("cuda"), "Cuda SDK not found!")

        -- add arch
        if is_arch("i386", "x86") then
            target:add("cuflags", "-m32", {force = true})
            target:add("culdflags", "-m32", {force = true})
        else
            target:add("cuflags", "-m64", {force = true})
            target:add("culdflags", "-m64", {force = true})
        end

        -- add ccbin
        local cu_ccbin = platform.tool("cu-ccbin")
        if cu_ccbin then
            target:add("culdflags", "-ccbin=" .. os.args(cu_ccbin), {force = true})
        end

        -- add links
        target:add("syslinks", "cudadevrt")
        local cudart = false
        for _, link in ipairs(table.join(target:get("links") or {}, target:get("syslinks"))) do
            if link == "cudart" or link == "cudart_static" then
                cudart = true
                break
            end
        end
        if not cudart then
            target:add("syslinks", "cudart_static")
        end
        if is_plat("linux") then
            target:add("syslinks", "rt", "pthread", "dl")
        end
        target:add("linkdirs", cuda.linkdirs)
        target:add("rpathdirs", cuda.linkdirs)

        -- add includedirs
        target:add("includedirs", cuda.includedirs)
    end)
<commit_msg>use cudagdb for cuda programs<commit_after>--!A cross-platform build utility based on Lua
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
--     http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- 
-- Copyright (C) 2015 - 2019, TBOOX Open Source Group.
--
-- @author      ruki
-- @file        xmake.lua
--

-- define rule: environment
rule("cuda.env")

    before_load(function (target)

        -- imports
        import("detect.sdks.find_cuda")

        -- find cuda sdk first
        local cuda = assert(find_cuda(nil, {verbose = true}), "Cuda SDK not found!")
        if cuda then
            target:data_set("cuda", cuda)
        end
    end)

    after_load(function (target)

        -- imports
        import("core.platform.platform")

        -- get cuda sdk
        local cuda = assert(target:data("cuda"), "Cuda SDK not found!")

        -- add arch
        if is_arch("i386", "x86") then
            target:add("cuflags", "-m32", {force = true})
            target:add("culdflags", "-m32", {force = true})
        else
            target:add("cuflags", "-m64", {force = true})
            target:add("culdflags", "-m64", {force = true})
        end

        -- add ccbin
        local cu_ccbin = platform.tool("cu-ccbin")
        if cu_ccbin then
            target:add("culdflags", "-ccbin=" .. os.args(cu_ccbin), {force = true})
        end

        -- add links
        target:add("syslinks", "cudadevrt")
        local cudart = false
        for _, link in ipairs(table.join(target:get("links") or {}, target:get("syslinks"))) do
            if link == "cudart" or link == "cudart_static" then
                cudart = true
                break
            end
        end
        if not cudart then
            target:add("syslinks", "cudart_static")
        end
        if is_plat("linux") then
            target:add("syslinks", "rt", "pthread", "dl")
        end
        target:add("linkdirs", cuda.linkdirs)
        target:add("rpathdirs", cuda.linkdirs)

        -- add includedirs
        target:add("includedirs", cuda.includedirs)
    end)

    before_run(function (target)
        import("core.project.config")
        import("lib.detect.find_tool")

        local debugger = config.get("debugger")
        if not debugger and find_tool("cudagdb") then
            config.set("debugger", "cudagdb")
        end
    end)

{'fraction_non_alphanumeric': 0.12667295004712537, 'fraction_numerical': 0.00942507068803016, 'mean_word_length': 2.115678214914856, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6863676', 'n_tokens_mistral': 1627, 'n_tokens_neox': 1558, 'n_words': 475}