Skip to content

Commit

Permalink
[WIP] Win64 native build (#69)
Browse files Browse the repository at this point in the history
* Win64 cygwin build and package

* Fix bitfield packing declarations for IWDG and TMC2209
  • Loading branch information
vintagepc authored Jul 13, 2021
1 parent 11a44c5 commit 49862be
Show file tree
Hide file tree
Showing 24 changed files with 211 additions and 154 deletions.
182 changes: 101 additions & 81 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
build_linux:
# The type of runner that the job will run on
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'NO_BUILD')"
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
run: cd ${{ runner.workspace }}/MINI404 && ./configure --target-list="buddy-softmmu"

- name: Build qemu-system-buddy
run: cd ${{ runner.workspace }}/MINI404 && make -j2
run: cd ${{ runner.workspace }}/MINI404 && make -j3

- name: Checkout Wiki
uses: actions/checkout@v2.2.0
Expand All @@ -86,14 +86,15 @@ jobs:
if: ${{ !github.event.pull_request }}
run: |
cd ${{ runner.workspace }}/MINI404/build
mv buddy-softmmu Mini404-dev
tar -jhcvf Mini404-development-build.tar.bz2 Mini404-dev
mv buddy-softmmu Mini404-dev-linux
mv assets Mini404-dev-linux
tar -jhcvf Mini404-dev-build-linux.tar.bz2 Mini404-dev-linux
- name: Upload artifact
if: ${{ !github.event.pull_request }}
uses: actions/upload-artifact@v2
with:
name: Binaries
path: ${{ runner.workspace }}/MINI404/build/Mini404-development-build.tar.bz2
path: ${{ runner.workspace }}/MINI404/build/Mini404-dev-build-linux.tar.bz2

# build_osx:
# # The type of runner that the job will run on
Expand Down Expand Up @@ -139,98 +140,118 @@ jobs:
# name: Binaries
# path: ${{ runner.workspace }}/MK404/build/MK404_OSX

# build_cygwin:
# # The type of runner that the job will run on
# runs-on: windows-latest
# if: "!contains(github.event.head_commit.message, 'NO_BUILD')"
# steps:
# - uses: actions/cache@v1
# with:
# path: C:\tools\chococache
# key: ${{ runner.os }}-cygwin-${{ github.sha }}
# restore-keys: |
# ${{ runner.os }}-cygwin-
# - name: Cygwin package cache
# uses: actions/cache@v1
# with:
# path: C:\tools\cygcache
# key: ${{ runner.os }}-cygwinpkgs-1_1
# restore-keys: |
# ${{ runner.os }}-cygwinpkgs-
# - name: Install cygwin
# run: |
# choco config set cacheLocation C:\tools\chococache
# choco install --no-progress cygwin
# - name: Install cygwin dependencies
# run: |
# C:\tools\cygwin\cygwinsetup.exe -qgnNdO -l C:/tools/cygcache -R C:/tools/cygwin -s http://mirrors.kernel.org/sourceware/cygwin/ -P cmake,make,libelf-devel,gcc-core,gcc-g++,libstdc++-6-devel,git,libglut-devel,libGLEW-devel,libSDL_sound-devel,libSDL-devel,avr-gcc,python2,libpng-devel
# shell: cmd

# - name: Checkout ${{ github.event.pull_request.head.ref }}
# uses: actions/checkout@v2.2.0
# if: ${{ github.event.pull_request }}
# with:
# repository: vintagepc/MK404.git
# ref: ${{ github.event.pull_request.head.sha }}
# submodules: true
build_cygwin:
# The type of runner that the job will run on
runs-on: windows-latest
if: "!contains(github.event.head_commit.message, 'NO_BUILD')"
steps:
- uses: actions/cache@v1
with:
path: C:\tools\chococache
key: ${{ runner.os }}-cygwin-${{ github.sha }}
restore-keys: |
${{ runner.os }}-cygwin-
- name: Cygwin package cache
uses: actions/cache@v1
with:
path: C:\tools\cygcache
key: ${{ runner.os }}-cygwinpkgs-1_1
restore-keys: |
${{ runner.os }}-cygwinpkgs-
- name: Install cygwin
run: |
choco config set cacheLocation C:\tools\chococache
choco install --no-progress cygwin
- name: Install cygwin dependencies
run: |
C:\tools\cygwin\cygwinsetup.exe -qgnNdO -l C:/tools/cygcache -R C:/tools/cygwin -s http://mirrors.kernel.org/sourceware/cygwin/ -P "mingw64-x86_64-gcc-g++,mingw64-x86_64-glew,mingw64-x86_64-freeglut,mingw64-x86_64-curl,mingw64-x86_64-glib-2.0,mingw64-x86_64-gtk3,mingw64-x86_64-libepoxy,mingw64-x86_64-pixman,mingw64-x86_64-pkg-config,mingw64-x86_64-libusb1.0,mingw64-x86_64-usbredir,python3-setuptools,git,gcc-core,make,zip"
shell: cmd

# - name: Checkout ${{ github.event.ref }}
# uses: actions/checkout@v2.2.0
# if: ${{ !github.event.pull_request }}
# with:
# repository: vintagepc/MK404.git
# ref: ${{ github.event.ref }}
# submodules: true
- name: Fix CRLF Checkout
run: git config --global core.autocrlf false

# - name: Configure build
# run: |
# echo %USERPROFILE%
# cd MK404
# mkdir build
# cd build
# set PATH=C:\tools\cygwin\bin;C:\tools\cygwin\usr\bin
# bash.exe -c "cmake -DCMAKE_BUILD_TYPE=RELEASE .."
# shell: cmd
- name: Checkout ${{ github.event.pull_request.head.ref }}
uses: actions/checkout@v2.2.0
if: ${{ github.event.pull_request }}
with:
repository: vintagepc/MINI404.git
ref: ${{ github.event.pull_request.head.sha }}
submodules: false

# - name: Build
# run: |
# cd ${{runner.workspace}}\MK404\build
# pwd
# set PATH=C:\tools\cygwin\bin;C:\tools\cygwin\usr\bin
# bash.exe -c "make -j2"
# shell: cmd
- name: Checkout ${{ github.event.ref }}
uses: actions/checkout@v2.2.0
if: ${{ !github.event.pull_request }}
with:
repository: vintagepc/MINI404.git
ref: ${{ github.event.ref }}
submodules: false

# - name: Upload Cygwin artifact
# if: ${{ !github.event.pull_request }}
# uses: actions/upload-artifact@v2
# with:
# name: Binaries
# path: ${{ runner.workspace }}/MK404/build/MK404.exe
# Note we need to sed LDFLAGS_NO_PIE because mingw's LD is no-pie by default and doesn't
# recognize the `--no-pie` argument... not that it matters because we don't need to build the ROMs here.
- name: Configure build
run: |
cd MINI404
mkdir build
cd build
set PATH=C:\tools\cygwin\bin;C:\tools\cygwin\usr\bin
bash.exe -c "../configure --cross-prefix=x86_64-w64-mingw32- --target-list=buddy-softmmu --enable-gtk --enable-libusb"
bash.exe -c "sed -i 's/LDFLAGS_NOPIE=-no-pie/LDFLAGS_NOPIE=/g' config-host.mak"
shell: cmd

- name: Build
run: |
cd ${{runner.workspace}}\MINI404\build
pwd
set PATH=C:\tools\cygwin\bin;C:\tools\cygwin\usr\bin
bash.exe -c "make -j3"
shell: cmd
- name: Assemble artifacts and libraries
if: ${{ !github.event.pull_request }}
run: |
cd ${{ runner.workspace }}/MINI404/build
mkdir Mini404-dev-w64
mv qemu-system-buddy.exe Mini404-dev-w64
mv assets Mini404-dev-w64
cd Mini404-dev-w64
set PATH=C:\tools\cygwin\bin;C:\tools\cygwin\usr\bin
bash.exe -c "mkdir pc-bios && echo \"Placeholder. DO NOT DELETE THIS DIRECTORY, IT MUST EXIST OR QEMU WILL HANG ON BOOT\" > pc-bios/README.txt"
bash.exe -c "for i in `ldd qemu-system-buddy.exe | grep \"not found\" | cut -f2 | cut -d\" \" -f1 | sort | uniq`; do echo Copying $i; cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/$i .; done"
bash.exe -c "while `ldd *.dll | grep -q \"not found\"`; do for i in `ldd *.dll | grep \"not found\" | cut -f2 | cut -d\" \" -f1 | sort | uniq`; do echo Copying $i; cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/$i .; done; sleep 2; done"
cd ..
zip -r Mini404-dev-build-w64.zip Mini404-dev-w64
shell: cmd

- name: Upload Cygwin artifact
if: ${{ !github.event.pull_request }}
uses: actions/upload-artifact@v2
with:
name: Binaries
path: ${{ runner.workspace }}/MINI404/build/Mini404-dev-build-w64.zip

Publish:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request }}
needs: [build]
needs: [build_linux, build_cygwin]
steps:
- name: Retrieve platform binaries
uses: actions/download-artifact@v2
with:
name: Binaries

- name: Extract assets
run: |
tar -jxvf Mini404-development-build.tar.bz2
- name: Check tag version
id: get_version
if: startsWith(github.ref, 'refs/tags/v')
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}

- name: Build ${{ steps.get_version.outputs.VERSION }} tarball
- name: Build ${{ steps.get_version.outputs.VERSION }} archives
if: startsWith(github.ref, 'refs/tags/v')
run: |
mv Mini404-dev Mini404-${{ steps.get_version.outputs.VERSION }}
tar -jcvf Mini404-${{ steps.get_version.outputs.VERSION }}-linux.tar.bz2 Mini404-${{ steps.get_version.outputs.VERSION }}
tar -jxvf Mini404-dev-build-linux.tar.bz2
unzip Mini404-dev-build-w64.zip
mv Mini404-dev-linux Mini404-${{ steps.get_version.outputs.VERSION }}-linux
mv Mini404-dev-w64 Mini404-${{ steps.get_version.outputs.VERSION }}-w64
tar -jcvf Mini404-${{ steps.get_version.outputs.VERSION }}-linux.tar.bz2 Mini404-${{ steps.get_version.outputs.VERSION }}-linux
zip -r Mini404-${{ steps.get_version.outputs.VERSION }}-w64.zip Mini404-${{ steps.get_version.outputs.VERSION }}-w64
- name: RELEASE THE KRAKEN
if: startsWith(github.ref, 'refs/tags/v')
Expand All @@ -240,11 +261,8 @@ jobs:
prerelease: false
files: |
Mini404-${{ steps.get_version.outputs.VERSION }}-linux.tar.bz2
- name: Rebuild dev tarball
if: steps.get_version.outcome == 'Skipped'
run: tar -jcvf Mini404-dev-linux.tar.bz2 Mini404-dev

Mini404-${{ steps.get_version.outputs.VERSION }}-w64.zip
- name: Publish prerelease
if: steps.get_version.outcome == 'Skipped'
uses: "marvinpinto/action-automatic-releases@latest"
Expand All @@ -255,3 +273,5 @@ jobs:
title: "Latest (Development) Build"
files: |
Mini404-dev-linux.tar.bz2
Mini404-dev-w64.zip
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Run CPPCheck
run: |
cd ${{ runner.workspace }}/MINI404
cppcheck --template='::{severity} file={file},line={line}::{message}' --error-exitcode=2 --inline-suppr --enable=warning --suppress='*:hw/arm/prusa/3rdParty/*' hw/arm/prusa/*
cppcheck --template='::{severity} file={file},line={line}::{message}' --error-exitcode=2 --inline-suppr --enable=warning --suppress='*:hw/arm/prusa/3rdParty/*' hw/arm/prusa
# - name: Run Clang-tidy
# run: |
Expand Down
2 changes: 1 addition & 1 deletion hw/arm/prusa/3rdParty/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
arm_ss.add(when: ['CONFIG_OPENGL', 'CONFIG_BUDDYBOARD'],
arm_ss.add(when: ['CONFIG_BUDDYBOARD'],
if_true: files('arcball/Camera.cpp',
'tinyobjloader/tiny_obj_loader.cc'
))
40 changes: 29 additions & 11 deletions hw/arm/prusa/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
subdir('3rdParty')
subdir('opengl')
libglut = cc.find_library('glut', required: false)
if build_machine.system() == 'cygwin'
message('Cross build, finding opengl32. libglew32 and libglu32')
libgl = cc.find_library('libopengl32', required: false)
libglu = cc.find_library('libglu32', required: false)
libglew = cc.find_library('libglew32', required: false)
else
message('Native build, looking for GLEW/GLU/GL')
libgl = cc.find_library('GL', required: false)
libglu = cc.find_library('GLU', required: false)
libglew = cc.find_library('GLEW', required: false)
endif

if libglut.found() and libglu.found() and libglew.found() and libgl.found()
message('OpenGL libraries found - enabling Mini404 GL extensions')
buddy_gl = declare_dependency(compile_args: '-DBUDDY_HAS_GL')
arm_ss.add(when: 'CONFIG_BUDDYBOARD', if_true: [libgl, libglu, libglut, libglew, buddy_gl])
subdir('3rdParty')
subdir('opengl')
subdir('assets')
else
message('OpenGL libraries not found. Install development packages for freeglut, glew, and mesa and re-run configure.')

endif



subdir('stm32f407')
subdir('assets')


arm_ss.add(when: 'CONFIG_BUDDYBOARD', if_true: files(
'prusa-mini.c',
Expand All @@ -21,11 +46,4 @@ arm_ss.add(when: 'CONFIG_BUDDYBOARD', if_true: files(
))

# Required if using Message queue IPC
c = meson.get_compiler('c')
arm_ss.add(when: 'CONFIG_BUDDYBOARD', if_true: cc.find_library('rt'))
arm_ss.add(when: ['CONFIG_BUDDYBOARD','CONFIG_OPENGL'], if_true: cc.find_library('glut'))
arm_ss.add(when: ['CONFIG_BUDDYBOARD','CONFIG_OPENGL'], if_true: cc.find_library('GLU'))
arm_ss.add(when: ['CONFIG_BUDDYBOARD','CONFIG_OPENGL'], if_true: cc.find_library('GL'))
arm_ss.add(when: ['CONFIG_BUDDYBOARD','CONFIG_OPENGL'], if_true: cc.find_library('GLEW'))

# hw_arch += {'arm': buddy_ss}

2 changes: 1 addition & 1 deletion hw/arm/prusa/opengl/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
arm_ss.add(when: ['CONFIG_OPENGL', 'CONFIG_BUDDYBOARD'],
arm_ss.add(when: ['CONFIG_BUDDYBOARD'],
if_true: files('GLDashboardMgr.cpp',
'GLMotor.cpp',
'IPCIndicator.cpp',
Expand Down
14 changes: 7 additions & 7 deletions hw/arm/prusa/parts/gl_dashboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ OBJECT_DEFINE_TYPE_SIMPLE_WITH_INTERFACES(GLDashboadState, gldashboard, GLDASHBO

static void gldashboard_realize(DeviceState *dev, Error **errp)
{
#ifdef CONFIG_OPENGL
#ifdef BUDDY_HAS_GL
GLDashboadState *s = GLDASHBOARD(dev);
if (s->dashboard_type) {
s->dashboardmgr = gl_dashboard_start(s->dashboard_type);
Expand All @@ -62,7 +62,7 @@ static void gldashboard_realize(DeviceState *dev, Error **errp)
}

static void gldashboard_motor_in(void *opaque, int n, int level) {
#ifdef CONFIG_OPENGL
#ifdef BUDDY_HAS_GL
GLDashboadState *s = GLDASHBOARD(opaque);
if (s->dashboard_type) {
gl_dashboard_update_motor(s->dashboardmgr,n,level);
Expand All @@ -71,7 +71,7 @@ static void gldashboard_motor_in(void *opaque, int n, int level) {
}

static void gldashboard_motor_stall_in(void *opaque, int n, int level) {
#ifdef CONFIG_OPENGL
#ifdef BUDDY_HAS_GL
GLDashboadState *s = GLDASHBOARD(opaque);
if (s->dashboard_type) {
gl_dashboard_update_motor_stall(s->dashboardmgr,n,level);
Expand All @@ -80,7 +80,7 @@ static void gldashboard_motor_stall_in(void *opaque, int n, int level) {
}

static void gldashboard_motor_enable_in(void *opaque, int n, int level) {
#ifdef CONFIG_OPENGL
#ifdef BUDDY_HAS_GL
GLDashboadState *s = GLDASHBOARD(opaque);
if (s->dashboard_type) {
gl_dashboard_update_motor_enable(s->dashboardmgr,n,level);
Expand All @@ -90,7 +90,7 @@ static void gldashboard_motor_enable_in(void *opaque, int n, int level) {


static void gldashboard_indicator_in(void *opaque, int n, int level) {
#ifdef CONFIG_OPENGL
#ifdef BUDDY_HAS_GL
GLDashboadState *s = GLDASHBOARD(opaque);
if (s->dashboard_type) {
gl_dashboard_update_indicator(s->dashboardmgr,n,level);
Expand All @@ -99,7 +99,7 @@ static void gldashboard_indicator_in(void *opaque, int n, int level) {
}

static void gldashboard_indicator_logic_in(void *opaque, int n, int level) {
#ifdef CONFIG_OPENGL
#ifdef BUDDY_HAS_GL
GLDashboadState *s = GLDASHBOARD(opaque);
if (s->dashboard_type) {
gl_dashboard_update_indicator(s->dashboardmgr,n,level ? 255 : 0);
Expand All @@ -112,7 +112,7 @@ static void gldashboard_finalize(Object *obj)
}

static void gldashboard_reset(DeviceState *dev) {
#ifdef CONFIG_OPENGL
#ifdef BUDDY_HAS_GL
GLDashboadState *s = GLDASHBOARD(dev);
if (s->dashboard_type) {
gl_dashboard_reset(s->dashboardmgr);
Expand Down
2 changes: 1 addition & 1 deletion hw/arm/prusa/parts/st7789v.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static uint32_t st7789v_transfer(SSISlave *dev, uint32_t data)
uint8_t r;
uint8_t a;
};
} color;
} QEMU_PACKED color;
color.full = 0;
uint16_t word = 0;
if (s->mode == ST7789V_CMD) {
Expand Down
Loading

0 comments on commit 49862be

Please sign in to comment.