Skip to content

Commit 071b7f1

Browse files
authored
Fix cargo path and add CARGO_TARGET for cross compile (python#19)
There are still some issues with compilation, but those can be sorted out in a future PR.
1 parent c9deee6 commit 071b7f1

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

Makefile.pre.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ DSYMUTIL_PATH= @DSYMUTIL_PATH@
6161
CARGO_HOME=@CARGO_HOME@
6262
CARGO_TARGET_DIR=@CARGO_TARGET_DIR@
6363
CARGO_PROFILE=@CARGO_PROFILE@
64+
CARGO_TARGET=@CARGO_TARGET@
6465

6566
GNULD= @GNULD@
6667

@@ -3373,7 +3374,7 @@ Python/thread.o: @THREADHEADERS@ $(srcdir)/Python/condvar.h
33733374
# Module dependencies and platform-specific files
33743375

33753376
cpython-sys: Modules/cpython-sys/Cargo.toml Modules/cpython-sys/build.rs Modules/cpython-sys/wrapper.h Modules/cpython-sys/parser.h
3376-
CARGO_TARGET_DIR=$(abs_builddir)/target PYTHON_BUILD_DIR=$(abs_builddir) cargo build --lib --locked --package cpython-sys --profile $(CARGO_PROFILE) --manifest-path $(srcdir)/Cargo.toml
3377+
CARGO_TARGET_DIR=$(abs_builddir)/target PYTHON_BUILD_DIR=$(abs_builddir) \$(CARGO_HOME)/bin/cargo build --lib --locked --package cpython-sys --profile $(CARGO_PROFILE) $(if $(CARGO_TARGET),--target=$(CARGO_TARGET)) --manifest-path $(srcdir)/Cargo.toml
33773378

33783379
# force rebuild when header file or module build flavor (static/shared) is changed
33793380
MODULE_DEPS_STATIC=Modules/config.c

Modules/makesetup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
287287
libs=
288288
# depends on the headers through cpython-sys
289289
rule="$objs: cpython-sys \$(srcdir)/Cargo.toml \$(srcdir)/Cargo.lock \$(srcdir)/$srcdir/$manifest $prefixed_srcs \$(PYTHON_HEADERS)"
290-
rule="$rule; CARGO_TARGET_DIR=\$(abs_builddir)/target PYTHON_BUILD_DIR=\$(abs_builddir) cargo build --lib --locked --package ${mods} --profile \$(CARGO_PROFILE) --manifest-path \$(srcdir)/Cargo.toml"
290+
rule="$rule; CARGO_TARGET_DIR=\$(abs_builddir)/target PYTHON_BUILD_DIR=\$(abs_builddir) \$(CARGO_HOME)/bin/cargo build --lib --locked --package ${mods} --profile \$(CARGO_PROFILE) \$(if \$(CARGO_TARGET),--target=\$(CARGO_TARGET)) --manifest-path \$(srcdir)/Cargo.toml"
291291
echo "$rule" >>$rulesf
292292
for mod in $mods
293293
do

configure

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4328,10 +4328,20 @@ else
43284328
CARGO_TARGET_DIR='debug'
43294329
CARGO_PROFILE='dev'
43304330
fi
4331+
# Set CARGO_TARGET for cross-compilation
4332+
case "$host" in
4333+
aarch64-apple-ios-simulator)
4334+
CARGO_TARGET="aarch64-apple-ios-sim"
4335+
;;
4336+
*)
4337+
CARGO_TARGET="$host"
4338+
;;
4339+
esac
43314340
fi
43324341
AC_SUBST([CARGO_HOME])
43334342
AC_SUBST([CARGO_TARGET_DIR])
43344343
AC_SUBST([CARGO_PROFILE])
4344+
AC_SUBST([CARGO_TARGET])
43354345

43364346

43374347
dnl detect sqlite3 from Emscripten emport

0 commit comments

Comments
 (0)