Skip to content

Commit

Permalink
FEAT: adding interactive building script with prebuild Windows r3 binary
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Oct 25, 2017
1 parent d7f26c1 commit d8486da
Show file tree
Hide file tree
Showing 10 changed files with 175 additions and 40 deletions.
1 change: 1 addition & 0 deletions make-Win.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
make\prebuild\r3-make-win.exe -qs make\make.r3
2 changes: 1 addition & 1 deletion make/build-Win-32bit.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
make make OS_ID=0.3.1
make make OS_ID=0.3.1 REBOL_TOOL=prebuild\r3-make-win.exe
make TOOLS=x:/MingW/i686-7.1.0-win32-dwarf-rt_v5-rev2/mingw32/bin/ all

SET BUILD_DIR=..\build\win-x86\
Expand Down
2 changes: 1 addition & 1 deletion make/build-Win-64bit.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
make make OS_ID=0.3.40
make make OS_ID=0.3.40 REBOL_TOOL=prebuild\r3-make-win.exe
make TOOLS=x:/MingW/mingw64/bin/ all

SET BUILD_DIR=..\build\win-x64\
Expand Down
6 changes: 6 additions & 0 deletions make/make-settings.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
REBOL [
purpose: {User defined building properties}
]

TOOLS-Win32: "x:/MingW/i686-7.1.0-win32-dwarf-rt_v5-rev2/mingw32/bin/"
TOOLS-Win64: "x:/MingW/mingw64/bin/"
99 changes: 99 additions & 0 deletions make/make.r3
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
REBOL []

;catch any error:
if error? set/any 'err try [

TOOLS-Win32: ""
TOOLS-Win64: ""

attempt [do %make-settings.r3]

cmd-menu: {^/^[[1;33;49mPlease choose version to build:^[[0m^/}

cmd-actions: [
"q" [quit]
"" [val: none]
]

settings: []

rebol-tool: join "prebuild\r3-make" switch/default system/version/4 [
1 [%-amiga ]
2 [
append settings [
"OSX - PPC" [0.2.04 %..\build\osx-ppc\ ""]
"OSX - Intel" [0.2.05 %..\build\osx-intel\ ""]
"OSX - Intel x64" [0.2.40 %..\build\osx-intel-x64\ ""]
]
%-osx ]
3 [
append settings [
"Win32 console" [0.3.01 %..\build\win-x86\ TOOLS-Win32]
"Win64 console" [0.3.40 %..\build\win-x64\ TOOLS-Win64]
]
%-win.exe]
4 [
append settings [
"Linux libc 2.3" [0.4.02 %../build/linux/ ""]
"Linux libc 2.5" [0.4.03 %../build/linux/ ""]
"Linux libc 2.11" [0.4.04 %../build/linux/ ""]
"Linux PPC" [0.4.10 %../build/linux/ ""]
"Linux ARM" [0.4.20 %../build/linux/ ""]
"Linux ARM bionic (Android)" [0.4.21 %../build/linux/ ""]
"Linux MIPS" [0.4.30 %../build/linux/ ""]
"Linux x64" [0.4.40 %../build/linux/ ""]
]
%-linux ]
5 [%-haiku ]
7 [%-freebsd]
9 [%-openbsd]
13 [%-android]
][ %"" ]

i: 1
foreach [name data] settings [
set [OS_ID BUILD_DIR TOOLS] data
append cmd-menu rejoin ["^-^[[1;32;49m" i "^[[0m: " name " (" OS_ID ")^/"]
append cmd-actions compose/deep [
(form i) [OS_ID: (OS_ID) BUILD_DIR: (BUILD_DIR) TOOLS: (TOOLS)]
]
i: i + 1
]
append cmd-menu {^-^[[1;32;49mq^[[0m: Quit^/}

eval-cmd: func[cmd [string! block!] /local err][
out: copy ""
if block? cmd [cmd: rejoin cmd]
prin "^[[1;33;49m"
print [cmd "^[[0m^[[36m"]
call/wait/shell cmd out
print "^[[0m"
;print out
]

menu?: true
forever [
if menu? [print cmd-menu]
error? try [val: trim/head/tail ask "^[[1;32;49mBuild version: ^[[0m"]
switch/default val cmd-actions [
print "What?"
val: none
]

if val [
eval-cmd [rebol-tool " -qs ../src/tools/make-make.r " OS_ID]
eval-cmd [{make TOOLS=} TOOLS { all}]

make-dir/deep BUILD_DIR
eval-cmd [{move /Y r3.exe } to-local-file BUILD_DIR]
eval-cmd [{move /Y host.exe } to-local-file BUILD_DIR]
eval-cmd [{move /Y libr3.dll } to-local-file BUILD_DIR]
eval-cmd [{dir } to-local-file BUILD_DIR]
menu?: true
]
]

][ ; there was some error!
print "ERROR!"
print err
]
55 changes: 29 additions & 26 deletions make/makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# REBOL Makefile -- Generated by make-make.r (do not edit) on 20-Oct-2017/12:45:26+2:00
# REBOL Makefile -- Generated by make-make.r (do not edit) on 25-Oct-2017/17:18:42+2:00
# This makefile is intentional kept simple to make builds possible on
# a wider range of target platforms.

Expand Down Expand Up @@ -39,22 +39,22 @@ R= $S/core
INCL ?= .
I= -I$(INCL) -I$S/include/

TO_OS?= TO_WIN32_X64
OS_ID?= 0.3.40
TO_OS?= TO_WIN32
OS_ID?= 0.3.1
BIN_SUFFIX= .exe
LIB_SUFFIX= .dll
RES= "objs/r3.res"
RAPI_FLAGS= -O2 -DUNICODE -D__LLP64__ -m64 -DENDIAN_LITTLE
HOST_FLAGS= -DREB_EXE -O2 -DUNICODE -D__LLP64__ -m64 -DENDIAN_LITTLE -D_FILE_OFFSET_BITS=64
RAPI_FLAGS= -O2 -DUNICODE -m32 -DENDIAN_LITTLE
HOST_FLAGS= -DREB_EXE -O2 -DUNICODE -m32 -DENDIAN_LITTLE -D_FILE_OFFSET_BITS=64
RLIB_FLAGS=

# Flags for core and for host:
RFLAGS= -c -D$(TO_OS) -DREB_API $(RAPI_FLAGS) $I
HFLAGS= -c -D$(TO_OS) -DREB_CORE $(HOST_FLAGS) $I
CLIB= -lwsock32 -lcomdlg32 -mconsole -Wl,--stack=4194300 -lm
CLIB= -m32 -lwsock32 -lcomdlg32 -mconsole -Wl,--stack=4194300 -lm

# REBOL is needed to build various include files:
REBOL_TOOL= r3-make$(BIN_SUFFIX)
REBOL_TOOL= prebuild/r3-make-win.exe
REBOL= $(CD)$(REBOL_TOOL) -qs

# For running tests, ship, build, etc.
Expand Down Expand Up @@ -113,7 +113,7 @@ purge:
$(MAKE) host$(BIN_SUFFIX)

testdo:
r3$(BIN_SUFFIX) --do "print {^/^[[32mI'm READY^[[0m}"
r3$(BIN_SUFFIX) --do "print {^/^[[1;32m### I'm READY ###^[[0m^/}"

test:
$(CP) r3$(BIN_SUFFIX) $(UP)/src/tests/
Expand Down Expand Up @@ -142,24 +142,24 @@ OBJS = objs/a-constants.o objs/a-globals.o objs/a-lib.o objs/b-boot.o \
objs/c-function.o objs/c-port.o objs/c-task.o objs/c-word.o \
objs/d-crash.o objs/d-dump.o objs/d-print.o objs/f-blocks.o \
objs/f-deci.o objs/f-dtoa.o objs/f-enbase.o objs/f-extension.o \
objs/f-math.o objs/f-modify.o objs/f-qsort.o objs/f-random.o \
objs/f-round.o objs/f-series.o objs/f-stubs.o objs/l-scan.o \
objs/l-types.o objs/m-gc.o objs/m-pools.o objs/m-series.o \
objs/n-control.o objs/n-data.o objs/n-io.o objs/n-loop.o \
objs/n-math.o objs/n-sets.o objs/n-strings.o objs/n-system.o \
objs/p-clipboard.o objs/p-console.o objs/p-dir.o objs/p-dns.o \
objs/p-event.o objs/p-file.o objs/p-net.o objs/s-cases.o \
objs/s-crc.o objs/s-file.o objs/s-find.o objs/s-make.o \
objs/s-mold.o objs/s-ops.o objs/s-trim.o objs/s-unicode.o \
objs/t-bitset.o objs/t-block.o objs/t-char.o objs/t-datatype.o \
objs/t-date.o objs/t-decimal.o objs/t-event.o objs/t-function.o \
objs/t-gob.o objs/t-image.o objs/t-integer.o objs/t-logic.o \
objs/t-map.o objs/t-money.o objs/t-none.o objs/t-object.o \
objs/t-pair.o objs/t-port.o objs/t-string.o objs/t-time.o \
objs/t-tuple.o objs/t-typeset.o objs/t-utype.o objs/t-vector.o \
objs/t-word.o objs/u-bmp.o objs/u-compress.o objs/u-dialect.o \
objs/u-gif.o objs/u-jpg.o objs/u-md5.o objs/u-parse.o \
objs/u-png.o objs/u-sha1.o objs/u-zlib.o
objs/f-int.o objs/f-math.o objs/f-modify.o objs/f-qsort.o \
objs/f-random.o objs/f-round.o objs/f-series.o objs/f-stubs.o \
objs/l-scan.o objs/l-types.o objs/m-gc.o objs/m-pools.o \
objs/m-series.o objs/n-control.o objs/n-data.o objs/n-io.o \
objs/n-loop.o objs/n-math.o objs/n-sets.o objs/n-strings.o \
objs/n-system.o objs/p-clipboard.o objs/p-console.o objs/p-dir.o \
objs/p-dns.o objs/p-event.o objs/p-file.o objs/p-net.o \
objs/s-cases.o objs/s-crc.o objs/s-file.o objs/s-find.o \
objs/s-make.o objs/s-mold.o objs/s-ops.o objs/s-trim.o \
objs/s-unicode.o objs/t-bitset.o objs/t-block.o objs/t-char.o \
objs/t-datatype.o objs/t-date.o objs/t-decimal.o objs/t-event.o \
objs/t-function.o objs/t-gob.o objs/t-image.o objs/t-integer.o \
objs/t-logic.o objs/t-map.o objs/t-money.o objs/t-none.o \
objs/t-object.o objs/t-pair.o objs/t-port.o objs/t-string.o \
objs/t-time.o objs/t-tuple.o objs/t-typeset.o objs/t-utype.o \
objs/t-vector.o objs/t-word.o objs/u-bmp.o objs/u-compress.o \
objs/u-dialect.o objs/u-gif.o objs/u-jpg.o objs/u-md5.o \
objs/u-parse.o objs/u-png.o objs/u-sha1.o objs/u-zlib.o

HOST = objs/host-main.o objs/host-args.o objs/host-device.o objs/host-stdio.o \
objs/dev-net.o objs/dev-dns.o objs/host-lib.o objs/dev-stdio.o \
Expand Down Expand Up @@ -262,6 +262,9 @@ objs/f-enbase.o: $R/f-enbase.c
objs/f-extension.o: $R/f-extension.c
$(CC) $R/f-extension.c $(RFLAGS) -o objs/f-extension.o

objs/f-int.o: $R/f-int.c
$(CC) $R/f-int.c $(RFLAGS) -o objs/f-int.o

objs/f-math.o: $R/f-math.c
$(CC) $R/f-math.c $(RFLAGS) -o objs/f-math.o

Expand Down
17 changes: 10 additions & 7 deletions make/makefile.vc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ I= /I..\src\include
TO_OS= TO_WIN32
OS_ID= 0.3.1

CFLAGS=/c /Os /D "UNICODE" /D "WIN32" /W3 /GR- /Zi /GS /Gy /GF /EHs-c- /GL /D "NDEBUG" /D "_CRT_SECURE_NO_WARNINGS"
CFLAGS=/c /Os /D "UNICODE" /D "WIN32" /D "ENDIAN_LITTLE" /W3 /GR- /Zi /GS /Gy /GF /EHs-c- /GL /D "NDEBUG" /D "_CRT_SECURE_NO_WARNINGS"

RAPI_FLAGS= $(CFLAGS)
HOST_FLAGS= $(CFLAGS)
Expand All @@ -24,27 +24,30 @@ HFLAGS= $(HOST_FLAGS) $(I) /D$(TO_OS) /DREB_CORE
LIBS= user32.lib ws2_32.lib advapi32.lib shell32.lib comdlg32.lib
LDFLAGS = /nologo /DEBUG /RELEASE /opt:ref /opt:icf /LTCG

REBOL= r3-make.exe -qs
REBOL= prebuild\r3-make-win.exe -qs

all: prep r3.exe
clean:
DEL /s /q objs

prep:
all: clean prep r3.exe

prep: objs
$(REBOL) $T/make-headers.r
$(REBOL) $T/make-boot.r $(OS_ID)
$(REBOL) $T/make-host-init.r
$(REBOL) $T/make-os-ext.r # ok, but not always
$(REBOL) $T/make-host-ext.r
$(REBOL) $T/make-reb-lib.r
windres r3.rc -O coff -o objs/r3.res
windres --target=pe-i386 r3.rc -O coff -o objs/r3.res

objs:
mkdir objs
if not exist objs MKDIR objs

OBJS = objs/a-constants.obj objs/a-globals.obj objs/a-lib.obj objs/b-boot.obj \
objs/b-init.obj objs/c-do.obj objs/c-error.obj objs/c-frame.obj \
objs/c-function.obj objs/c-port.obj objs/c-task.obj objs/c-word.obj \
objs/d-crash.obj objs/d-dump.obj objs/d-print.obj objs/f-blocks.obj \
objs/f-deci.obj objs/f-dtoa.obj objs/f-enbase.obj objs/f-extension.obj objs/f-math.obj \
objs/f-deci.obj objs/f-dtoa.obj objs/f-enbase.obj objs/f-extension.obj objs/f-int.obj objs/f-math.obj \
objs/f-modify.obj objs/f-random.obj objs/f-round.obj objs/f-series.obj \
objs/f-stubs.obj objs/l-scan.obj objs/l-types.obj objs/m-gc.obj \
objs/m-pools.obj objs/m-series.obj objs/n-control.obj objs/n-data.obj \
Expand Down
Binary file added make/prebuild/r3-make-win.exe
Binary file not shown.
15 changes: 13 additions & 2 deletions make/vcbuild.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
@ECHO OFF

REM Allow to explicitly specify the desired Visual Studio version

if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat" (
CALL "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat"
IF NOT ERRORLEVEL 1 GOTO BUILD
)

IF /I "%1" == "vc17" GOTO TRY_VS17
IF /I "%1" == "vc15" GOTO TRY_VS15
IF /I "%1" == "vc12" GOTO TRY_VS12
Expand All @@ -9,26 +15,31 @@ IF /I "%1" == "vc9" GOTO TRY_VS9

REM vs15 is VS 2017
:TRY_VS17
CALL "%VS150COMNTOOLS%\VsDevCmd.bat" 2>NUL
echo Trying VS17...
CALL "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" 2>NUL
IF NOT ERRORLEVEL 1 GOTO BUILD

REM vs14 is VS 2015
:TRY_VS17
:TRY_VS15
echo Trying VS15...
CALL "%VS140COMNTOOLS%\vsvars32.bat" 2>NUL
IF NOT ERRORLEVEL 1 GOTO BUILD

REM vs12 is VS 2012
:TRY_VS12
echo Trying VS12...
CALL "%VS120COMNTOOLS%\vsvars32.bat" 2>NUL
IF NOT ERRORLEVEL 1 GOTO BUILD

REM vs10 is VS 2010
:TRY_VS10
echo Trying VS10...
CALL "%VS100COMNTOOLS%\vsvars32.bat" 2>NUL
IF NOT ERRORLEVEL 1 GOTO BUILD

REM vs9 is VS 2008
:TRY_VS9
echo Trying VS9...
CALL "%VS90COMNTOOLS%\vsvars32.bat" 2>NUL
IF NOT ERRORLEVEL 1 GOTO BUILD

Expand Down
18 changes: 15 additions & 3 deletions src/tools/make-make.r
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ HFLAGS= -c -D$(TO_OS) -DREB_CORE $(HOST_FLAGS) $I
CLIB=
# REBOL is needed to build various include files:
REBOL_TOOL= r3-make$(BIN_SUFFIX)
REBOL_TOOL=
REBOL= $(CD)$(REBOL_TOOL) -qs
# For running tests, ship, build, etc.
Expand Down Expand Up @@ -147,7 +147,7 @@ purge:
$(MAKE) host$(BIN_SUFFIX)
testdo:
r3$(BIN_SUFFIX) --do "print {^^/^^[[32mI'm READY^^[[0m}"
r3$(BIN_SUFFIX) --do "print {^^/^^[[1;32m### I'm READY ###^^[[0m^^/}"
test:
$(CP) r3$(BIN_SUFFIX) $(UP)/src/tests/
Expand Down Expand Up @@ -392,11 +392,23 @@ macro+ TO_OS to-def
macro+ OS_ID os-plat
macro+ LS pick ["dir" "ls -l"] flag? DIR
macro+ CP pick [copy cp] flag? COP
macro+ REBOL_TOOL join %prebuild/r3-make switch/default system/version/4 [
1 [%-amiga ]
2 [%-osx ]
3 [%-win.exe]
4 [%-linux ]
5 [%-haiku ]
7 [%-freebsd]
9 [%-openbsd]
13 [%-android]
][ %"" ]

unless flag? -SP [ ; Use standard paths:
macro+ UP ".."
macro+ CD "./"
]
if os-plat/2 = 3 [macro+ REBOL ">NUL:"] ; Temporary workaround for R3 on Win7.
;Oldes: Why there was the next line?
;if os-plat/2 = 3 [macro+ REBOL ">NUL:"] ; Temporary workaround for R3 on Win7.
either flag? EXE [
macro+ BIN_SUFFIX %.exe
macro+ LIB_SUFFIX %.dll
Expand Down

0 comments on commit d8486da

Please sign in to comment.