Skip to content
This repository was archived by the owner on Nov 4, 2021. It is now read-only.

Commit 663666f

Browse files
authored
Merge pull request #15 from open-tool-forge/feature/2-windows-build
Feature/2 windows build
2 parents 9d24a0f + ace042f commit 663666f

13 files changed

+481
-86
lines changed

azure-pipelines.yml

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
trigger:
2+
branches:
3+
exclude:
4+
# master branch publishes releases - avoid merges triggering a new release
5+
- master
6+
17
schedules:
28
- cron: "0 4 * * *"
39
displayName: Nightly build at 0400 UTC
@@ -26,6 +32,7 @@ stages:
2632
jobs:
2733
- job: build_toolchain
2834
displayName: Build toolchain
35+
timeoutInMinutes: 0
2936
strategy:
3037
matrix:
3138
linux_x86_64:
@@ -34,9 +41,6 @@ stages:
3441
osx:
3542
ARCH: darwin
3643
vm_image: macOS-10.15
37-
# win64:
38-
# ARCH: windows_amd64
39-
# vm_image: vs2017-win2016
4044
pool:
4145
vmImage: '$(vm_image)'
4246
steps:
@@ -53,6 +57,54 @@ stages:
5357
name: build_toolchain
5458
- publish: _packages/build_$(ARCH)/fpga-toolchain-$(ARCH)-$(RELEASE_TAG).tar.gz
5559
artifact: fpga-toolchain-$(ARCH)-$(RELEASE_TAG)
60+
- job: build_toolchain_windows_amd64
61+
displayName: Build toolchain windows_amd64
62+
timeoutInMinutes: 0
63+
pool:
64+
vmImage: vs2017-win2016
65+
variables:
66+
ARCH: windows_amd64
67+
MINGW_ARCH: x86_64
68+
steps:
69+
- powershell: |
70+
Set-MpPreference -DisableArchiveScanning $true
71+
Set-MpPreference -DisableRealtimeMonitoring $true
72+
Set-MpPreference -DisableBehaviorMonitoring $true
73+
- download: current
74+
artifact: ecp5-bba
75+
- bash: |
76+
RELEASE_TAG=nightly-$(date +'%Y%m%d')
77+
# create pipeline variable
78+
echo "##vso[task.setvariable variable=RELEASE_TAG]$RELEASE_TAG"
79+
- script: copy $(Pipeline.Workspace)\ecp5-bba\ecp5-bba-linux_x86_64-nightly.tar.gz $(Build.Repository.LocalPath)\chipdb.tar.gz
80+
displayName: Copy BBA artifact
81+
- script: |
82+
set MSYS_ROOT=%CD:~0,2%\msys64
83+
echo ##vso[task.setvariable variable=MSYS_ROOT]%MSYS_ROOT%
84+
git clone https://github.com/msys2/msys2-ci-base.git %MSYS_ROOT%
85+
%MSYS_ROOT%\usr\bin\rm -rf %MSYS_ROOT%\.git
86+
displayName: Install MSYS2
87+
- script: |
88+
set PATH=%MSYS_ROOT%\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
89+
%MSYS_ROOT%\usr\bin\pacman --noconfirm -Syyuu
90+
displayName: Update MSYS2
91+
- script: |
92+
set PATH=%MSYS_ROOT%\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
93+
%MSYS_ROOT%\usr\bin\pacman --noconfirm --needed -S git base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake
94+
%MSYS_ROOT%\usr\bin\pacman --noconfirm -Scc
95+
displayName: Install Toolchain
96+
- script: |
97+
set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
98+
%MSYS_ROOT%\usr\bin\sed -i "s|#CacheDir.*|CacheDir=/c/Users/%USERNAME%/AppData/Local/Temp|g" /etc/pacman.conf
99+
set MSYS=winsymlinks:nativestrict
100+
%MSYS_ROOT%\msys2_shell.cmd -defterm -no-start -mingw64 -full-path -here -c "./build.sh windows_amd64"
101+
displayName: CI-Build
102+
env:
103+
MSYSTEM: MINGW64
104+
CHERE_INVOKING: yes
105+
MINGW_INSTALLS: mingw64
106+
- publish: _packages/build_$(ARCH)/fpga-toolchain-$(ARCH)-$(RELEASE_TAG).zip
107+
artifact: fpga-toolchain-$(ARCH)-$(RELEASE_TAG)
56108

57109
- stage: publish_release
58110
displayName: publish release

build.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export NAME=fpga-toolchain
2121
# -- Debug flags
2222
INSTALL_DEPS=1
2323
COMPILE_DFU_UTIL=1
24-
COMPILE_ICESTORM=1
2524
COMPILE_YOSYS=1
25+
COMPILE_ICESTORM=1
2626
COMPILE_NEXTPNR_ICE40=1
2727
COMPILE_NEXTPNR_ECP5=1
2828
COMPILE_ECPPROG=1
@@ -60,12 +60,15 @@ mkdir -p $PACKAGE_DIR/$NAME/share
6060

6161
# -- Test script function
6262
function test_bin {
63-
. $WORK_DIR/test/test_bin.sh $1
64-
if [ $? != "0" ]; then
65-
exit 1
63+
if [[ ${ARCH:0:7} != "windows" ]]; then
64+
. $WORK_DIR/test/test_bin.sh $1
65+
if [ $? != "0" ]; then
66+
exit 1
67+
fi
6668
fi
6769
}
6870

71+
6972
# -- Print function
7073
function print {
7174
echo ""

scripts/build_setup.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
set -e
55

6+
export MAKE="make"
7+
68
if [ $ARCH == "linux_x86_64" ]; then
79
export CC="gcc"
810
export CXX="g++"
@@ -46,6 +48,14 @@ if [ $ARCH == "windows_amd64" ]; then
4648
export CXX="x86_64-w64-mingw32-g++"
4749
export HOST_FLAGS="--host=x86_64-w64-mingw32"
4850
export ABC_ARCHFLAGS="-DSIZEOF_VOID_P=8 -DSIZEOF_LONG=4 -DSIZEOF_INT=4 -DWIN32_NO_DLL -DHAVE_STRUCT_TIMESPEC -D_POSIX_SOURCE -fpermissive -w"
51+
export MAKE="mingw32-make"
52+
53+
export EMBEDDED_PY_VER=$(python.exe -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')
54+
mkdir -p $PACKAGE_DIR/$NAME/lib/python$EMBEDDED_PY_VER
55+
cp -L -R /mingw64/lib/python$EMBEDDED_PY_VER $PACKAGE_DIR/$NAME/lib
56+
# this isn't necessary and takes up ~half the size
57+
rm -rf $PACKAGE_DIR/$NAME/lib/python$EMBEDDED_PY_VER/test
58+
cp /mingw64/bin/{libgcc_s_seh-1.dll,libstdc++-6.dll,libwinpthread-1.dll,libpython$EMBEDDED_PY_VER.dll} $PACKAGE_DIR/$NAME/bin
4959
fi
5060

5161
if [ $ARCH == "darwin" ]; then
@@ -70,3 +80,5 @@ fi
7080
if [ $J -gt 1 ]; then
7181
J=$(($J-1))
7282
fi
83+
84+
echo Running with J=$J

scripts/compile-nextpnr-ecp5.sh

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fi
5454
rm -f $nextpnr_dir/CMakeCache.txt $prjtrellis_dir/CMakeCache.txt
5555

5656
cd $BUILD_DIR
57-
mkdir chipdb
57+
mkdir -p chipdb
5858
cd chipdb
5959
tar -xvf $WORK_DIR/chipdb.tar.gz
6060

@@ -91,20 +91,39 @@ then
9191
cd ..
9292
elif [ ${ARCH:0:7} = "windows" ]
9393
then
94-
echo "Build not functioning on Windows"
95-
exit 1
96-
else
9794
cd $BUILD_DIR/$prjtrellis_dir/libtrellis
95+
cmake \
96+
-G "MinGW Makefiles" \
97+
-DBUILD_SHARED=OFF \
98+
-DSTATIC_BUILD=ON \
99+
-DBUILD_PYTHON=OFF \
100+
-DCMAKE_INSTALL_PREFIX=$PACKAGE_DIR/$NAME \
101+
-DCURRENT_GIT_VERSION=$prjtrellis_commit \
102+
-DBoost_USE_STATIC_LIBS=ON \
103+
.
104+
mingw32-make -j$J CXX="$CXX" LIBS="-lm"
105+
mingw32-make install
98106

99-
# # The first run of the build produces the Python shared library
100-
# # (Disabled since we now use PREGENERATED_BBA_PATH)
101-
# cmake \
102-
# -DBUILD_SHARED=ON \
103-
# -DSTATIC_BUILD=OFF \
104-
# -DBUILD_PYTHON=ON \
105-
# .
106-
# make -j$J CXX="$CXX"
107-
# rm -rf CMakeCache.txt
107+
cd $BUILD_DIR/$nextpnr_dir
108+
cp $WORK_DIR/scripts/nextpnr-CMakeLists.txt CMakeLists.txt
109+
110+
cmake \
111+
-G "MinGW Makefiles" \
112+
-DARCH=ecp5 \
113+
-DTRELLIS_ROOT=$BUILD_DIR/$prjtrellis_dir \
114+
-DPYTRELLIS_LIBDIR=$BUILD_DIR/$prjtrellis_dir/libtrellis \
115+
-DPREGENERATED_BBA_PATH=$BUILD_DIR/chipdb/ecp5-bba/bba \
116+
-DBoost_USE_STATIC_LIBS=ON \
117+
-DBUILD_GUI=OFF \
118+
-DBUILD_PYTHON=ON \
119+
-DBUILD_HEAP=ON \
120+
-DSTATIC_BUILD=ON \
121+
.
122+
123+
mingw32-make -j$J CXX="$CXX" LIBS="-static -lstdc++ -lm" VERBOSE=1
124+
cd ..
125+
else
126+
cd $BUILD_DIR/$prjtrellis_dir/libtrellis
108127

109128
# The second run builds the static libraries we'll use in the final release
110129
cmake \
@@ -131,7 +150,7 @@ else
131150
-DSTATIC_BUILD=ON \
132151
-DBoost_USE_STATIC_LIBS=ON \
133152
.
134-
make -j$J CXX="$CXX"
153+
make -j$J CXX="$CXX" LIBS="-static -lstdc++ -lm"
135154

136155
# Install a copy of Python, since Python libraries are not compatible
137156
# across minor versions.
@@ -149,13 +168,15 @@ fi || exit 1
149168

150169
# -- Copy the executables to the bin dir
151170
mkdir -p $PACKAGE_DIR/$NAME/bin
152-
$WORK_DIR/scripts/test_bin.sh $BUILD_DIR/$nextpnr_dir/nextpnr-ecp5$EXE
171+
# $WORK_DIR/scripts/test_bin.sh $BUILD_DIR/$nextpnr_dir/nextpnr-ecp5$EXE
153172
cp $BUILD_DIR/$nextpnr_dir/nextpnr-ecp5$EXE $PACKAGE_DIR/$NAME/bin/nextpnr-ecp5$EXE
154173
for i in ecpmulti ecppack ecppll ecpunpack ecpbram
155174
do
156-
$WORK_DIR/scripts/test_bin.sh $BUILD_DIR/$prjtrellis_dir/libtrellis/$i$EXE
175+
# $WORK_DIR/scripts/test_bin.sh $BUILD_DIR/$prjtrellis_dir/libtrellis/$i$EXE
157176
cp $BUILD_DIR/$prjtrellis_dir/libtrellis/$i$EXE $PACKAGE_DIR/$NAME/bin/$i$EXE
158177
done
159178

160179
# Do a test run of the new binary
161180
$PACKAGE_DIR/$NAME/bin/nextpnr-ecp5$EXE --help
181+
echo 'print("hello from python!")' > hello.py
182+
$PACKAGE_DIR/$NAME/bin/nextpnr-ecp5$EXE --run hello.py

scripts/compile_dfu_util.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ if [ $ARCH == "darwin" ]; then
2727
--includedir=/opt/local/include \
2828
USB_CFLAGS="-I$LIBUSB_ROOT/include/libusb-1.0" \
2929
USB_LIBS="$LIBUSB_ROOT/lib/libusb-1.0.a -Wl,-framework,IOKit -Wl,-framework,CoreFoundation"
30-
make
30+
$MAKE
31+
elif [ ${ARCH:0:7} = "windows" ]
32+
then
33+
./configure USB_LIBS="-static -lpthread -lusb-1.0"
34+
$MAKE
3135
else
3236
./configure USB_CFLAGS="-I$WORK_DIR/build-data/include/libusb-1.0" USB_LIBS="-static $WORK_DIR/build-data/lib/$ARCH/libusb-1.0.a -lpthread"
33-
make
37+
$MAKE
3438
fi
3539

3640
TOOLS="dfu-util dfu-prefix dfu-suffix"

scripts/compile_ecpprog.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,19 @@ if [ $ARCH == "darwin" ]; then
2424
sed -i "" "s/-ggdb //;" Makefile
2525
# pkg-config is used to set LDLIBS in this Makefile and doesn't quite do what we want
2626
sed -i "" "s/\$^ \$(LDLIBS)/\$^ \$(LDSTATICLIBS)/g" Makefile
27-
make -j$J CC="$CC" \
27+
$MAKE -j$J CC="$CC" \
2828
PKG_CONFIG=":" \
2929
LDSTATICLIBS="$LIBFTDI_ROOT/lib/libftdi1.a $LIBUSB_ROOT/lib/libusb-1.0.a -Wl,-framework,IOKit -Wl,-framework,CoreFoundation" \
3030
CFLAGS="-MD -O0 -Wall -std=c99 -I$LIBFTDI_ROOT/include/libftdi1 $CFLAGS"
31+
elif [ ${ARCH:0:7} = "windows" ]
32+
then
33+
sed -i "s/-ggdb //;" Makefile
34+
$MAKE -j$J CC="$CC" \
35+
LDFLAGS="-static -pthread"
3136
else
3237
sed -i "s/-ggdb //;" Makefile
3338
sed -i "s/\$^ \$(LDLIBS)/\$^ \$(LDLIBS) \$(LDUSBSTATIC)/g" Makefile
34-
make -j$J CC="$CC" \
39+
$MAKE -j$J CC="$CC" \
3540
LDFLAGS="-static -pthread -L$WORK_DIR/build-data/lib/$ARCH " \
3641
LDUSBSTATIC="-lusb-1.0"\
3742
CFLAGS="-MD -O0 -Wall -std=c99 -I$WORK_DIR/build-data/include/libftdi1 -I$WORK_DIR/build-data/include/libusb-1.0"

scripts/compile_icestorm.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ if [ $ARCH == "darwin" ]; then
3333
make -j$J CXX="$CXX" \
3434
CXXFLAGS="-std=c++11 $CXXFLAGS" \
3535
SUBDIRS="icebox icepack icemulti icepll icetime icebram"
36+
elif [ ${ARCH:0:7} = "windows" ]
37+
then
38+
sed -i "s/-ggdb //;" Makefile
39+
$MAKE -j$J CC="$CC" STATIC=1
3640
else
3741
sed -i "s/-ggdb //;" config.mk
3842
sed -i "s/\$^ \$(LDLIBS)/\$^ \$(LDLIBS) \$(LDUSBSTATIC)/g" iceprog/Makefile
@@ -47,19 +51,14 @@ fi
4751

4852
TOOLS="iceprog icepack icemulti icepll icetime icebram"
4953

50-
EXE_O=
51-
if [ -f icepack/icepack.exe ]; then
52-
EXE_O=.exe
53-
fi
54-
5554
# -- Test the generated executables
5655
for dir in $TOOLS; do
57-
test_bin $dir/$dir$EXE_O
56+
test_bin $dir/$dir$EXE
5857
done
5958

6059
# -- Copy the executables to the bin dir
6160
for dir in $TOOLS; do
62-
cp $dir/$dir$EXE_O $PACKAGE_DIR/$NAME/bin/$dir$EXE
61+
cp $dir/$dir$EXE $PACKAGE_DIR/$NAME/bin/$dir$EXE
6362
done
6463

6564
# -- Copy the chipdb*.txt data files

scripts/compile_iverilog.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,21 @@ if [ $ARCH == "darwin" ]; then
2828
./configure --prefix=$PACKAGE_DIR/$NAME \
2929
--exec-prefix=$PACKAGE_DIR/$NAME \
3030

31-
make
31+
$MAKE
3232

3333
export PATH=$OLDPATH
34+
elif [ ${ARCH:0:7} = "windows" ]
35+
then
36+
./configure --prefix=$PACKAGE_DIR/$NAME \
37+
--exec-prefix=$PACKAGE_DIR/$NAME \
38+
LDFLAGS="-static -lstdc++ -lm" \
39+
40+
$MAKE
3441
else
3542
./configure --prefix=$PACKAGE_DIR/$NAME \
3643
--exec-prefix=$PACKAGE_DIR/$NAME \
3744

38-
make
45+
$MAKE
3946
fi
4047

41-
make install
42-
48+
$MAKE install

scripts/compile_nextpnr-ice40.sh

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,20 @@ if [ $ARCH == "darwin" ]; then
4343
.
4444
make -j$J CXX="$CXX" LIBS="-lm -fno-lto -ldl -lutil"
4545
elif [ ${ARCH:0:7} == "windows" ]; then
46+
cp $WORK_DIR/scripts/nextpnr-CMakeLists.txt CMakeLists.txt
47+
4648
cmake \
47-
-DARCH=ice40 \
48-
-DBUILD_HEAP=ON \
49-
-DCMAKE_SYSTEM_NAME=Windows \
50-
-DBUILD_GUI=OFF \
51-
-DSTATIC_BUILD=ON \
52-
-DICEBOX_ROOT=$PACKAGE_DIR/$NAME/share/icebox \
53-
-DBoost_USE_STATIC_LIBS=ON \
54-
.
55-
make -j$J CXX="$CXX" LIBS="-static -static-libstdc++ -static-libgcc -lm"
49+
-G "MinGW Makefiles" \
50+
-DARCH=ice40 \
51+
-DBUILD_HEAP=ON \
52+
-DBUILD_GUI=OFF \
53+
-DBUILD_PYTHON=ON \
54+
-DSTATIC_BUILD=ON \
55+
-DICEBOX_ROOT=$PACKAGE_DIR/$NAME/share/icebox \
56+
-DBoost_USE_STATIC_LIBS=ON \
57+
.
58+
59+
$MAKE -j$J CXX="$CXX" VERBOSE=1
5660
else
5761
cmake \
5862
-DARCH=ice40 \

0 commit comments

Comments
 (0)