diff --git a/.github/workflows/alpine.build.sh b/.github/workflows/alpine.build.sh index 56a9edb092..775f78de9e 100755 --- a/.github/workflows/alpine.build.sh +++ b/.github/workflows/alpine.build.sh @@ -6,7 +6,7 @@ pwd uname -a -make +make -j4 ./v --version diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1159726c8..ed20a4667d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,25 @@ name: CI on: [push, pull_request] jobs: + ubuntu-tcc: + runs-on: ubuntu-18.04 + env: + VFLAGS: -cc tcc + steps: + - uses: actions/checkout@v1 + - name: Install dependencies + run: sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list; sudo apt-get update; sudo apt-get install --quiet -y libglfw3 libglfw3-dev libfreetype6-dev libssl-dev sqlite3 libsqlite3-dev libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev + - name: Build v + run: echo $VFLAGS && make -j4 && ./v -o v v.v + - name: Test v->c + run: | + sudo ln -s /var/tmp/tcc/bin/tcc /usr/local/bin/tcc + tcc -version + ./v -o v2 v.v # Make sure vtcc can build itself + ./v test-compiler + - name: Test v binaries + run: ./v build-vbinaries + alpine-docker-musl-gcc: name: alpine-musl runs-on: ubuntu-latest @@ -35,7 +54,7 @@ jobs: brew install freetype glfw openssl postgres sdl2 sdl2_ttf sdl2_mixer sdl2_image export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/" - name: Build V - run: make && ./v -o v v.v + run: make -j4 && ./v -o v v.v - name: Build V using V run: ./v -o v2 v.v && ./v2 -o v3 v.v - name: Test symlink @@ -72,7 +91,7 @@ jobs: - name: Install dependencies run: sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list; sudo apt-get update; sudo apt-get install --quiet -y postgresql libpq-dev libglfw3 libglfw3-dev libfreetype6-dev libssl-dev sqlite3 libsqlite3-dev libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev - name: Build V - run: make && ./v -cc gcc -o v v.v + run: make -j4 && ./v -cc gcc -o v v.v - name: Test V run: ./v test-compiler - name: Test v binaries @@ -121,26 +140,6 @@ jobs: - name: Test V run: echo "test" #./v.exe examples/hello_world.v && examples/hello_world.exe - - ubuntu-tcc: - runs-on: ubuntu-18.04 - env: - VFLAGS: -cc tcc - steps: - - uses: actions/checkout@v1 - - name: Install dependencies - run: sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list; sudo apt-get update; sudo apt-get install --quiet -y libglfw3 libglfw3-dev libfreetype6-dev libssl-dev sqlite3 libsqlite3-dev libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev - - name: Build v - run: echo $VFLAGS && make && ./v -o v v.v - - name: Test v->c - run: | - sudo ln -s /var/tmp/tcc/bin/tcc /usr/local/bin/tcc - tcc -version - ./v -o v2 v.v # Make sure vtcc can build itself - ./v test-compiler - - name: Test v binaries - run: ./v build-vbinaries - ubuntu-musl: runs-on: ubuntu-18.04 env: @@ -153,7 +152,7 @@ jobs: - name: Install dependencies run: sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list; sudo apt-get update; sudo apt-get install --quiet -y musl musl-tools libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev - name: Build v - run: echo $VFLAGS && make && ./v -o v v.v + run: echo $VFLAGS && make -j4 && ./v -o v v.v - name: Test v binaries run: ./v build-vbinaries # - name: Test v->js diff --git a/Makefile b/Makefile index 9f51de01c1..41e5248e6b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,14 @@ CC ?= cc +VCFILE := v.c +TMPVC := /tmp/vc +TMPTCC := /var/tmp/tcc +VCREPO := https://github.com/vlang/vc +TCCREPO := https://github.com/vlang/tccbin +GITCLEANPULL := git clean -xf && git pull --quiet +GITFASTCLONE := git clone --depth 1 --quiet + +#### Platform detections and overrides: _SYS := $(shell uname 2>/dev/null || echo Unknown) _SYS := $(patsubst MSYS%,MSYS,$(_SYS)) _SYS := $(patsubst MINGW%,MinGW,$(_SYS)) @@ -20,14 +29,20 @@ ifdef ANDROID_ROOT ANDROID := 1 undefine LINUX endif +##### -all: fresh_vc fresh_tcc ifdef WIN32 - $(CC) -std=c99 -w -o v0.exe vc/v_win.c $(LDFLAGS) +TCCREPO := https://github.com/vlang/tccbin_win +VCFILE := v_win.c +endif + +all: latest_vc latest_tcc +ifdef WIN32 + $(CC) -std=c99 -w -o v0.exe $(TMPVC)/$(VCFILE) $(LDFLAGS) ./v0.exe -o v.exe v.v rm -f v0.exe else - $(CC) -std=gnu11 -w -o v vc/v.c $(LDFLAGS) -lm + $(CC) -std=gnu11 -w -o v $(TMPVC)/$(VCFILE) $(LDFLAGS) -lm ifdef ANDROID chmod 755 v endif @@ -35,32 +50,50 @@ endif V_V=`git rev-parse --short HEAD`; \ if [ $$VC_V != $$V_V ]; then \ echo "Self rebuild ($$VC_V => $$V_V)"; \ - ./v -o v v.v; \ + $(MAKE) selfcompile; \ fi) ifndef ANDROID - ./v build module vlib/builtin > /dev/null - ./v build module vlib/strings > /dev/null - ./v build module vlib/strconv > /dev/null + $(MAKE) modules endif endif - rm -rf vc/ @echo "V has been successfully built" +clean: + rm -rf $(TMPTCC) + rm -rf $(TMPVC) + git clean -xf + +latest_vc: $(TMPVC)/.git/config + cd $(TMPVC) && $(GITCLEANPULL) fresh_vc: - rm -rf vc/ - git clone --depth 1 --quiet https://github.com/vlang/vc - #cp fns.h vc/fns.h + rm -rf $(TMPVC) + $(GITFASTCLONE) $(VCREPO) $(TMPVC) + +latest_tcc: $(TMPTCC)/.git/config +ifndef ANDROID + cd $(TMPTCC) && $(GITCLEANPULL) +endif fresh_tcc: -ifdef WIN32 - rm -rf /var/tmp/tcc/ - git clone --depth 1 --quiet https://github.com/vlang/tccbin_win /var/tmp/tcc -endif -ifdef LINUX - rm -rf /var/tmp/tcc/ - git clone --depth 1 --quiet https://github.com/vlang/tccbin /var/tmp/tcc +ifndef ANDROID + rm -rf $(TMPTCC) + $(GITFASTCLONE) $(TCCREPO) $(TMPTCC) endif +$(TMPTCC)/.git/config: + $(MAKE) fresh_tcc + +$(TMPVC)/.git/config: + $(MAKE) fresh_vc + selfcompile: ./v -o v v.v + +modules: module_builtin module_strings module_strconv +module_builtin: + ./v build module vlib/builtin > /dev/null +module_strings: + ./v build module vlib/strings > /dev/null +module_strconv: + ./v build module vlib/strconv > /dev/null