Skip to content

Commit

Permalink
Merge pull request #13 from paldepind/support-mason
Browse files Browse the repository at this point in the history
Add support for Mason
  • Loading branch information
paldepind authored Mar 30, 2024
2 parents 918ee7a + d26e20c commit fec7e32
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ request.
|-----------|------------------|--------------------------------------------|--------------------------------------------------------|
| Cargo | Rust | `Cargo.toml` | `cargo build` <br/> `cargo run` <br/> `cargo test` |
| Poetry | Python | `pyproject.toml` with `[tool.poetry]` | `poetry build` <br/> run n/a <br/> `poetry run pytest` |
| CMake | C/C++/Obj-C | `CMakeLists.txt` | `cmake --build . --target test` |
| CMake | C, C++ and Obj-C | `CMakeLists.txt` | `cmake --build . --target test` |
| Meson | C, C++, etc. | `meson.build` | `meson compile` <br/> run n/a <br/> `meson test` |
| npm | JavaScript, etc. | `package.json` | `npm build` <br/> `npm start` <br/> `npm test` |
| yarn | JavaScript, etc. | `package.json` and `yarn.lock` | `yarn build` <br/> `yarn start` <br/> `yarn test` |
| Maven | Java, etc. | `pom.xml` | `mvn compile` <br/> run n/a <br/> `mvn test` |
Expand Down
21 changes: 20 additions & 1 deletion projectdo
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

VERSION="0.2.0"
VERSION="0.2.1"

# Global mutable variables.
QUIET=false
Expand Down Expand Up @@ -107,6 +107,24 @@ try_cargo() {
fi
}

# Meson

try_meson() {
if [ -f meson.build ]; then
case $ACTION in
build)
execute "meson compile"
exit ;;
test)
execute "meson test"
exit ;;
run)
echo "projectdo does not know how to run a project with Meson."
exit
esac
fi
}

# CMake

try_cmake() {
Expand Down Expand Up @@ -272,6 +290,7 @@ detect_and_run() {
try_cargo
try_stack
try_cabal
try_meson
try_cmake
try_maven
try_lein
Expand Down
11 changes: 11 additions & 0 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,17 @@ if describe "latex"; then
fi
fi

if describe "meson"; then
if it "can build with meson"; then
do_build_in "meson"; assert
assertEqual "$RUN_RESULT" "meson compile"
fi
if it "can test with meson"; then
do_test_in "meson"; assert
assertEqual "$RUN_RESULT" "meson test"
fi
fi

echo ""

if [ $ANY_ERRORS = true ]; then
Expand Down
Empty file added tests/meson/CMakeLists.txt
Empty file.
8 changes: 8 additions & 0 deletions tests/meson/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
project('meson', 'c',
version : '0.1',
default_options : ['warning_level=3'])

exe = executable('meson', 'meson.c',
install : true)

test('basic', exe)
12 changes: 12 additions & 0 deletions tests/meson/meson.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <stdio.h>

#define PROJECT_NAME "meson"

int main(int argc, char **argv) {
if(argc != 1) {
printf("%s takes no arguments.\n", argv[0]);
return 1;
}
printf("This is project %s.\n", PROJECT_NAME);
return 0;
}

0 comments on commit fec7e32

Please sign in to comment.