diff options
| author | ruki <[email protected]> | 2022-09-16 00:54:06 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-09-16 00:54:06 +0800 |
| commit | de0a0f52c3d83a7b1b079318156a1f99eb53746b (patch) | |
| tree | a094328bc9e939bae3f79bbc4e8bb70564c69613 | |
| parent | 1fb310ac5b3eb8100281021429994c53de30ccfd (diff) | |
pass cross file to meson
| -rw-r--r-- | xmake/modules/package/tools/meson.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/xmake/modules/package/tools/meson.lua b/xmake/modules/package/tools/meson.lua index f76604735..489809702 100644 --- a/xmake/modules/package/tools/meson.lua +++ b/xmake/modules/package/tools/meson.lua @@ -47,6 +47,28 @@ function _map_linkflags(package, targetkind, sourcekinds, name, values) return linker.map_flags(targetkind, sourcekinds, name, values, {target = package}) end +-- is cross compilation? +function _is_cross_compilation(package) + if not package:is_plat(os.subhost()) then + return true + end + if package:is_plat("macosx") and not package:is_arch(os.subarch()) then + return true + end + return false +end + +-- get cross file +function _get_cross_file(package, opt) + local crossfile = path.join(_get_buildir(package, opt), "cross_file.txt") + if not os.isfile(crossfile) then + local file = io.open(crossfile, "w") + file:print("") + file:close() + end + return crossfile +end + -- get configs function _get_configs(package, configs, opt) @@ -73,6 +95,11 @@ function _get_configs(package, configs, opt) table.insert(configs, "-Db_vscrt=" .. package:config("vs_runtime"):lower()) end + -- add cross file + if _is_cross_compilation(package) then + table.insert(configs, "--cross-file=" .. _get_cross_file(package, opt)) + end + -- add build directory table.insert(configs, _get_buildir(package, opt)) return configs |
