Skip to content

Commit

Permalink
improve links
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Feb 25, 2025
1 parent c1fac4f commit ac47c85
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions tests/projects/kotlin-native/package/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ add_rules("mode.debug", "mode.release")

add_requires("kotlin-native")
add_requires("kotlin-native::org.jetbrains.kotlinx:kotlinx-serialization-json 1.8.0", {alias = "json"})
add_requires("kotlin-native::org.jetbrains.kotlinx:kotlinx-serialization-json 1.8.0", {alias = "json"})

target("test")
set_kind("binary")
Expand Down
9 changes: 5 additions & 4 deletions xmake/languages/kotlin/load.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,26 @@ function _get_apis()
, "target.add_ldflags"
, "target.add_arflags"
, "target.add_shflags"
, "target.add_rpathdirs" -- @note do not translate path, it's usually an absolute path or contains $ORIGIN/@loader_path
, "target.add_links"
-- option.add_xxx
, "option.add_kcflags"
, "option.add_ldflags"
, "option.add_arflags"
, "option.add_shflags"
, "option.add_rpathdirs"
, "option.add_links"
-- toolchain.add_xxx
, "toolchain.add_kcflags"
, "toolchain.add_ldflags"
, "toolchain.add_arflags"
, "toolchain.add_shflags"
, "toolchain.add_rpathdirs"
, "toolchain.add_links"
}
apis.paths = {
-- target.add_xxx
"target.add_linkdirs"
-- option.add_xxx
, "option.add_linkdirs"
-- toolchain.add_xxx
, "toolchain.add_linkdirs"
}
return apis
end
Expand Down
4 changes: 0 additions & 4 deletions xmake/languages/kotlin/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ language("kotlin")
, "config.frameworkdirs"
, "target.linkdirs"
, "target.frameworkdirs"
, "target.rpathdirs"
, "target.strip"
, "target.symbols"
, "toolchain.linkdirs"
, "toolchain.frameworkdirs"
, "toolchain.rpathdirs"
, "config.frameworks"
, "target.frameworks"
, "toolchain.frameworks"
Expand All @@ -63,12 +61,10 @@ language("kotlin")
, "config.frameworkdirs"
, "target.linkdirs"
, "target.frameworkdirs"
, "target.rpathdirs"
, "target.strip"
, "target.symbols"
, "toolchain.linkdirs"
, "toolchain.frameworkdirs"
, "toolchain.rpathdirs"
, "config.frameworks"
, "target.frameworks"
, "toolchain.frameworks"
Expand Down
5 changes: 5 additions & 0 deletions xmake/modules/core/tools/kotlinc_native.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ import("lib.detect.find_tool")
function init(self)
end

-- make the link flag
function nf_link(self, lib)
return {"-l", lib}
end

-- make the build arguments list
function buildargv(self, sourcefiles, targetkind, targetfile, flags, opt)
return self:program(), table.join(flags, sourcefiles, "-o", targetfile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,14 @@ end
function _install_package(name, opt)
local installdir = opt.installdir
local basename = name:split(":")[2] .. "-" .. opt.triplet
local library_file = path.join(installdir, "lib", basename .. ".klib")
local library_url = ("%s/%s-%s/%s-%s.klib"):format(opt.repository, (name:gsub("%.", "/"):gsub(":", "/")), opt.triplet, basename, opt.version)
local library_file = path.join(installdir, "klib", "platform", opt.plat .. "_" .. opt.arch, basename .. ".klib")
local library_url = ("%s/%s-%s/%s/%s-%s.klib"):format(opt.repository, (name:gsub("%.", "/"):gsub(":", "/")), opt.triplet, opt.version, basename, opt.version)
http.download(library_url, library_file, {
insecure = global.get("insecure-ssl")})

local manifest_file = path.join(installdir, "installed_manifest.txt")
io.save(manifest_file, {
links = basename,
linkdirs = path.directory(library_file),
links = library_file,
libfiles = library_file,
version = opt.version})
end
Expand Down Expand Up @@ -107,6 +106,8 @@ function main(name, opt)

-- do install
_install_package(name, {
plat = plat,
arch = arch,
triplet = triplet,
installdir = installdir,
version = version,
Expand Down

0 comments on commit ac47c85

Please sign in to comment.