Skip to content

Commit f17058b

Browse files
authored
Merge pull request #3 from ccrma/meson
Replacing cmake with meson (WIP) wow it's actually working
2 parents 4b2cc42 + c04f8d1 commit f17058b

39 files changed

+1488
-295
lines changed

.github/workflows/build-unit-tests.yml

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
- os: windows-latest
3030
c_compiler: cl
3131
cpp_compiler: cl
32+
meson_flags: --backend vs
3233
- os: ubuntu-latest
3334
c_compiler: gcc
3435
cpp_compiler: g++
@@ -38,29 +39,21 @@ jobs:
3839
steps:
3940
- uses: actions/checkout@v3
4041

41-
- name: Set reusable strings
42-
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
43-
id: strings
44-
shell: bash
45-
run: |
46-
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
47-
48-
- name: Configure CMake
49-
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
50-
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
51-
run: >
52-
cmake -B ${{ steps.strings.outputs.build-output-dir }}
53-
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
54-
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
55-
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
56-
-S ${{ github.workspace }}
57-
58-
- name: Build
59-
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
60-
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} -j
61-
62-
- name: Test
63-
working-directory: ${{ steps.strings.outputs.build-output-dir }}
64-
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
65-
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
66-
run: ctest
42+
- name: Set up python
43+
uses: actions/setup-python@v5
44+
with:
45+
python-version: '3.x'
46+
- name: Install dependencies
47+
run: python -m pip install meson ninja
48+
- name: Add msbuild to PATH
49+
if: ${{ matrix.os == 'windows-latest' }}
50+
uses: microsoft/setup-msbuild@v2
51+
- name: Configure Project
52+
run: meson setup builddir/ ${{ matrix.meson_flags }}
53+
env:
54+
CC: ${{ matrix.c_compiler }}
55+
CXX: ${{ matrix.cpp_compiler }}
56+
- name: Compile
57+
run: meson compile -C builddir/
58+
- name: Run Tests
59+
run: "meson test -C builddir/ -v chump:"

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,13 @@
4545
build*/
4646
*.cmake
4747

48+
# Externals
4849
third-party/*
50+
subprojects/Catch2-3.6.0/
51+
subprojects/Catch2-3.7.1/
52+
subprojects/curl-8.8.0/*
53+
subprojects/nlohmann_json-3.11.2/*
54+
subprojects/packagecache/*
55+
.vscode/
56+
57+

README.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,35 @@ The ChucK Manager of Packages
1010
### Linux
1111
`apt-get install libssl-dev libncurses5-dev libncursesw5-dev`
1212

13+
14+
1315
## Building & Testing
1416

1517
### Linux
1618
```
17-
# Create a build dir
18-
mkdir build
19-
cd build
20-
# configure cmake
21-
cmake . -S ../
22-
# compile
23-
cmake --build . -j
24-
# run tests
25-
ctest
19+
# configure build dir
20+
meson setup builddir
21+
# Go to build dir
22+
cd builddir
23+
# Compile the project
24+
meson compile
25+
# Run unit tests
26+
meson test
2627
```
2728

2829
### Windows
2930
```
30-
# create build directory in build/
31-
cmake -Bbuild
32-
# compile
33-
cmake --build build -j
34-
# run tests
35-
cd build
36-
# configure your build dir
37-
ctest -C Debug # or Release
38-
ctest
31+
# configure build dir
32+
meson setup builddir --backend vs
33+
# Go to build dir
34+
cd builddir
35+
# Compile the project
36+
meson compile
37+
# Run unit tests
38+
meson test
39+
40+
# If you want to run chump.exe, you need to run it in a meson devenv:
41+
meson devenv -C .\builddir\
42+
.\chump-cli\chump.exe
43+
3944
```

chump-cli/main.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// desc: command line chuck entry point
66
//-----------------------------------------------------------------------------
77

8+
#include "chuck_version.h"
89
#include "exec.h"
910
#include "manager.h"
1011
#include "util.h"
@@ -25,8 +26,13 @@ int main( int argc, const char ** argv ) {
2526
fs::create_directories(path);
2627

2728
// Build manager and run command
28-
Manager* m = new Manager("../data/packages.json");
29-
execCommand(cmd, args, m);
29+
try {
30+
Manager* m = new Manager("../data/packages.json", path, ChuckVersion::makeSystemVersion(), ApiVersion::makeSystemVersion(), whichOS(), true);
31+
execCommand(cmd, args, m);
32+
} catch (const std::exception &e) {
33+
std::cerr << e.what() << std::endl;
34+
return 1;
35+
}
3036

3137
return 0;
3238
}

chump-cli/meson.build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
executable(
2+
'chump', 'main.cpp',
3+
include_directories : inc,
4+
dependencies: chump_lib_dep
5+
)

data/packages.json

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
{
1818
"version": "1.0.0",
1919
"api_version": "10.1",
20-
"language_version": "1.5.2.3",
20+
"language_version_min": "1.5.2.0",
2121
"os": "linux",
2222
"files": [
2323
"https://ccrma.stanford.edu/~nshaheed/chugins/Hydra/linux/Hydra.chug"
@@ -26,10 +26,80 @@
2626
{
2727
"version": "1.0.0",
2828
"api_version": "10.1",
29-
"language_version": "1.5.2.3",
29+
"language_version_min": "1.5.2.0",
3030
"os": "windows",
3131
"files": [
32-
"http://ccrma.stanford.edu/~nshaheed/chugins/Hydra/linux/Hydra.chug"
32+
"https://ccrma.stanford.edu/~nshaheed/chugins/Hydra/linux/Hydra.chug"
33+
]
34+
}
35+
]
36+
},
37+
{
38+
"name": "Rec",
39+
"authors": [
40+
"Nick Shaheed"
41+
],
42+
"homepage": "https://github.com/nshaheed/helper-ck",
43+
"repository": "https://github.com/nshaheed/helper-ck",
44+
"license": "tbd",
45+
"description": "Helper functions for recording to audio files. Supports recording from dac, ugens, and arrays of ugens.",
46+
"keywords": [
47+
"utility",
48+
"recording"
49+
],
50+
"versions": [
51+
{
52+
"version": "1.0.0",
53+
"api_version": "10.1",
54+
"language_version_min": "1.5.2.0",
55+
"os": "linux",
56+
"files": [
57+
"https://github.com/nshaheed/helper-ck/raw/7a0a9be47a89c4d91ff2ea4b6ea02dc740ec8278/Rec.ck"
58+
]
59+
}
60+
]
61+
},
62+
{
63+
"name": "TestPackage",
64+
"authors": [
65+
"Nick Shaheed"
66+
],
67+
"homepage": "",
68+
"repository": "",
69+
"license": "gpl3",
70+
"description": "This is a test package for running integration tests.",
71+
"keywords": [
72+
"tests",
73+
"useless",
74+
"do no use",
75+
"seriously"
76+
],
77+
"versions": [
78+
{
79+
"version": "0.9.0",
80+
"api_version": "9.1",
81+
"language_version_min": "1.5.2.0",
82+
"os": "linux",
83+
"files": [
84+
"https://ccrma.stanford.edu/~nshaheed/chugins/test_package/1.0.0/doesnotexist.ck"
85+
]
86+
},
87+
{
88+
"version": "1.0.0",
89+
"api_version": "9.1",
90+
"language_version_min": "1.5.2.0",
91+
"os": "linux",
92+
"files": [
93+
"https://ccrma.stanford.edu/~nshaheed/chugins/test_package/1.0.0/hello.ck"
94+
]
95+
},
96+
{
97+
"version": "2.0.0",
98+
"api_version": "10.1",
99+
"language_version_min": "1.5.2.6",
100+
"os": "linux",
101+
"files": [
102+
"https://ccrma.stanford.edu/~nshaheed/chugins/test_package/2.0.0/hello.ck"
33103
]
34104
}
35105
]

extern/pdcurses/meson.build

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
pdcurses_lib_sources = [
2+
'common/acs437.h',
3+
'common/acsgr.h',
4+
'common/acsuni.h',
5+
'common/font437.h',
6+
'common/iconbmp.h',
7+
'curses.h',
8+
'curspriv.h',
9+
'panel.h',
10+
'pdcurses/addch.c',
11+
'pdcurses/addchstr.c',
12+
'pdcurses/addstr.c',
13+
'pdcurses/attr.c',
14+
'pdcurses/beep.c',
15+
'pdcurses/bkgd.c',
16+
'pdcurses/border.c',
17+
'pdcurses/clear.c',
18+
'pdcurses/color.c',
19+
'pdcurses/debug.c',
20+
'pdcurses/delch.c',
21+
'pdcurses/deleteln.c',
22+
'pdcurses/getch.c',
23+
'pdcurses/getstr.c',
24+
'pdcurses/getyx.c',
25+
'pdcurses/inch.c',
26+
'pdcurses/inchstr.c',
27+
'pdcurses/initscr.c',
28+
'pdcurses/inopts.c',
29+
'pdcurses/insch.c',
30+
'pdcurses/insstr.c',
31+
'pdcurses/instr.c',
32+
'pdcurses/kernel.c',
33+
'pdcurses/keyname.c',
34+
'pdcurses/mouse.c',
35+
'pdcurses/move.c',
36+
'pdcurses/outopts.c',
37+
'pdcurses/overlay.c',
38+
'pdcurses/pad.c',
39+
'pdcurses/panel.c',
40+
'pdcurses/printw.c',
41+
'pdcurses/refresh.c',
42+
'pdcurses/scanw.c',
43+
'pdcurses/scroll.c',
44+
'pdcurses/scr_dump.c',
45+
'pdcurses/slk.c',
46+
'pdcurses/termattr.c',
47+
'pdcurses/touch.c',
48+
'pdcurses/util.c',
49+
'pdcurses/window.c',
50+
'wincon/pdcclip.c',
51+
'wincon/pdcdisp.c',
52+
'wincon/pdcgetsc.c',
53+
'wincon/pdckbd.c',
54+
'wincon/pdcscrn.c',
55+
'wincon/pdcsetsc.c',
56+
'wincon/pdcutil.c',
57+
'wincon/pdcwin.h',
58+
]
59+
60+
pdcurses_lib = static_library(
61+
'pdcurses_lib',
62+
sources: pdcurses_lib_sources,
63+
install: true
64+
)
65+
66+
pdcurses_lib_dep = declare_dependency(
67+
link_with : pdcurses_lib
68+
)

include/chuck_version.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#ifndef __CHUCKVERSION_H__
2+
#define __CHUCKVERSION_H__
3+
4+
#include <string>
5+
6+
using std::string;
7+
8+
struct ChuckVersion {
9+
ChuckVersion();
10+
ChuckVersion(string version_string);
11+
12+
static ChuckVersion makeSystemVersion();
13+
static ChuckVersion makeVersion(string version_string);
14+
15+
// Format is mega.major.minor.patch (i.e. 1.5.2.4)
16+
int mega;
17+
int major;
18+
int minor;
19+
int patch;
20+
21+
friend bool operator==(const ChuckVersion& lhs, const ChuckVersion& rhs);
22+
friend bool operator!=(const ChuckVersion& lhs, const ChuckVersion& rhs);
23+
friend bool operator<(const ChuckVersion& lhs, const ChuckVersion& rhs);
24+
friend bool operator<=(const ChuckVersion& lhs, const ChuckVersion& rhs);
25+
friend bool operator>(const ChuckVersion& lhs, const ChuckVersion& rhs);
26+
friend bool operator>=(const ChuckVersion& lhs, const ChuckVersion& rhs);
27+
28+
void set_version(string version_string);
29+
30+
friend std::ostream& operator<<(std::ostream& os, const ChuckVersion& pkg);
31+
};
32+
33+
34+
struct ApiVersion {
35+
ApiVersion();
36+
ApiVersion(string version_string);
37+
38+
static ApiVersion makeSystemVersion();
39+
static ApiVersion makeVersion(string version_string);
40+
41+
42+
// Format is major.minor (i.e. 10.1)
43+
int major;
44+
int minor;
45+
46+
friend bool operator==(const ApiVersion& lhs, const ApiVersion& rhs);
47+
friend bool operator!=(const ApiVersion& lhs, const ApiVersion& rhs);
48+
friend bool operator<(const ApiVersion& lhs, const ApiVersion& rhs);
49+
friend bool operator<=(const ApiVersion& lhs, const ApiVersion& rhs);
50+
friend bool operator>(const ApiVersion& lhs, const ApiVersion& rhs);
51+
friend bool operator>=(const ApiVersion& lhs, const ApiVersion& rhs);
52+
53+
void set_version(string version_string);
54+
55+
friend std::ostream& operator<<(std::ostream& os, const ApiVersion& pkg);
56+
};
57+
58+
#endif

0 commit comments

Comments
 (0)