Skip to content

Commit

Permalink
improve on_fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
star-hengxing committed Nov 15, 2024
1 parent f879b6e commit a030f5c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
31 changes: 17 additions & 14 deletions packages/o/openjdk/fetch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@ function main(package, opt)
local java = package:find_tool("java", opt)
if not java then return end

local result = {}
result.version = java.version

if package:is_binary() then
return true
else
if is_host("windows") then
local sdkdir = os.getenv("JAVA_HOME")
if not os.isdir(sdkdir) then
return
end
return result
end

local result = {}
result.version = java.version
result.includedirs = {path.join(sdkdir, "include"), path.join(sdkdir, "include", "win32")}
result.linkdirs = path.join(sdkdir, "lib")
result.links = {"jvm", "jawt"}
package:addenv("PATH", path.join(sdkdir, "bin"), path.join(sdkdir, "bin", "server"))
return result
if is_host("windows") then
local sdkdir = os.getenv("JAVA_HOME")
if not os.isdir(sdkdir) then
return
end

result.includedirs = {path.join(sdkdir, "include"), path.join(sdkdir, "include", "win32")}
result.linkdirs = path.join(sdkdir, "lib")
result.links = {"jvm", "jawt"}
package:addenv("PATH", path.join(sdkdir, "bin"), path.join(sdkdir, "bin", "server"))
return result
end
-- TODO: linux, mac
-- ubuntu: /usr/lib/jvm/java-11-openjdk-amd64
end
7 changes: 5 additions & 2 deletions packages/o/openjdk/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@ package("openjdk")
add_configs("debug", {description = "Enable debug symbols.", default = false, type = "boolean", readonly = true})

if is_plat("linux") then
add_deps("alsa-lib", {configs = {shared = true, versioned = false}})
add_deps("freetype", "libxtst", "libxi", "libxrender")
add_extsources("pacman::jdk-openjdk", "apt::default-jdk")
elseif is_plat("macosx") then
add_extsources("brew::openjdk")
end

if is_plat("linux") then
add_deps("alsa-lib", {configs = {shared = true, versioned = false}})
add_deps("freetype", "libxtst", "libxi", "libxrender")
end

set_policy("package.precompiled", false)

on_fetch("fetch")
Expand Down

0 comments on commit a030f5c

Please sign in to comment.