-
-
Save mgorges/037acf44b4ac580e6101fa54acabe2cf to your computer and use it in GitHub Desktop.
Patch to allow shared c-file cache between architectures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/languages/scm.sh b/languages/scm.sh | |
index adbd341..5aa09437 100644 | |
--- a/languages/scm.sh | |
+++ b/languages/scm.sh | |
@@ -78,8 +78,16 @@ compile_payload_scm() | |
else | |
rmifexists ${SYS_HOSTPREFIX}/lib/gambcext.o1 | |
fi | |
- #-------- | |
- # compile scheme source files | |
+ #------- | |
+ # Allow the user to override global C file caching | |
+ if [ "X$TARGETED_C_PATH" = "X" ]; then | |
+ c_path=$SYS_PREFIXROOT/build | |
+ else | |
+ c_path=$SYS_PREFIX/build | |
+ fi | |
+ o_path=$SYS_PREFIX/build | |
+ #------- | |
+ # Preparing C files from SCM first | |
mkdir -p "$SYS_PREFIX/build" | |
scm_csrcs= | |
scm_link_dirty=no | |
@@ -87,59 +95,66 @@ compile_payload_scm() | |
dmsg_scm "compiling $scm_src .." | |
scm_path=`dirname $scm_src` | |
scm_chsh=`stringhash "$scm_src"` | |
- scm_ctgt="$SYS_PREFIX/build/${scm_chsh}.c" | |
- scm_otgt="$SYS_PREFIX/build/${scm_chsh}.o" | |
+ scm_ctgt="$c_path/${scm_chsh}.c" | |
scm_dirty=no | |
scm_hdr="$scm_path/"`basename $scm_src .scm`.sch | |
- if [ ! -f $scm_otgt ] || [ ! -f $scm_ctgt ]; then | |
+ if [ ! -f $scm_ctgt ]; then | |
scm_dirty=yes | |
else | |
scm_topdir=`dirname $scm_src` | |
scm_topdir=`basename $scm_topdir` | |
if [ "X$scm_topdir" = "Xtextures" ] || [ "X$scm_topdir" = "Xstrings" ] || [ "Xscm_$topdir" = "Xfonts" ]; then | |
- if [ `isnewer "$scm_src" "$scm_otgt"` = "yes" ]; then | |
+ if [ `isnewer "$scm_src" "$scm_ctgt"` = "yes" ]; then | |
scm_dirty=yes | |
fi | |
else | |
- if [ `newersourceindir "$scm_src" "$scm_otgt"` = "yes" ]; then | |
+ if [ `newersourceindir "$scm_src" "$scm_ctgt"` = "yes" ]; then | |
scm_dirty=yes | |
fi | |
- # This is actually much too less, should test all included/loaded files too. | |
- if [ -f $scm_hdr -a `isnewer "$scm_hdr" "$scm_otgt"` = "yes" ]; then | |
+ # This is actually much too less, should test all included/loaded files too. | |
+ if [ -f $scm_hdr -a `isnewer "$scm_hdr" "$scm_ctgt"` = "yes" ]; then | |
+ scm_dirty=yes | |
+ fi | |
+ # ln_repl module special-case: always re-compile to make global macro changes available | |
+ if [ "X$scm_topdir" = "Xln_repl" ]; then | |
scm_dirty=yes | |
fi | |
- # ln_repl module special-case: always re-compile to make global macro changes available | |
- if [ "X$scm_topdir" = "Xln_repl" ]; then | |
- scm_dirty=yes | |
- fi | |
fi | |
fi | |
if [ $scm_dirty = yes ]; then | |
echo " $scm_src .." | |
scm_link_dirty=yes | |
rmifexists "$scm_ctgt" | |
- if [ -f $scm_hdr ]; then scm_hdr="-e '(load \"$scm_hdr\")'"; else scm_hdr=""; fi | |
- gsc_processing="" | |
- # if [ $SYS_VERBOSE ]; then gsc_processing="$gsc_processing -expansion"; fi | |
- veval "$SYS_GSC -:~~tgt=${SYS_PREFIX} -prelude \"$scm_opts\" -c -o $scm_ctgt $gsc_processing $scm_hdr $scm_src" | |
+ if [ -f $scm_hdr ]; then scm_hdr="-e '(load \"$scm_hdr\")'"; else scm_hdr=""; fi | |
+ gsc_processing="" | |
if [ $veval_result != "0" ]; then rmifexists "$scm_ctgt"; fi | |
+ veval "$SYS_GSC -:~~tgt=${SYS_PREFIX} -warnings -prelude \"$scm_opts\" -c -o $scm_ctgt $scm_src" | |
assertfile "$scm_ctgt" | |
- rmifexists "$scm_otgt" | |
- veval "$SYS_ENV $SYS_CC $payload_cdefs -c -o $scm_otgt $scm_ctgt -I$SYS_PREFIX/include -I$SYS_PREFIX/include/freetype2 -I$scm_path" | |
- assertfile "$scm_otgt" | |
fi | |
scm_csrcs="$scm_csrcs $scm_ctgt" | |
- payload_objs="$payload_objs $scm_otgt" | |
+ done | |
+ # ------ | |
+ # compile c files if needed | |
+ for c_src in $scm_csrcs; do | |
+ dmsg_scm "compiling $c_src .." | |
+ c_src_base=`basename ${c_src}` | |
+ c_otgt=`echo "$o_path/$c_src_base" | sed 's/c$/o/'` | |
+ if [ ! -f $c_otgt -o `isnewer "$c_src" "$c_otgt"` = "yes" ]; then | |
+ rmifexists "$c_otgt" | |
+ veval "$SYS_ENV $SYS_CC $payload_cdefs -c -o $c_otgt $c_src -I$SYS_PREFIX/include -I$SYS_PREFIX/include/freetype2 -I$scm_path" | |
+ assertfile "$c_otgt" | |
+ fi | |
+ payload_objs="$payload_objs $c_otgt" | |
done | |
# ------- | |
# compile scheme linker file | |
- scm_lctgt=`echo "$scm_ctgt" | sed 's/\.c$/\_\.c/'` | |
- scm_lotgt=`echo "$scm_lctgt" | sed 's/c$/o/'` | |
+ scm_lctgt="$c_path/${scm_chsh}_.c" | |
+ scm_lotgt="$o_path/${scm_chsh}_.o" | |
if [ $scm_link_dirty = yes ] || [ ! -f $scm_lotgt ]; then | |
- vecho "$SYS_GSC -link $scm_csrcs" | |
+ vecho "$SYS_GSC -warnings -link $scm_csrcs" | |
scm_link_here=`pwd` | |
cd `dirname $scm_lctgt` | |
- $SYS_GSC -link $scm_csrcs | |
+ $SYS_GSC -warnings -link $scm_csrcs | |
cd $scm_link_here | |
assertfile $scm_lctgt | |
veval "$SYS_ENV $SYS_CC $payload_cdefs -o $scm_lotgt -c $scm_lctgt -I$SYS_PREFIX/include" | |
@@ -148,7 +163,7 @@ compile_payload_scm() | |
payload_objs="$payload_objs $scm_lotgt" | |
# ------- | |
# compile scheme hook | |
- scm_hctgt="$SYS_PREFIX/build/scm_hook.c" | |
+ scm_hctgt="$o_path/scm_hook.c" | |
scm_hotgt=`echo "$scm_hctgt" | sed 's/c$/o/'` | |
scm_hooksrc=`locatefile "languages/scm.c" silent` | |
assertfile $scm_hooksrc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment