Преглед на файлове

Scripts update; for macOS

Arturs Jefimovs преди 1 месец
родител
ревизия
b4ede84221
променени са 5 файла, в които са добавени 64 реда и са изтрити 6 реда
  1. 5 0
      Data/bin/compile.bat
  2. 7 2
      Data/bin/compile.sh
  3. 5 0
      Data/bin/link.bat
  4. 13 4
      Data/bin/link.sh
  5. 34 0
      Data/bin/patch.sh

+ 5 - 0
Data/bin/compile.bat

@@ -30,6 +30,11 @@ IF "%FNAME:~1,2%"==":\" GOTO ENDIF2
 IF NOT EXIST _Build MD _Build
 CD _Build || EXIT /b 407
 
+
+
+
+
+
 SET OFRDIR=%DIR%OfrontPlus\Target\Win32
 SET PATH=%OFRDIR%;%PATH%
 SET OBERON=.;%DIR%..\..\src;%OFRDIR%\Lib\Sym

+ 7 - 2
Data/bin/compile.sh

@@ -1,5 +1,5 @@
 #!/bin/bash
-### This script is automatically run by Free Oberon on Linux
+### This script is automatically run by Free Oberon on Linux and macOS
 ### for each compiled module. The initial current directory of
 ### the script is where FreeOberon executable is located.
 ### You are free to edit this file to adjust the process.
@@ -30,7 +30,12 @@ fi
 mkdir -p _Build
 cd _Build
 
-OFRDIR="$DIR/OfrontPlus/Target/Linux_amd64"
+if [[ "$(uname)" == "Darwin" ]]; then
+  THISOS="macOS"
+else
+  THISOS="Linux_amd64"
+fi
+OFRDIR="$DIR/OfrontPlus/Target/$THISOS"
 PATH="$OFRDIR:$PATH"
 export OBERON=".:$DIR/../../src:$OFRDIR/Lib/Sym"
 OFR="ofront+ -s -88 -7w"

+ 5 - 0
Data/bin/link.bat

@@ -18,6 +18,11 @@ CD _Build >nul 2>&1
 
 SET ONAME=%~n1
 SET GCCDIR=%DIR%mingw32\bin
+
+
+
+
+
 SET FOBDIR=%DIR%..\..
 SET OFRDIR=%DIR%OfrontPlus
 SET OFRTAR=%OFRDIR%\Target\Win32

+ 13 - 4
Data/bin/link.sh

@@ -1,5 +1,5 @@
 #!/bin/bash
-### This script is run by Free Oberon on Linux
+### This script is run by Free Oberon on Linux and macOS
 ### to link user programs.
 ### When it is being run, the current directory
 ### must be the root directory of Free Oberon.
@@ -18,9 +18,14 @@ cd _Build
 THENAME="${1%.*}"
 ONAME="${THENAME##*/}"
 
+if [[ "$(uname)" == "Darwin" ]]; then
+  THISOS="macOS"
+else
+  THISOS="Linux_amd64"
+fi
 FOBDIR="$DIR/../.."
 OFRDIR="$DIR/OfrontPlus"
-OFRTAR="$OFRDIR/Target/Linux_amd64"
+OFRTAR="$OFRDIR/Target/$THISOS"
 PATH="$OFRTAR:$PATH"
 CC="gcc"
 
@@ -42,8 +47,12 @@ done
 
 
 
-# FOR DEBUG ADD: -g -fvar-tracking
-$CC -O0 -g -fvar-tracking -fno-exceptions \
+
+
+
+
+
+$CC -O0 -g -fno-exceptions \
   -I $FOBDIR/src \
   -I $OFRDIR/Mod/Lib \
   -I $OFRTAR/Lib/Obj \

+ 34 - 0
Data/bin/patch.sh

@@ -0,0 +1,34 @@
+#!/bin/bash
+### This script adds a code snippet to the compiled main C file.
+### The snippet is required for Allegro5 required on macOS.
+
+TARGET_FILE="$1"
+TEMP_FILE="temp_${TARGET_FILE}"
+
+if [ ! -f "$TARGET_FILE" ]; then
+    echo "File $TARGET_FILE not found!"
+    exit 1
+fi
+
+PATTERN="\/\*={76}\*\/"
+
+awk -v insertfile="/dev/stdin" '
+{
+    print
+    if ($0 ~ /\/\*={76}\*\//) {
+        while ((getline line < insertfile) > 0) {
+            print line
+        }
+        close(insertfile)
+    }
+}' "$TARGET_FILE" > "$TEMP_FILE" <<'EOF'
+extern INTEGER SYSTEM_argc;
+extern void *SYSTEM_argv;
+#undef main
+#define main(__argc, __argv) _main (void *stktop); \
+  int _al_mangled_main (__argc, __argv) { \
+    SYSTEM_argc = argc; SYSTEM_argv = argv; return _main(&argv); } \
+  int __attribute__ ((noinline)) _main (void *stktop)
+EOF
+
+mv "$TEMP_FILE" "$TARGET_FILE"