Skip to content

Commit

Permalink
Add CMakeList for compile proto
Browse files Browse the repository at this point in the history
  • Loading branch information
MizukiSonoko committed Jun 13, 2017
1 parent d3dc9f9 commit 925836d
Show file tree
Hide file tree
Showing 18 changed files with 85 additions and 1,251 deletions.
30 changes: 2 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,44 +1,18 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 2.5)
PROJECT(iroha C CXX)

SET(CMAKE_CXX_FLAGS "-std=c++1y -Wall -fPIC")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3")
SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wextra -Wno-unused-parameter -O0")
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)

option(BENCHMARKING "Build benchmarks" OFF)
option(TESTING "Build tests" ON)

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
message(STATUS "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
message(STATUS "-DTESTING=${TESTING}")
message(STATUS "-DBENCHMARKING=${BENCHMARKING}")

set(IROHA_SCHEMA_DIR "${PROJECT_SOURCE_DIR}/schema")

include_directories(
${PROJECT_SOURCE_DIR}/core
${PROJECT_SOURCE_DIR}/core/infra/ametsuchi/include
${IROHA_SCHEMA_DIR}
)

include("cmake/dependencies.cmake")
set(IROHA_SCHEMA_DIR "${PROJECT_SOURCE_DIR}/schema")
add_subdirectory(schema)
add_subdirectory(core)
add_subdirectory(peer)
add_subdirectory(tools)

link_directories(${PROJECT_BINARY_DIR}/lib)

if(TESTING)
enable_testing()
add_subdirectory(test)
endif()


if(BENCHMARKING)
add_subdirectory(benchmark)
endif()
6 changes: 3 additions & 3 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ add_dependencies(spdlog gabime_spdlog)
#########################
find_package(protobuf)

ExternalProject_Add(gvanas_keccak
ExternalProject_Add(protobuf
GIT_REPOSITORY "https://github.com/google/protobuf"
GIT_TAG "v3.3.0"
BUILD_IN_SOURCE 1
Expand All @@ -163,8 +163,8 @@ ExternalProject_Add(gvanas_keccak
TEST_COMMAND "" # remove test step
UPDATE_COMMAND "" # remove update step
)
ExternalProject_Get_Property(gvanas_keccak source_dir)
set(keccak_SOURCE_DIR "${source_dir}")
ExternalProject_Get_Property(protobuf source_dir)
set(protobuf_SOURCE_DIR "${source_dir}")



Expand Down
5 changes: 5 additions & 0 deletions schema/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@

# ToDo use macro
execute_process(COMMAND "protoc -I. --cpp_out=. --proto_path=commands.proto block.proto")
execute_process(COMMAND "protoc -I. --cpp_out=. --proto_path=commands.proto asset.proto")
execute_process(COMMAND "protoc -I. --cpp_out=. --proto_path=commands.proto commands.proto")
execute_process(COMMAND "protoc -I. --cpp_out=. --proto_path=commands.proto primitive.proto")
4 changes: 2 additions & 2 deletions schema/asset.proto
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
syntax = "proto3";
package iroha.protocol; // I think protocol is better, by mizuki
package iroha.protocol;

// For Add/Subtract/Transfer
message Asset{
string asset_id = 1;
int64 amount = 2;
int32 precision = 3;
string data = 4;
}
}
67 changes: 3 additions & 64 deletions schema/block.proto
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
syntax = "proto3";
package iroha.protocol; // I think protocol is better, by mizuki
import "actions.proto";

message Signature {
bytes pubkey = 1;
bytes signature = 2;
}
package iroha.protocol;
import "commands.proto";
import "primitive.proto";

message Transaction {
message Header {
Expand Down Expand Up @@ -38,61 +34,4 @@ message Block {

Header header = 1;
Body body = 2;
}

// It will be separated from this file.
message Command {
// AssetCommand
message AssetCommand{
oneof asset_command {
Add add = 1;
Subtract subtract = 2;
Transfer transfer = 3;
Exchange exchange = 4;
AssetSetPermission asset_set_permission = 5;
}
}
// AccountCommand
message AccountCommand {
oneof account_command {
SignatoriesRegister signatories_register = 1;
SignatoriesUnregister signatories_unregister = 2;
SetQuorum set_quorum = 3;
AccountGrant account_grant = 4;
AccountDeprive account_deprive = 5;
}
}
// DomainCommand
message DomainCommand {
oneof domain_command {
// Add asset as concept(type?) to domain
// If add asset as wallet to user, use AssetCommand::Add.
AssetCreate asset_create = 1;
DomainCreate domain_create = 2;

AccountCreate account_create = 3;
AccountDelete account_delete = 4;
AccountRegister account_register = 5;
AccountUnregister account_unregister = 6;

DomainSetPermission domain_set_permission = 7;
DomainSetNotify domain_set_notify = 8;
}
}
// PeerCommand
message PeerCommand {
oneof peer_command {
PeerAdd peer_add = 1;
PeerRemove peer_remove = 2;
PeerSetTrust peer_set_trust = 3;
PeerChangeTrust peer_change_trust = 4;
PeerSetState peer_set_state = 5;
}
}
oneof command {
AssetCommand asset_command = 1;
AccountCommand account_command = 2;
DomainCommand domain_command = 3;
PeerCommand peer_command = 4;
}
}
65 changes: 63 additions & 2 deletions schema/commands.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
syntax = "proto3";
package iroha.protocol;
import "asset.proto";
import "primitive.proto";

// AssetCommand
message Add{
Expand All @@ -17,6 +19,7 @@ message Transfer{
}
// ToDo
message Exchange{}

message AssetSetPermission{
string domain_id = 1;
string account_id = 2;
Expand Down Expand Up @@ -79,13 +82,71 @@ message DomainSetPermission{
}
message DomainSetNotify{
string target_address = 1;
// ToDo set log level
}


// ToDo
// PeerCommand
message PeerAdd{}
message PeerRemove{}
message PeerSetTrust{}
message PeerChangeTrust{}
message PeerSetState{}




message Command {
// AssetCommand
message AssetCommand{
oneof asset_command {
Add add = 1;
Subtract subtract = 2;
Transfer transfer = 3;
Exchange exchange = 4;
AssetSetPermission asset_set_permission = 5;
}
}
// AccountCommand
message AccountCommand {
oneof account_command {
SignatoriesRegister signatories_register = 1;
SignatoriesUnregister signatories_unregister = 2;
SetQuorum set_quorum = 3;
AccountGrant account_grant = 4;
AccountDeprive account_deprive = 5;
}
}
// DomainCommand
message DomainCommand {
oneof domain_command {
// Add asset as concept(type?) to domain
// If add asset as wallet to user, use AssetCommand::Add.
AssetCreate asset_create = 1;
DomainCreate domain_create = 2;

AccountCreate account_create = 3;
AccountSuspend account_delete = 4;
AccountRegister account_register = 5;
AccountUnregister account_unregister = 6;

DomainSetPermission domain_set_permission = 7;
DomainSetNotify domain_set_notify = 8;
}
}
// PeerCommand
message PeerCommand {
oneof peer_command {
PeerAdd peer_add = 1;
PeerRemove peer_remove = 2;
PeerSetTrust peer_set_trust = 3;
PeerChangeTrust peer_change_trust = 4;
PeerSetState peer_set_state = 5;
}
}
oneof command {
AssetCommand asset_command = 1;
AccountCommand account_command = 2;
DomainCommand domain_command = 3;
PeerCommand peer_command = 4;
}
}
7 changes: 7 additions & 0 deletions schema/primitive.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = "proto3";
package iroha.protocol; // I think protocol is better, by mizuki

message Signature {
bytes pubkey = 1;
bytes signature = 2;
}
54 changes: 0 additions & 54 deletions tools/CMakeLists.txt

This file was deleted.

35 changes: 0 additions & 35 deletions tools/add_peer.cpp

This file was deleted.

Loading

0 comments on commit 925836d

Please sign in to comment.