Skip to content

Commit

Permalink
Install (#31)
Browse files Browse the repository at this point in the history
Add `make install` `make uninstall` and `make check-install` features.

`check-install` compiles, links, and runs the `example/decode` program.  This ensures the headers and library are installed correctly.

Moved `include/ict` into `include/xenon/ict`.

Signed-off-by: Mark Beckwith <wythe@intrig.com>
  • Loading branch information
wythe authored Aug 28, 2019
1 parent cd4097a commit 0e25bb9
Show file tree
Hide file tree
Showing 47 changed files with 128 additions and 157 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "include/ict"]
path = include/ict
path = include/xenon/ict
url = https://github.com/intrig/ict.git
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ notifications:
email: false
compiler:
- gcc

os:
-linux

script:
- ./configure && make && make check && sudo make install && sudo ldconfig && make check-install
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all clean realclean check test update get-deps
.PHONY: all clean realclean check test update get-deps install uninstall check-install

all: include/ict/ict.h build
ninja -C build
Expand All @@ -17,7 +17,17 @@ realclean:
check: build
ninja -C build test

test: check
install: build
ninja -C build install

uninstall:
ninja -C build uninstall

check-install: build
XDDLPATH=/usr/local/share/xddl xv unit/xddlunit/icd_gold.xv
c++ -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -std=c++17 -O3 -o 'build/decode.cpp.o' -c examples/decode.cpp
c++ -o build/decode 'build/decode.cpp.o' -lxenon
XDDLPATH=/usr/local/share/xddl build/decode

tags:
@echo Making tags...
Expand Down
40 changes: 23 additions & 17 deletions examples/decode.cpp
Original file line number Diff line number Diff line change
@@ -1,58 +1,64 @@
//-- Copyright 2016 Intrig
//-- See https://github.com/intrig/xenon for license.
#include <iostream>
#include <vector>
#include <xenon/xenon.h>

using std::cout;
using std::cerr;
using std::cout;

struct nv_pairs {
nv_pairs(const std::string & name, int64_t value) : name(name), value(value) {}
nv_pairs(const std::string &name, int64_t value)
: name(name), value(value) {}
std::string name;
int64_t value;
};

int main(int, char**) {
int main(int, char **) {
try {
auto fields = std::vector<nv_pairs>();

cout << "loading\n";
xenon::spec_server doc("~/wythe/xenon/xddl/icd.xddl");
xenon::spec_server doc("icd.xddl");
cout << "assigning\n";
auto msg = xenon::parse(doc, "0101046B102C000114E03003603800203801C03801E03801F030037030002030"
"00903000603000E0300120300130380000300110300030380080300200300210"
"3001903001603000F03000703000403000C03000503000D1A03C9E16C18070DE"
"2C7CFF3C7CC1001E00E01C000389");
auto msg = xenon::parse(
doc,
"0101046B102C000114E03003603800203801C03801E03801F030037030002030"
"00903000603000E0300120300130380000300110300030380080300200300210"
"3001903001603000F03000703000403000C03000503000D1A03C9E16C18070DE"
"2C7CFF3C7CC1001E00E01C000389");

cout << "iterating over top level nodes only\n";
for (auto c = msg.begin(); c != msg.end(); ++c) {
// and now we can process each node
cout << c->name() << '\n';
}

cout << "putting fields and their values into a vector: " << xenon::to_text(msg);
cout << "putting fields and their values into a vector: "
<< xenon::to_text(msg);

// We can do this using the ict::recurse() algorithm that takes a root node and a lambda expression. The first
// cursor parameter in the lambda expression is a cursor to the current node.
// We can do this using the ict::recurse() algorithm that takes a root
// node and a lambda expression. The first cursor parameter in the
// lambda expression is a cursor to the current node.
ict::recurse(msg.root(), [&](xenon::message::cursor c) {
if (c->consumes()) fields.emplace_back(c->name(), c->value());
if (c->consumes())
fields.emplace_back(c->name(), c->value());
});
cout << "done, processed " << fields.size() << " fields\n\n";

cout << "now find a field: DATA/MSG_TYPE\n";
auto c = xenon::find_first(msg, "DATA/MSG_TYPE");

if (c != msg.end()) cout << "found it! " << xenon::description(c) << "\n\n";
if (c != msg.end())
cout << "found it! " << xenon::description(c) << "\n\n";

cout << "now find another\n";
c = xenon::find_first(msg.root(), "RLP_CAP_INFO_BLOCK/MAX_MS_NAK_ROUNDS_FWD");
c = xenon::find_first(msg.root(),
"RLP_CAP_INFO_BLOCK/MAX_MS_NAK_ROUNDS_FWD");
if (c != msg.end()) {
cout << "found it! " << c->value() << "\n";
cout << "full path is: " << xenon::path_string(c) << "\n\n";
}

} catch (std::exception & e) {
} catch (std::exception &e) {
cerr << e.what() << '\n';
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/sibs.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//-- Copyright 2016 Intrig
//-- See https://github.com/intrig/xenon for license.
#include <iostream>
#include <ict/command.h>
#include <xenon/ict/command.h>
#include <xenon/xenon.h>

using std::cout;
Expand Down
2 changes: 1 addition & 1 deletion include/xenon/DateTime.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <ctime>
#include <iomanip>

#include <ict/ict.h>
#include "ict/ict.h"

#ifdef _WIN32
#define NOMINMAX
Expand Down
2 changes: 1 addition & 1 deletion include/xenon/att_pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//-- Copyright 2016 Intrig
//-- See https://github.com/intrig/xenon for license.
#include <vector>
#include <ict/string64.h>
#include <xenon/ict/string64.h>

namespace xenon {
struct att_pair {
Expand Down
4 changes: 1 addition & 3 deletions include/xenon/cpp_code.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once
//-- Copyright 2016 Intrig
//-- See https://github.com/intrig/xenon for license.
#include <ict/ict.h>
#include "ict/ict.h"

#include <string>
#include <vector>
Expand Down
4 changes: 1 addition & 3 deletions include/xenon/functions.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once
//-- Copyright 2016 Intrig
//-- See https://github.com/intrig/xenon for license.
#include <ict/ict.h>
#include "ict/ict.h"
#include <vector>
#include <string>

Expand Down
35 changes: 34 additions & 1 deletion include/xenon/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,38 @@ xddl_h = custom_target(
'xddl_h',
output : 'xddl.h',
input : '../../src/xddl.xspx',
command : [xspx_exe, '-H', '@OUTPUT@', '-S', 'foo.cpp', '@INPUT@'])
command : [xspx_exe, '-H', '@OUTPUT@', '-S', 'foo.cpp', '@INPUT@'],
install : true,
install_dir : get_option('includedir') + '/xenon')

install_headers(
'DateTime.h',
'att_pair.h',
'cloned_ptr.h',
'cpp_code.h',
'functions.h',
'message.h',
'node.h',
'recref.h',
'spec_server.h',
'xddl_code.h',
'xddl_head.h',
'xddl_parser.h',
'xddl_tail.h',
'xenon.h',
'ximsi.h',
'xml_parser.h',
'xml_parser_base.h',
install_dir : get_option('includedir') + '/xenon')

install_headers(
'ict/bitstring.h',
'ict/command.h',
'ict/exception.h',
'ict/expr.h',
'ict/ict.h',
'ict/multivector.h',
'ict/netvar.h',
'ict/osstream.h',
'ict/string64.h',
install_dir : get_option('includedir') + '/xenon/ict')
5 changes: 1 addition & 4 deletions include/xenon/message.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#pragma once
//-- Copyright 2016 Intrig
//-- See https://github.com/intrig/xenon for license.
// #include <ict/multivector.h>
#include <ict/bitstring.h>
#include "ict/bitstring.h"
#include "xddl.h"
#include <xenon/node.h>

Expand Down
8 changes: 3 additions & 5 deletions include/xenon/node.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#pragma once
//-- Copyright 2016 Intrig
//-- See https://github.com/intrig/xenon for license.
#include <ict/bitstring.h>
#include <ict/multivector.h>
#include <ict/string64.h>
#include "ict/bitstring.h"
#include "ict/multivector.h"
#include "ict/string64.h"
#include <memory>
#include <functional>
#include <iostream>
Expand Down
3 changes: 1 addition & 2 deletions include/xenon/recref.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include <ict/ict.h>
#include "ict/ict.h"
#include <string>

namespace ict {
Expand Down
2 changes: 1 addition & 1 deletion include/xenon/xddl_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//-- Copyright 2016 Intrig
//-- See https://github.com/intrig/xenon for license.
#include <xenon/xml_parser_base.h>
#include <ict/osstream.h>
#include <xenon/ict/osstream.h>

#include <stack>
#include <map>
Expand Down
10 changes: 4 additions & 6 deletions include/xenon/xddl_head.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#pragma once
//-- Copyright 2016 Intrig
//-- See https://github.com/intrig/xenon for license.
#include <ict/string64.h>
#include <ict/ict.h>
#include <ict/multivector.h>
#include "ict/ict.h"
#include "ict/string64.h"
#include "ict/multivector.h"
#include <string>
#include <ict/expr.h>
#include "ict/expr.h"
#include <xenon/att_pair.h>
#include <xenon/functions.h>
#include <xenon/recref.h>
Expand Down
4 changes: 1 addition & 3 deletions include/xenon/xenon.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#pragma once
//-- Copyright 2016 Intrig
//-- See https://github.com/intrig/xenon for license.
#include <random>
#include <functional>
#include <xenon/recref.h>
#include <xenon/message.h>
#include <xenon/spec_server.h>
#include <ict/bitstring.h>
#include "ict/bitstring.h"
namespace xenon {
inline ict::bitstring serialize(const message & m) {
ict::obitstream bs;
Expand Down
9 changes: 3 additions & 6 deletions include/xenon/ximsi.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#pragma once
//-- Copyright 2016 Intrig
//-- See https://github.com/intrig/xenon for license.

#include <string.h>
#include <iostream>
#include <ict/bitstring.h>
#include <ict/exception.h>
#include "ict/bitstring.h"
#include "ict/exception.h"
#include <cstdint>
#include <ict/netvar.h>
#include "ict/netvar.h"

namespace ict {
namespace util {
Expand Down
2 changes: 1 addition & 1 deletion include/xenon/xml_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <xenon/xml_parser_base.h>

#include <ict/string64.h>
#include <xenon/ict/string64.h>
#include <xenon/att_pair.h>

// TODO: rewrite XmlParserBase to be
Expand Down
2 changes: 1 addition & 1 deletion include/xenon/xml_parser_base.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
//-- Copyright 2016 Intrig
//-- See https://github.com/intrig/xenon for license.
#include <ict/ict.h>
#include "ict/ict.h"

#include <string>
#include <iostream>
Expand Down
5 changes: 5 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ subdir('xddl')
subdir('unit')
subdir('examples')
subdir('perf')

install_subdir('xddl',
exclude_directories : ['logs', 'IP/logs'],
exclude_files : ['README.txt', '3GPP/36.331.asn', '3GPP/25.331.asn'],
install_dir : get_option('datadir'))
2 changes: 1 addition & 1 deletion perf/decode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <vector>
#include <xenon/xenon.h>
#include <xenon/xddl_code.h>
#include <ict/command.h>
#include <xenon/ict/command.h>
#include <boost/filesystem.hpp>

namespace bf = boost::filesystem;
Expand Down
3 changes: 2 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ xddl_cpp = custom_target(

xenon_lib = library('xenon', 'lua-5.1.4/src/lua_all.cpp', 'xml_parser_base.cpp',
'message.cpp', 'xenon.cpp', xddl_h, xddl_cpp,
include_directories : [inc, lua_inc])
include_directories : [inc, lua_inc],
install : true)
4 changes: 2 additions & 2 deletions src/xddl.xspx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
#include &lt;xenon/xddl_head.h&gt;
#include &lt;memory&gt;
#include &lt;bitset&gt;
#include &lt;ict/multivector.h&gt;
#include &lt;ict/expr.h&gt;
#include &lt;xenon/ict/multivector.h&gt;
#include &lt;xenon/ict/expr.h&gt;
</code>

<!-- code segment at the bottom of header file. -->
Expand Down
2 changes: 1 addition & 1 deletion src/xenon.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//-- Copyright 2016 Intrig
//-- See https://github.com/intrig/xenon for license.
#include <algorithm>
#include <ict/bitstring.h>
#include <xenon/ict/bitstring.h>
#include <xenon/xenon.h>
#include <xenon/node.h>
#include <xenon/xddl.h>
Expand Down
6 changes: 1 addition & 5 deletions src/xml_parser_base.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
//-- Copyright 2016 Intrig
//-- See https://github.com/intrig/xenon for license.

#include <xenon/xml_parser_base.h>

#include <ict/ict.h>
#include <xenon/ict/ict.h>

namespace xenon {
// order matters here, index is state()
Expand Down
2 changes: 1 addition & 1 deletion tools/asnstrip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <algorithm>
#include <vector>

#include <ict/command.h>
#include <xenon/ict/command.h>
#include <xenon/xddl_code.h>


Expand Down
2 changes: 1 addition & 1 deletion tools/asnx/asn1.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <iostream>
#include <fstream>
#include "asnast.h"
#include <ict/command.h>
#include <xenon/ict/command.h>
#include <cstdio>

using namespace std;
Expand Down
2 changes: 1 addition & 1 deletion tools/asnx/asnast.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//-- Copyright 2016 Intrig
//-- See https://github.com/intrig/xenon for license.
#include "asnast.h"
#include <ict/ict.h>
#include <xenon/ict/ict.h>

using namespace std;

Expand Down
Loading

0 comments on commit 0e25bb9

Please sign in to comment.