diff --git a/xmake-requires.lock b/xmake-requires.lock index ec2f25e..7eae899 100755 --- a/xmake-requires.lock +++ b/xmake-requires.lock @@ -75,12 +75,6 @@ }, version = "3.4" }, - ["imguitextselect#31fecfc4"] = { - repo = { - url = "./xmake" - }, - version = "1.1.1" - }, ["imgui v1.91.0-docking#8ff1f880"] = { branch = "v1.91.0-docking", repo = { @@ -90,6 +84,12 @@ }, version = "v1.91.0-docking" }, + ["imguitextselect#31fecfc4"] = { + repo = { + url = "./xmake" + }, + version = "1.1.1" + }, ["libffi#f26e00a1"] = { repo = { branch = "master", @@ -368,12 +368,6 @@ }, version = "3.4" }, - ["imguitextselect#31fecfc4"] = { - repo = { - url = "./xmake" - }, - version = "1.1.1" - }, ["imgui v1.91.0-docking#8ff1f880"] = { repo = { branch = "master", @@ -382,6 +376,12 @@ }, version = "v1.91.0-docking" }, + ["imguitextselect#31fecfc4"] = { + repo = { + url = "./xmake" + }, + version = "1.1.1" + }, ["ninja#31fecfc4"] = { repo = { branch = "master", @@ -451,9 +451,6 @@ version = "v1.3.1" } }, - __meta__ = { - version = "1.0" - }, ["windows|x64"] = { ["botan#d6ce37d7"] = { repo = { @@ -495,12 +492,6 @@ }, version = "3.4" }, - ["imguitextselect#31fecfc4"] = { - repo = { - url = "./xmake" - }, - version = "1.1.1" - }, ["imgui v1.91.0-docking#8ff1f880"] = { repo = { branch = "master", @@ -509,6 +500,12 @@ }, version = "v1.91.0-docking" }, + ["imguitextselect#31fecfc4"] = { + repo = { + url = "./xmake" + }, + version = "1.1.1" + }, ["ninja#31fecfc4"] = { repo = { branch = "master", @@ -578,4 +575,4 @@ version = "v1.3.1" } } -} +} \ No newline at end of file diff --git a/xmake.lua b/xmake.lua index 2638517..10faf9e 100755 --- a/xmake.lua +++ b/xmake.lua @@ -169,11 +169,11 @@ target("WhaleConnect") -- Download font files next to executable on pre-build before_build(function (target) - import("xmake.download").download_fonts(target:targetdir()) + import("xmake.download").downloadFonts(target:targetdir()) end) after_install(function (target) - import("xmake.download").download_licenses(target:installdir()) + import("xmake.download").downloadLicenses(target:installdir()) end) target("socket-tests") diff --git a/xmake/download.lua b/xmake/download.lua index 1ff3946..f87a83d 100755 --- a/xmake/download.lua +++ b/xmake/download.lua @@ -1,13 +1,13 @@ -- Copyright 2021-2024 Aidan Sun and the WhaleConnect contributors -- SPDX-License-Identifier: GPL-3.0-or-later -function download_licenses(installdir) +function downloadLicenses(installdir) print("Downloading licenses...") -- Licenses are installed to Resources in macOS bundle - local target_dir = is_plat("macosx") and path.join(installdir, "Contents", "Resources") or installdir + local targetDir = is_plat("macosx") and path.join(installdir, "Contents", "Resources") or installdir - local license_files = { + local licenseFiles = { -- Libraries ["bluez"] = { "https://raw.githubusercontent.com/bluez/bluez/master/LICENSES/preferred/GPL-2.0" }, ["botan"] = { "https://raw.githubusercontent.com/randombit/botan/master/license.txt" }, @@ -30,28 +30,28 @@ function download_licenses(installdir) } local http = import("net.http") - for name, urls in pairs(license_files) do + for name, urls in pairs(licenseFiles) do for _, url in ipairs(urls) do local filename = path.filename(url) - local target_path = path.join(target_dir, "3rdparty", name, filename) + local targetPath = path.join(targetDir, "3rdparty", name, filename) - if not os.isfile(target_path) then - print("- %s -> %s", url, target_path) - http.download(url, target_path) + if not os.isfile(targetPath) then + print("- %s -> %s", url, targetPath) + http.download(url, targetPath) end end end end -function download_fonts(targetdir) - local font_path = path.join(targetdir, "NotoSansMono-Regular.ttf") - local icon_font_path = path.join(targetdir, "remixicon.ttf") +function downloadFonts(targetdir) + local fontPath = path.join(targetdir, "NotoSansMono-Regular.ttf") + local iconFontPath = path.join(targetdir, "remixicon.ttf") - if not os.isfile(font_path) then - os.ln(os.getenv("NOTO_SANS_MONO_PATH"), font_path) + if not os.isfile(fontPath) then + os.ln(os.getenv("NOTO_SANS_MONO_PATH"), fontPath) end - if not os.isfile(icon_font_path) then - os.ln(os.getenv("REMIX_ICON_PATH"), icon_font_path) + if not os.isfile(iconFontPath) then + os.ln(os.getenv("REMIX_ICON_PATH"), iconFontPath) end end diff --git a/xmake/parse_lock_file.lua b/xmake/parse_lock_file.lua index d24f121..1d266aa 100755 --- a/xmake/parse_lock_file.lua +++ b/xmake/parse_lock_file.lua @@ -6,49 +6,53 @@ import("core.base.json") import("core.base.semver") -all_packages = {} +allPackages = {} -function record_packages(packages, os_key) +function recordPackages(packages, osKey) for package, info in pairs(packages) do local name = package:match("^([%w_%-]+)") - if all_packages[name] == nil then + if allPackages[name] == nil then local version = info["version"] - local parsed_version = semver.is_valid(version) and semver.new(version):shortstr() or version + local parsedVersion = semver.is_valid(version) and semver.new(version):shortstr() or version local online = info["repo"]["url"]:match("^https://") - local repo_root = online + local repoRoot = online and path.join(val("globaldir"), "repositories", "xmake-repo") or path.join(val("projectdir"), "xmake") - all_packages[name] = { - version = parsed_version, - filepath = path.join(repo_root, "packages", name:sub(1, 1), name, "xmake.lua"), + allPackages[name] = { + filepath = path.join(repoRoot, "packages", name:sub(1, 1), name, "xmake.lua"), os = {} } + + local prevVersion = allPackages[name]["version"] + if prevVersion == nil or (semver.is_valid(prevVersion) and semver.compare(parsedVersion, prevVersion) == 1) then + allPackages[name]["version"] = parsedVersion + end end - table.insert(all_packages[name]["os"], os_key) + table.insert(allPackages[name]["os"], osKey) end end function main(...) - package_info = io.load(path.join(os.projectdir(), "xmake-requires.lock")) - for platform, packages in pairs(package_info) do + pkgInfo = io.load(path.join(os.projectdir(), "xmake-requires.lock")) + for platform, packages in pairs(pkgInfo) do if platform ~= "__meta__" then local os = platform:match("(.+)|") - local os_key = "" + local osKey = "" if os == "linux" then - os_key = "L" + osKey = "L" elseif os == "macosx" then - os_key = "M" + osKey = "M" elseif os == "windows" then - os_key = "W" + osKey = "W" end - record_packages(packages, os_key) + recordPackages(packages, osKey) end end - json.savefile(path.join(os.projectdir(), "build", "packages.json"), all_packages) + json.savefile(path.join(os.projectdir(), "build", "packages.json"), allPackages) end