Browse Source

Windows: restore functionality after split to FreeOberon and fob

Arthur Yefimov 3 years ago
parent
commit
acc8eecb9d
8 changed files with 117 additions and 40 deletions
  1. 21 5
      Data/bin/compile.bat
  2. 3 5
      Data/bin/compile.sh
  3. 17 6
      Data/bin/link_console.bat
  4. 17 6
      Data/bin/link_graph.bat
  5. 2 1
      src/Builder.Mod
  6. 17 9
      src/Env.Mod
  7. 21 7
      src/make.bat
  8. 19 1
      src/make.sh

+ 21 - 5
Data/bin/compile.bat

@@ -4,15 +4,31 @@ REM for each compiled module. The initial current directory of
 REM the script is where FreeOberon executable is located.
 REM the script is where FreeOberon executable is located.
 REM You are free to edit this file to adjust the process.
 REM You are free to edit this file to adjust the process.
 
 
-CD bin >nul 2>&1
-SET CURDIR=%~dp0
-SET OFRDIR=%CURDIR%OfrontPlus\Target\Win32
+REM Set DIR = directory of this script
+
+
+
+
+
+
+SET DIR=%~dp0
+
+SET FNAME=%1
+
+IF "%NFAME:~0,1%"=="\" GOTO ENDIF1
+  SET FNAME=..\%FNAME%
+:ENDIF1
+
+IF NOT EXIST _Build MD _Build
+CD _Build
+
+SET OFRDIR=%DIR%OfrontPlus\Target\Win32
 SET PATH=%OFRDIR%;%PATH%
 SET PATH=%OFRDIR%;%PATH%
-SET OBERON=.;%CURDIR%..\..\src;%OFRDIR%\Lib\Sym
+SET OBERON=.;%DIR%..\..\src;%OFRDIR%\Lib\Sym
 SET OFR=ofront+ -s -88 -7w
 SET OFR=ofront+ -s -88 -7w
 
 
 ECHO ON
 ECHO ON
-@%OFR% %2 ..\Programs\%1
+@%OFR% %2 %FNAME%
 @SET RETCODE=%ERRORLEVEL%
 @SET RETCODE=%ERRORLEVEL%
 @ECHO OFF
 @ECHO OFF
 EXIT /b %RETCODE%
 EXIT /b %RETCODE%

+ 3 - 5
Data/bin/compile.sh

@@ -4,12 +4,12 @@
 #   the script is where FreeOberon executable is located.
 #   the script is where FreeOberon executable is located.
 #   You are free to edit this file to adjust the process.
 #   You are free to edit this file to adjust the process.
 
 
-# Set DIR = directory of this script
+#   Set DIR = directory of this script
 SOURCE=${BASH_SOURCE[0]}
 SOURCE=${BASH_SOURCE[0]}
-while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
+while [ -h "$SOURCE" ]; do
   DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
   DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
   SOURCE=$(readlink "$SOURCE")
   SOURCE=$(readlink "$SOURCE")
-  [[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
+  [[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE
 done
 done
 DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
 DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
 
 
@@ -19,7 +19,6 @@ if [[ "${FNAME:0:1}" != "/" ]]; then
   FNAME=../$FNAME
   FNAME=../$FNAME
 fi
 fi
 
 
-
 mkdir -p _Build
 mkdir -p _Build
 cd _Build
 cd _Build
 
 
@@ -28,7 +27,6 @@ PATH="$OFRDIR:$PATH"
 export OBERON=".:$DIR/../../src:$OFRDIR/Lib/Sym"
 export OBERON=".:$DIR/../../src:$OFRDIR/Lib/Sym"
 OFR="ofront+ -s -88 -7w"
 OFR="ofront+ -s -88 -7w"
 
 
-
 $OFR $2 $FNAME
 $OFR $2 $FNAME
 retcode=$?
 retcode=$?
 cd ..
 cd ..

+ 17 - 6
Data/bin/link_console.bat

@@ -4,13 +4,22 @@ REM to link a console program.
 REM When it is being run, the current directory
 REM When it is being run, the current directory
 REM must be the root directory of Free Oberon.
 REM must be the root directory of Free Oberon.
 
 
-CD bin >nul 2>&1
-@DEL /s %~n1.exe >nul 2>&1
-SET CURDIR=%~dp0
+
+REM Set DIR = directory of this script
+
+
+
+
+
+SET DIR=%~dp0
+
+CD _Build >nul 2>&1
+
+
 SET ONAME=%~n1
 SET ONAME=%~n1
-SET GCCDIR=%CURDIR%mingw32\bin
-SET FOBDIR=%CURDIR%..\..
-SET OFRDIR=%CURDIR%OfrontPlus
+SET GCCDIR=%DIR%mingw32\bin
+SET FOBDIR=%DIR%..\..
+SET OFRDIR=%DIR%OfrontPlus
 SET OFRTAR=%OFRDIR%\Target\Win32
 SET OFRTAR=%OFRDIR%\Target\Win32
 SET PATH=%OFRTAR%;%GCCDIR%;%PATH%
 SET PATH=%OFRTAR%;%GCCDIR%;%PATH%
 SET CC=gcc
 SET CC=gcc
@@ -28,6 +37,8 @@ GOTO START
 REM END Put all ARGS.
 REM END Put all ARGS.
 ECHO ON
 ECHO ON
 
 
+@DEL /s %~n1.exe >nul 2>&1
+
 @%CC% -O0 -fno-exceptions ^
 @%CC% -O0 -fno-exceptions ^
   -I %FOBDIR%\src ^
   -I %FOBDIR%\src ^
   -I %OFRDIR%\Mod\Lib ^
   -I %OFRDIR%\Mod\Lib ^

+ 17 - 6
Data/bin/link_graph.bat

@@ -4,13 +4,22 @@ REM to link a graphics program.
 REM When it is being run, the current directory
 REM When it is being run, the current directory
 REM must be the root directory of Free Oberon.
 REM must be the root directory of Free Oberon.
 
 
-CD bin >nul 2>&1
-@DEL /s %~n1.exe >nul 2>&1
-SET CURDIR=%~dp0
+
+REM Set DIR = directory of this script
+
+
+
+
+
+SET DIR=%~dp0
+
+CD _Build >nul 2>&1
+
+
 SET ONAME=%~n1
 SET ONAME=%~n1
-SET GCCDIR=%CURDIR%mingw32\bin
-SET FOBDIR=%CURDIR%..\..
-SET OFRDIR=%CURDIR%OfrontPlus
+SET GCCDIR=%DIR%mingw32\bin
+SET FOBDIR=%DIR%..\..
+SET OFRDIR=%DIR%OfrontPlus
 SET OFRTAR=%OFRDIR%\Target\Win32
 SET OFRTAR=%OFRDIR%\Target\Win32
 SET PATH=%OFRTAR%;%GCCDIR%;%PATH%
 SET PATH=%OFRTAR%;%GCCDIR%;%PATH%
 SET CC=gcc
 SET CC=gcc
@@ -28,6 +37,8 @@ GOTO START
 REM END Put all ARGS.
 REM END Put all ARGS.
 ECHO ON
 ECHO ON
 
 
+@DEL /s %~n1.exe >nul 2>&1
+
 @%CC% -O0 -fno-exceptions ^
 @%CC% -O0 -fno-exceptions ^
   -I %FOBDIR%\src ^
   -I %FOBDIR%\src ^
   -I %OFRDIR%\Mod\Lib ^
   -I %OFRDIR%\Mod\Lib ^

+ 2 - 1
src/Builder.Mod

@@ -158,7 +158,7 @@ PROCEDURE GetModuleName*(IN fname: ARRAY OF CHAR; VAR modname: ARRAY OF CHAR);
 VAR i, j: INTEGER;
 VAR i, j: INTEGER;
 BEGIN i := 0; j := 0;
 BEGIN i := 0; j := 0;
   WHILE fname[i] # 0X DO INC(i) END; DEC(i);
   WHILE fname[i] # 0X DO INC(i) END; DEC(i);
-  WHILE (i # -1) & (fname[i] # '/') DO DEC(i) END; INC(i);
+  WHILE (i # -1) & (fname[i] # '/') & (fname[i] # '\') DO DEC(i) END; INC(i);
   WHILE (fname[i] # 0X) & (fname[i] # '.') DO
   WHILE (fname[i] # 0X) & (fname[i] # '.') DO
     modname[j] := fname[i]; INC(i); INC(j)
     modname[j] := fname[i]; INC(i); INC(j)
   END;
   END;
@@ -220,6 +220,7 @@ BEGIN ok := TRUE;
         p := p.next
         p := p.next
       END
       END
     END;
     END;
+    ;;;;Out.String(cmd);Out.Ln;
     Utf8.Encode(cmd, q);
     Utf8.Encode(cmd, q);
     success := (Term.RunProcess(q, buf, bufLen, len, err) # 0) & (err = 0);
     success := (Term.RunProcess(q, buf, bufLen, len, err) # 0) & (err = 0);
     IF ~success & (onError # NIL) THEN
     IF ~success & (onError # NIL) THEN

+ 17 - 9
src/Env.Mod

@@ -1,5 +1,5 @@
 MODULE Env;
 MODULE Env;
-IMPORT CmdArgs, Platform, Utf8;
+IMPORT CmdArgs, Platform, Utf8, SYSTEM;
 TYPE SHORTCHAR = Utf8.SHORTCHAR;
 TYPE SHORTCHAR = Utf8.SHORTCHAR;
 
 
 VAR count: INTEGER;
 VAR count: INTEGER;
@@ -27,19 +27,27 @@ END GetByName;
 PROCEDURE GetAppDir*(VAR s: ARRAY OF CHAR);
 PROCEDURE GetAppDir*(VAR s: ARRAY OF CHAR);
 VAR c, delim: CHAR;
 VAR c, delim: CHAR;
   i: INTEGER;
   i: INTEGER;
+  z: ARRAY 260 OF SHORTCHAR;
 BEGIN
 BEGIN
-  GetByName('_', s);
-  s[LEN(s) - 1] := 0X;
+  IF Platform.Windows THEN
+    Platform.GetStartDir(z);
+    Utf8.Decode(z, s)
+  ELSE
+    GetByName('_', s);
+    IF s[0] # 0X THEN
+      s[LEN(s) - 1] := 0X;
 
 
-  i := 0; WHILE s[i] # 0X DO INC(i) END;
+      i := 0; WHILE s[i] # 0X DO INC(i) END;
 
 
-  IF Platform.Windows THEN delim := '\' ELSE delim := '/' END;
+      IF Platform.Windows THEN delim := '\' ELSE delim := '/' END;
 
 
-  c := s[0]; s[0] := delim;
-  REPEAT DEC(i) UNTIL s[i] = delim;
-  s[0] := c;
+      c := s[0]; s[0] := delim;
+      REPEAT DEC(i) UNTIL s[i] = delim;
+      s[0] := c;
 
 
-  s[i + 1] := 0X
+      s[i + 1] := 0X
+    END
+  END
 END GetAppDir;
 END GetAppDir;
 
 
 BEGIN
 BEGIN

+ 21 - 7
src/make.bat

@@ -1,5 +1,6 @@
 @ECHO OFF
 @ECHO OFF
-SET PROG=FreeOberon
+SET PROG1=FreeOberon
+SET PROG2=fob
 SET OFRDIR=..\Data\bin\OfrontPlus\Target\Win32
 SET OFRDIR=..\Data\bin\OfrontPlus\Target\Win32
 SET GCCDIR=C:\mingw-w64\i686\mingw32\bin
 SET GCCDIR=C:\mingw-w64\i686\mingw32\bin
 SET GCCDIR=..\Data\bin\mingw32\bin
 SET GCCDIR=..\Data\bin\mingw32\bin
@@ -57,11 +58,15 @@ ECHO ON
 @IF ERRORLEVEL 1 GOTO ERR
 @IF ERRORLEVEL 1 GOTO ERR
 %OFR% -Cw Editor.Mod
 %OFR% -Cw Editor.Mod
 @IF ERRORLEVEL 1 GOTO ERR
 @IF ERRORLEVEL 1 GOTO ERR
+%OFR% -Cw Builder.Mod
+@IF ERRORLEVEL 1 GOTO ERR
 %OFR% -Cwm FreeOberon.Mod
 %OFR% -Cwm FreeOberon.Mod
 @IF ERRORLEVEL 1 GOTO ERR
 @IF ERRORLEVEL 1 GOTO ERR
+%OFR% -7wm Fob.Mod
+@IF ERRORLEVEL 1 GOTO ERR
 windres resources.rc resources.o
 windres resources.rc resources.o
 @IF ERRORLEVEL 1 GOTO ERR
 @IF ERRORLEVEL 1 GOTO ERR
-@REM                        -O0 change to -Os (?)   add -s (?)
+
 %CCFULL% -c Utf8.c
 %CCFULL% -c Utf8.c
 @IF ERRORLEVEL 1 GOTO ERR
 @IF ERRORLEVEL 1 GOTO ERR
 %CCFULL% -c Strings.c
 %CCFULL% -c Strings.c
@@ -99,18 +104,27 @@ windres resources.rc resources.o
   StrList.o Dir.o Graph.o TermBox.o
   StrList.o Dir.o Graph.o TermBox.o
 @IF ERRORLEVEL 1 GOTO ERR
 @IF ERRORLEVEL 1 GOTO ERR
 
 
-%CCFULL% -o ..\%PROG%.exe resources.o ^
+%CCFULL% -o ..\%PROG1%.exe resources.o ^
   Graph.c TermBox.c ^
   Graph.c TermBox.c ^
   Config.c term\term_win32.c ^
   Config.c term\term_win32.c ^
-  Term.c OV.c FoStrings.c EditorText.c Editor.c ^
-  %PROG%.c ^
+  Term.c OV.c FoStrings.c EditorText.c Editor.c Builder.c ^
+  FreeOberon.c ^
   ..\Data\bin\FreeOberon.a ^
   ..\Data\bin\FreeOberon.a ^
   %OFRDIR%\Lib\Ofront.a ^
   %OFRDIR%\Lib\Ofront.a ^
   -lallegro -lallegro_primitives -lallegro_image ^
   -lallegro -lallegro_primitives -lallegro_image ^
   -I..\Data\bin\mingw32\include ^
   -I..\Data\bin\mingw32\include ^
   -Wl,-e_WinMain@16 ^
   -Wl,-e_WinMain@16 ^
-  -nostartfiles %OFRDIR%\..\..\Mod\Lib\crt1.c ^
-  -Wl,-subsystem,windows
+  -nostartfiles %OFRDIR%\..\..\Mod\Lib\crt1.c
+
+%CCFULL% -o ..\%PROG2%.exe ^
+  FoStrings.c Builder.c ^
+  Term.c term/term_win32.c ^
+  Config.c Fob.c ^
+  ..\Data\bin\FreeOberon.a ^
+  %OFRDIR%\Lib\Ofront.a ^
+  -I..\Data\bin\mingw32\include ^
+  -Wl,-e_WinMain@16 ^
+  -nostartfiles %OFRDIR%\..\..\Mod\Lib\crt1.c
 
 
 @GOTO QUIT
 @GOTO QUIT
 :ERR
 :ERR

+ 19 - 1
src/make.sh

@@ -3,6 +3,7 @@ PROG1="FreeOberon"
 PROG2="fob"
 PROG2="fob"
 OFRDIR="../Data/bin/OfrontPlus/Target/Linux_amd64"
 OFRDIR="../Data/bin/OfrontPlus/Target/Linux_amd64"
 
 
+
 PATH="$OFRDIR:$PATH"
 PATH="$OFRDIR:$PATH"
 export OBERON=.:$OFRDIR/Lib/Sym
 export OBERON=.:$OFRDIR/Lib/Sym
 
 
@@ -65,27 +66,44 @@ $OFR -7wm Fob.Mod &&
 
 
 
 
 
 
+
 $CCFULL -c Utf8.c &&
 $CCFULL -c Utf8.c &&
+
 $CCFULL -c Strings.c &&
 $CCFULL -c Strings.c &&
+
 $CCFULL -c Reals.c &&
 $CCFULL -c Reals.c &&
+
 $CCFULL -c Int.c &&
 $CCFULL -c Int.c &&
+
 $CCFULL -c In.c &&
 $CCFULL -c In.c &&
+
 $CCFULL -c Out.c &&
 $CCFULL -c Out.c &&
+
 $CCFULL -c Args.c &&
 $CCFULL -c Args.c &&
+
 $CCFULL -c Env.c &&
 $CCFULL -c Env.c &&
+
 $CCFULL -c Files.c &&
 $CCFULL -c Files.c &&
+
 $CCFULL -c Texts.c &&
 $CCFULL -c Texts.c &&
+
 $CCFULL -c Random.c &&
 $CCFULL -c Random.c &&
+
 $CCFULL -c StrList.c &&
 $CCFULL -c StrList.c &&
+
 $CCFULL -c Dir.c &&
 $CCFULL -c Dir.c &&
+
 $CCFULL -c Graph.c &&
 $CCFULL -c Graph.c &&
+
 $CCFULL -c TermBox.c &&
 $CCFULL -c TermBox.c &&
 
 
+
 $AR -crs ../Data/bin/libFreeOberon.a \
 $AR -crs ../Data/bin/libFreeOberon.a \
   Utf8.o Strings.o Reals.o Int.o In.o Out.o Args.o Env.o \
   Utf8.o Strings.o Reals.o Int.o In.o Out.o Args.o Env.o \
   Files.o Texts.o Random.o \
   Files.o Texts.o Random.o \
   StrList.o Dir.o Graph.o TermBox.o &&
   StrList.o Dir.o Graph.o TermBox.o &&
 
 
+
 $CCFULL -o ../$PROG1 \
 $CCFULL -o ../$PROG1 \
   Graph.c TermBox.c \
   Graph.c TermBox.c \
   Term.c term/term_linux.c \
   Term.c term/term_linux.c \
@@ -98,10 +116,10 @@ $CCFULL -o ../$PROG1 \
     allegro_acodec-5 allegro_font-5 allegro_dialog-5 \
     allegro_acodec-5 allegro_font-5 allegro_dialog-5 \
     allegro-5 --libs --cflags) &&
     allegro-5 --libs --cflags) &&
 
 
+
 $CCFULL -o ../$PROG2 \
 $CCFULL -o ../$PROG2 \
   FoStrings.c Builder.c \
   FoStrings.c Builder.c \
   Term.c term/term_linux.c \
   Term.c term/term_linux.c \
   Config.c Fob.c \
   Config.c Fob.c \
   ../Data/bin/libFreeOberon.a \
   ../Data/bin/libFreeOberon.a \
   $OFRDIR/Lib/libOfront.a
   $OFRDIR/Lib/libOfront.a
-