feature/kb #14

Merged
cromer merged 27 commits from feature/kb into develop 2023-02-23 01:09:37 -03:00
10 changed files with 60 additions and 33 deletions
Showing only changes of commit 48955026c4 - Show all commits

View File

@ -1 +0,0 @@
../include/version.h.in

View File

@ -29,12 +29,4 @@ if docs_enabled
endif endif
endif endif
lib_enabled = get_option('lib')
if lib_enabled
subdir('lib')
endif
bin_enabled = get_option('bin')
if bin_enabled
subdir('src') subdir('src')
endif

View File

@ -1,13 +1,3 @@
option('bin',
type: 'boolean',
value: true,
description: 'Build the obelisk compiler'
)
option('lib',
type: 'boolean',
value: true,
description: 'Build the obelisk library'
)
option('docs', option('docs',
type: 'boolean', type: 'boolean',
value: true, value: true,

27
src/lib/include/obelisk.h Normal file
View File

@ -0,0 +1,27 @@
#include <string>
/**
* @brief The obelisk namespace contains everything needed to compile obelisk.
* code.
*
*/
namespace obelisk
{
class Obelisk
{
public:
/**
* @brief Get the obelisk version.
*
* @return std::string The version.
*/
std::string getVersion();
/**
* @brief Get the obelisk library so version.
*
* @return int The version.
*/
int getLibVersion();
};
} // namespace obelisk

View File

@ -7,14 +7,23 @@ configure_file(input : 'version.h.in',
) )
obelisk_lib_sources = files( obelisk_lib_sources = files(
'obelisk.cpp'
) )
sqlite3 = dependency('sqlite3') sqlite3 = dependency('sqlite3')
library('obelisk', incdirs = include_directories(['.', 'include'])
lib = library('obelisk',
obelisk_lib_sources, obelisk_lib_sources,
include_directories: incdirs,
dependencies : [sqlite3], dependencies : [sqlite3],
version : meson.project_version(), version : meson.project_version(),
soversion : project_version_lib, soversion : project_version_lib,
install : true install : true
) )
libobelisk_dep = declare_dependency(
include_directories : incdirs,
link_with : lib,
sources : obelisk_lib_sources
)

14
src/lib/obelisk.cpp Normal file
View File

@ -0,0 +1,14 @@
#include "include/obelisk.h"
#include "version.h"
// TODO: Move the models to the library then link the compiler to the library
std::string obelisk::Obelisk::getVersion()
{
return obelisk::version;
}
int obelisk::Obelisk::getLibVersion()
{
return obelisk::soVersion;
}

View File

@ -10,5 +10,7 @@ namespace obelisk
* @brief The current library version of obelisk. * @brief The current library version of obelisk.
* *
*/ */
const std::string soVersion = "@so_version@"; // clang-format off
const int soVersion = @so_version@;
// clang-format on
} // namespace obelisk } // namespace obelisk

View File

@ -1,10 +1,4 @@
conf_data = configuration_data() subdir('lib')
conf_data.set('version', meson.project_version())
conf_data.set('so_version', project_version_lib)
configure_file(input : 'version.h.in',
output : 'version.h',
configuration : conf_data
)
obelisk_sources = files( obelisk_sources = files(
'obelisk.cpp', 'obelisk.cpp',
@ -29,7 +23,7 @@ link_args = ' ' + r.stdout().replace('\n', ' ')
executable('obelisk', executable('obelisk',
obelisk_sources, obelisk_sources,
dependencies : [sqlite3], dependencies : [libobelisk_dep, sqlite3],
cpp_args : cpp_args.split(), cpp_args : cpp_args.split(),
link_args : link_args.split(), link_args : link_args.split(),
install : true install : true

View File

@ -1,8 +1,9 @@
#include "knowledge_base.h" #include "knowledge_base.h"
#include "lexer.h" #include "lexer.h"
#include "lib/include/obelisk.h"
#include "lib/version.h"
#include "obelisk.h" #include "obelisk.h"
#include "parser.h" #include "parser.h"
#include "version.h"
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
@ -123,7 +124,7 @@ int main(int argc, char** argv)
return EXIT_SUCCESS; return EXIT_SUCCESS;
break; break;
case 'v' : case 'v' :
std::cout << "obelisk " << obelisk::version << std::endl; std::cout << "obelisk " << (new obelisk::Obelisk())->getVersion() << std::endl;
return EXIT_SUCCESS; return EXIT_SUCCESS;
break; break;
default : default :

View File

@ -1 +0,0 @@
../include/version.h.in