Skip to content

Commit

Permalink
Build a backend binary using AppVeyor's Ubuntu image
Browse files Browse the repository at this point in the history
  • Loading branch information
rprichard committed May 2, 2018
1 parent b62ec95 commit 87b7417
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 19 deletions.
9 changes: 7 additions & 2 deletions backend/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
STRIP ?= strip

all : ../out/wslbridge-backend

../out/wslbridge-backend : wslbridge-backend.cc ../common/SocketIo.cc ../common/SocketIo.h ../VERSION.txt Makefile
mkdir -p ../out
g++ -std=c++11 -fno-exceptions \
$(CXX) -std=c++11 -fno-exceptions \
-static-libgcc -static-libstdc++ \
-D_GNU_SOURCE \
-DWSLBRIDGE_VERSION=$(shell cat ../VERSION.txt) \
-Wall -O2 $< ../common/SocketIo.cc -o $@ -lutil -pthread
strip $@
$(STRIP) $@

clean:
rm -f ../out/wslbridge-backend
1 change: 1 addition & 0 deletions dist/cygwin-prebuilts/make-cygwin-prebuilts.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from util import glob_paths, rmpath, mkdirs, buildTimeStamp, projectDir, getGppVer


sys.platform == 'win32' or sys.exit('error: script only runs on Windows (no Cygwin/MSYS)')
shutil.which('7z') or sys.exit('error: 7z missing')
shutil.which('curl') or sys.exit('error: curl missing')

Expand Down
1 change: 1 addition & 0 deletions dist/cygwin-prebuilts/make-msys2-prebuilts.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def checkSha256(path, expected):
path, expected, actual))


sys.platform == 'win32' or sys.exit('error: script only runs on Windows (no Cygwin/MSYS)')
shutil.which('7z') or sys.exit('error: 7z missing')
shutil.which('curl') or sys.exit('error: curl missing')

Expand Down
29 changes: 22 additions & 7 deletions dist/frontend/appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
image:
- Ubuntu
- Visual Studio 2017

environment:
matrix:
- CYGWIN_VARIANT: cygwin32
- CYGWIN_VARIANT: cygwin64
- CYGWIN_VARIANT: msys32
- CYGWIN_VARIANT: msys64
- { COMPONENT: frontend, CYGWIN_VARIANT: cygwin32 }
- { COMPONENT: frontend, CYGWIN_VARIANT: cygwin64 }
- { COMPONENT: frontend, CYGWIN_VARIANT: msys32 }
- { COMPONENT: frontend, CYGWIN_VARIANT: msys64 }
- { COMPONENT: backend }

matrix:
exclude:
- { image: Ubuntu, COMPONENT: frontend }
- { image: Visual Studio 2017, COMPONENT: backend }

build_script:
- C:\Python36-x64\python.exe dist\frontend\make-frontend-packages.py
for:
- matrix: { only: [ COMPONENT: backend ] }
build_script:
- python3 dist/frontend/make-backend-package.py
- matrix: { only: [ COMPONENT: frontend ] }
build_script:
- C:\Python35-x64\python.exe dist\frontend\make-frontend-packages.py

artifacts:
- path: out\artifact\*-frontend.tar.xz
- path: out\artifact\*.tar.gz
37 changes: 37 additions & 0 deletions dist/frontend/make-backend-package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python3
import os
import sys
sys.path.insert(1, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import util

import shutil

from os.path import abspath
from subprocess import check_call
from util import projectDir, rmpath, mkdirs

sys.platform == 'linux' or sys.exit('error: script only runs on Linux')
shutil.which('git') or sys.exit('error: git missing')
shutil.which('make') or sys.exit('error: make missing')
shutil.which('tar') or sys.exit('error: tar missing')

buildDir = os.path.join(projectDir, 'out', 'build-backend')
artifactDir = os.path.join(projectDir, 'out', 'artifact')

rmpath(buildDir)
mkdirs(buildDir)
mkdirs(artifactDir)

os.chdir(buildDir)

prebuiltUrl = 'https://github.com/rprichard/x86_64-linux-glibc2.15-4.8.git'
prebuiltPath = abspath('linux-prebuilt')
artifactPath = os.path.join(artifactDir, 'backend.tar.gz')

check_call(['git', 'clone', prebuiltUrl, prebuiltPath])

os.putenv('CXX', os.path.join(prebuiltPath, 'bin', 'x86_64-linux-g++'))
os.putenv('STRIP', os.path.join(prebuiltPath, 'bin', 'x86_64-linux-strip'))
check_call(['make', 'clean'], cwd=os.path.join(projectDir, 'backend'))
check_call(['make'], cwd=os.path.join(projectDir, 'backend'))
check_call(['tar', 'cfa', artifactPath, '-C', '..', 'wslbridge-backend'])
10 changes: 4 additions & 6 deletions dist/frontend/make-frontend-packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from subprocess import check_call
from util import projectDir, rmpath, mkdirs

sys.platform == 'win32' or sys.exit('error: script only runs on Windows (no Cygwin/MSYS)')
shutil.which('7z') or sys.exit('error: 7z missing')
shutil.which('curl') or sys.exit('error: curl missing')

Expand Down Expand Up @@ -39,16 +40,13 @@
check_call(['curl', '-fL', url, '-o', '{}.7z'.format(platform)])
check_call(['7z', 'x', '{}.7z'.format(platform)])

# XXX: There is no 'make clean', so do it inline. There are no intermediate
# build files.
rmpath(os.path.join(projectDir, 'out', 'wslbridge.exe'))

platformBinDir = abspath(os.path.join(platform, binDir))
artifactPath = os.path.join(artifactDir, '{}-frontend.tar.xz'.format(platform))
artifactPath = os.path.join(artifactDir, '{}-frontend.tar.gz'.format(platform))

origPATH = os.getenv('PATH')
os.putenv('PATH', platformBinDir + os.pathsep + origPATH)
check_call([os.path.join(platformBinDir, 'make.exe')], cwd=os.path.join(projectDir, 'frontend'))
check_call([os.path.join(platformBinDir, 'make.exe'), 'clean'], cwd=os.path.join(projectDir, 'frontend'))
check_call([os.path.join(platformBinDir, 'make.exe')], cwd=os.path.join(projectDir, 'frontend'))
check_call([os.path.join(platformBinDir, 'tar.exe'), 'cfa',
relpath(artifactPath, os.getcwd()).replace('\\', '/'),
'-C', '..', 'wslbridge.exe'])
Expand Down
3 changes: 1 addition & 2 deletions dist/util.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import sys

# Install Python from https://www.python.org.
(sys.version_info[0:2] >= (3, 6)) or sys.exit('error: script requires Python 3.6 or above')
sys.platform == 'win32' or sys.exit('error: script only runs on Windows (no Cygwin/MSYS)')
(sys.version_info[0:2] >= (3, 5)) or sys.exit('error: script requires Python 3.5 or above')

import os
import re
Expand Down
9 changes: 7 additions & 2 deletions frontend/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
STRIP ?= strip

all : ../out/wslbridge.exe

../out/wslbridge.exe : wslbridge.cc ../common/SocketIo.cc ../common/SocketIo.h ../VERSION.txt Makefile
mkdir -p ../out
g++ -std=c++11 -fno-exceptions \
$(CXX) -std=c++11 -fno-exceptions \
-static -static-libgcc -static-libstdc++ \
-D_GNU_SOURCE -D_WIN32_WINNT=0x0600 -DUNICODE -D_UNICODE \
-DWSLBRIDGE_VERSION=$(shell cat ../VERSION.txt) \
-Wall -O2 $< ../common/SocketIo.cc -o $@
strip $@
$(STRIP) $@

clean:
rm -f ../out/wslbridge.exe

0 comments on commit 87b7417

Please sign in to comment.