515 changed files with 35107 additions and 11672 deletions
@ -0,0 +1,183 @@ |
|||||
|
/*
|
||||
|
This file is part of cpp-ethereum. |
||||
|
|
||||
|
cpp-ethereum is free software: you can redistribute it and/or modify |
||||
|
it under the terms of the GNU General Public License as published by |
||||
|
the Free Software Foundation, either version 3 of the License, or |
||||
|
(at your option) any later version. |
||||
|
|
||||
|
cpp-ethereum is distributed in the hope that it will be useful, |
||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
GNU General Public License for more details. |
||||
|
|
||||
|
You should have received a copy of the GNU General Public License |
||||
|
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
/** @file ExportState.cpp
|
||||
|
* @author Arkadiy Paronyan <arkadiy@ethdev.com> |
||||
|
* @date 2015 |
||||
|
*/ |
||||
|
|
||||
|
#include "ExportState.h" |
||||
|
#include <QFileDialog> |
||||
|
#include <QTextStream> |
||||
|
#include <libethereum/Client.h> |
||||
|
#include "MainWin.h" |
||||
|
#include "ui_ExportState.h" |
||||
|
|
||||
|
using namespace std; |
||||
|
using namespace dev; |
||||
|
using namespace dev::eth; |
||||
|
|
||||
|
ExportStateDialog::ExportStateDialog(Main* _parent): |
||||
|
QDialog(_parent), |
||||
|
ui(new Ui::ExportState), |
||||
|
m_main(_parent) |
||||
|
{ |
||||
|
ui->setupUi(this); |
||||
|
connect(ui->close, &QPushButton::clicked, this, &ExportStateDialog::close); |
||||
|
connect(ui->accounts, &QListWidget::itemSelectionChanged, this, &ExportStateDialog::generateJSON); |
||||
|
connect(ui->contracts, &QListWidget::itemSelectionChanged, this, &ExportStateDialog::generateJSON); |
||||
|
fillBlocks(); |
||||
|
} |
||||
|
|
||||
|
ExportStateDialog::~ExportStateDialog() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
dev::eth::Client* ExportStateDialog::ethereum() const |
||||
|
{ |
||||
|
return m_main->ethereum(); |
||||
|
} |
||||
|
|
||||
|
void ExportStateDialog::on_block_editTextChanged() |
||||
|
{ |
||||
|
QString text = ui->block->currentText(); |
||||
|
int i = ui->block->count(); |
||||
|
while (i-- >= 0) |
||||
|
if (ui->block->itemText(i) == text) |
||||
|
return; |
||||
|
fillBlocks(); |
||||
|
} |
||||
|
|
||||
|
void ExportStateDialog::on_block_currentIndexChanged(int _index) |
||||
|
{ |
||||
|
m_block = ui->block->itemData(_index).toUInt(); |
||||
|
fillContracts(); |
||||
|
} |
||||
|
|
||||
|
void ExportStateDialog::fillBlocks() |
||||
|
{ |
||||
|
BlockChain const& bc = ethereum()->blockChain(); |
||||
|
QStringList filters = ui->block->currentText().toLower().split(QRegExp("\\s+"), QString::SkipEmptyParts); |
||||
|
const unsigned numLastBlocks = 10; |
||||
|
if (ui->block->count() == 0) |
||||
|
{ |
||||
|
unsigned i = numLastBlocks; |
||||
|
for (auto h = bc.currentHash(); bc.details(h) && i; h = bc.details(h).parent, --i) |
||||
|
{ |
||||
|
auto d = bc.details(h); |
||||
|
ui->block->addItem(QString("#%1 %2").arg(d.number).arg(h.abridged().c_str()), d.number); |
||||
|
if (h == bc.genesisHash()) |
||||
|
break; |
||||
|
} |
||||
|
if (ui->block->currentIndex() < 0) |
||||
|
ui->block->setCurrentIndex(0); |
||||
|
m_recentBlocks = numLastBlocks - i; |
||||
|
} |
||||
|
|
||||
|
int i = ui->block->count(); |
||||
|
while (i > 0 && i >= m_recentBlocks) |
||||
|
ui->block->removeItem(i--); |
||||
|
|
||||
|
h256Set blocks; |
||||
|
for (QString f: filters) |
||||
|
{ |
||||
|
if (f.startsWith("#")) |
||||
|
f = f.remove(0, 1); |
||||
|
if (f.size() == 64) |
||||
|
{ |
||||
|
h256 h(f.toStdString()); |
||||
|
if (bc.isKnown(h)) |
||||
|
blocks.insert(h); |
||||
|
for (auto const& b: bc.withBlockBloom(LogBloom().shiftBloom<3>(sha3(h)), 0, -1)) |
||||
|
blocks.insert(bc.numberHash(b)); |
||||
|
} |
||||
|
else if (f.toLongLong() <= bc.number()) |
||||
|
blocks.insert(bc.numberHash((unsigned)f.toLongLong())); |
||||
|
else if (f.size() == 40) |
||||
|
{ |
||||
|
Address h(f.toStdString()); |
||||
|
for (auto const& b: bc.withBlockBloom(LogBloom().shiftBloom<3>(sha3(h)), 0, -1)) |
||||
|
blocks.insert(bc.numberHash(b)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
for (auto const& h: blocks) |
||||
|
{ |
||||
|
auto d = bc.details(h); |
||||
|
ui->block->addItem(QString("#%1 %2").arg(d.number).arg(h.abridged().c_str()), d.number); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void ExportStateDialog::fillContracts() |
||||
|
{ |
||||
|
ui->accounts->clear(); |
||||
|
ui->contracts->clear(); |
||||
|
ui->accounts->setEnabled(true); |
||||
|
ui->contracts->setEnabled(true); |
||||
|
for (auto i: ethereum()->addresses(m_block)) |
||||
|
{ |
||||
|
string r = m_main->render(i); |
||||
|
(new QListWidgetItem(QString("%2: %1 [%3]").arg(formatBalance(ethereum()->balanceAt(i)).c_str()).arg(QString::fromStdString(r)).arg((unsigned)ethereum()->countAt(i)), ethereum()->codeAt(i).empty() ? ui->accounts : ui->contracts)) |
||||
|
->setData(Qt::UserRole, QByteArray((char const*)i.data(), Address::size)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void ExportStateDialog::generateJSON() |
||||
|
{ |
||||
|
std::stringstream json; |
||||
|
json << "{\n"; |
||||
|
std::string prefix; |
||||
|
for(QListWidgetItem* item: ui->accounts->selectedItems()) |
||||
|
{ |
||||
|
auto hba = item->data(Qt::UserRole).toByteArray(); |
||||
|
auto address = Address((byte const*)hba.data(), Address::ConstructFromPointer); |
||||
|
json << prefix << "\t\"" << toHex(address.ref()) << "\": { \"wei\": \"" << ethereum()->balanceAt(address, m_block) << "\" }"; |
||||
|
prefix = ",\n"; |
||||
|
} |
||||
|
for(QListWidgetItem* item: ui->contracts->selectedItems()) |
||||
|
{ |
||||
|
auto hba = item->data(Qt::UserRole).toByteArray(); |
||||
|
auto address = Address((byte const*)hba.data(), Address::ConstructFromPointer); |
||||
|
json << prefix << "\t\"" << toHex(address.ref()) << "\":\n\t{\n\t\t\"wei\": \"" << ethereum()->balanceAt(address, m_block) << "\",\n"; |
||||
|
json << "\t\t\"code\": \"" << toHex(ethereum()->codeAt(address, m_block)) << "\",\n"; |
||||
|
std::map<u256, u256> storage = ethereum()->storageAt(address, m_block); |
||||
|
if (!storage.empty()) |
||||
|
{ |
||||
|
json << "\t\t\"storage\":\n\t\t{\n"; |
||||
|
for (auto s: storage) |
||||
|
json << "\t\t\t\"" << toHex(s.first) << "\": \"" << toHex(s.second) << "\"" << (s.first == storage.rbegin()->first ? "" : ",") <<"\n"; |
||||
|
json << "\t\t}\n"; |
||||
|
} |
||||
|
json << "\t}"; |
||||
|
prefix = ",\n"; |
||||
|
} |
||||
|
json << "\n}"; |
||||
|
json.flush(); |
||||
|
|
||||
|
ui->json->setEnabled(true); |
||||
|
ui->json->setText(QString::fromStdString(json.str())); |
||||
|
ui->saveButton->setEnabled(true); |
||||
|
} |
||||
|
|
||||
|
void ExportStateDialog::on_saveButton_clicked() |
||||
|
{ |
||||
|
QString fn = QFileDialog::getSaveFileName(this, "Save state", QString(), "JSON Files (*.json)"); |
||||
|
if (!fn.endsWith(".json")) |
||||
|
fn = fn.append(".json"); |
||||
|
ofstream file(fn.toStdString()); |
||||
|
if (file.is_open()) |
||||
|
file << ui->json->toPlainText().toStdString(); |
||||
|
} |
@ -0,0 +1,57 @@ |
|||||
|
/*
|
||||
|
This file is part of cpp-ethereum. |
||||
|
|
||||
|
cpp-ethereum is free software: you can redistribute it and/or modify |
||||
|
it under the terms of the GNU General Public License as published by |
||||
|
the Free Software Foundation, either version 3 of the License, or |
||||
|
(at your option) any later version. |
||||
|
|
||||
|
cpp-ethereum is distributed in the hope that it will be useful, |
||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
GNU General Public License for more details. |
||||
|
|
||||
|
You should have received a copy of the GNU General Public License |
||||
|
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
/** @file ExportState.h
|
||||
|
* @author Arkadiy Paronyan <arkadiy@ethdev.com> |
||||
|
* @date 2015 |
||||
|
*/ |
||||
|
|
||||
|
#pragma once |
||||
|
|
||||
|
#include <memory> |
||||
|
#include <QDialog> |
||||
|
#include <libethcore/Common.h> |
||||
|
|
||||
|
namespace Ui { class ExportState; } |
||||
|
namespace dev { namespace eth { class Client; } } |
||||
|
|
||||
|
class Main; |
||||
|
|
||||
|
class ExportStateDialog: public QDialog |
||||
|
{ |
||||
|
Q_OBJECT |
||||
|
|
||||
|
public: |
||||
|
explicit ExportStateDialog(Main* _parent = 0); |
||||
|
virtual ~ExportStateDialog(); |
||||
|
|
||||
|
private slots: |
||||
|
void on_block_editTextChanged(); |
||||
|
void on_block_currentIndexChanged(int _index); |
||||
|
void on_saveButton_clicked(); |
||||
|
|
||||
|
private: |
||||
|
dev::eth::Client* ethereum() const; |
||||
|
void fillBlocks(); |
||||
|
void fillContracts(); |
||||
|
void generateJSON(); |
||||
|
|
||||
|
private: |
||||
|
std::unique_ptr<Ui::ExportState> ui; |
||||
|
Main* m_main; |
||||
|
int m_recentBlocks = 0; |
||||
|
dev::eth::BlockNumber m_block = dev::eth::LatestBlock; |
||||
|
}; |
@ -0,0 +1,183 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<ui version="4.0"> |
||||
|
<class>ExportState</class> |
||||
|
<widget class="QDialog" name="ExportState"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>0</x> |
||||
|
<y>0</y> |
||||
|
<width>490</width> |
||||
|
<height>522</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="windowTitle"> |
||||
|
<string>Export State</string> |
||||
|
</property> |
||||
|
<property name="modal"> |
||||
|
<bool>true</bool> |
||||
|
</property> |
||||
|
<layout class="QGridLayout" name="gridLayout"> |
||||
|
<item row="0" column="0"> |
||||
|
<widget class="QLabel" name="label5"> |
||||
|
<property name="sizePolicy"> |
||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> |
||||
|
<horstretch>0</horstretch> |
||||
|
<verstretch>0</verstretch> |
||||
|
</sizepolicy> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string>&Block</string> |
||||
|
</property> |
||||
|
<property name="buddy"> |
||||
|
<cstring>block</cstring> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="0" column="1"> |
||||
|
<widget class="QComboBox" name="block"> |
||||
|
<property name="editable"> |
||||
|
<bool>true</bool> |
||||
|
</property> |
||||
|
<property name="currentText"> |
||||
|
<string/> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="1" column="0"> |
||||
|
<widget class="QLabel" name="label_7"> |
||||
|
<property name="text"> |
||||
|
<string>&Accounts</string> |
||||
|
</property> |
||||
|
<property name="buddy"> |
||||
|
<cstring>accounts</cstring> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="1" column="1"> |
||||
|
<widget class="QListWidget" name="accounts"> |
||||
|
<property name="enabled"> |
||||
|
<bool>false</bool> |
||||
|
</property> |
||||
|
<property name="sizePolicy"> |
||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> |
||||
|
<horstretch>0</horstretch> |
||||
|
<verstretch>1</verstretch> |
||||
|
</sizepolicy> |
||||
|
</property> |
||||
|
<property name="selectionMode"> |
||||
|
<enum>QAbstractItemView::MultiSelection</enum> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="2" column="0"> |
||||
|
<widget class="QLabel" name="label_6"> |
||||
|
<property name="text"> |
||||
|
<string>&Contracts</string> |
||||
|
</property> |
||||
|
<property name="buddy"> |
||||
|
<cstring>contracts</cstring> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="2" column="1"> |
||||
|
<widget class="QListWidget" name="contracts"> |
||||
|
<property name="enabled"> |
||||
|
<bool>false</bool> |
||||
|
</property> |
||||
|
<property name="sizePolicy"> |
||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> |
||||
|
<horstretch>0</horstretch> |
||||
|
<verstretch>1</verstretch> |
||||
|
</sizepolicy> |
||||
|
</property> |
||||
|
<property name="selectionMode"> |
||||
|
<enum>QAbstractItemView::MultiSelection</enum> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="3" column="0"> |
||||
|
<widget class="QLabel" name="label_2"> |
||||
|
<property name="sizePolicy"> |
||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Maximum"> |
||||
|
<horstretch>0</horstretch> |
||||
|
<verstretch>0</verstretch> |
||||
|
</sizepolicy> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string>&JSON</string> |
||||
|
</property> |
||||
|
<property name="alignment"> |
||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> |
||||
|
</property> |
||||
|
<property name="buddy"> |
||||
|
<cstring>json</cstring> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="3" column="1"> |
||||
|
<widget class="QTextEdit" name="json"> |
||||
|
<property name="enabled"> |
||||
|
<bool>false</bool> |
||||
|
</property> |
||||
|
<property name="sizePolicy"> |
||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> |
||||
|
<horstretch>0</horstretch> |
||||
|
<verstretch>2</verstretch> |
||||
|
</sizepolicy> |
||||
|
</property> |
||||
|
<property name="readOnly"> |
||||
|
<bool>true</bool> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="4" column="1"> |
||||
|
<layout class="QHBoxLayout" name="horizontalLayout"> |
||||
|
<item> |
||||
|
<widget class="QPushButton" name="saveButton"> |
||||
|
<property name="enabled"> |
||||
|
<bool>false</bool> |
||||
|
</property> |
||||
|
<property name="sizePolicy"> |
||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> |
||||
|
<horstretch>0</horstretch> |
||||
|
<verstretch>0</verstretch> |
||||
|
</sizepolicy> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string>&Save...</string> |
||||
|
</property> |
||||
|
<property name="shortcut"> |
||||
|
<string>Esc</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<spacer name="horizontalSpacer"> |
||||
|
<property name="orientation"> |
||||
|
<enum>Qt::Horizontal</enum> |
||||
|
</property> |
||||
|
<property name="sizeHint" stdset="0"> |
||||
|
<size> |
||||
|
<width>40</width> |
||||
|
<height>20</height> |
||||
|
</size> |
||||
|
</property> |
||||
|
</spacer> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QPushButton" name="close"> |
||||
|
<property name="text"> |
||||
|
<string>&Close</string> |
||||
|
</property> |
||||
|
<property name="shortcut"> |
||||
|
<string>Esc</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</widget> |
||||
|
<resources/> |
||||
|
<connections/> |
||||
|
</ui> |
@ -0,0 +1,161 @@ |
|||||
|
#.rst: |
||||
|
# CMakeParseArguments |
||||
|
# ------------------- |
||||
|
# |
||||
|
# |
||||
|
# |
||||
|
# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> |
||||
|
# <multi_value_keywords> args...) |
||||
|
# |
||||
|
# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions |
||||
|
# for parsing the arguments given to that macro or function. It |
||||
|
# processes the arguments and defines a set of variables which hold the |
||||
|
# values of the respective options. |
||||
|
# |
||||
|
# The <options> argument contains all options for the respective macro, |
||||
|
# i.e. keywords which can be used when calling the macro without any |
||||
|
# value following, like e.g. the OPTIONAL keyword of the install() |
||||
|
# command. |
||||
|
# |
||||
|
# The <one_value_keywords> argument contains all keywords for this macro |
||||
|
# which are followed by one value, like e.g. DESTINATION keyword of the |
||||
|
# install() command. |
||||
|
# |
||||
|
# The <multi_value_keywords> argument contains all keywords for this |
||||
|
# macro which can be followed by more than one value, like e.g. the |
||||
|
# TARGETS or FILES keywords of the install() command. |
||||
|
# |
||||
|
# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the |
||||
|
# keywords listed in <options>, <one_value_keywords> and |
||||
|
# <multi_value_keywords> a variable composed of the given <prefix> |
||||
|
# followed by "_" and the name of the respective keyword. These |
||||
|
# variables will then hold the respective value from the argument list. |
||||
|
# For the <options> keywords this will be TRUE or FALSE. |
||||
|
# |
||||
|
# All remaining arguments are collected in a variable |
||||
|
# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see |
||||
|
# whether your macro was called with unrecognized parameters. |
||||
|
# |
||||
|
# As an example here a my_install() macro, which takes similar arguments |
||||
|
# as the real install() command: |
||||
|
# |
||||
|
# :: |
||||
|
# |
||||
|
# function(MY_INSTALL) |
||||
|
# set(options OPTIONAL FAST) |
||||
|
# set(oneValueArgs DESTINATION RENAME) |
||||
|
# set(multiValueArgs TARGETS CONFIGURATIONS) |
||||
|
# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" |
||||
|
# "${multiValueArgs}" ${ARGN} ) |
||||
|
# ... |
||||
|
# |
||||
|
# |
||||
|
# |
||||
|
# Assume my_install() has been called like this: |
||||
|
# |
||||
|
# :: |
||||
|
# |
||||
|
# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub) |
||||
|
# |
||||
|
# |
||||
|
# |
||||
|
# After the cmake_parse_arguments() call the macro will have set the |
||||
|
# following variables: |
||||
|
# |
||||
|
# :: |
||||
|
# |
||||
|
# MY_INSTALL_OPTIONAL = TRUE |
||||
|
# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install() |
||||
|
# MY_INSTALL_DESTINATION = "bin" |
||||
|
# MY_INSTALL_RENAME = "" (was not used) |
||||
|
# MY_INSTALL_TARGETS = "foo;bar" |
||||
|
# MY_INSTALL_CONFIGURATIONS = "" (was not used) |
||||
|
# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL" |
||||
|
# |
||||
|
# |
||||
|
# |
||||
|
# You can then continue and process these variables. |
||||
|
# |
||||
|
# Keywords terminate lists of values, e.g. if directly after a |
||||
|
# one_value_keyword another recognized keyword follows, this is |
||||
|
# interpreted as the beginning of the new option. E.g. |
||||
|
# my_install(TARGETS foo DESTINATION OPTIONAL) would result in |
||||
|
# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION |
||||
|
# would be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. |
||||
|
|
||||
|
#============================================================================= |
||||
|
# Copyright 2010 Alexander Neundorf <neundorf@kde.org> |
||||
|
# |
||||
|
# Distributed under the OSI-approved BSD License (the "License"); |
||||
|
# see accompanying file Copyright.txt for details. |
||||
|
# |
||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the |
||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
|
# See the License for more information. |
||||
|
#============================================================================= |
||||
|
# (To distribute this file outside of CMake, substitute the full |
||||
|
# License text for the above reference.) |
||||
|
|
||||
|
|
||||
|
if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) |
||||
|
return() |
||||
|
endif() |
||||
|
set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) |
||||
|
|
||||
|
|
||||
|
function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) |
||||
|
# first set all result variables to empty/FALSE |
||||
|
foreach(arg_name ${_singleArgNames} ${_multiArgNames}) |
||||
|
set(${prefix}_${arg_name}) |
||||
|
endforeach() |
||||
|
|
||||
|
foreach(option ${_optionNames}) |
||||
|
set(${prefix}_${option} FALSE) |
||||
|
endforeach() |
||||
|
|
||||
|
set(${prefix}_UNPARSED_ARGUMENTS) |
||||
|
|
||||
|
set(insideValues FALSE) |
||||
|
set(currentArgName) |
||||
|
|
||||
|
# now iterate over all arguments and fill the result variables |
||||
|
foreach(currentArg ${ARGN}) |
||||
|
list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword |
||||
|
list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword |
||||
|
list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword |
||||
|
|
||||
|
if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) |
||||
|
if(insideValues) |
||||
|
if("${insideValues}" STREQUAL "SINGLE") |
||||
|
set(${prefix}_${currentArgName} ${currentArg}) |
||||
|
set(insideValues FALSE) |
||||
|
elseif("${insideValues}" STREQUAL "MULTI") |
||||
|
list(APPEND ${prefix}_${currentArgName} ${currentArg}) |
||||
|
endif() |
||||
|
else() |
||||
|
list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) |
||||
|
endif() |
||||
|
else() |
||||
|
if(NOT ${optionIndex} EQUAL -1) |
||||
|
set(${prefix}_${currentArg} TRUE) |
||||
|
set(insideValues FALSE) |
||||
|
elseif(NOT ${singleArgIndex} EQUAL -1) |
||||
|
set(currentArgName ${currentArg}) |
||||
|
set(${prefix}_${currentArgName}) |
||||
|
set(insideValues "SINGLE") |
||||
|
elseif(NOT ${multiArgIndex} EQUAL -1) |
||||
|
set(currentArgName ${currentArg}) |
||||
|
set(${prefix}_${currentArgName}) |
||||
|
set(insideValues "MULTI") |
||||
|
endif() |
||||
|
endif() |
||||
|
|
||||
|
endforeach() |
||||
|
|
||||
|
# propagate the result variables to the caller: |
||||
|
foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) |
||||
|
set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) |
||||
|
endforeach() |
||||
|
set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) |
||||
|
|
||||
|
endfunction() |
@ -0,0 +1,33 @@ |
|||||
|
# Find libcpuid |
||||
|
# |
||||
|
# Find the libcpuid includes and library |
||||
|
# |
||||
|
# if you nee to add a custom library search path, do it via via CMAKE_PREFIX_PATH |
||||
|
# |
||||
|
# This module defines |
||||
|
# CPUID_INCLUDE_DIRS, where to find header, etc. |
||||
|
# CPUID_LIBRARIES, the libraries needed to use cpuid. |
||||
|
# CPUID_FOUND, If false, do not try to use cpuid. |
||||
|
|
||||
|
# only look in default directories |
||||
|
find_path( |
||||
|
CPUID_INCLUDE_DIR |
||||
|
NAMES libcpuid/libcpuid.h |
||||
|
DOC "libcpuid include dir" |
||||
|
) |
||||
|
|
||||
|
find_library( |
||||
|
CPUID_LIBRARY |
||||
|
NAMES cpuid |
||||
|
DOC "libcpuid library" |
||||
|
) |
||||
|
|
||||
|
set(CPUID_INCLUDE_DIRS ${CPUID_INCLUDE_DIR}) |
||||
|
set(CPUID_LIBRARIES ${CPUID_LIBRARY}) |
||||
|
|
||||
|
# handle the QUIETLY and REQUIRED arguments and set CPUID_FOUND to TRUE |
||||
|
# if all listed variables are TRUE, hide their existence from configuration view |
||||
|
include(FindPackageHandleStandardArgs) |
||||
|
find_package_handle_standard_args(cpuid DEFAULT_MSG CPUID_INCLUDE_DIR CPUID_LIBRARY) |
||||
|
mark_as_advanced (CPUID_INCLUDE_DIR CPUID_LIBRARY) |
||||
|
|
@ -0,0 +1,136 @@ |
|||||
|
#.rst: |
||||
|
# FindOpenCL |
||||
|
# ---------- |
||||
|
# |
||||
|
# Try to find OpenCL |
||||
|
# |
||||
|
# Once done this will define:: |
||||
|
# |
||||
|
# OpenCL_FOUND - True if OpenCL was found |
||||
|
# OpenCL_INCLUDE_DIRS - include directories for OpenCL |
||||
|
# OpenCL_LIBRARIES - link against this library to use OpenCL |
||||
|
# OpenCL_VERSION_STRING - Highest supported OpenCL version (eg. 1.2) |
||||
|
# OpenCL_VERSION_MAJOR - The major version of the OpenCL implementation |
||||
|
# OpenCL_VERSION_MINOR - The minor version of the OpenCL implementation |
||||
|
# |
||||
|
# The module will also define two cache variables:: |
||||
|
# |
||||
|
# OpenCL_INCLUDE_DIR - the OpenCL include directory |
||||
|
# OpenCL_LIBRARY - the path to the OpenCL library |
||||
|
# |
||||
|
|
||||
|
#============================================================================= |
||||
|
# Copyright 2014 Matthaeus G. Chajdas |
||||
|
# |
||||
|
# Distributed under the OSI-approved BSD License (the "License"); |
||||
|
# see accompanying file Copyright.txt for details. |
||||
|
# |
||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the |
||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
|
# See the License for more information. |
||||
|
#============================================================================= |
||||
|
# (To distribute this file outside of CMake, substitute the full |
||||
|
# License text for the above reference.) |
||||
|
|
||||
|
function(_FIND_OPENCL_VERSION) |
||||
|
include(CheckSymbolExists) |
||||
|
include(CMakePushCheckState) |
||||
|
set(CMAKE_REQUIRED_QUIET ${OpenCL_FIND_QUIETLY}) |
||||
|
|
||||
|
CMAKE_PUSH_CHECK_STATE() |
||||
|
foreach(VERSION "2_0" "1_2" "1_1" "1_0") |
||||
|
set(CMAKE_REQUIRED_INCLUDES "${OpenCL_INCLUDE_DIR}") |
||||
|
|
||||
|
if(APPLE) |
||||
|
CHECK_SYMBOL_EXISTS( |
||||
|
CL_VERSION_${VERSION} |
||||
|
"${OpenCL_INCLUDE_DIR}/OpenCL/cl.h" |
||||
|
OPENCL_VERSION_${VERSION}) |
||||
|
else() |
||||
|
CHECK_SYMBOL_EXISTS( |
||||
|
CL_VERSION_${VERSION} |
||||
|
"${OpenCL_INCLUDE_DIR}/CL/cl.h" |
||||
|
OPENCL_VERSION_${VERSION}) |
||||
|
endif() |
||||
|
|
||||
|
if(OPENCL_VERSION_${VERSION}) |
||||
|
string(REPLACE "_" "." VERSION "${VERSION}") |
||||
|
set(OpenCL_VERSION_STRING ${VERSION} PARENT_SCOPE) |
||||
|
string(REGEX MATCHALL "[0-9]+" version_components "${VERSION}") |
||||
|
list(GET version_components 0 major_version) |
||||
|
list(GET version_components 1 minor_version) |
||||
|
set(OpenCL_VERSION_MAJOR ${major_version} PARENT_SCOPE) |
||||
|
set(OpenCL_VERSION_MINOR ${minor_version} PARENT_SCOPE) |
||||
|
break() |
||||
|
endif() |
||||
|
endforeach() |
||||
|
CMAKE_POP_CHECK_STATE() |
||||
|
endfunction() |
||||
|
|
||||
|
find_path(OpenCL_INCLUDE_DIR |
||||
|
NAMES |
||||
|
CL/cl.h OpenCL/cl.h |
||||
|
PATHS |
||||
|
ENV "PROGRAMFILES(X86)" |
||||
|
ENV AMDAPPSDKROOT |
||||
|
ENV INTELOCLSDKROOT |
||||
|
ENV NVSDKCOMPUTE_ROOT |
||||
|
ENV CUDA_PATH |
||||
|
ENV ATISTREAMSDKROOT |
||||
|
PATH_SUFFIXES |
||||
|
include |
||||
|
OpenCL/common/inc |
||||
|
"AMD APP/include") |
||||
|
|
||||
|
_FIND_OPENCL_VERSION() |
||||
|
|
||||
|
if(WIN32) |
||||
|
if(CMAKE_SIZEOF_VOID_P EQUAL 4) |
||||
|
find_library(OpenCL_LIBRARY |
||||
|
NAMES OpenCL |
||||
|
PATHS |
||||
|
ENV "PROGRAMFILES(X86)" |
||||
|
ENV AMDAPPSDKROOT |
||||
|
ENV INTELOCLSDKROOT |
||||
|
ENV CUDA_PATH |
||||
|
ENV NVSDKCOMPUTE_ROOT |
||||
|
ENV ATISTREAMSDKROOT |
||||
|
PATH_SUFFIXES |
||||
|
"AMD APP/lib/x86" |
||||
|
lib/x86 |
||||
|
lib/Win32 |
||||
|
OpenCL/common/lib/Win32) |
||||
|
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) |
||||
|
find_library(OpenCL_LIBRARY |
||||
|
NAMES OpenCL |
||||
|
PATHS |
||||
|
ENV "PROGRAMFILES(X86)" |
||||
|
ENV AMDAPPSDKROOT |
||||
|
ENV INTELOCLSDKROOT |
||||
|
ENV CUDA_PATH |
||||
|
ENV NVSDKCOMPUTE_ROOT |
||||
|
ENV ATISTREAMSDKROOT |
||||
|
PATH_SUFFIXES |
||||
|
"AMD APP/lib/x86_64" |
||||
|
lib/x86_64 |
||||
|
lib/x64 |
||||
|
OpenCL/common/lib/x64) |
||||
|
endif() |
||||
|
else() |
||||
|
find_library(OpenCL_LIBRARY |
||||
|
NAMES OpenCL) |
||||
|
endif() |
||||
|
|
||||
|
set(OpenCL_LIBRARIES ${OpenCL_LIBRARY}) |
||||
|
set(OpenCL_INCLUDE_DIRS ${OpenCL_INCLUDE_DIR}) |
||||
|
|
||||
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) |
||||
|
find_package_handle_standard_args( |
||||
|
OpenCL |
||||
|
FOUND_VAR OpenCL_FOUND |
||||
|
REQUIRED_VARS OpenCL_LIBRARY OpenCL_INCLUDE_DIR |
||||
|
VERSION_VAR OpenCL_VERSION_STRING) |
||||
|
|
||||
|
mark_as_advanced( |
||||
|
OpenCL_INCLUDE_DIR |
||||
|
OpenCL_LIBRARY) |
@ -0,0 +1,382 @@ |
|||||
|
#.rst: |
||||
|
# FindPackageHandleStandardArgs |
||||
|
# ----------------------------- |
||||
|
# |
||||
|
# |
||||
|
# |
||||
|
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<name> ... ) |
||||
|
# |
||||
|
# This function is intended to be used in FindXXX.cmake modules files. |
||||
|
# It handles the REQUIRED, QUIET and version-related arguments to |
||||
|
# find_package(). It also sets the <packagename>_FOUND variable. The |
||||
|
# package is considered found if all variables <var1>... listed contain |
||||
|
# valid results, e.g. valid filepaths. |
||||
|
# |
||||
|
# There are two modes of this function. The first argument in both |
||||
|
# modes is the name of the Find-module where it is called (in original |
||||
|
# casing). |
||||
|
# |
||||
|
# The first simple mode looks like this: |
||||
|
# |
||||
|
# :: |
||||
|
# |
||||
|
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<name> |
||||
|
# (DEFAULT_MSG|"Custom failure message") <var1>...<varN> ) |
||||
|
# |
||||
|
# If the variables <var1> to <varN> are all valid, then |
||||
|
# <UPPERCASED_NAME>_FOUND will be set to TRUE. If DEFAULT_MSG is given |
||||
|
# as second argument, then the function will generate itself useful |
||||
|
# success and error messages. You can also supply a custom error |
||||
|
# message for the failure case. This is not recommended. |
||||
|
# |
||||
|
# The second mode is more powerful and also supports version checking: |
||||
|
# |
||||
|
# :: |
||||
|
# |
||||
|
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME |
||||
|
# [FOUND_VAR <resultVar>] |
||||
|
# [REQUIRED_VARS <var1>...<varN>] |
||||
|
# [VERSION_VAR <versionvar>] |
||||
|
# [HANDLE_COMPONENTS] |
||||
|
# [CONFIG_MODE] |
||||
|
# [FAIL_MESSAGE "Custom failure message"] ) |
||||
|
# |
||||
|
# In this mode, the name of the result-variable can be set either to |
||||
|
# either <UPPERCASED_NAME>_FOUND or <OriginalCase_Name>_FOUND using the |
||||
|
# FOUND_VAR option. Other names for the result-variable are not |
||||
|
# allowed. So for a Find-module named FindFooBar.cmake, the two |
||||
|
# possible names are FooBar_FOUND and FOOBAR_FOUND. It is recommended |
||||
|
# to use the original case version. If the FOUND_VAR option is not |
||||
|
# used, the default is <UPPERCASED_NAME>_FOUND. |
||||
|
# |
||||
|
# As in the simple mode, if <var1> through <varN> are all valid, |
||||
|
# <packagename>_FOUND will be set to TRUE. After REQUIRED_VARS the |
||||
|
# variables which are required for this package are listed. Following |
||||
|
# VERSION_VAR the name of the variable can be specified which holds the |
||||
|
# version of the package which has been found. If this is done, this |
||||
|
# version will be checked against the (potentially) specified required |
||||
|
# version used in the find_package() call. The EXACT keyword is also |
||||
|
# handled. The default messages include information about the required |
||||
|
# version and the version which has been actually found, both if the |
||||
|
# version is ok or not. If the package supports components, use the |
||||
|
# HANDLE_COMPONENTS option to enable handling them. In this case, |
||||
|
# find_package_handle_standard_args() will report which components have |
||||
|
# been found and which are missing, and the <packagename>_FOUND variable |
||||
|
# will be set to FALSE if any of the required components (i.e. not the |
||||
|
# ones listed after OPTIONAL_COMPONENTS) are missing. Use the option |
||||
|
# CONFIG_MODE if your FindXXX.cmake module is a wrapper for a |
||||
|
# find_package(... NO_MODULE) call. In this case VERSION_VAR will be |
||||
|
# set to <NAME>_VERSION and the macro will automatically check whether |
||||
|
# the Config module was found. Via FAIL_MESSAGE a custom failure |
||||
|
# message can be specified, if this is not used, the default message |
||||
|
# will be displayed. |
||||
|
# |
||||
|
# Example for mode 1: |
||||
|
# |
||||
|
# :: |
||||
|
# |
||||
|
# find_package_handle_standard_args(LibXml2 DEFAULT_MSG |
||||
|
# LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) |
||||
|
# |
||||
|
# |
||||
|
# |
||||
|
# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and |
||||
|
# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to |
||||
|
# TRUE. If it is not found and REQUIRED was used, it fails with |
||||
|
# FATAL_ERROR, independent whether QUIET was used or not. If it is |
||||
|
# found, success will be reported, including the content of <var1>. On |
||||
|
# repeated Cmake runs, the same message won't be printed again. |
||||
|
# |
||||
|
# Example for mode 2: |
||||
|
# |
||||
|
# :: |
||||
|
# |
||||
|
# find_package_handle_standard_args(LibXslt |
||||
|
# FOUND_VAR LibXslt_FOUND |
||||
|
# REQUIRED_VARS LibXslt_LIBRARIES LibXslt_INCLUDE_DIRS |
||||
|
# VERSION_VAR LibXslt_VERSION_STRING) |
||||
|
# |
||||
|
# In this case, LibXslt is considered to be found if the variable(s) |
||||
|
# listed after REQUIRED_VAR are all valid, i.e. LibXslt_LIBRARIES and |
||||
|
# LibXslt_INCLUDE_DIRS in this case. The result will then be stored in |
||||
|
# LibXslt_FOUND . Also the version of LibXslt will be checked by using |
||||
|
# the version contained in LibXslt_VERSION_STRING. Since no |
||||
|
# FAIL_MESSAGE is given, the default messages will be printed. |
||||
|
# |
||||
|
# Another example for mode 2: |
||||
|
# |
||||
|
# :: |
||||
|
# |
||||
|
# find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4) |
||||
|
# find_package_handle_standard_args(Automoc4 CONFIG_MODE) |
||||
|
# |
||||
|
# In this case, FindAutmoc4.cmake wraps a call to find_package(Automoc4 |
||||
|
# NO_MODULE) and adds an additional search directory for automoc4. Here |
||||
|
# the result will be stored in AUTOMOC4_FOUND. The following |
||||
|
# FIND_PACKAGE_HANDLE_STANDARD_ARGS() call produces a proper |
||||
|
# success/error message. |
||||
|
|
||||
|
#============================================================================= |
||||
|
# Copyright 2007-2009 Kitware, Inc. |
||||
|
# |
||||
|
# Distributed under the OSI-approved BSD License (the "License"); |
||||
|
# see accompanying file Copyright.txt for details. |
||||
|
# |
||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the |
||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
|
# See the License for more information. |
||||
|
#============================================================================= |
||||
|
# (To distribute this file outside of CMake, substitute the full |
||||
|
# License text for the above reference.) |
||||
|
|
||||
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake) |
||||
|
include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) |
||||
|
|
||||
|
# internal helper macro |
||||
|
macro(_FPHSA_FAILURE_MESSAGE _msg) |
||||
|
if (${_NAME}_FIND_REQUIRED) |
||||
|
message(FATAL_ERROR "${_msg}") |
||||
|
else () |
||||
|
if (NOT ${_NAME}_FIND_QUIETLY) |
||||
|
message(STATUS "${_msg}") |
||||
|
endif () |
||||
|
endif () |
||||
|
endmacro() |
||||
|
|
||||
|
|
||||
|
# internal helper macro to generate the failure message when used in CONFIG_MODE: |
||||
|
macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) |
||||
|
# <name>_CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found: |
||||
|
if(${_NAME}_CONFIG) |
||||
|
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})") |
||||
|
else() |
||||
|
# If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version. |
||||
|
# List them all in the error message: |
||||
|
if(${_NAME}_CONSIDERED_CONFIGS) |
||||
|
set(configsText "") |
||||
|
list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount) |
||||
|
math(EXPR configsCount "${configsCount} - 1") |
||||
|
foreach(currentConfigIndex RANGE ${configsCount}) |
||||
|
list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename) |
||||
|
list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version) |
||||
|
set(configsText "${configsText} ${filename} (version ${version})\n") |
||||
|
endforeach() |
||||
|
if (${_NAME}_NOT_FOUND_MESSAGE) |
||||
|
set(configsText "${configsText} Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n") |
||||
|
endif() |
||||
|
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}") |
||||
|
|
||||
|
else() |
||||
|
# Simple case: No Config-file was found at all: |
||||
|
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}") |
||||
|
endif() |
||||
|
endif() |
||||
|
endmacro() |
||||
|
|
||||
|
|
||||
|
function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) |
||||
|
|
||||
|
# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in |
||||
|
# new extended or in the "old" mode: |
||||
|
set(options CONFIG_MODE HANDLE_COMPONENTS) |
||||
|
set(oneValueArgs FAIL_MESSAGE VERSION_VAR FOUND_VAR) |
||||
|
set(multiValueArgs REQUIRED_VARS) |
||||
|
set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} ) |
||||
|
list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX) |
||||
|
|
||||
|
if(${INDEX} EQUAL -1) |
||||
|
set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG}) |
||||
|
set(FPHSA_REQUIRED_VARS ${ARGN}) |
||||
|
set(FPHSA_VERSION_VAR) |
||||
|
else() |
||||
|
|
||||
|
CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) |
||||
|
|
||||
|
if(FPHSA_UNPARSED_ARGUMENTS) |
||||
|
message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"") |
||||
|
endif() |
||||
|
|
||||
|
if(NOT FPHSA_FAIL_MESSAGE) |
||||
|
set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG") |
||||
|
endif() |
||||
|
endif() |
||||
|
|
||||
|
# now that we collected all arguments, process them |
||||
|
|
||||
|
if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG") |
||||
|
set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") |
||||
|
endif() |
||||
|
|
||||
|
# In config-mode, we rely on the variable <package>_CONFIG, which is set by find_package() |
||||
|
# when it successfully found the config-file, including version checking: |
||||
|
if(FPHSA_CONFIG_MODE) |
||||
|
list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG) |
||||
|
list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS) |
||||
|
set(FPHSA_VERSION_VAR ${_NAME}_VERSION) |
||||
|
endif() |
||||
|
|
||||
|
if(NOT FPHSA_REQUIRED_VARS) |
||||
|
message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") |
||||
|
endif() |
||||
|
|
||||
|
list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) |
||||
|
|
||||
|
string(TOUPPER ${_NAME} _NAME_UPPER) |
||||
|
string(TOLOWER ${_NAME} _NAME_LOWER) |
||||
|
|
||||
|
if(FPHSA_FOUND_VAR) |
||||
|
if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$") |
||||
|
set(_FOUND_VAR ${FPHSA_FOUND_VAR}) |
||||
|
else() |
||||
|
message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.") |
||||
|
endif() |
||||
|
else() |
||||
|
set(_FOUND_VAR ${_NAME_UPPER}_FOUND) |
||||
|
endif() |
||||
|
|
||||
|
# collect all variables which were not found, so they can be printed, so the |
||||
|
# user knows better what went wrong (#6375) |
||||
|
set(MISSING_VARS "") |
||||
|
set(DETAILS "") |
||||
|
# check if all passed variables are valid |
||||
|
unset(${_FOUND_VAR}) |
||||
|
foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS}) |
||||
|
if(NOT ${_CURRENT_VAR}) |
||||
|
set(${_FOUND_VAR} FALSE) |
||||
|
set(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}") |
||||
|
else() |
||||
|
set(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]") |
||||
|
endif() |
||||
|
endforeach() |
||||
|
if(NOT "${${_FOUND_VAR}}" STREQUAL "FALSE") |
||||
|
set(${_FOUND_VAR} TRUE) |
||||
|
endif() |
||||
|
|
||||
|
# component handling |
||||
|
unset(FOUND_COMPONENTS_MSG) |
||||
|
unset(MISSING_COMPONENTS_MSG) |
||||
|
|
||||
|
if(FPHSA_HANDLE_COMPONENTS) |
||||
|
foreach(comp ${${_NAME}_FIND_COMPONENTS}) |
||||
|
if(${_NAME}_${comp}_FOUND) |
||||
|
|
||||
|
if(NOT DEFINED FOUND_COMPONENTS_MSG) |
||||
|
set(FOUND_COMPONENTS_MSG "found components: ") |
||||
|
endif() |
||||
|
set(FOUND_COMPONENTS_MSG "${FOUND_COMPONENTS_MSG} ${comp}") |
||||
|
|
||||
|
else() |
||||
|
|
||||
|
if(NOT DEFINED MISSING_COMPONENTS_MSG) |
||||
|
set(MISSING_COMPONENTS_MSG "missing components: ") |
||||
|
endif() |
||||
|
set(MISSING_COMPONENTS_MSG "${MISSING_COMPONENTS_MSG} ${comp}") |
||||
|
|
||||
|
if(${_NAME}_FIND_REQUIRED_${comp}) |
||||
|
set(${_FOUND_VAR} FALSE) |
||||
|
set(MISSING_VARS "${MISSING_VARS} ${comp}") |
||||
|
endif() |
||||
|
|
||||
|
endif() |
||||
|
endforeach() |
||||
|
set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}") |
||||
|
set(DETAILS "${DETAILS}[c${COMPONENT_MSG}]") |
||||
|
endif() |
||||
|
|
||||
|
# version handling: |
||||
|
set(VERSION_MSG "") |
||||
|
set(VERSION_OK TRUE) |
||||
|
set(VERSION ${${FPHSA_VERSION_VAR}}) |
||||
|
|
||||
|
# check with DEFINED here as the requested or found version may be "0" |
||||
|
if (DEFINED ${_NAME}_FIND_VERSION) |
||||
|
if(DEFINED ${FPHSA_VERSION_VAR}) |
||||
|
|
||||
|
if(${_NAME}_FIND_VERSION_EXACT) # exact version required |
||||
|
# count the dots in the version string |
||||
|
string(REGEX REPLACE "[^.]" "" _VERSION_DOTS "${VERSION}") |
||||
|
# add one dot because there is one dot more than there are components |
||||
|
string(LENGTH "${_VERSION_DOTS}." _VERSION_DOTS) |
||||
|
if (_VERSION_DOTS GREATER ${_NAME}_FIND_VERSION_COUNT) |
||||
|
# Because of the C++ implementation of find_package() ${_NAME}_FIND_VERSION_COUNT |
||||
|
# is at most 4 here. Therefore a simple lookup table is used. |
||||
|
if (${_NAME}_FIND_VERSION_COUNT EQUAL 1) |
||||
|
set(_VERSION_REGEX "[^.]*") |
||||
|
elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 2) |
||||
|
set(_VERSION_REGEX "[^.]*\\.[^.]*") |
||||
|
elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 3) |
||||
|
set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*") |
||||
|
else () |
||||
|
set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*") |
||||
|
endif () |
||||
|
string(REGEX REPLACE "^(${_VERSION_REGEX})\\..*" "\\1" _VERSION_HEAD "${VERSION}") |
||||
|
unset(_VERSION_REGEX) |
||||
|
if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _VERSION_HEAD) |
||||
|
set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") |
||||
|
set(VERSION_OK FALSE) |
||||
|
else () |
||||
|
set(VERSION_MSG "(found suitable exact version \"${VERSION}\")") |
||||
|
endif () |
||||
|
unset(_VERSION_HEAD) |
||||
|
else () |
||||
|
if (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") |
||||
|
set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") |
||||
|
set(VERSION_OK FALSE) |
||||
|
else () |
||||
|
set(VERSION_MSG "(found suitable exact version \"${VERSION}\")") |
||||
|
endif () |
||||
|
endif () |
||||
|
unset(_VERSION_DOTS) |
||||
|
|
||||
|
else() # minimum version specified: |
||||
|
if ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") |
||||
|
set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"") |
||||
|
set(VERSION_OK FALSE) |
||||
|
else () |
||||
|
set(VERSION_MSG "(found suitable version \"${VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")") |
||||
|
endif () |
||||
|
endif() |
||||
|
|
||||
|
else() |
||||
|
|
||||
|
# if the package was not found, but a version was given, add that to the output: |
||||
|
if(${_NAME}_FIND_VERSION_EXACT) |
||||
|
set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") |
||||
|
else() |
||||
|
set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") |
||||
|
endif() |
||||
|
|
||||
|
endif() |
||||
|
else () |
||||
|
if(VERSION) |
||||
|
set(VERSION_MSG "(found version \"${VERSION}\")") |
||||
|
endif() |
||||
|
endif () |
||||
|
|
||||
|
if(VERSION_OK) |
||||
|
set(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]") |
||||
|
else() |
||||
|
set(${_FOUND_VAR} FALSE) |
||||
|
endif() |
||||
|
|
||||
|
|
||||
|
# print the result: |
||||
|
if (${_FOUND_VAR}) |
||||
|
FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}") |
||||
|
else () |
||||
|
|
||||
|
if(FPHSA_CONFIG_MODE) |
||||
|
_FPHSA_HANDLE_FAILURE_CONFIG_MODE() |
||||
|
else() |
||||
|
if(NOT VERSION_OK) |
||||
|
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") |
||||
|
else() |
||||
|
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}") |
||||
|
endif() |
||||
|
endif() |
||||
|
|
||||
|
endif () |
||||
|
|
||||
|
set(${_FOUND_VAR} ${${_FOUND_VAR}} PARENT_SCOPE) |
||||
|
|
||||
|
endfunction() |
@ -0,0 +1,57 @@ |
|||||
|
#.rst: |
||||
|
# FindPackageMessage |
||||
|
# ------------------ |
||||
|
# |
||||
|
# |
||||
|
# |
||||
|
# FIND_PACKAGE_MESSAGE(<name> "message for user" "find result details") |
||||
|
# |
||||
|
# This macro is intended to be used in FindXXX.cmake modules files. It |
||||
|
# will print a message once for each unique find result. This is useful |
||||
|
# for telling the user where a package was found. The first argument |
||||
|
# specifies the name (XXX) of the package. The second argument |
||||
|
# specifies the message to display. The third argument lists details |
||||
|
# about the find result so that if they change the message will be |
||||
|
# displayed again. The macro also obeys the QUIET argument to the |
||||
|
# find_package command. |
||||
|
# |
||||
|
# Example: |
||||
|
# |
||||
|
# :: |
||||
|
# |
||||
|
# if(X11_FOUND) |
||||
|
# FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}" |
||||
|
# "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]") |
||||
|
# else() |
||||
|
# ... |
||||
|
# endif() |
||||
|
|
||||
|
#============================================================================= |
||||
|
# Copyright 2008-2009 Kitware, Inc. |
||||
|
# |
||||
|
# Distributed under the OSI-approved BSD License (the "License"); |
||||
|
# see accompanying file Copyright.txt for details. |
||||
|
# |
||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the |
||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
|
# See the License for more information. |
||||
|
#============================================================================= |
||||
|
# (To distribute this file outside of CMake, substitute the full |
||||
|
# License text for the above reference.) |
||||
|
|
||||
|
function(FIND_PACKAGE_MESSAGE pkg msg details) |
||||
|
# Avoid printing a message repeatedly for the same find result. |
||||
|
if(NOT ${pkg}_FIND_QUIETLY) |
||||
|
string(REPLACE "\n" "" details "${details}") |
||||
|
set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) |
||||
|
if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") |
||||
|
# The message has not yet been printed. |
||||
|
message(STATUS "${msg}") |
||||
|
|
||||
|
# Save the find details in the cache to avoid printing the same |
||||
|
# message again. |
||||
|
set("${DETAILS_VAR}" "${details}" |
||||
|
CACHE INTERNAL "Details about finding ${pkg}") |
||||
|
endif() |
||||
|
endif() |
||||
|
endfunction() |
@ -0,0 +1,18 @@ |
|||||
|
# this module expects |
||||
|
# DLLS |
||||
|
# CONF |
||||
|
# DESTINATION |
||||
|
|
||||
|
# example usage: |
||||
|
# cmake -DDLL_DEBUG=xd.dll -DDLL_RELEASE=x.dll -DCONFIGURATION=Release -DDESTINATION=dest -P scripts/copydlls.cmake |
||||
|
|
||||
|
# this script is created cause we do not know configuration in multiconfiguration generators at cmake configure phase ;) |
||||
|
|
||||
|
if ("${CONF}" STREQUAL "Release") |
||||
|
set(DLL ${DLL_RELEASE}) |
||||
|
else () # Debug |
||||
|
set(DLL ${DLL_DEBUG}) |
||||
|
endif() |
||||
|
|
||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${DLL}" "${DESTINATION}") |
||||
|
|
@ -0,0 +1,30 @@ |
|||||
|
// this file is autogenerated, do not modify!!!
|
||||
|
#pragma once |
||||
|
|
||||
|
#include <string> |
||||
|
#include <map> |
||||
|
|
||||
|
namespace dev |
||||
|
{ |
||||
|
namespace eth |
||||
|
{ |
||||
|
|
||||
|
class ${ETH_RESOURCE_NAME} |
||||
|
{ |
||||
|
public: |
||||
|
${ETH_RESOURCE_NAME}() |
||||
|
{ |
||||
|
${ETH_RESULT_DATA} |
||||
|
${ETH_RESULT_INIT} |
||||
|
} |
||||
|
|
||||
|
std::string loadResourceAsString(std::string _name) { return std::string(m_resources[_name], m_sizes[_name]); } |
||||
|
|
||||
|
private: |
||||
|
std::map <std::string, const char*> m_resources; |
||||
|
std::map <std::string, unsigned> m_sizes; |
||||
|
}; |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
@ -0,0 +1,57 @@ |
|||||
|
# based on: http://stackoverflow.com/questions/11813271/embed-resources-eg-shader-code-images-into-executable-library-with-cmake |
||||
|
# |
||||
|
# example: |
||||
|
# cmake -DETH_RES_FILE=test.cmake -P resources.cmake |
||||
|
# |
||||
|
# where test.cmake is: |
||||
|
# |
||||
|
# # BEGIN OF cmake.test |
||||
|
# |
||||
|
# set(copydlls "copydlls.cmake") |
||||
|
# set(conf "configure.cmake") |
||||
|
# |
||||
|
# # this three properties must be set! |
||||
|
# |
||||
|
# set(ETH_RESOURCE_NAME "EthResources") |
||||
|
# set(ETH_RESOURCE_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}") |
||||
|
# set(ETH_RESOURCES "copydlls" "conf") |
||||
|
# |
||||
|
# # END of cmake.test |
||||
|
# |
||||
|
|
||||
|
# should define ETH_RESOURCES |
||||
|
include(${ETH_RES_FILE}) |
||||
|
|
||||
|
set(ETH_RESULT_DATA "") |
||||
|
set(ETH_RESULT_INIT "") |
||||
|
|
||||
|
# resource is a name visible for cpp application |
||||
|
foreach(resource ${ETH_RESOURCES}) |
||||
|
|
||||
|
# filename is the name of file which will be used in app |
||||
|
set(filename ${${resource}}) |
||||
|
|
||||
|
# filedata is a file content |
||||
|
file(READ ${filename} filedata HEX) |
||||
|
|
||||
|
# read full name of the file |
||||
|
file(GLOB filename ${filename}) |
||||
|
|
||||
|
# Convert hex data for C compatibility |
||||
|
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," filedata ${filedata}) |
||||
|
|
||||
|
# append static variables to result variable |
||||
|
set(ETH_RESULT_DATA "${ETH_RESULT_DATA} static const unsigned char eth_${resource}[] = {\n // ${filename}\n ${filedata}\n};\n") |
||||
|
|
||||
|
# append init resources |
||||
|
set(ETH_RESULT_INIT "${ETH_RESULT_INIT} m_resources[\"${resource}\"] = (char const*)eth_${resource};\n") |
||||
|
set(ETH_RESULT_INIT "${ETH_RESULT_INIT} m_sizes[\"${resource}\"] = sizeof(eth_${resource});\n") |
||||
|
|
||||
|
endforeach(resource) |
||||
|
|
||||
|
set(ETH_DST_NAME "${ETH_RESOURCE_LOCATION}/${ETH_RESOURCE_NAME}") |
||||
|
|
||||
|
configure_file("${CMAKE_CURRENT_LIST_DIR}/resource.hpp.in" "${ETH_DST_NAME}.hpp.tmp") |
||||
|
|
||||
|
include("${CMAKE_CURRENT_LIST_DIR}/../EthUtils.cmake") |
||||
|
replace_if_different("${ETH_DST_NAME}.hpp.tmp" "${ETH_DST_NAME}.hpp") |
@ -1,36 +1,31 @@ |
|||||
FROM ubuntu:14.04 |
FROM ubuntu:utopic |
||||
|
MAINTAINER caktux |
||||
|
|
||||
ENV DEBIAN_FRONTEND noninteractive |
ENV DEBIAN_FRONTEND noninteractive |
||||
|
|
||||
|
# Usual update / upgrade |
||||
RUN apt-get update |
RUN apt-get update |
||||
RUN apt-get upgrade -y |
RUN apt-get upgrade -q -y |
||||
|
RUN apt-get dist-upgrade -q -y |
||||
|
|
||||
# Ethereum dependencies |
# Let our containers upgrade themselves |
||||
RUN apt-get install -qy build-essential g++-4.8 git cmake libboost-all-dev libcurl4-openssl-dev wget |
RUN apt-get install -q -y unattended-upgrades |
||||
RUN apt-get install -qy automake unzip libgmp-dev libtool libleveldb-dev yasm libminiupnpc-dev libreadline-dev scons |
|
||||
RUN apt-get install -qy libjsoncpp-dev libargtable2-dev |
|
||||
RUN apt-get install -qy libncurses5-dev libcurl4-openssl-dev wget |
|
||||
RUN apt-get install -qy libjsoncpp-dev libargtable2-dev libmicrohttpd-dev |
|
||||
|
|
||||
# Ethereum PPA |
# Install Ethereum |
||||
RUN apt-get install -qy software-properties-common |
RUN apt-get install -q -y software-properties-common |
||||
RUN add-apt-repository ppa:ethereum/ethereum |
RUN add-apt-repository ppa:ethereum/ethereum |
||||
RUN add-apt-repository ppa:ethereum/ethereum-dev |
RUN add-apt-repository ppa:ethereum/ethereum-dev |
||||
RUN apt-get update |
RUN apt-get update |
||||
RUN apt-get install -qy libcryptopp-dev libjson-rpc-cpp-dev |
RUN apt-get install -q -y eth |
||||
|
|
||||
# LLVM-3.5 |
# Install supervisor |
||||
RUN wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key|sudo apt-key add - |
RUN apt-get install -q -y supervisor |
||||
RUN echo "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.5 main\ndeb-src http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.5 main" > /etc/apt/sources.list.d/llvm-trusty.list |
|
||||
RUN apt-get update |
|
||||
RUN apt-get install -qy llvm-3.5 libedit-dev |
|
||||
|
|
||||
# Fix llvm-3.5 cmake paths |
# Add supervisor configs |
||||
RUN mkdir -p /usr/lib/llvm-3.5/share/llvm && ln -s /usr/share/llvm-3.5/cmake /usr/lib/llvm-3.5/share/llvm/cmake |
ADD supervisord.conf supervisord.conf |
||||
|
|
||||
# Build Ethereum (HEADLESS) |
EXPOSE 8080 |
||||
RUN git clone --depth=1 https://github.com/ethereum/cpp-ethereum |
EXPOSE 30303 |
||||
RUN mkdir -p cpp-ethereum/build |
|
||||
RUN cd cpp-ethereum/build && cmake .. -DHEADLESS=1 -DLLVM_DIR=/usr/share/llvm-3.5/cmake -DEVMJIT=1 && make -j $(cat /proc/cpuinfo | grep processor | wc -l) && make install |
|
||||
RUN ldconfig |
|
||||
|
|
||||
ENTRYPOINT ["/usr/local/bin/eth"] |
CMD ["-n", "-c", "/supervisord.conf"] |
||||
|
ENTRYPOINT ["/usr/bin/supervisord"] |
||||
|
@ -1,17 +1,30 @@ |
|||||
# Dockerfile for cpp-ethereum |
# Dockerfile for cpp-ethereum |
||||
Dockerfile to build a bleeding edge cpp-ethereum docker image from source |
|
||||
|
|
||||
docker build -t cppeth < Dockerfile |
### Quick usage |
||||
|
|
||||
Run a simple peer server |
docker run -d ethereum/client-cpp |
||||
|
|
||||
docker run -i cppeth -m off -o peer -x 256 |
### Building |
||||
|
|
||||
GUI is compiled but not exposed. You can mount /cpp-ethereum/build to access binaries: |
Dockerfile to build a cpp-ethereum docker image from source |
||||
|
|
||||
cid = $(docker run -i -v /cpp-ethereum/build cppeth -m off -o peer -x 256) |
docker build -t cpp-ethereum . |
||||
docker inspect $cid # <-- Find volume path in JSON output |
|
||||
|
|
||||
You may also modify the Docker image to run the GUI and expose a |
### Running |
||||
ssh/VNC server in order to tunnel an X11 or VNC session. |
|
||||
|
|
||||
|
docker run -d cpp-ethereum |
||||
|
|
||||
|
### Usage |
||||
|
|
||||
|
First enter the container: |
||||
|
|
||||
|
docker exec -it <container name> bash |
||||
|
|
||||
|
Inspect logs: |
||||
|
|
||||
|
cat /var/log/cpp-ethereum.log |
||||
|
cat /var/log/cpp-ethereum.err |
||||
|
|
||||
|
Restart supervisor service: |
||||
|
|
||||
|
supervisorctl restart cpp-ethereum |
||||
|
@ -0,0 +1,23 @@ |
|||||
|
[supervisord] |
||||
|
nodaemon=false |
||||
|
|
||||
|
[program:eth] |
||||
|
priority=30 |
||||
|
directory=/ |
||||
|
command=eth --bootstrap --json-rpc |
||||
|
user=root |
||||
|
autostart=true |
||||
|
autorestart=true |
||||
|
startsecs=10 |
||||
|
stopsignal=QUIT |
||||
|
stdout_logfile=/var/log/eth.log |
||||
|
stderr_logfile=/var/log/eth.err |
||||
|
|
||||
|
[unix_http_server] |
||||
|
file=%(here)s/supervisor.sock |
||||
|
|
||||
|
[supervisorctl] |
||||
|
serverurl=unix://%(here)s/supervisor.sock |
||||
|
|
||||
|
[rpcinterface:supervisor] |
||||
|
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface |
@ -0,0 +1,39 @@ |
|||||
|
/**
|
||||
|
* This file is generated by jsonrpcstub, DO NOT CHANGE IT MANUALLY! |
||||
|
*/ |
||||
|
|
||||
|
#ifndef JSONRPC_CPP_STUB_FARM_H_ |
||||
|
#define JSONRPC_CPP_STUB_FARM_H_ |
||||
|
|
||||
|
#include <jsonrpccpp/client.h> |
||||
|
|
||||
|
class Farm : public jsonrpc::Client |
||||
|
{ |
||||
|
public: |
||||
|
Farm(jsonrpc::IClientConnector &conn, jsonrpc::clientVersion_t type = jsonrpc::JSONRPC_CLIENT_V2) : jsonrpc::Client(conn, type) {} |
||||
|
|
||||
|
Json::Value eth_getWork() throw (jsonrpc::JsonRpcException) |
||||
|
{ |
||||
|
Json::Value p; |
||||
|
p = Json::nullValue; |
||||
|
Json::Value result = this->CallMethod("eth_getWork",p); |
||||
|
if (result.isArray()) |
||||
|
return result; |
||||
|
else |
||||
|
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
||||
|
} |
||||
|
bool eth_submitWork(const std::string& param1, const std::string& param2, const std::string& param3) throw (jsonrpc::JsonRpcException) |
||||
|
{ |
||||
|
Json::Value p; |
||||
|
p.append(param1); |
||||
|
p.append(param2); |
||||
|
p.append(param3); |
||||
|
Json::Value result = this->CallMethod("eth_submitWork",p); |
||||
|
if (result.isBool()) |
||||
|
return result.asBool(); |
||||
|
else |
||||
|
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
#endif //JSONRPC_CPP_STUB_FARM_H_
|
@ -0,0 +1,28 @@ |
|||||
|
/**
|
||||
|
* This file is generated by jsonrpcstub, DO NOT CHANGE IT MANUALLY! |
||||
|
*/ |
||||
|
|
||||
|
#ifndef JSONRPC_CPP_STUB_PHONEHOME_H_ |
||||
|
#define JSONRPC_CPP_STUB_PHONEHOME_H_ |
||||
|
|
||||
|
#include <jsonrpccpp/client.h> |
||||
|
|
||||
|
class PhoneHome : public jsonrpc::Client |
||||
|
{ |
||||
|
public: |
||||
|
PhoneHome(jsonrpc::IClientConnector &conn, jsonrpc::clientVersion_t type = jsonrpc::JSONRPC_CLIENT_V2) : jsonrpc::Client(conn, type) {} |
||||
|
|
||||
|
int report_benchmark(const std::string& param1, int param2) throw (jsonrpc::JsonRpcException) |
||||
|
{ |
||||
|
Json::Value p; |
||||
|
p.append(param1); |
||||
|
p.append(param2); |
||||
|
Json::Value result = this->CallMethod("report_benchmark",p); |
||||
|
if (result.isInt()) |
||||
|
return result.asInt(); |
||||
|
else |
||||
|
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
#endif //JSONRPC_CPP_STUB_PHONEHOME_H_
|
@ -0,0 +1,4 @@ |
|||||
|
[ |
||||
|
{ "name": "eth_getWork", "params": [], "order": [], "returns": []}, |
||||
|
{ "name": "eth_submitWork", "params": ["", "", ""], "order": [], "returns": true} |
||||
|
] |
@ -0,0 +1,3 @@ |
|||||
|
[ |
||||
|
{ "name": "report_benchmark", "params": [ "", 0 ], "order": [], "returns": 0 } |
||||
|
] |
@ -0,0 +1,45 @@ |
|||||
|
cmake_policy(SET CMP0015 NEW) |
||||
|
set(CMAKE_AUTOMOC OFF) |
||||
|
|
||||
|
aux_source_directory(. SRC_LIST) |
||||
|
|
||||
|
include_directories(BEFORE ..) |
||||
|
include_directories(${Boost_INCLUDE_DIRS}) |
||||
|
include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) |
||||
|
|
||||
|
set(EXECUTABLE ethminer) |
||||
|
|
||||
|
file(GLOB HEADERS "*.h") |
||||
|
|
||||
|
add_executable(${EXECUTABLE} ${SRC_LIST} ${HEADERS}) |
||||
|
|
||||
|
add_dependencies(${EXECUTABLE} BuildInfo.h) |
||||
|
|
||||
|
target_link_libraries(${EXECUTABLE} ${Boost_REGEX_LIBRARIES}) |
||||
|
|
||||
|
if (READLINE_FOUND) |
||||
|
target_link_libraries(${EXECUTABLE} ${READLINE_LIBRARIES}) |
||||
|
endif() |
||||
|
|
||||
|
if (JSONRPC) |
||||
|
target_link_libraries(${EXECUTABLE} web3jsonrpc) |
||||
|
target_link_libraries(${EXECUTABLE} ${JSON_RPC_CPP_CLIENT_LIBRARIES}) |
||||
|
target_link_libraries(${EXECUTABLE} ${CURL_LIBRARIES}) |
||||
|
if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) |
||||
|
eth_copy_dlls(${EXECUTABLE} CURL_DLLS) |
||||
|
endif() |
||||
|
endif() |
||||
|
|
||||
|
target_link_libraries(${EXECUTABLE} webthree) |
||||
|
target_link_libraries(${EXECUTABLE} ethash) |
||||
|
|
||||
|
if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) |
||||
|
eth_copy_dlls("${EXECUTABLE}" MHD_DLLS) |
||||
|
endif() |
||||
|
|
||||
|
if (APPLE) |
||||
|
install(TARGETS ${EXECUTABLE} DESTINATION bin) |
||||
|
else() |
||||
|
eth_install_executable(${EXECUTABLE}) |
||||
|
endif() |
||||
|
|
@ -0,0 +1,39 @@ |
|||||
|
/**
|
||||
|
* This file is generated by jsonrpcstub, DO NOT CHANGE IT MANUALLY! |
||||
|
*/ |
||||
|
|
||||
|
#ifndef JSONRPC_CPP_STUB_FARM_H_ |
||||
|
#define JSONRPC_CPP_STUB_FARM_H_ |
||||
|
|
||||
|
#include <jsonrpccpp/client.h> |
||||
|
|
||||
|
class Farm : public jsonrpc::Client |
||||
|
{ |
||||
|
public: |
||||
|
Farm(jsonrpc::IClientConnector &conn, jsonrpc::clientVersion_t type = jsonrpc::JSONRPC_CLIENT_V2) : jsonrpc::Client(conn, type) {} |
||||
|
|
||||
|
Json::Value eth_getWork() throw (jsonrpc::JsonRpcException) |
||||
|
{ |
||||
|
Json::Value p; |
||||
|
p = Json::nullValue; |
||||
|
Json::Value result = this->CallMethod("eth_getWork",p); |
||||
|
if (result.isArray()) |
||||
|
return result; |
||||
|
else |
||||
|
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
||||
|
} |
||||
|
bool eth_submitWork(const std::string& param1, const std::string& param2, const std::string& param3) throw (jsonrpc::JsonRpcException) |
||||
|
{ |
||||
|
Json::Value p; |
||||
|
p.append(param1); |
||||
|
p.append(param2); |
||||
|
p.append(param3); |
||||
|
Json::Value result = this->CallMethod("eth_submitWork",p); |
||||
|
if (result.isBool()) |
||||
|
return result.asBool(); |
||||
|
else |
||||
|
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
#endif //JSONRPC_CPP_STUB_FARM_H_
|
@ -0,0 +1,28 @@ |
|||||
|
/**
|
||||
|
* This file is generated by jsonrpcstub, DO NOT CHANGE IT MANUALLY! |
||||
|
*/ |
||||
|
|
||||
|
#ifndef JSONRPC_CPP_STUB_PHONEHOME_H_ |
||||
|
#define JSONRPC_CPP_STUB_PHONEHOME_H_ |
||||
|
|
||||
|
#include <jsonrpccpp/client.h> |
||||
|
|
||||
|
class PhoneHome : public jsonrpc::Client |
||||
|
{ |
||||
|
public: |
||||
|
PhoneHome(jsonrpc::IClientConnector &conn, jsonrpc::clientVersion_t type = jsonrpc::JSONRPC_CLIENT_V2) : jsonrpc::Client(conn, type) {} |
||||
|
|
||||
|
int report_benchmark(const std::string& param1, int param2) throw (jsonrpc::JsonRpcException) |
||||
|
{ |
||||
|
Json::Value p; |
||||
|
p.append(param1); |
||||
|
p.append(param2); |
||||
|
Json::Value result = this->CallMethod("report_benchmark",p); |
||||
|
if (result.isInt()) |
||||
|
return result.asInt(); |
||||
|
else |
||||
|
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
#endif //JSONRPC_CPP_STUB_PHONEHOME_H_
|
@ -0,0 +1,4 @@ |
|||||
|
[ |
||||
|
{ "name": "eth_getWork", "params": [], "order": [], "returns": []}, |
||||
|
{ "name": "eth_submitWork", "params": ["", "", ""], "order": [], "returns": true} |
||||
|
] |
@ -0,0 +1,484 @@ |
|||||
|
/*
|
||||
|
This file is part of cpp-ethereum. |
||||
|
|
||||
|
cpp-ethereum is free software: you can redistribute it and/or modify |
||||
|
it under the terms of the GNU General Public License as published by |
||||
|
the Free Software Foundation, either version 3 of the License, or |
||||
|
(at your option) any later version. |
||||
|
|
||||
|
cpp-ethereum is distributed in the hope that it will be useful, |
||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
GNU General Public License for more details. |
||||
|
|
||||
|
You should have received a copy of the GNU General Public License |
||||
|
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
/** @file main.cpp
|
||||
|
* @author Gav Wood <i@gavwood.com> |
||||
|
* @date 2014 |
||||
|
* Ethereum client. |
||||
|
*/ |
||||
|
|
||||
|
#include <thread> |
||||
|
#include <chrono> |
||||
|
#include <fstream> |
||||
|
#include <iostream> |
||||
|
#include <signal.h> |
||||
|
|
||||
|
#include <boost/algorithm/string.hpp> |
||||
|
#include <boost/algorithm/string/trim_all.hpp> |
||||
|
|
||||
|
#include <libdevcrypto/FileSystem.h> |
||||
|
#include <libevmcore/Instruction.h> |
||||
|
#include <libdevcore/StructuredLogger.h> |
||||
|
#include <libethcore/ProofOfWork.h> |
||||
|
#include <libethcore/EthashAux.h> |
||||
|
#include <libevm/VM.h> |
||||
|
#include <libevm/VMFactory.h> |
||||
|
#include <libethereum/All.h> |
||||
|
#include <libwebthree/WebThree.h> |
||||
|
#if ETH_JSONRPC || !ETH_TRUE |
||||
|
#include <libweb3jsonrpc/WebThreeStubServer.h> |
||||
|
#include <jsonrpccpp/server/connectors/httpserver.h> |
||||
|
#include <jsonrpccpp/client/connectors/httpclient.h> |
||||
|
#endif |
||||
|
#include "BuildInfo.h" |
||||
|
#if ETH_JSONRPC || !ETH_TRUE |
||||
|
#include "PhoneHome.h" |
||||
|
#include "Farm.h" |
||||
|
#endif |
||||
|
using namespace std; |
||||
|
using namespace dev; |
||||
|
using namespace dev::p2p; |
||||
|
using namespace dev::eth; |
||||
|
using namespace boost::algorithm; |
||||
|
using dev::eth::Instruction; |
||||
|
|
||||
|
#undef RETURN |
||||
|
|
||||
|
bool isTrue(std::string const& _m) |
||||
|
{ |
||||
|
return _m == "on" || _m == "yes" || _m == "true" || _m == "1"; |
||||
|
} |
||||
|
|
||||
|
bool isFalse(std::string const& _m) |
||||
|
{ |
||||
|
return _m == "off" || _m == "no" || _m == "false" || _m == "0"; |
||||
|
} |
||||
|
|
||||
|
void help() |
||||
|
{ |
||||
|
cout |
||||
|
<< "Usage ethminer [OPTIONS]" << endl |
||||
|
<< "Options:" << endl << endl |
||||
|
#if ETH_JSONRPC || !ETH_TRUE |
||||
|
<< "Work farming mode:" << endl |
||||
|
<< " -F,--farm <url> Put into mining farm mode with the work server at URL (default: http://127.0.0.1:8080)" << endl |
||||
|
<< " --farm-recheck <n> Leave n ms between checks for changed work (default: 500)." << endl |
||||
|
#endif |
||||
|
<< "Benchmarking mode:" << endl |
||||
|
<< " -M,--benchmark Benchmark for mining and exit; use with --cpu and --opencl." << endl |
||||
|
<< " --benchmark-warmup <seconds> Set the duration of warmup for the benchmark tests (default: 3)." << endl |
||||
|
<< " --benchmark-trial <seconds> Set the duration for each trial for the benchmark tests (default: 3)." << endl |
||||
|
<< " --benchmark-trials <n> Set the duration of warmup for the benchmark tests (default: 5)." << endl |
||||
|
#if ETH_JSONRPC || !ETH_TRUE |
||||
|
<< " --phone-home <on/off> When benchmarking, publish results (default: on)" << endl |
||||
|
#endif |
||||
|
<< "DAG creation mode:" << endl |
||||
|
<< " -D,--create-dag <number> Create the DAG in preparation for mining on given block and exit." << endl |
||||
|
<< "General Options:" << endl |
||||
|
<< " -C,--cpu When mining, use the CPU." << endl |
||||
|
<< " -G,--opencl When mining use the GPU via OpenCL." << endl |
||||
|
<< " --opencl-platform <n> When mining using -G/--opencl use OpenCL platform n (default: 0)." << endl |
||||
|
<< " --opencl-device <n> When mining using -G/--opencl use OpenCL device n (default: 0)." << endl |
||||
|
<< " -t, --mining-threads <n> Limit number of CPU/GPU miners to n (default: use everything available on selected platform)" << endl |
||||
|
<< " -v,--verbosity <0 - 9> Set the log verbosity from 0 to 9 (default: 8)." << endl |
||||
|
<< " -V,--version Show the version and exit." << endl |
||||
|
<< " -h,--help Show this help message and exit." << endl |
||||
|
; |
||||
|
exit(0); |
||||
|
} |
||||
|
|
||||
|
string credits() |
||||
|
{ |
||||
|
std::ostringstream cout; |
||||
|
cout |
||||
|
<< "Ethereum (++) " << dev::Version << endl |
||||
|
<< " Code by Gav Wood et al, (c) 2013, 2014, 2015." << endl |
||||
|
<< " Based on a design by Vitalik Buterin." << endl << endl; |
||||
|
return cout.str(); |
||||
|
} |
||||
|
|
||||
|
void version() |
||||
|
{ |
||||
|
cout << "eth version " << dev::Version << endl; |
||||
|
cout << "eth network protocol version: " << dev::eth::c_protocolVersion << endl; |
||||
|
cout << "Client database version: " << dev::eth::c_databaseVersion << endl; |
||||
|
cout << "Build: " << DEV_QUOTED(ETH_BUILD_PLATFORM) << "/" << DEV_QUOTED(ETH_BUILD_TYPE) << endl; |
||||
|
exit(0); |
||||
|
} |
||||
|
|
||||
|
void doInitDAG(unsigned _n) |
||||
|
{ |
||||
|
BlockInfo bi; |
||||
|
bi.number = _n; |
||||
|
cout << "Initializing DAG for epoch beginning #" << (bi.number / 30000 * 30000) << " (seedhash " << bi.seedHash().abridged() << "). This will take a while." << endl; |
||||
|
Ethash::prep(bi); |
||||
|
exit(0); |
||||
|
} |
||||
|
|
||||
|
enum class OperationMode |
||||
|
{ |
||||
|
DAGInit, |
||||
|
Benchmark, |
||||
|
Farm |
||||
|
}; |
||||
|
|
||||
|
enum class MinerType |
||||
|
{ |
||||
|
CPU, |
||||
|
GPU |
||||
|
}; |
||||
|
|
||||
|
void doBenchmark(MinerType _m, bool _phoneHome, unsigned _warmupDuration = 15, unsigned _trialDuration = 3, unsigned _trials = 5) |
||||
|
{ |
||||
|
BlockInfo genesis = CanonBlockChain::genesis(); |
||||
|
genesis.difficulty = 1 << 18; |
||||
|
cdebug << genesis.boundary(); |
||||
|
|
||||
|
GenericFarm<Ethash> f; |
||||
|
f.onSolutionFound([&](ProofOfWork::Solution) { return false; }); |
||||
|
|
||||
|
string platformInfo = _m == MinerType::CPU ? ProofOfWork::CPUMiner::platformInfo() : _m == MinerType::GPU ? ProofOfWork::GPUMiner::platformInfo() : ""; |
||||
|
cout << "Benchmarking on platform: " << platformInfo << endl; |
||||
|
|
||||
|
cout << "Preparing DAG..." << endl; |
||||
|
Ethash::prep(genesis); |
||||
|
|
||||
|
genesis.difficulty = u256(1) << 63; |
||||
|
genesis.noteDirty(); |
||||
|
f.setWork(genesis); |
||||
|
if (_m == MinerType::CPU) |
||||
|
f.startCPU(); |
||||
|
else if (_m == MinerType::GPU) |
||||
|
f.startGPU(); |
||||
|
|
||||
|
map<uint64_t, MiningProgress> results; |
||||
|
uint64_t mean = 0; |
||||
|
uint64_t innerMean = 0; |
||||
|
for (unsigned i = 0; i <= _trials; ++i) |
||||
|
{ |
||||
|
if (!i) |
||||
|
cout << "Warming up..." << endl; |
||||
|
else |
||||
|
cout << "Trial " << i << "... " << flush; |
||||
|
this_thread::sleep_for(chrono::seconds(i ? _trialDuration : _warmupDuration)); |
||||
|
|
||||
|
auto mp = f.miningProgress(); |
||||
|
f.resetMiningProgress(); |
||||
|
if (!i) |
||||
|
continue; |
||||
|
auto rate = mp.rate(); |
||||
|
|
||||
|
cout << rate << endl; |
||||
|
results[rate] = mp; |
||||
|
mean += rate; |
||||
|
if (i > 1 && i < 5) |
||||
|
innerMean += rate; |
||||
|
} |
||||
|
f.stop(); |
||||
|
innerMean /= (_trials - 2); |
||||
|
cout << "min/mean/max: " << results.begin()->second.rate() << "/" << (mean / _trials) << "/" << results.rbegin()->second.rate() << " H/s" << endl; |
||||
|
cout << "inner mean: " << innerMean << " H/s" << endl; |
||||
|
|
||||
|
(void)_phoneHome; |
||||
|
#if ETH_JSONRPC || !ETH_TRUE |
||||
|
if (_phoneHome) |
||||
|
{ |
||||
|
cout << "Phoning home to find world ranking..." << endl; |
||||
|
jsonrpc::HttpClient client("http://gav.ethdev.com:3000/benchmark"); |
||||
|
PhoneHome rpc(client); |
||||
|
try |
||||
|
{ |
||||
|
unsigned ranking = rpc.report_benchmark(platformInfo, innerMean); |
||||
|
cout << "Ranked: " << ranking << " of all benchmarks." << endl; |
||||
|
} |
||||
|
catch (...) |
||||
|
{ |
||||
|
cout << "Error phoning home. ET is sad." << endl; |
||||
|
} |
||||
|
} |
||||
|
#endif |
||||
|
exit(0); |
||||
|
} |
||||
|
|
||||
|
struct HappyChannel: public LogChannel { static const char* name() { return ":-D"; } static const int verbosity = 1; }; |
||||
|
struct SadChannel: public LogChannel { static const char* name() { return ":-("; } static const int verbosity = 1; }; |
||||
|
|
||||
|
void doFarm(MinerType _m, string const& _remote, unsigned _recheckPeriod) |
||||
|
{ |
||||
|
(void)_m; |
||||
|
(void)_remote; |
||||
|
(void)_recheckPeriod; |
||||
|
#if ETH_JSONRPC || !ETH_TRUE |
||||
|
jsonrpc::HttpClient client(_remote); |
||||
|
Farm rpc(client); |
||||
|
GenericFarm<Ethash> f; |
||||
|
if (_m == MinerType::CPU) |
||||
|
f.startCPU(); |
||||
|
else if (_m == MinerType::GPU) |
||||
|
f.startGPU(); |
||||
|
|
||||
|
ProofOfWork::WorkPackage current; |
||||
|
while (true) |
||||
|
try |
||||
|
{ |
||||
|
bool completed = false; |
||||
|
ProofOfWork::Solution solution; |
||||
|
f.onSolutionFound([&](ProofOfWork::Solution sol) |
||||
|
{ |
||||
|
solution = sol; |
||||
|
return completed = true; |
||||
|
}); |
||||
|
for (unsigned i = 0; !completed; ++i) |
||||
|
{ |
||||
|
if (current) |
||||
|
cnote << "Mining on PoWhash" << current.headerHash << ": " << f.miningProgress(); |
||||
|
else |
||||
|
cnote << "Getting work package..."; |
||||
|
Json::Value v = rpc.eth_getWork(); |
||||
|
h256 hh(v[0].asString()); |
||||
|
if (hh != current.headerHash) |
||||
|
{ |
||||
|
current.headerHash = hh; |
||||
|
current.seedHash = h256(v[1].asString()); |
||||
|
current.boundary = h256(fromHex(v[2].asString()), h256::AlignRight); |
||||
|
cnote << "Got work package:" << current.headerHash << " < " << current.boundary; |
||||
|
f.setWork(current); |
||||
|
} |
||||
|
this_thread::sleep_for(chrono::milliseconds(_recheckPeriod)); |
||||
|
} |
||||
|
cnote << "Solution found; submitting [" << solution.nonce << "," << current.headerHash << "," << solution.mixHash << "] to" << _remote << "..."; |
||||
|
bool ok = rpc.eth_submitWork("0x" + toString(solution.nonce), "0x" + toString(current.headerHash), "0x" + toString(solution.mixHash)); |
||||
|
if (ok) |
||||
|
clog(HappyChannel) << "Submitted and accepted."; |
||||
|
else |
||||
|
clog(SadChannel) << "Not accepted."; |
||||
|
current.reset(); |
||||
|
} |
||||
|
catch (jsonrpc::JsonRpcException&) |
||||
|
{ |
||||
|
for (auto i = 3; --i; this_thread::sleep_for(chrono::seconds(1))) |
||||
|
cerr << "JSON-RPC problem. Probably couldn't connect. Retrying in " << i << "... \r"; |
||||
|
cerr << endl; |
||||
|
} |
||||
|
#endif |
||||
|
exit(0); |
||||
|
} |
||||
|
|
||||
|
int main(int argc, char** argv) |
||||
|
{ |
||||
|
// Init defaults
|
||||
|
Defaults::get(); |
||||
|
|
||||
|
/// Operating mode.
|
||||
|
OperationMode mode = OperationMode::Farm; |
||||
|
|
||||
|
/// Mining options
|
||||
|
MinerType minerType = MinerType::CPU; |
||||
|
unsigned openclPlatform = 0; |
||||
|
unsigned openclDevice = 0; |
||||
|
unsigned miningThreads = UINT_MAX; |
||||
|
|
||||
|
/// DAG initialisation param.
|
||||
|
unsigned initDAG = 0; |
||||
|
|
||||
|
/// Benchmarking params
|
||||
|
bool phoneHome = true; |
||||
|
unsigned benchmarkWarmup = 3; |
||||
|
unsigned benchmarkTrial = 3; |
||||
|
unsigned benchmarkTrials = 5; |
||||
|
|
||||
|
/// Farm params
|
||||
|
string farmURL = "http://127.0.0.1:8080"; |
||||
|
unsigned farmRecheckPeriod = 500; |
||||
|
|
||||
|
for (int i = 1; i < argc; ++i) |
||||
|
{ |
||||
|
string arg = argv[i]; |
||||
|
if ((arg == "-F" || arg == "--farm") && i + 1 < argc) |
||||
|
{ |
||||
|
mode = OperationMode::Farm; |
||||
|
farmURL = argv[++i]; |
||||
|
} |
||||
|
else if (arg == "--farm-recheck" && i + 1 < argc) |
||||
|
try { |
||||
|
farmRecheckPeriod = stol(argv[++i]); |
||||
|
} |
||||
|
catch (...) |
||||
|
{ |
||||
|
cerr << "Bad " << arg << " option: " << argv[i] << endl; |
||||
|
return -1; |
||||
|
} |
||||
|
else if (arg == "--opencl-platform" && i + 1 < argc) |
||||
|
try { |
||||
|
openclPlatform = stol(argv[++i]); |
||||
|
} |
||||
|
catch (...) |
||||
|
{ |
||||
|
cerr << "Bad " << arg << " option: " << argv[i] << endl; |
||||
|
return -1; |
||||
|
} |
||||
|
else if (arg == "--opencl-device" && i + 1 < argc) |
||||
|
try { |
||||
|
openclDevice = stol(argv[++i]); |
||||
|
miningThreads = 1; |
||||
|
} |
||||
|
catch (...) |
||||
|
{ |
||||
|
cerr << "Bad " << arg << " option: " << argv[i] << endl; |
||||
|
return -1; |
||||
|
} |
||||
|
else if (arg == "--phone-home" && i + 1 < argc) |
||||
|
{ |
||||
|
string m = argv[++i]; |
||||
|
if (isTrue(m)) |
||||
|
phoneHome = true; |
||||
|
else if (isFalse(m)) |
||||
|
phoneHome = false; |
||||
|
else |
||||
|
{ |
||||
|
cerr << "Bad " << arg << " option: " << m << endl; |
||||
|
return -1; |
||||
|
} |
||||
|
} |
||||
|
else if (arg == "--benchmark-warmup" && i + 1 < argc) |
||||
|
try { |
||||
|
benchmarkWarmup = stol(argv[++i]); |
||||
|
} |
||||
|
catch (...) |
||||
|
{ |
||||
|
cerr << "Bad " << arg << " option: " << argv[i] << endl; |
||||
|
return -1; |
||||
|
} |
||||
|
else if (arg == "--benchmark-trial" && i + 1 < argc) |
||||
|
try { |
||||
|
benchmarkTrial = stol(argv[++i]); |
||||
|
} |
||||
|
catch (...) |
||||
|
{ |
||||
|
cerr << "Bad " << arg << " option: " << argv[i] << endl; |
||||
|
return -1; |
||||
|
} |
||||
|
else if (arg == "--benchmark-trials" && i + 1 < argc) |
||||
|
try { |
||||
|
benchmarkTrials = stol(argv[++i]); |
||||
|
} |
||||
|
catch (...) |
||||
|
{ |
||||
|
cerr << "Bad " << arg << " option: " << argv[i] << endl; |
||||
|
return -1; |
||||
|
} |
||||
|
else if (arg == "-C" || arg == "--cpu") |
||||
|
minerType = MinerType::CPU; |
||||
|
else if (arg == "-G" || arg == "--opencl") |
||||
|
minerType = MinerType::GPU; |
||||
|
else if ((arg == "-D" || arg == "--create-dag") && i + 1 < argc) |
||||
|
{ |
||||
|
string m = boost::to_lower_copy(string(argv[++i])); |
||||
|
mode = OperationMode::DAGInit; |
||||
|
try |
||||
|
{ |
||||
|
initDAG = stol(m); |
||||
|
} |
||||
|
catch (...) |
||||
|
{ |
||||
|
cerr << "Bad " << arg << " option: " << m << endl; |
||||
|
return -1; |
||||
|
} |
||||
|
} |
||||
|
else if ((arg == "-w" || arg == "--check-pow") && i + 4 < argc) |
||||
|
{ |
||||
|
string m; |
||||
|
try |
||||
|
{ |
||||
|
BlockInfo bi; |
||||
|
m = boost::to_lower_copy(string(argv[++i])); |
||||
|
h256 powHash(m); |
||||
|
m = boost::to_lower_copy(string(argv[++i])); |
||||
|
h256 seedHash; |
||||
|
if (m.size() == 64 || m.size() == 66) |
||||
|
seedHash = h256(m); |
||||
|
else |
||||
|
seedHash = EthashAux::seedHash(stol(m)); |
||||
|
m = boost::to_lower_copy(string(argv[++i])); |
||||
|
bi.difficulty = u256(m); |
||||
|
auto boundary = bi.boundary(); |
||||
|
m = boost::to_lower_copy(string(argv[++i])); |
||||
|
bi.nonce = h64(m); |
||||
|
auto r = EthashAux::eval(seedHash, powHash, bi.nonce); |
||||
|
bool valid = r.value < boundary; |
||||
|
cout << (valid ? "VALID :-)" : "INVALID :-(") << endl; |
||||
|
cout << r.value << (valid ? " < " : " >= ") << boundary << endl; |
||||
|
cout << " where " << boundary << " = 2^256 / " << bi.difficulty << endl; |
||||
|
cout << " and " << r.value << " = ethash(" << powHash << ", " << bi.nonce << ")" << endl; |
||||
|
cout << " with seed as " << seedHash << endl; |
||||
|
if (valid) |
||||
|
cout << "(mixHash = " << r.mixHash << ")" << endl; |
||||
|
cout << "SHA3( light(seed) ) = " << sha3(EthashAux::light(seedHash)->data()) << endl; |
||||
|
exit(0); |
||||
|
} |
||||
|
catch (...) |
||||
|
{ |
||||
|
cerr << "Bad " << arg << " option: " << m << endl; |
||||
|
return -1; |
||||
|
} |
||||
|
} |
||||
|
else if (arg == "-M" || arg == "--benchmark") |
||||
|
mode = OperationMode::Benchmark; |
||||
|
else if ((arg == "-t" || arg == "--mining-threads") && i + 1 < argc) |
||||
|
{ |
||||
|
try { |
||||
|
miningThreads = stol(argv[++i]); |
||||
|
} |
||||
|
catch (...) |
||||
|
{ |
||||
|
cerr << "Bad " << arg << " option: " << argv[i] << endl; |
||||
|
return -1; |
||||
|
} |
||||
|
} |
||||
|
else if ((arg == "-v" || arg == "--verbosity") && i + 1 < argc) |
||||
|
g_logVerbosity = atoi(argv[++i]); |
||||
|
else if (arg == "-h" || arg == "--help") |
||||
|
help(); |
||||
|
else if (arg == "-V" || arg == "--version") |
||||
|
version(); |
||||
|
else |
||||
|
{ |
||||
|
cerr << "Invalid argument: " << arg << endl; |
||||
|
exit(-1); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (minerType == MinerType::CPU) |
||||
|
ProofOfWork::CPUMiner::setNumInstances(miningThreads); |
||||
|
else if (minerType == MinerType::GPU) |
||||
|
{ |
||||
|
ProofOfWork::GPUMiner::setDefaultPlatform(openclPlatform); |
||||
|
ProofOfWork::GPUMiner::setDefaultDevice(openclDevice); |
||||
|
ProofOfWork::GPUMiner::setNumInstances(miningThreads); |
||||
|
} |
||||
|
|
||||
|
if (mode == OperationMode::DAGInit) |
||||
|
doInitDAG(initDAG); |
||||
|
|
||||
|
if (mode == OperationMode::Benchmark) |
||||
|
doBenchmark(minerType, phoneHome, benchmarkWarmup, benchmarkTrial, benchmarkTrials); |
||||
|
|
||||
|
if (mode == OperationMode::Farm) |
||||
|
doFarm(minerType, farmURL, farmRecheckPeriod); |
||||
|
|
||||
|
return 0; |
||||
|
} |
||||
|
|
@ -0,0 +1,3 @@ |
|||||
|
[ |
||||
|
{ "name": "report_benchmark", "params": [ "", 0 ], "order": [], "returns": 0 } |
||||
|
] |
@ -1,59 +0,0 @@ |
|||||
cmake_minimum_required(VERSION 2.8.12) |
|
||||
|
|
||||
include(ExternalProject) |
|
||||
include(CMakeParseArguments) |
|
||||
include(eth_download.cmake) |
|
||||
|
|
||||
# all dependencies will be installed into this directory, separated by platform |
|
||||
string(TOLOWER ${CMAKE_SYSTEM_NAME} _system_name) |
|
||||
set(ETH_DEPENDENCY_INSTALL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/install/${_system_name}") |
|
||||
set(ETH_DEPENDENCY_SERVER "https://build.ethdev.com/builds/${_system_name}-precompiled") |
|
||||
file(MAKE_DIRECTORY ${ETH_DEPENDENCY_INSTALL_DIR}/lib) |
|
||||
file(MAKE_DIRECTORY ${ETH_DEPENDENCY_INSTALL_DIR}/include) |
|
||||
file(MAKE_DIRECTORY ${ETH_DEPENDENCY_INSTALL_DIR}/bin) |
|
||||
|
|
||||
if (ETH_COMPILE) |
|
||||
# json-rpc-cpp and its dependencies |
|
||||
include(compile/jsoncpp.cmake) |
|
||||
include(compile/argtable2.cmake) |
|
||||
include(compile/curl.cmake) |
|
||||
include(compile/json-rpc-cpp.cmake) |
|
||||
|
|
||||
# qt and its dependencies |
|
||||
include(compile/icu.cmake) |
|
||||
include(compile/jom.cmake) |
|
||||
include(compile/qt.cmake) |
|
||||
|
|
||||
# leveldb and its dependencies |
|
||||
include(compile/snappy.cmake) |
|
||||
include(compile/leveldb.cmake) |
|
||||
|
|
||||
# cryptopp |
|
||||
include(compile/cryptopp.cmake) |
|
||||
|
|
||||
# boost |
|
||||
include(compile/boost.cmake) |
|
||||
else() |
|
||||
eth_download(jsoncpp) |
|
||||
eth_download(microhttpd) |
|
||||
eth_download(json-rpc-cpp |
|
||||
VERSION 4.2 |
|
||||
OSX_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/json-rpc-cpp_osx.sh |
|
||||
) |
|
||||
|
|
||||
if (APPLE) |
|
||||
eth_download(snappy OSX_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/snappy_osx.sh) |
|
||||
endif() |
|
||||
|
|
||||
eth_download(leveldb OSX_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/leveldb_osx.sh) |
|
||||
eth_download(qt VERSION 5.4) |
|
||||
eth_download(cryptopp) |
|
||||
eth_download(boost) |
|
||||
eth_download(curl) |
|
||||
|
|
||||
endif() |
|
||||
|
|
||||
# will be re-eanbled later |
|
||||
# include(miniupnpc.cmake) |
|
||||
# if install phase of extep fails, even if libs are already created, the ethereum install will fail |
|
||||
|
|
@ -1,16 +0,0 @@ |
|||||
# cpp-ethereum external dependencies |
|
||||
|
|
||||
**This is Work-in-Progress!** |
|
||||
|
|
||||
This directory hosts the external libraries that are needed to build cpp-ethereum. |
|
||||
|
|
||||
To automatically download, build, and link libraries, do |
|
||||
``` |
|
||||
cd extdep; mkdir build; cd build; cmake ..; make |
|
||||
``` |
|
||||
this will take some time. |
|
||||
|
|
||||
|
|
||||
To check which libraries are already included, check `CMakeLists.txt`. Other libraries still need to be fetched via the system's package manager. |
|
||||
|
|
||||
Libraries will be installed in `cpp-ethereum/extdep/install/<platform-name>` |
|
@ -1,9 +0,0 @@ |
|||||
# hacky way to resolve nested dependencies - needed for json-rpc-cpp |
|
||||
find_library(CURL_LIBRARY NAMES curl |
|
||||
PATHS |
|
||||
${ETH_DEPENDENCY_INSTALL_DIR}/lib |
|
||||
) |
|
||||
|
|
||||
set(CURL_LIBRARIES ${CURL_LIBRARY}) |
|
||||
set(CURL_INCLUDE_DIRS ${ETH_DEPENDENCY_INSTALL_DIR}/include) |
|
||||
|
|
@ -1,13 +0,0 @@ |
|||||
if (APPLE) |
|
||||
|
|
||||
elseif (WIN32) |
|
||||
ExternalProject_Add(argtable2 |
|
||||
GIT_REPOSITORY https://github.com/debris/argtable.git |
|
||||
GIT_TAG master |
|
||||
BINARY_DIR argtable2-prefix/src/argtable2 |
|
||||
CONFIGURE_COMMAND cmake . |
|
||||
BUILD_COMMAND devenv argtable2.sln /build release |
|
||||
INSTALL_COMMAND cmd /c cp src/Release/argtable2.lib ${ETH_DEPENDENCY_INSTALL_DIR}/lib && cp src/argtable2.h ${ETH_DEPENDENCY_INSTALL_DIR}/include |
|
||||
) |
|
||||
else() |
|
||||
endif() |
|
@ -1,19 +0,0 @@ |
|||||
if (APPLE) |
|
||||
|
|
||||
elseif (WIN32) |
|
||||
set(boost_address_model) |
|
||||
# on windows 64: |
|
||||
# set(boost_address_model address-model=64) |
|
||||
|
|
||||
set(boost_targets --with-filesystem --with-system --with-thread --with-date_time --with-regex --with-test --with-chrono --with-program_options) |
|
||||
ExternalProject_Add(boost |
|
||||
URL http://downloads.sourceforge.net/project/boost/boost/1.55.0/boost_1_55_0.tar.gz |
|
||||
BINARY_DIR boost-prefix/src/boost |
|
||||
CONFIGURE_COMMAND ./bootstrap.bat |
|
||||
BUILD_COMMAND ./b2.exe -j4 --build-type=complete link=static runtime-link=shared variant=debug,release threading=multi ${boost_addressModel} ${boost_targets} install --prefix=${ETH_DEPENDENCY_INSTALL_DIR} |
|
||||
INSTALL_COMMAND cmake -E rename ${ETH_DEPENDENCY_INSTALL_DIR}/include/boost-1_55/boost ${ETH_DEPENDENCY_INSTALL_DIR}/include/boost |
|
||||
) |
|
||||
else() |
|
||||
|
|
||||
endif() |
|
||||
|
|
@ -1,33 +0,0 @@ |
|||||
# CryptoPP does not have good cross-platform support, there exist several different other projects to make it work ... |
|
||||
|
|
||||
# TODO the OS X build throws a lot of warnings, but compiles fine |
|
||||
if (APPLE) |
|
||||
ExternalProject_Add(cryptopp |
|
||||
URL https://downloads.sourceforge.net/project/cryptopp/cryptopp/5.6.2/cryptopp562.zip |
|
||||
BINARY_DIR cryptopp-prefix/src/cryptopp |
|
||||
CONFIGURE_COMMAND "" |
|
||||
BUILD_COMMAND make CXX=clang++ CXXFLAGS=-DCRYPTOPP_DISABLE_ASM |
|
||||
INSTALL_COMMAND make install PREFIX=${ETH_DEPENDENCY_INSTALL_DIR} |
|
||||
) |
|
||||
elseif (WIN32) |
|
||||
file(MAKE_DIRECTORY ${ETH_DEPENDENCY_INSTALL_DIR}/include/cryptopp) |
|
||||
|
|
||||
ExternalProject_Add(cryptopp |
|
||||
SVN_REPOSITORY http://svn.code.sf.net/p/cryptopp/code/trunk/c5 |
|
||||
SVN_REVISION -r "541" |
|
||||
BINARY_DIR cryptopp-prefix/src/cryptopp |
|
||||
CONFIGURE_COMMAND devenv cryptest.sln /upgrade |
|
||||
BUILD_COMMAND devenv cryptest.sln /build release |
|
||||
INSTALL_COMMAND cmd /c cp Win32/DLL_Output/Release/cryptopp.dll ${ETH_DEPENDENCY_INSTALL_DIR}/lib && cp Win32/DLL_Output/Release/cryptopp.lib ${ETH_DEPENDENCY_INSTALL_DIR}/lib && cp *.h ${ETH_DEPENDENCY_INSTALL_DIR}/include/cryptopp |
|
||||
) |
|
||||
# on Linux, the default Makefile does not work. |
|
||||
else() |
|
||||
ExternalProject_Add(cryptopp |
|
||||
URL https://github.com/mmoss/cryptopp/archive/v5.6.2.zip |
|
||||
BINARY_DIR cryptopp-prefix/src/cryptopp |
|
||||
CONFIGURE_COMMAND "" |
|
||||
BUILD_COMMAND scons --shared --prefix=${ETH_DEPENDENCY_INSTALL_DIR} |
|
||||
INSTALL_COMMAND "" |
|
||||
) |
|
||||
endif() |
|
||||
|
|
@ -1,29 +0,0 @@ |
|||||
if (APPLE) |
|
||||
ExternalProject_Add(curl |
|
||||
URL http://curl.haxx.se/download/curl-7.38.0.tar.bz2 |
|
||||
BINARY_DIR curl-prefix/src/curl |
|
||||
CONFIGURE_COMMAND ./configure --with-darwinssl --prefix=${ETH_DEPENDENCY_INSTALL_DIR} --exec-prefix=${ETH_DEPENDENCY_INSTALL_DIR} |
|
||||
BUILD_COMMAND make -j 3 |
|
||||
INSTALL_COMMAND make install |
|
||||
) |
|
||||
elseif (WIN32) |
|
||||
ExternalProject_Add(curl |
|
||||
GIT_REPOSITORY https://github.com/debris/libcurl-7.29 |
|
||||
GIT_TAG master |
|
||||
BINARY_DIR curl-prefix/src/curl |
|
||||
CONFIGURE_COMMAND "" |
|
||||
BUILD_COMMAND "" |
|
||||
INSTALL_COMMAND cmd /c cp lib/release/libcurl.lib ${ETH_DEPENDENCY_INSTALL_DIR}/lib && cp -R include/curl ${ETH_DEPENDENCY_INSTALL_DIR}/include |
|
||||
) |
|
||||
|
|
||||
else() |
|
||||
ExternalProject_Add(curl |
|
||||
URL http://curl.haxx.se/download/curl-7.38.0.tar.bz2 |
|
||||
BINARY_DIR curl-prefix/src/curl |
|
||||
CONFIGURE_COMMAND CONFIG_CMD ./configure --prefix=${ETH_DEPENDENCY_INSTALL_DIR} --exec-prefix=${ETH_DEPENDENCY_INSTALL_DIR} |
|
||||
BUILD_COMMAND make -j 3 |
|
||||
INSTALL_COMMAND make install |
|
||||
) |
|
||||
|
|
||||
endif() |
|
||||
|
|
@ -1,17 +0,0 @@ |
|||||
if (APPLE) |
|
||||
|
|
||||
elseif (WIN32) |
|
||||
ExternalProject_Add(icu |
|
||||
GIT_REPOSITORY https://github.com/debris/icu-win32.git |
|
||||
GIT_TAG master |
|
||||
BINARY_DIR icu-prefix/src/icu |
|
||||
CONFIGURE_COMMAND "" |
|
||||
BUILD_COMMAND "" |
|
||||
INSTALL_COMMAND cmake -E copy_directory . ${ETH_DEPENDENCY_INSTALL_DIR} |
|
||||
) |
|
||||
|
|
||||
else() |
|
||||
|
|
||||
endif() |
|
||||
|
|
||||
|
|
@ -1,16 +0,0 @@ |
|||||
if (APPLE) |
|
||||
|
|
||||
|
|
||||
elseif (WIN32) |
|
||||
ExternalProject_Add(jom |
|
||||
URL http://download.qt-project.org/official_releases/jom/jom.zip |
|
||||
BINARY_DIR jom-prefix/src/jom |
|
||||
CONFIGURE_COMMAND "" |
|
||||
BUILD_COMMAND "" |
|
||||
INSTALL_COMMAND cmake -E copy jom.exe ${ETH_DEPENDENCY_INSTALL_DIR}/bin |
|
||||
) |
|
||||
|
|
||||
else() |
|
||||
|
|
||||
endif() |
|
||||
|
|
@ -1,40 +0,0 @@ |
|||||
# json-rpc-cpp is under heavy development, not yet stable, and multiplatform builds are not yet available. |
|
||||
# DO NOT MESS WITH THESE SETTINGS! IF YOU HAVE TO MAKE CHANGES HERE, CONSULT sven@ethdev.com BEFOREHAND!! |
|
||||
|
|
||||
# DO NOT CHANGE ANYTHING HERE! |
|
||||
if(APPLE) |
|
||||
ExternalProject_Add(json-rpc-cpp |
|
||||
# DEPENDS argtable2 jsoncpp |
|
||||
# DEPENDS curl # re-enable later, when we build curl again |
|
||||
GIT_REPOSITORY https://github.com/cinemast/libjson-rpc-cpp.git |
|
||||
GIT_TAG v0.3.2 |
|
||||
BINARY_DIR json-rpc-cpp-prefix/src/json-rpc-cpp |
|
||||
CONFIGURE_COMMAND cmake -DCMAKE_INSTALL_PREFIX=${ETH_DEPENDENCY_INSTALL_DIR} -DCMAKE_MODULE_PATH:PATH=${CMAKE_CURRENT_SOURCE_DIR}/cmake -DETH_DEPENDENCY_INSTALL_DIR:PATH=${ETH_DEPENDENCY_INSTALL_DIR} -DCMAKE_BUILD_TYPE=None -DCMAKE_FIND_FRAMEWORK=LAST -Wno-dev . |
|
||||
BUILD_COMMAND make -j 3 |
|
||||
INSTALL_COMMAND make install && ${CMAKE_CURRENT_SOURCE_DIR}/scripts/json-rpc-cpp_osx.sh . ${ETH_DEPENDENCY_INSTALL_DIR} |
|
||||
) |
|
||||
|
|
||||
elseif (WIN32) |
|
||||
ExternalProject_Add(json-rpc-cpp |
|
||||
DEPENDS argtable2 jsoncpp curl |
|
||||
GIT_REPOSITORY https://github.com/debris/libjson-rpc-cpp.git |
|
||||
GIT_TAG windows |
|
||||
BINARY_DIR json-rpc-cpp-prefix/src/json-rpc-cpp |
|
||||
CONFIGURE_COMMAND cmake -DCMAKE_PREFIX_PATH=${ETH_DEPENDENCY_INSTALL_DIR} -DCURL_LIBRARIES=${ETH_DEPENDENCY_INSTALL_DIR}/lib/libcurl.lib . |
|
||||
BUILD_COMMAND devenv libjson-rpc-cpp.sln /build release |
|
||||
INSTALL_COMMAND cmd /c cp lib/Release/* ${ETH_DEPENDENCY_INSTALL_DIR}/lib && cp -R src/jsonrpccpp ${ETH_DEPENDENCY_INSTALL_DIR}/include |
|
||||
) |
|
||||
else() |
|
||||
ExternalProject_Add(json-rpc-cpp |
|
||||
# DEPENDS argtable2 jsoncpp |
|
||||
# DEPENDS curl # re-enable later, when we build curl again |
|
||||
GIT_REPOSITORY https://github.com/cinemast/libjson-rpc-cpp.git |
|
||||
GIT_TAG v0.3.2 |
|
||||
BINARY_DIR json-rpc-cpp-prefix/src/json-rpc-cpp |
|
||||
CONFIGURE_COMMAND cmake -DCMAKE_INSTALL_PREFIX=${ETH_DEPENDENCY_INSTALL_DIR} -DCMAKE_MODULE_PATH:PATH=${CMAKE_CURRENT_SOURCE_DIR}/cmake -DETH_DEPENDENCY_INSTALL_DIR:PATH=${ETH_DEPENDENCY_INSTALL_DIR} -DCMAKE_BUILD_TYPE=None -DCMAKE_FIND_FRAMEWORK=LAST . |
|
||||
BUILD_COMMAND make -j 3 |
|
||||
INSTALL_COMMAND make install |
|
||||
) |
|
||||
|
|
||||
endif() |
|
||||
|
|
@ -1,16 +0,0 @@ |
|||||
if (APPLE) |
|
||||
|
|
||||
elseif (WIN32) |
|
||||
|
|
||||
file(MAKE_DIRECTORY ${ETH_DEPENDENCY_INSTALL_DIR}/include/jsoncpp) |
|
||||
ExternalProject_Add(jsoncpp |
|
||||
GIT_REPOSITORY https://github.com/open-source-parsers/jsoncpp |
|
||||
GIT_TAG svn-import |
|
||||
BINARY_DIR jsoncpp-prefix/src/jsoncpp |
|
||||
CONFIGURE_COMMAND cmake . |
|
||||
BUILD_COMMAND devenv jsoncpp.sln /build release |
|
||||
INSTALL_COMMAND cmd /c cp lib/Release/jsoncpp.lib ${ETH_DEPENDENCY_INSTALL_DIR}/lib && cp -R include/json ${ETH_DEPENDENCY_INSTALL_DIR}/include/jsoncpp |
|
||||
) |
|
||||
|
|
||||
else() |
|
||||
endif() |
|
@ -1,23 +0,0 @@ |
|||||
if (APPLE) |
|
||||
ExternalProject_Add(leveldb |
|
||||
#DEPENDS snappy |
|
||||
URL https://leveldb.googlecode.com/files/leveldb-1.15.0.tar.gz |
|
||||
BINARY_DIR leveldb-prefix/src/leveldb |
|
||||
#CONFIGURE_COMMAND patch < ${CMAKE_CURRENT_SOURCE_DIR}/compile/leveldb_osx.patch |
|
||||
CONFIGURE_COMMAND "" |
|
||||
BUILD_COMMAND export ETH_DEPENDENCY_INSTALL_DIR=${ETH_DEPENDENCY_INSTALL_DIR} && make -j 3 |
|
||||
INSTALL_COMMAND cp -rf include/leveldb ${ETH_DEPENDENCY_INSTALL_DIR}/include/ && cp libleveldb.a ${ETH_DEPENDENCY_INSTALL_DIR}/lib && cp libleveldb.dylib.1.15 ${ETH_DEPENDENCY_INSTALL_DIR}/lib/libleveldb.dylib |
|
||||
) |
|
||||
elseif (WIN32) |
|
||||
ExternalProject_Add(leveldb |
|
||||
GIT_REPOSITORY https://github.com/debris/leveldb-win32.git |
|
||||
GIT_TAG master |
|
||||
BINARY_DIR leveldb-prefix/src/leveldb |
|
||||
CONFIGURE_COMMAND "" |
|
||||
BUILD_COMMAND "" |
|
||||
INSTALL_COMMAND cmd /c cp lib/LibLevelDB.lib ${ETH_DEPENDENCY_INSTALL_DIR}/lib/leveldb.lib && cp -R include/leveldb ${ETH_DEPENDENCY_INSTALL_DIR}/include |
|
||||
) |
|
||||
else() |
|
||||
|
|
||||
endif() |
|
||||
|
|
@ -1,18 +0,0 @@ |
|||||
--- Makefile 2014-11-07 00:54:05.000000000 +0100
|
|
||||
+++ MakefilePatch 2014-11-07 00:56:59.000000000 +0100
|
|
||||
@@ -17,11 +17,11 @@
|
|
||||
# this file is generated by the previous line to set build flags and sources |
|
||||
include build_config.mk |
|
||||
|
|
||||
-CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
|
|
||||
-CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT)
|
|
||||
+CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
|
|
||||
+CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) -DSNAPPY -I$(ETH_DEPENDENCY_INSTALL_DIR)/include
|
|
||||
|
|
||||
-LDFLAGS += $(PLATFORM_LDFLAGS)
|
|
||||
-LIBS += $(PLATFORM_LIBS)
|
|
||||
+LDFLAGS += $(PLATFORM_LDFLAGS) -L$(ETH_DEPENDENCY_INSTALL_DIR)/lib
|
|
||||
+LIBS += $(PLATFORM_LIBS) -lsnappy
|
|
||||
|
|
||||
LIBOBJECTS = $(SOURCES:.cc=.o) |
|
||||
MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o) |
|
@ -1,32 +0,0 @@ |
|||||
if (APPLE) |
|
||||
ExternalProject_add(qt |
|
||||
URL http://qtmirror.ics.com/pub/qtproject/official_releases/qt/5.3/5.3.2/single/qt-everywhere-opensource-src-5.3.2.tar.gz |
|
||||
BINARY_DIR qt-prefix/src/qt |
|
||||
PATCH_COMMAND patch -d qtmultimedia/src/plugins/avfoundation/mediaplayer < ${CMAKE_CURRENT_SOURCE_DIR}/compile/qt_osx.patch |
|
||||
CONFIGURE_COMMAND ./configure -prefix ${ETH_DEPENDENCY_INSTALL_DIR} -system-zlib -qt-libpng -qt-libjpeg -confirm-license -opensource -nomake tests -release -nomake examples -no-xcb -arch x86_64 |
|
||||
BUILD_COMMAND make |
|
||||
INSTALL_COMMAND make install |
|
||||
) |
|
||||
elseif(WIN32) |
|
||||
ExternalProject_Add(qt |
|
||||
DEPENDS icu jom |
|
||||
URL http://qtmirror.ics.com/pub/qtproject/official_releases/qt/5.3/5.3.2/single/qt-everywhere-opensource-src-5.3.2.tar.gz |
|
||||
BINARY_DIR qt-prefix/src/qt |
|
||||
UPDATE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/compile/qt_tools.bat |
|
||||
#PATCH_COMMAND cmake -E copy ${CMAKE_CURRENT_SOURCE_DIR}/compile/qt_configure.bat qtbase/configure.bat |
|
||||
CONFIGURE_COMMAND configure -prefix ${ETH_DEPENDENCY_INSTALL_DIR} -opensource -confirm-license -release -opengl desktop -platform win32-msvc2013 -icu -I ${ETH_DEPENDENCY_INSTALL_DIR}/include -L ${ETH_DEPENDENCY_INSTALL_DIR}/lib -nomake tests -nomake examples |
|
||||
BUILD_COMMAND nmake |
|
||||
INSTALL_COMMAND nmake install |
|
||||
) |
|
||||
|
|
||||
ExternalProject_Add_Step(qt configure_paths |
|
||||
COMMAND set PATH=${ETH_DEPENDENCY_INSTALL_DIR}/bin;%cd%/gnuwin32/bin;%cd%/qtbase/bin;%PATH% |
|
||||
DEPENDEES patch |
|
||||
DEPENDERS configure |
|
||||
) |
|
||||
|
|
||||
else() |
|
||||
|
|
||||
endif() |
|
||||
|
|
||||
|
|
@ -1,111 +0,0 @@ |
|||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |
|
||||
:: |
|
||||
:: Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). |
|
||||
:: Contact: http://www.qt-project.org/legal |
|
||||
:: |
|
||||
:: This file is part of the tools applications of the Qt Toolkit. |
|
||||
:: |
|
||||
:: $QT_BEGIN_LICENSE:LGPL$ |
|
||||
:: Commercial License Usage |
|
||||
:: Licensees holding valid commercial Qt licenses may use this file in |
|
||||
:: accordance with the commercial license agreement provided with the |
|
||||
:: Software or, alternatively, in accordance with the terms contained in |
|
||||
:: a written agreement between you and Digia. For licensing terms and |
|
||||
:: conditions see http://qt.digia.com/licensing. For further information |
|
||||
:: use the contact form at http://qt.digia.com/contact-us. |
|
||||
:: |
|
||||
:: GNU Lesser General Public License Usage |
|
||||
:: Alternatively, this file may be used under the terms of the GNU Lesser |
|
||||
:: General Public License version 2.1 as published by the Free Software |
|
||||
:: Foundation and appearing in the file LICENSE.LGPL included in the |
|
||||
:: packaging of this file. Please review the following information to |
|
||||
:: ensure the GNU Lesser General Public License version 2.1 requirements |
|
||||
:: will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
||||
:: |
|
||||
:: In addition, as a special exception, Digia gives you certain additional |
|
||||
:: rights. These rights are described in the Digia Qt LGPL Exception |
|
||||
:: version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
||||
:: |
|
||||
:: GNU General Public License Usage |
|
||||
:: Alternatively, this file may be used under the terms of the GNU |
|
||||
:: General Public License version 3.0 as published by the Free Software |
|
||||
:: Foundation and appearing in the file LICENSE.GPL included in the |
|
||||
:: packaging of this file. Please review the following information to |
|
||||
:: ensure the GNU General Public License version 3.0 requirements will be |
|
||||
:: met: http://www.gnu.org/copyleft/gpl.html. |
|
||||
:: |
|
||||
:: |
|
||||
:: $QT_END_LICENSE$ |
|
||||
:: |
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |
|
||||
|
|
||||
@echo off |
|
||||
set QTSRC=%~dp0 |
|
||||
set QTDIR=%CD% |
|
||||
::if not exist %QTSRC%\.gitignore goto sconf |
|
||||
echo Please wait while bootstrapping configure ... |
|
||||
|
|
||||
for %%C in (cl.exe icl.exe g++.exe perl.exe) do set %%C=%%~$PATH:C |
|
||||
|
|
||||
if "%perl.exe%" == "" ( |
|
||||
echo Perl not found in PATH. Aborting. >&2 |
|
||||
exit /b 1 |
|
||||
) |
|
||||
if not exist mkspecs ( |
|
||||
md mkspecs |
|
||||
if errorlevel 1 goto exit |
|
||||
) |
|
||||
perl %QTSRC%bin\syncqt.pl -minimal -module QtCore -outdir %QTDIR% %QTSRC% |
|
||||
if errorlevel 1 goto exit |
|
||||
|
|
||||
if not exist tools\configure ( |
|
||||
md tools\configure |
|
||||
if errorlevel 1 goto exit |
|
||||
) |
|
||||
cd tools\configure |
|
||||
if errorlevel 1 goto exit |
|
||||
|
|
||||
echo #### Generated by configure.bat - DO NOT EDIT! ####> Makefile |
|
||||
echo/>> Makefile |
|
||||
for /f "tokens=3 usebackq" %%V in (`findstr QT_VERSION_STR %QTSRC%\src\corelib\global\qglobal.h`) do @echo QTVERSION = %%~V>> Makefile |
|
||||
if not "%cl.exe%" == "" ( |
|
||||
echo CXX = cl>>Makefile |
|
||||
echo EXTRA_CXXFLAGS =>>Makefile |
|
||||
rem This must have a trailing space. |
|
||||
echo QTSRC = %QTSRC% >> Makefile |
|
||||
set tmpl=win32 |
|
||||
set make=nmake |
|
||||
) else if not "%icl.exe%" == "" ( |
|
||||
echo CXX = icl>>Makefile |
|
||||
echo EXTRA_CXXFLAGS = /Zc:forScope>>Makefile |
|
||||
rem This must have a trailing space. |
|
||||
echo QTSRC = %QTSRC% >> Makefile |
|
||||
set tmpl=win32 |
|
||||
set make=nmake |
|
||||
) else if not "%g++.exe%" == "" ( |
|
||||
echo CXX = g++>>Makefile |
|
||||
echo EXTRA_CXXFLAGS =>>Makefile |
|
||||
rem This must NOT have a trailing space. |
|
||||
echo QTSRC = %QTSRC:\=/%>> Makefile |
|
||||
set tmpl=mingw |
|
||||
set make=mingw32-make |
|
||||
) else ( |
|
||||
echo No suitable compiler found in PATH. Aborting. >&2 |
|
||||
cd ..\.. |
|
||||
exit /b 1 |
|
||||
) |
|
||||
echo/>> Makefile |
|
||||
type %QTSRC%tools\configure\Makefile.%tmpl% >> Makefile |
|
||||
|
|
||||
%make% |
|
||||
if errorlevel 1 (cd ..\.. & exit /b 1) |
|
||||
|
|
||||
cd ..\.. |
|
||||
|
|
||||
:conf |
|
||||
configure.exe -srcdir %QTSRC% %* |
|
||||
goto exit |
|
||||
|
|
||||
:sconf |
|
||||
%QTSRC%\configure.exe %* |
|
||||
:exit |
|
@ -1,11 +0,0 @@ |
|||||
--- avfmediaplayersession.mm 2014-09-11 12:48:26.000000000 +0200
|
|
||||
+++ avfmediaplayersessionPatch.mm 2014-12-01 12:53:14.000000000 +0100
|
|
||||
@@ -295,7 +295,7 @@
|
|
||||
//AVPlayerItem "status" property value observer. |
|
||||
if (context == AVFMediaPlayerSessionObserverStatusObservationContext) |
|
||||
{ |
|
||||
- AVPlayerStatus status = [[change objectForKey:NSKeyValueChangeNewKey] integerValue];
|
|
||||
+ AVPlayerStatus status = (AVPlayerStatus)[[change objectForKey:NSKeyValueChangeNewKey] integerValue];
|
|
||||
switch (status) |
|
||||
{ |
|
||||
//Indicates that the status of the player is not yet known because |
|
@ -1,2 +0,0 @@ |
|||||
rem : import VC environment vars |
|
||||
call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86 |
|
@ -1,14 +0,0 @@ |
|||||
if (APPLE) |
|
||||
ExternalProject_Add(snappy |
|
||||
URL https://snappy.googlecode.com/files/snappy-1.1.1.tar.gz |
|
||||
BINARY_DIR snappy-prefix/src/snappy |
|
||||
CONFIGURE_COMMAND ./configure --disable-dependency-tracking --prefix=${ETH_DEPENDENCY_INSTALL_DIR} |
|
||||
BUILD_COMMAND "" |
|
||||
INSTALL_COMMAND make install |
|
||||
) |
|
||||
elseif(WIN32) |
|
||||
|
|
||||
else() |
|
||||
|
|
||||
endif() |
|
||||
|
|
@ -1,74 +0,0 @@ |
|||||
# this macro requires the following variables to be specified: |
|
||||
# |
|
||||
# ETH_DEPENDENCY_SERVER - server from which dependencies should be downloaded |
|
||||
# ETH_DEPENDENCY_INSTALL_DIR - install location for all dependencies |
|
||||
# |
|
||||
# usage: |
|
||||
# |
|
||||
# eth_download("json-rpc-cpp") |
|
||||
# eth_download("json-rpc-cpp" VERSION "0.3.2") |
|
||||
# |
|
||||
# params: |
|
||||
# VERSION - exact version we want to use |
|
||||
# OSX_SCRIPT - script which will be executed on apple in install phase |
|
||||
# UNIX_SCRIPT - script which will be executed on unix in install phase |
|
||||
# WIN_SCRIPT - script which will be executed on win in install phase |
|
||||
|
|
||||
# OSX_SCRIPT, WIN_SCRIPT, UNIX_SCRIPT are taking 2 params: |
|
||||
# $1 is package_source, |
|
||||
# $2 is ETH_DEPENDENCY_INSTALL_DIR |
|
||||
# |
|
||||
# parsing arguments |
|
||||
# http://www.cmake.org/cmake/help/v3.0/module/CMakeParseArguments.html |
|
||||
# |
|
||||
# for macos you may need to specify OSX_SCRIPT with install_name_tool to fix dylib |
|
||||
# http://stackoverflow.com/questions/2985315/using-install-name-tool-whats-going-wrong |
|
||||
# |
|
||||
# TODO: |
|
||||
# check if install_command is handling symlinks correctly on linux and windows |
|
||||
|
|
||||
macro(eth_download eth_package_name) |
|
||||
|
|
||||
set (extra_macro_args ${ARGN}) |
|
||||
set (options) |
|
||||
set (one_value_args VERSION OSX_SCRIPT UNIX_SCRIPT WIN_SCRIPT) |
|
||||
set (multi_value_args) |
|
||||
cmake_parse_arguments (ETH_DOWNLOAD "${options}" "${one_value_args}" "${multi_value_args}" ${extra_macro_args}) |
|
||||
|
|
||||
if (ETH_DOWNLOAD_VERSION) |
|
||||
set(eth_tar_name "${eth_package_name}-${ETH_DOWNLOAD_VERSION}.tar.gz") |
|
||||
else() |
|
||||
set(eth_tar_name "${eth_package_name}.tar.gz") |
|
||||
endif() |
|
||||
|
|
||||
message(STATUS "download path for ${eth_package_name} is : ${ETH_DEPENDENCY_SERVER}/${eth_tar_name}") |
|
||||
|
|
||||
# we need that to copy symlinks |
|
||||
# see http://superuser.com/questions/138587/how-to-copy-symbolic-links |
|
||||
if (APPLE) |
|
||||
set (eth_package_copy cp -a . ${ETH_DEPENDENCY_INSTALL_DIR}) |
|
||||
set (eth_package_install ${ETH_DOWNLOAD_OSX_SCRIPT}) |
|
||||
elseif (UNIX) |
|
||||
set (eth_package_copy cp -a . ${ETH_DEPENDENCY_INSTALL_DIR}) |
|
||||
set (eth_package_install ${ETH_DOWNLOAD_UNIX_SCRIPT}) |
|
||||
else () |
|
||||
set (eth_package_copy cmake -E copy_directory . ${ETH_DEPENDENCY_INSTALL_DIR}) |
|
||||
set (eth_package_install ${ETH_DOWNLOAD_WIN_SCRIPT}) |
|
||||
endif() |
|
||||
|
|
||||
if (eth_package_install) |
|
||||
message(STATUS "install script: ${eth_package_install}") |
|
||||
set (eth_package_install ${eth_package_install} . ${ETH_DEPENDENCY_INSTALL_DIR}) |
|
||||
else () |
|
||||
set (eth_package_install echo 0) # cause empty string is not handled properly |
|
||||
endif() |
|
||||
|
|
||||
ExternalProject_Add(${eth_package_name} |
|
||||
URL ${ETH_DEPENDENCY_SERVER}/${eth_tar_name} |
|
||||
BINARY_DIR ${eth_package_name}-prefix/src/${eth_package_name} |
|
||||
CONFIGURE_COMMAND "" |
|
||||
BUILD_COMMAND ${eth_package_copy} |
|
||||
INSTALL_COMMAND ${eth_package_install} |
|
||||
) |
|
||||
endmacro() |
|
||||
|
|
@ -0,0 +1,38 @@ |
|||||
|
REM get stuff! |
||||
|
if not exist download mkdir download |
||||
|
if not exist install mkdir install |
||||
|
if not exist install\windows mkdir install\windows |
||||
|
|
||||
|
set eth_server=https://build.ethdev.com/builds/windows-precompiled |
||||
|
|
||||
|
call :download boost 1.55.0 |
||||
|
call :download cryptopp 5.6.2 |
||||
|
call :download curl 7.4.2 |
||||
|
call :download jsoncpp 1.6.2 |
||||
|
call :download json-rpc-cpp 0.5.0 |
||||
|
call :download leveldb 1.2 |
||||
|
call :download microhttpd 0.9.2 |
||||
|
call :download qt 5.4.1 |
||||
|
|
||||
|
goto :EOF |
||||
|
|
||||
|
:download |
||||
|
|
||||
|
set eth_name=%1 |
||||
|
set eth_version=%2 |
||||
|
|
||||
|
cd download |
||||
|
|
||||
|
if not exist %eth_name%-%eth_version%.tar.gz ( |
||||
|
for /f "tokens=2 delims={}" %%g in ('bitsadmin /create %eth_name%-%eth_version%.tar.gz') do ( |
||||
|
bitsadmin /transfer {%%g} /download /priority normal %eth_server%/%eth_name%-%eth_version%.tar.gz %cd%\%eth_name%-%eth_version%.tar.gz |
||||
|
bitsadmin /cancel {%%g} |
||||
|
) |
||||
|
) |
||||
|
if not exist %eth_name%-%eth_version% cmake -E tar -zxvf %eth_name%-%eth_version%.tar.gz |
||||
|
cmake -E copy_directory %eth_name%-%eth_version% ..\install\windows |
||||
|
|
||||
|
cd .. |
||||
|
|
||||
|
goto :EOF |
||||
|
|
@ -1,11 +0,0 @@ |
|||||
# TODO this file is not used yet, but will be in future |
|
||||
include(ExternalProject) |
|
||||
|
|
||||
ExternalProject_Add(miniupnpc |
|
||||
URL http://miniupnp.tuxfamily.org/files/download.php?file=miniupnpc-1.9.20141027.tar.gz |
|
||||
BINARY_DIR miniupnpc-prefix/src/miniupnpc |
|
||||
CONFIGURE_COMMAND "" |
|
||||
BUILD_COMMAND make -j 3 |
|
||||
INSTALL_COMMAND make install INSTALLPREFIX=${ETH_DEPENDENCY_INSTALL_DIR} |
|
||||
) |
|
||||
|
|
@ -1,29 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
|
|
||||
ETH_DEPENDENCY_SOURCE_DIR=$1 |
|
||||
ETH_DEPENDENCY_INSTALL_DIR=$2 |
|
||||
|
|
||||
OLD_COMMON_DYLIB="libjsonrpccpp-common.0.dylib" |
|
||||
|
|
||||
COMMON_DYLIB=${ETH_DEPENDENCY_INSTALL_DIR}/lib/libjsonrpccpp-common.0.dylib |
|
||||
SERVER_DYLIB=${ETH_DEPENDENCY_INSTALL_DIR}/lib/libjsonrpccpp-server.0.dylib |
|
||||
CLIENT_DYLIB=${ETH_DEPENDENCY_INSTALL_DIR}/lib/libjsonrpccpp-client.0.dylib |
|
||||
|
|
||||
# fix bin |
|
||||
STAB_EXEC=${ETH_DEPENDENCY_INSTALL_DIR}/bin/jsonrpcstub |
|
||||
install_name_tool -change ${OLD_COMMON_DYLIB} ${COMMON_DYLIB} ${STAB_EXEC} |
|
||||
|
|
||||
# fix common |
|
||||
install_name_tool -id ${COMMON_DYLIB} ${COMMON_DYLIB} |
|
||||
|
|
||||
# fix server |
|
||||
install_name_tool -id ${SERVER_DYLIB} ${SERVER_DYLIB} |
|
||||
install_name_tool -change ${OLD_COMMON_DYLIB} ${COMMON_DYLIB} ${SERVER_DYLIB} |
|
||||
|
|
||||
# fix client |
|
||||
install_name_tool -id ${CLIENT_DYLIB} ${CLIENT_DYLIB} |
|
||||
install_name_tool -change ${OLD_COMMON_DYLIB} ${COMMON_DYLIB} ${CLIENT_DYLIB} |
|
||||
|
|
||||
# TODO fix argtable and jsoncpp once they are downloaded as dependencies |
|
||||
|
|
||||
|
|
@ -1,12 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
|
|
||||
ETH_DEPENDENCY_SOURCE_DIR=$1 |
|
||||
ETH_DEPENDENCY_INSTALL_DIR=$2 |
|
||||
|
|
||||
OLD_SNAPPY_DYLIB="/Users/marekkotewicz/ethereum/cpp-ethereum/extdep/install/darwin/lib/libsnappy.1.dylib" |
|
||||
SNAPPY_DYLIB=${ETH_DEPENDENCY_INSTALL_DIR}/lib/libsnappy.dylib |
|
||||
LEVELDB_DYLIB=${ETH_DEPENDENCY_INSTALL_DIR}/lib/libleveldb.dylib |
|
||||
|
|
||||
install_name_tool -id ${LEVELDB_DYLIB} ${LEVELDB_DYLIB} |
|
||||
install_name_tool -change ${OLD_SNAPPY_DYLIB} ${SNAPPY_DYLIB} ${LEVELDB_DYLIB} |
|
||||
|
|
@ -1,8 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
|
|
||||
ETH_DEPENDENCY_SOURCE_DIR=$1 |
|
||||
ETH_DEPENDENCY_INSTALL_DIR=$2 |
|
||||
|
|
||||
SNAPPY_DYLIB=${ETH_DEPENDENCY_INSTALL_DIR}/lib/libsnappy.dylib |
|
||||
install_name_tool -id ${SNAPPY_DYLIB} ${SNAPPY_DYLIB} |
|
||||
|
|
@ -0,0 +1,148 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
namespace dev |
||||
|
{ |
||||
|
namespace con |
||||
|
{ |
||||
|
|
||||
|
#ifdef _WIN32 |
||||
|
|
||||
|
#define EthReset "" // Text Reset
|
||||
|
|
||||
|
#define EthReset "" // Text Reset
|
||||
|
|
||||
|
// Regular Colors
|
||||
|
#define EthBlack "" // Black
|
||||
|
#define EthCoal "" // Black
|
||||
|
#define EthGray "" // White
|
||||
|
#define EthWhite "" // White
|
||||
|
#define EthMaroon "" // Red
|
||||
|
#define EthRed "" // Red
|
||||
|
#define EthGreen "" // Green
|
||||
|
#define EthLime "" // Green
|
||||
|
#define EthOrange "" // Yellow
|
||||
|
#define EthYellow "" // Yellow
|
||||
|
#define EthNavy "" // Blue
|
||||
|
#define EthBlue "" // Blue
|
||||
|
#define EthViolet "" // Purple
|
||||
|
#define EthPurple "" // Purple
|
||||
|
#define EthTeal "" // Cyan
|
||||
|
#define EthCyan "" // Cyan
|
||||
|
|
||||
|
#define EthBlackBold "" // Black
|
||||
|
#define EthCoalBold "" // Black
|
||||
|
#define EthGrayBold "" // White
|
||||
|
#define EthWhiteBold "" // White
|
||||
|
#define EthMaroonBold "" // Red
|
||||
|
#define EthRedBold "" // Red
|
||||
|
#define EthGreenBold "" // Green
|
||||
|
#define EthLimeBold "" // Green
|
||||
|
#define EthOrangeBold "" // Yellow
|
||||
|
#define EthYellowBold "" // Yellow
|
||||
|
#define EthNavyBold "" // Blue
|
||||
|
#define EthBlueBold "" // Blue
|
||||
|
#define EthVioletBold "" // Purple
|
||||
|
#define EthPurpleBold "" // Purple
|
||||
|
#define EthTealBold "" // Cyan
|
||||
|
#define EthCyanBold "" // Cyan
|
||||
|
|
||||
|
// Background
|
||||
|
#define EthOnBlack "" // Black
|
||||
|
#define EthOnCoal "" // Black
|
||||
|
#define EthOnGray "" // White
|
||||
|
#define EthOnWhite "" // White
|
||||
|
#define EthOnMaroon "" // Red
|
||||
|
#define EthOnRed "" // Red
|
||||
|
#define EthOnGreen "" // Green
|
||||
|
#define EthOnLime "" // Green
|
||||
|
#define EthOnOrange "" // Yellow
|
||||
|
#define EthOnYellow "" // Yellow
|
||||
|
#define EthOnNavy "" // Blue
|
||||
|
#define EthOnBlue "" // Blue
|
||||
|
#define EthOnViolet "" // Purple
|
||||
|
#define EthOnPurple "" // Purple
|
||||
|
#define EthOnTeal "" // Cyan
|
||||
|
#define EthOnCyan "" // Cyan
|
||||
|
|
||||
|
// Underline
|
||||
|
#define EthBlackUnder "" // Black
|
||||
|
#define EthGrayUnder "" // White
|
||||
|
#define EthMaroonUnder "" // Red
|
||||
|
#define EthGreenUnder "" // Green
|
||||
|
#define EthOrangeUnder "" // Yellow
|
||||
|
#define EthNavyUnder "" // Blue
|
||||
|
#define EthVioletUnder "" // Purple
|
||||
|
#define EthTealUnder "" // Cyan
|
||||
|
|
||||
|
#else |
||||
|
|
||||
|
#define EthReset "\x1b[0m" // Text Reset
|
||||
|
|
||||
|
// Regular Colors
|
||||
|
#define EthBlack "\x1b[30m" // Black
|
||||
|
#define EthCoal "\x1b[90m" // Black
|
||||
|
#define EthGray "\x1b[37m" // White
|
||||
|
#define EthWhite "\x1b[97m" // White
|
||||
|
#define EthMaroon "\x1b[31m" // Red
|
||||
|
#define EthRed "\x1b[91m" // Red
|
||||
|
#define EthGreen "\x1b[32m" // Green
|
||||
|
#define EthLime "\x1b[92m" // Green
|
||||
|
#define EthOrange "\x1b[33m" // Yellow
|
||||
|
#define EthYellow "\x1b[93m" // Yellow
|
||||
|
#define EthNavy "\x1b[34m" // Blue
|
||||
|
#define EthBlue "\x1b[94m" // Blue
|
||||
|
#define EthViolet "\x1b[35m" // Purple
|
||||
|
#define EthPurple "\x1b[95m" // Purple
|
||||
|
#define EthTeal "\x1b[36m" // Cyan
|
||||
|
#define EthCyan "\x1b[96m" // Cyan
|
||||
|
|
||||
|
#define EthBlackBold "\x1b[1;30m" // Black
|
||||
|
#define EthCoalBold "\x1b[1;90m" // Black
|
||||
|
#define EthGrayBold "\x1b[1;37m" // White
|
||||
|
#define EthWhiteBold "\x1b[1;97m" // White
|
||||
|
#define EthMaroonBold "\x1b[1;31m" // Red
|
||||
|
#define EthRedBold "\x1b[1;91m" // Red
|
||||
|
#define EthGreenBold "\x1b[1;32m" // Green
|
||||
|
#define EthLimeBold "\x1b[1;92m" // Green
|
||||
|
#define EthOrangeBold "\x1b[1;33m" // Yellow
|
||||
|
#define EthYellowBold "\x1b[1;93m" // Yellow
|
||||
|
#define EthNavyBold "\x1b[1;34m" // Blue
|
||||
|
#define EthBlueBold "\x1b[1;94m" // Blue
|
||||
|
#define EthVioletBold "\x1b[1;35m" // Purple
|
||||
|
#define EthPurpleBold "\x1b[1;95m" // Purple
|
||||
|
#define EthTealBold "\x1b[1;36m" // Cyan
|
||||
|
#define EthCyanBold "\x1b[1;96m" // Cyan
|
||||
|
|
||||
|
// Background
|
||||
|
#define EthOnBlack "\x1b[40m" // Black
|
||||
|
#define EthOnCoal "\x1b[100m" // Black
|
||||
|
#define EthOnGray "\x1b[47m" // White
|
||||
|
#define EthOnWhite "\x1b[107m" // White
|
||||
|
#define EthOnMaroon "\x1b[41m" // Red
|
||||
|
#define EthOnRed "\x1b[101m" // Red
|
||||
|
#define EthOnGreen "\x1b[42m" // Green
|
||||
|
#define EthOnLime "\x1b[102m" // Green
|
||||
|
#define EthOnOrange "\x1b[43m" // Yellow
|
||||
|
#define EthOnYellow "\x1b[103m" // Yellow
|
||||
|
#define EthOnNavy "\x1b[44m" // Blue
|
||||
|
#define EthOnBlue "\x1b[104m" // Blue
|
||||
|
#define EthOnViolet "\x1b[45m" // Purple
|
||||
|
#define EthOnPurple "\x1b[105m" // Purple
|
||||
|
#define EthOnTeal "\x1b[46m" // Cyan
|
||||
|
#define EthOnCyan "\x1b[106m" // Cyan
|
||||
|
|
||||
|
// Underline
|
||||
|
#define EthBlackUnder "\x1b[4;30m" // Black
|
||||
|
#define EthGrayUnder "\x1b[4;37m" // White
|
||||
|
#define EthMaroonUnder "\x1b[4;31m" // Red
|
||||
|
#define EthGreenUnder "\x1b[4;32m" // Green
|
||||
|
#define EthOrangeUnder "\x1b[4;33m" // Yellow
|
||||
|
#define EthNavyUnder "\x1b[4;34m" // Blue
|
||||
|
#define EthVioletUnder "\x1b[4;35m" // Purple
|
||||
|
#define EthTealUnder "\x1b[4;36m" // Cyan
|
||||
|
|
||||
|
#endif |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue