package("quickjs-ng") set_homepage("https://github.com/quickjs-ng/quickjs") set_description("QuickJS, the Next Generation: a mighty JavaScript engine") set_license("MIT") add_urls("https://github.com/quickjs-ng/quickjs/archive/refs/tags/$(version).tar.gz", "https://github.com/quickjs-ng/quickjs.git") add_versions("v0.5.0", "41212a6fb84bfe07d61772c02513734b7a06465843ba8f76f1ce1e5df866f489") if is_plat("linux", "bsd") then add_syslinks("m", "pthread") end add_deps("cmake") if on_check then on_check("windows", function (package) local msvc = package:toolchain("msvc") if msvc then local vs = msvc:config("vs") assert(vs and tonumber(vs) >= 2022, "package(quickjs-ng): need vs >= 2022") end end) end on_install("!iphoneos and windows|!x86", function (package) local configs = {} table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) table.insert(configs, "-DCONFIG_ASAN=" .. (package:config("asan") and "ON" or "OFF")) if package:config("shared") and package:is_plat("windows") then table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON") end import("package.tools.cmake").install(package, configs) end) on_test(function (package) assert(package:has_cfuncs("JS_NewRuntime", {includes = "quickjs.h"})) end)