ADD: project settings.

main
bog 2023-09-09 13:02:52 +02:00
parent 59eab10960
commit dfd65e5fc3
8 changed files with 124 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*~*
*\#*
build
.cache

12
Makefile Normal file
View File

@ -0,0 +1,12 @@
.PHONY: build tests
build:
meson setup build
meson compile -C build
tests: build
build/joko-tests
install: tests
meson install -C build

6
lib/commons.hpp Normal file
View File

@ -0,0 +1,6 @@
#ifndef jk_COMMONS_HPP
#define jk_COMMONS_HPP
#include "mutils.hpp"
#endif

9
lib/config.in.hpp Normal file
View File

@ -0,0 +1,9 @@
#ifndef jk_CONFIG_IN_HPP
#define jk_CONFIG_IN_HPP
#include <filesystem>
#define JOKO_VERSION "@version@"
#define JOKO_LIBDIR std::filesystem::path("@libdir@")
#endif

4
lib/mutils.hpp Normal file
View File

@ -0,0 +1,4 @@
#ifndef jk_MUTILS_HPP
#define jk_MUTILS_HPP
#endif

46
meson.build Normal file
View File

@ -0,0 +1,46 @@
project('joko',
'cpp',
version: '0.0.0',
default_options: [
'warning_level=3',
'cpp_std=c++17'
])
joko_libdir = get_option('prefix') / get_option('libdir') / 'joko'
conf = configuration_data()
conf.set('version', meson.project_version())
conf.set('libdir', joko_libdir)
configure_file(
input: 'lib/config.in.hpp',
output: 'config.hpp',
configuration: conf
)
joko_lib = static_library(
'joko',
sources: [
],
dependencies: [
])
joko_dep = declare_dependency(link_with: joko_lib)
executable('joko',
sources: [
'src/main.cpp',
],
dependencies: [
joko_dep
],
install: true)
executable('joko-tests',
sources: [
'tests/main.cpp'
],
dependencies: [
joko_dep,
dependency('catch2')
])

41
src/main.cpp Normal file
View File

@ -0,0 +1,41 @@
#include <iostream>
#include <getopt.h>
#include "config.hpp"
int main(int argc, char** argv)
{
int index;
struct option options[] = {
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{0, 0, 0, 0}
};
int c = getopt_long(argc, argv, "hv", options, &index);
switch (c)
{
case 'h': {
std::cout << "Usage: joko [OPTIONS] source_file" << std::endl;
std::cout << "OPTIONS" << std::endl;
std::cout << "\t" << "-h, --help"
<< "\t" << "show this message." << std::endl;
std::cout << "\t" << "-v, --version"
<< "\t" << "show joko version." << std::endl;
return 0;
} break;
case 'v': {
std::cout << "--- Joko Programming Language ---" << std::endl;
std::cout << "[License]: " << "GPL v3 (see LICENSE)" << std::endl;
std::cout << "[Version]: " << JOKO_VERSION << std::endl;
std::cout << "[Lib directory]: " << JOKO_LIBDIR << std::endl;
return 0;
} break;
}
return 0;
}

2
tests/main.cpp Normal file
View File

@ -0,0 +1,2 @@
#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>