Skip to content

Commit 270cc26

Browse files
authored
GitHub build actions (#18)
1 parent 672c3e8 commit 270cc26

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+881
-162
lines changed

.github/workflows/build.yml

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: CMake on macOS and Linux
2+
3+
on:
4+
[workflow_call, workflow_dispatch]
5+
6+
7+
jobs:
8+
build:
9+
runs-on: ${{ matrix.os }}
10+
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [macos-latest, ubuntu-latest]
15+
build_type: [Release]
16+
# c_compiler: [gcc, clang, cl]
17+
c_compiler: [gcc, clang]
18+
include:
19+
# - os: windows-latest
20+
# c_compiler: cl
21+
# cpp_compiler: cl
22+
- os: ubuntu-latest
23+
c_compiler: gcc
24+
cpp_compiler: g++
25+
- os: macos-latest
26+
c_compiler: clang
27+
cpp_compiler: clang++
28+
exclude:
29+
- os: windows-latest
30+
c_compiler: gcc
31+
- os: windows-latest
32+
c_compiler: clang
33+
- os: ubuntu-latest
34+
c_compiler: cl
35+
- os: ubuntu-latest
36+
c_compiler: clang
37+
- os: macos-latest
38+
c_compiler: gcc
39+
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Set reusable strings
44+
id: strings
45+
shell: bash
46+
run: |
47+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
48+
49+
- name: Install Qt
50+
uses: jurplel/install-qt-action@v4
51+
with:
52+
version: '6.7.2'
53+
target: 'desktop'
54+
55+
- name: Install libraries and dependencies (ubuntu)
56+
if: matrix.os == 'ubuntu-latest'
57+
run: |
58+
sudo apt-get install -y libgsl27 libgsl-dev libxml2 libxml2-dev cups libcups2 libreadline-dev
59+
60+
- name: Install libraries and dependencies using Homebrew (macos)
61+
if: matrix.os == 'macos-latest'
62+
run: |
63+
brew install gsl libxml2 libomp
64+
echo "OpenMP_ROOT=\"/opt/homebrew/opt/libomp/\"" >> "$GITHUB_ENV"
65+
66+
- name: Obtain files from outside the repository
67+
run: |
68+
./get_external_files.sh
69+
70+
- name: Checkout JIBAL
71+
uses: actions/checkout@v4
72+
with:
73+
repository: JYU-IBA/jibal
74+
path: jibal
75+
76+
- name: Configure JIBAL
77+
run: >
78+
cmake -B ${{ github.workspace }}/build_jibal
79+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
80+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
81+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
82+
-S ${{ github.workspace }}/jibal
83+
84+
- name: Build JIBAL
85+
run: cmake --build ${{ github.workspace }}/build_jibal --config ${{ matrix.build_type }}
86+
87+
- name: Install JIBAL
88+
run: |
89+
cmake --install ${{ github.workspace }}/build_jibal --prefix ${{ github.workspace }}/install
90+
sudo cmake --install ${{ github.workspace }}/build_jibal
91+
92+
- name: Configure
93+
run: >
94+
cmake -B ${{ github.workspace }}/build_qjabs
95+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
96+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
97+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
98+
-S ${{ github.workspace }}/qjabs
99+
100+
- name: Build
101+
run: cmake --build ${{ github.workspace }}/build_qjabs --config ${{ matrix.build_type }}
102+
103+
- name: Install
104+
run: cmake --install ${{ github.workspace }}/build_qjabs --prefix ${{ github.workspace }}/install
105+
106+
- name: Deploy Qt app (macos)
107+
if: matrix.os == 'macos-latest'
108+
run: |
109+
cd release_scripts
110+
./deploy_mac.sh
111+
cp ${{ github.workspace }}/build_qjabs/JaBS*.dmg ${{ github.workspace }}/install
112+
113+
- name: Upload artifact
114+
uses: actions/upload-artifact@v4
115+
with:
116+
name: artifact-${{matrix.os}}
117+
path: ${{ github.workspace }}/install

.github/workflows/build_windows.yml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: CMake on Windows
2+
3+
on:
4+
[workflow_call, workflow_dispatch]
5+
6+
env:
7+
BUILD_TYPE: Release
8+
9+
jobs:
10+
build:
11+
runs-on: windows-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install Qt
17+
uses: jurplel/install-qt-action@v4
18+
with:
19+
version: '6.7.2'
20+
target: 'desktop'
21+
22+
- name: vcpkg build
23+
uses: johnwason/vcpkg-action@v6
24+
id: vcpkg
25+
with:
26+
pkgs: gsl getopt libxml2
27+
triplet: x64-windows-release
28+
token: ${{ github.token }}
29+
github-binarycache: true
30+
31+
- name: Obtain files from outside the repository
32+
shell: cmd
33+
run: |
34+
cd ${{runner.workspace}}\jabs
35+
.\get_external_files.bat
36+
37+
- name: Checkout JIBAL
38+
uses: actions/checkout@v4
39+
with:
40+
repository: JYU-IBA/jibal
41+
path: jibal
42+
43+
- name: Configure JIBAL
44+
run: cmake ${{ steps.vcpkg.outputs.vcpkg-cmake-config }} -B ${{github.workspace}}\build_jibal -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -S ${{github.workspace}}\jibal
45+
46+
- name: Build JIBAL
47+
run: cmake --build ${{ github.workspace }}\build_jibal --config ${{ env.build_type }}
48+
49+
- name: Install JIBAL
50+
run: cmake --install ${{ github.workspace }}\build_jibal --prefix ${{ github.workspace }}\install
51+
52+
- name: Configure JaBS
53+
run: cmake ${{ steps.vcpkg.outputs.vcpkg-cmake-config }} -DCMAKE_PREFIX_PATH="${{github.workspace}}\install" -B ${{github.workspace}}\build_jabs -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -S ${{github.workspace}}
54+
55+
- name: Build JaBS
56+
run: cmake --build ${{github.workspace}}\build_jabs --config ${{env.BUILD_TYPE}}
57+
58+
- name: Install JaBS
59+
run: cmake --install ${{ github.workspace }}\build_jabs --prefix ${{ github.workspace }}\install
60+
61+
- name: Configure QJaBS
62+
run: cmake ${{ steps.vcpkg.outputs.vcpkg-cmake-config }} -DCMAKE_PREFIX_PATH="${{github.workspace}}\install" -B ${{github.workspace}}\build_qjabs -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -S ${{github.workspace}}\qjabs
63+
64+
- name: Build QJaBS
65+
run: cmake --build ${{github.workspace}}\build_qjabs --config ${{env.BUILD_TYPE}}
66+
67+
- name: Deploy Qt
68+
run: ${{env.QT_ROOT_DIR}}\bin\windeployqt ${{github.workspace}}\build_qjabs\${{ env.build_type }}\qjabs.exe
69+
- name: Run deploy script
70+
shell: cmd
71+
run: |
72+
cd ${{runner.workspace}}\jabs\release_scripts
73+
.\deploy_win.bat
74+
75+
- name: Upload artifact
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: artifact-windows
79+
path: |
80+
${{ github.workspace }}/build_qjabs/${{ env.build_type }}
81+

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ qjabs/.vscode/
99
*.swp
1010
*.dmg
1111
*.zip
12-
QCustomPlot.tar.gz
12+
*.tar.gz
1313
qcustomplot

INSTALL.md

+68-19
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,77 @@ Standalone Windows and macOS disk images (dmg) are found in [GitHub releases](ht
66

77
JaBS uses a standard CMake build system. See instructions on [running CMake](https://cmake.org/runningcmake/) or follow instructions below.
88

9-
Run script `get_qcustomplot.sh` or download [QCustomPlot](https://www.qcustomplot.com/index.php/download) source code manually. The cpp and h files must be placed in qjabs directory.
9+
JaBS depends on [GSL](https://www.gnu.org/software/gsl/), [JIBAL](https://github.com/JYU-IBA/jibal), [libxml2](https://gitlab.gnome.org/GNOME/libxml2/-/wikis/home), and the GUI (QJaBS)
10+
depends additionally on [Qt 6](https://www.qt.io/) and [QCustomPlot](https://www.qcustomplot.com/).
1011

11-
## Microsoft Windows 10:
12+
Preferred compiler on Windows is MSVC 2019 (for Qt compatibility), Clang on macOS and GCC on Linux.
13+
14+
Creating binary distributions may be challenging, see [GitHub workflows](.github/workflows). The Windows binary distribution is created with this workflow.
1215

13-
1. Install [JIBAL](https://github.com/JYU-IBA/jibal/blob/master/INSTALL.md).
14-
2. Install *libxml2* using vcpkg (follow the JIBAL instructions mutatis mutandis)
15-
3. See and run [deploy_win.bat](release_scripts/deploy_win.bat) file to prepare a standalone installation. There are hard coded locations in the file, so be sure to change those if necessary.
16+
There are scripts that manage downloading QCustomPlot and JIBAL datafiles (for Windows and macOS).
1617
## Linux
17-
1. Install [JIBAL](https://github.com/JYU-IBA/jibal/blob/master/INSTALL.md).
18-
2. Install *libxml2* using your distributions package manager
19-
- On Ubuntu / Debian / Raspberry Pi OS: `apt install libxml2-dev`
20-
- On Arch: `pacman -S libxml2`
21-
3. Install also *libreadline-dev* (optional)
22-
4. Run the following:
18+
1. Install dependencies using your distributions package manager
19+
- On Ubuntu / Debian / Raspberry Pi OS: `sudo apt install libgsl27 libgsl-dev libxml2 libxml2-dev libreadline-dev`
20+
- On Arch: `sudo pacman -S gsl libxml2 readline`
21+
2. Obtain source codes of [JIBAL](https://github.com/JYU-IBA/jibal/) and JaBS (this repository)
22+
```shell
23+
git clone https://github.com/JYU-IBA/jibal.git
24+
git clone https://github.com/JYU-IBA/jabs.git
25+
```
26+
3. Compile JIBAL and install it to /usr/local (recommended, but you may also install it to some other prefix)
27+
```shell
28+
cmake -B jibal/build_jibal -S jibal
29+
cmake --build jibal/build_jibal
30+
sudo cmake --install build_jibal
31+
```
32+
33+
4. Compile and install JaBS (CLI version)
34+
```shell
35+
cmake -B jabs/build_jabs -S jabs
36+
cmake --build jabs/build_jabs
37+
sudo cmake --install jabs/build_jabs
38+
```
39+
5. Install dependencies for the Qt version:
40+
```shell
41+
sudo apt install qt6-base-dev
42+
```
43+
6. Run script `get_external_files.sh` or download [QCustomPlot](https://www.qcustomplot.com/index.php/download) source code manually. The cpp and h files must be placed in qjabs directory.
44+
45+
7. Compile and install QJaBS (Qt GUI version)
46+
```shell
47+
cmake -B jabs/build_qjabs -S jabs/qjabs
48+
cmake --build jabs/build_qjabs
49+
sudo cmake --install jabs/build_qjabs
50+
```
2351

24-
$ git clone https://github.com/JYU-IBA/jabs.git
25-
$ mkdir build && cd build
26-
$ cmake ../
27-
$ make
28-
$ sudo make install
52+
If you get errors when running JaBS, check that the JIBAL library can be found, e.g.
53+
```shell
54+
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"
55+
sudo ldconfig
56+
```
57+
58+
There are also build scripts in the [release scripts](release_scripts/) directory. See what they do before running them.
59+
60+
You will also need some stopping data for JIBAL:
61+
```shell
62+
curl "http://users.jyu.fi/~jaakjuli/jibal/data/data.tar.gz" -o "jibal_data.tar.gz"
63+
tar zxvf jibal_data.tar.gz -C "$HOME/.jibal"
64+
```
65+
66+
## Microsoft Windows 10:
2967

30-
5. Compiling Qt GUI, install Qt 6 and try similar build steps in [qjabs](qjabs/) directory
68+
1. Install Build tools for [Visual Studio 2019.](https://visualstudio.microsoft.com/downloads/)
69+
2. Install Qt 6.7.2 (or maybe something later). This might be easier to do with [unofficial tools](https://github.com/miurahr/aqtinstall/).
70+
3. Install *gsl*, *getopt*, *libxml2* using vcpkg. Make sure your triplet is x64-windows-release.
71+
4. Follow steps for Linux above, but
72+
- Run the first cmake (configure) with: `cmake -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-release -DVCPKG_MANIFEST_MODE=OFF -DCMAKE_BUILD_TYPE=Release -B build_dir -S source_dir`
73+
- Install JIBAL (and everything else) to some prefix (here: *install*) with `cmake --install build_jibal --prefix install`
74+
- Give subsequent JaBS and QJaBS CMake configure steps `-DCMAKE_PREFIX_PATH=install` so that JaBS can find the installed JIBAL library from the directory given by the prefix
75+
5. Run [Qt Windows Deployment tool](https://doc.qt.io/qt-6/windows-deployment.html) (windeployqt) on qjabs.exe:
76+
```shell
77+
windeployqt build_qjabs\Release\qjabs.exe
78+
```
79+
6. See and run [deploy_win.bat](release_scripts/deploy_win.bat) file to prepare a standalone installation. This is mostly intended to be run by GitHub, so some hard-coded directories may be different than in the instructions above.
3180

3281
## MacOS:
3382
1. Install [Homebrew](https://brew.sh/)
@@ -36,8 +85,8 @@ Run script `get_qcustomplot.sh` or download [QCustomPlot](https://www.qcustomplo
3685
$ brew tap JYU-IBA/iba
3786
$ brew install jabs-cli
3887

39-
4. If you want to develop JaBS and not just use it, follow Linux instructions above, install *libxml2*, *readline* and *qt6* using Homebrew. Installing *libomp* from homebrew is also recommended to enable OpenMP parallel processing. You may need to set the *OpenMP_ROOT* environment variable to get CMake to find it on Apple silicon, like this:
88+
3. If you want to develop JaBS and not just use it, follow Linux instructions above, install *libxml2*, *readline* and *qt6* using Homebrew. Installing *libomp* from homebrew is also recommended to enable OpenMP parallel processing. You may need to set the *OpenMP_ROOT* environment variable to get CMake to find it on Apple silicon, like this:
4089

4190
$ export OpenMP_ROOT="/opt/homebrew/opt/libomp/"
4291

43-
5. Disk image (dmg) can be created using [deploy_mac.sh](release_scripts/deploy_mac.sh) script, assuming JIBAL data can be found from home directory.
92+
4. Disk image (dmg) for QJaBS app can be created using [deploy_mac.sh](release_scripts/deploy_mac.sh) script. Note that some assumptions are made, so read it be fore using it. Running cmake --install is recommended for JIBAL and JaBS, but not for QJaBS.

QCustomPlot.tar.gz.sha256

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
https://www.qcustomplot.com/release/2.1.1/QCustomPlot.tar.gz
12
9afc16e70e8bd8c8d5b13020387716f5e063e115b6599f0421a3846dc6ec312a

get_external_files.bat

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
curl "https://www.qcustomplot.com/release/2.1.1/QCustomPlot.tar.gz" -o QCustomPlot.tar.gz
2+
tar -zxvf QCustomPlot.tar.gz
3+
copy qcustomplot\qcustomplot.h qjabs
4+
copy qcustomplot\qcustomplot.cpp qjabs

get_qcustomplot.sh get_external_files.sh

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#!/bin/bash
2-
qcustomplot_version="2.1.1"
3-
release_url="https://www.qcustomplot.com/release/${qcustomplot_version}/";
42
for file in QCustomPlot.tar.gz; do
53
shafile="${file}.sha256"
6-
url="${release_url}${file}"
7-
echo "Downloading $file using curl from $url"
8-
curl "$url" -o "$file"
9-
if echo "$(cat $shafile) QCustomPlot.tar.gz" | shasum -a 256 --check --status; then
4+
url="$(head -n 1 "$shafile")"
5+
if [ -f "${file}" ]; then
6+
echo "File $file already exists, not downloading."
7+
else
8+
echo "Downloading $file using curl from $url"
9+
curl "$url" -o "$file"
10+
fi
11+
if echo "$(tail -n 1 $shafile) $file" | shasum -a 256 --check --status; then
1012
echo "$file passes SHA sum check."
1113
if [[ "$file" == "QCustomPlot.tar.gz" ]]; then
1214
tar -xf "$file"

qjabs/CMakeLists.txt

+11-14
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,6 @@ set(PROJECT_SOURCES
117117
icons.qrc
118118
)
119119

120-
set(MACOSX_BUNDLE_ICON_FILE icon.icns)
121-
set(app_icon_macos "${CMAKE_CURRENT_SOURCE_DIR}/icons/icon.icns")
122-
set_source_files_properties(${app_icon_macos} PROPERTIES
123-
MACOSX_PACKAGE_LOCATION "Resources")
124-
125120
if (WIN32)
126121
set(app_icon_resource_windows "${CMAKE_CURRENT_SOURCE_DIR}/icon.rc")
127122
qt_add_executable(qjabs
@@ -130,11 +125,20 @@ if (WIN32)
130125
${app_icon_resource_windows}
131126
)
132127
elseif(APPLE)
133-
qt_add_executable(qjabs
134-
MACOSX_BUNDLE
128+
set(MACOSX_BUNDLE_ICON_FILE icon.icns)
129+
set(app_icon_macos "${CMAKE_CURRENT_SOURCE_DIR}/icons/icon.icns")
130+
set_source_files_properties(${app_icon_macos} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
131+
qt_add_executable(qjabs MACOSX_BUNDLE
135132
${PROJECT_SOURCES}
136133
${app_icon_macos}
137134
)
135+
set_target_properties(qjabs PROPERTIES
136+
MACOSX_BUNDLE_BUNDLE_NAME JaBS
137+
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
138+
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
139+
MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
140+
MACOSX_BUNDLE_ICON_FILE icon.icns
141+
)
138142
else()
139143
qt_add_executable(qjabs
140144
${PROJECT_SOURCES}
@@ -163,13 +167,6 @@ if(OpenMP_C_FOUND)
163167
target_link_libraries(qjabs PUBLIC OpenMP::OpenMP_C)
164168
endif()
165169

166-
set_target_properties(qjabs PROPERTIES
167-
MACOSX_BUNDLE_BUNDLE_NAME JaBS
168-
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
169-
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
170-
MACOSX_BUNDLE_ICON_FILE icon.icns
171-
)
172-
173170
install(TARGETS qjabs
174171
BUNDLE DESTINATION .
175172
RUNTIME DESTINATION bin)

0 commit comments

Comments
 (0)