diff options
| author | ruki <[email protected]> | 2020-10-24 00:50:22 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-10-24 00:50:22 +0800 |
| commit | 1d192142d27973332edae50e0b1c4a37080ea65f (patch) | |
| tree | 6a7e434741cc85aec6ff9c2d23bd7f1485fb305c /xmake/actions/require/fetch.lua | |
| parent | d0ae5c6e46a2a90974b6dd478464e77453fe3352 (diff) | |
fetch cflags and ldflags
Diffstat (limited to 'xmake/actions/require/fetch.lua')
| -rw-r--r-- | xmake/actions/require/fetch.lua | 57 |
1 files changed, 50 insertions, 7 deletions
diff --git a/xmake/actions/require/fetch.lua b/xmake/actions/require/fetch.lua index eb125eb53..da4157226 100644 --- a/xmake/actions/require/fetch.lua +++ b/xmake/actions/require/fetch.lua @@ -19,17 +19,12 @@ -- -- imports -import("core.base.task") import("core.base.option") import("core.base.hashset") import("core.project.project") import("core.package.package", {alias = "core_package"}) -import("devel.git") -import("utils.archive") -import("impl.utils.filter") import("impl.package") import("impl.repository") -import("impl.environment") import("impl.utils.get_requires") -- fetch the given package info @@ -42,10 +37,21 @@ function main(requires_raw) return end + -- get the fetching modes + local fetchmodes = option.get("fetch_modes") + if fetchmodes then + fetchmodes = hashset.from(fetchmodes:split(',', {plain = true})) + end + -- fetch all packages local fetchinfos = {} for _, instance in ipairs(package.load_packages(requires, {requires_extra = requires_extra})) do - local fetchinfo = instance:fetch() + local fetchinfo + if fetchmodes and fetchmodes:has("deps") then + fetchinfo = instance:fetchdeps() + else + fetchinfo = instance:fetch() + end if fetchinfo then table.insert(fetchinfos, fetchinfo) end @@ -53,7 +59,44 @@ function main(requires_raw) -- show results if #fetchinfos > 0 then - print(fetchinfos) + local flags = {} + if fetchmodes:has("cflags") then + for _, fetchinfo in ipairs(fetchinfos) do + for _, includedir in ipairs(fetchinfo.includedirs) do + table.insert(flags, "-I" .. os.args(includedir)) + end + for _, define in ipairs(fetchinfo.defines) do + table.insert(flags, "-D" .. define) + end + for _, cflag in ipairs(fetchinfo.cflags) do + table.insert(flags, cflag) + end + for _, cxflag in ipairs(fetchinfo.cxflags) do + table.insert(flags, cxflag) + end + for _, cxxflag in ipairs(fetchinfo.cxxflags) do + table.insert(flags, cxxflag) + end + end + end + if fetchmodes:has("ldflags") then + for _, fetchinfo in ipairs(fetchinfos) do + for _, linkdir in ipairs(fetchinfo.linkdirs) do + table.insert(flags, "-L" .. os.args(linkdir)) + end + for _, link in ipairs(fetchinfo.links) do + table.insert(flags, "-l" .. link) + end + for _, ldflag in ipairs(fetchinfo.ldflags) do + table.insert(flags, ldflags) + end + end + end + if #flags > 0 then + print(table.concat(flags, " ")) + else + print(fetchinfos) + end end end |
