Skip to content

Commit

Permalink
support cross-compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
star-hengxing committed Dec 28, 2024
1 parent 69865d2 commit edecc01
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
12 changes: 12 additions & 0 deletions packages/i/igraph/arith_osx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* Suitable for macOS on x86_64 and arm64 */
/* Not suitable for 32-bit macOS */

#define IEEE_8087
#define Arith_Kind_ASL 1
#define Long int
#define Intcast (int)(long)
#define Double_Align
#define X64_bit_pointers
#define NANCHECK
#define QNaN0 0x0
#define QNaN1 0x7ff80000
8 changes: 8 additions & 0 deletions packages/i/igraph/arith_win32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* Windows 32-bit */

#define IEEE_8087
#define Arith_Kind_ASL 1
#define Double_Align
#define NANCHECK
#define QNaN0 0x0
#define QNaN1 0x7ff80000
8 changes: 8 additions & 0 deletions packages/i/igraph/arith_win64.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* Windows 32-bit */

#define IEEE_8087
#define Arith_Kind_ASL 1
#define Double_Align
#define NANCHECK
#define QNaN0 0x0
#define QNaN1 0x7ff80000
26 changes: 22 additions & 4 deletions packages/i/igraph/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ package("igraph")

on_check(function (package)
if package:is_cross() then
raise("package(igraph) unsupported cross-compilation now")
end
if is_subhost("msys") and xmake:version():lt("2.9.7") then
raise("package(igraph) requires xmake >= 2.9.7 on msys")
if not package:is_plat("windows", "macosx") then
raise("package(igraph) unsupported cross-compilation now. To support it, see https://igraph.org/c/html/latest/igraph-Installation.html#igraph-Installation-cross-compiling")
end
end
end)

Expand All @@ -38,6 +37,7 @@ package("igraph")
end

-- TODO: unbundle deps gmp, arpack, blas, lapack
-- https://igraph.org/c/html/latest/igraph-Installation.html#igraph-Installation-prerequisites
if package:is_plat("linux", "macosx") then
package:add("deps", "gmp")
end
Expand Down Expand Up @@ -89,6 +89,24 @@ package("igraph")
table.insert(configs, "-DIGRAPH_OPENMP_SUPPORT=" .. (package:config("openmp") and "ON" or "OFF"))
-- AUTO -> find_package, ON -> find_dependency (unavailable)
table.insert(configs, "-DIGRAPH_GRAPHML_SUPPORT=" .. (package:config("graphml") and "AUTO" or "OFF"))
if package:is_cross() then
-- from https://github.com/microsoft/vcpkg/tree/0857a4b08c14030bbe41e80accb2b1fddb047a74/ports/igraph
local header
if package:is_plat("macosx") then
header = "arith_osx.h"
elseif package:is_plat("windows") then
if package:is_arch64() then
header = "arith_win64.h"
else
header = "arith_win32.h"
end
end

if header then
local header_path = path.unix(path.join(os.scriptdir(), header))
table.insert(configs, "-DF2C_EXTERNAL_ARITH_HEADER=" .. header_path)
end
end

local opt = {}
if package:config("glpk") then
Expand Down

0 comments on commit edecc01

Please sign in to comment.