Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix build for open source code. #23

Merged
merged 6 commits into from
Jan 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 111 additions & 49 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include(CMakeParseArguments)
# building on Linux under GCC right now, so we might as well just hard
# code the flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wno-sign-compare")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-sign-compare -Wno-bool-compare")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable -Woverloaded-virtual -Wnon-virtual-dtor")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized -Wdeprecated-declarations")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations")
Expand All @@ -24,26 +24,36 @@ include_directories(${CMAKE_BINARY_DIR}/gen/common/network/if/gen-cpp2)

# System libraries
find_library(GLOG glog)
find_library(BOOSTSER boost_serialization)
find_library(BOOSTFS boost_filesystem)
find_library(BOOSTSYS boost_system)
find_library(BOOSTTHREAD boost_thread)
find_library(DOUBLECONV double-conversion)
find_library(GFLAGS gflags)
find_library(GLOG glog)
find_library(PTHREAD pthread)
find_library(USB usb-1.0)
find_library(PCAP pcap)
find_library(SNAPPY snappy)
find_library(ZLIB z)
find_library(SSL ssl)
find_library(CRYPTO crypto)

# External libraries that are not generally available. Look in external/
# for these. This is where getdeps.sh will toss them.
find_library(FOLLY folly PATHS ${CMAKE_SOURCE_DIR}/external/folly/folly/.libs)
find_library(THRIFT thrift PATHS ${CMAKE_SOURCE_DIR}/external/fbthrift/thrift/lib/cpp/.libs)
find_library(WANGLE wangle PATHS ${CMAKE_SOURCE_DIR}/external/wangle/wangle/build/lib)
find_library(THRIFT libthrift.a PATHS ${CMAKE_SOURCE_DIR}/external/fbthrift/thrift/lib/cpp/.libs)
find_library(THRIFTPROTO thriftprotocol PATHS ${CMAKE_SOURCE_DIR}/external/fbthrift/thrift/lib/cpp2/.libs)
find_library(THRIFTCPP2 thriftcpp2 PATHS ${CMAKE_SOURCE_DIR}/external/fbthrift/thrift/lib/cpp2/.libs)
find_library(OPENNSL opennsl PATHS ${CMAKE_SOURCE_DIR}/external/OpenNSL/bin/wedge-trident/)
find_library(IPROUTE2 netlink PATHS ${CMAKE_SOURCE_DIR}/external/iproute2/lib/)
find_library(OPENNSL opennsl PATHS ${CMAKE_SOURCE_DIR}/external/OpenNSL/bin/wedge-trident)
find_library(IPROUTE2 netlink PATHS ${CMAKE_SOURCE_DIR}/external/iproute2/lib)

include_directories(${CMAKE_SOURCE_DIR}/external/OpenNSL/include)
include_directories(${CMAKE_SOURCE_DIR}/external/iproute2/include)
include_directories(${CMAKE_SOURCE_DIR}/external/folly)
include_directories(${CMAKE_SOURCE_DIR}/external/fbthrift)
include_directories(${CMAKE_SOURCE_DIR}/external/wangle)

add_executable(wedge_agent
fboss/agent/platforms/wedge/WedgePlatform.cpp
Expand All @@ -55,62 +65,48 @@ add_executable(wedge_agent
)
target_link_libraries(wedge_agent fboss_agent)

add_executable(sim_agent
fboss/agent/platforms/sim/sim_ctrl.cpp
)
target_link_libraries(sim_agent fboss_agent)

add_library(fboss_agent STATIC
common/stats/ServiceData.cpp

fboss/agent/ApplyThriftConfig.cpp
fboss/agent/ArpHandler.cpp
fboss/agent/DHCPv4Handler.cpp
fboss/agent/DHCPv6Handler.cpp
fboss/agent/HighresCounterSubscriptionHandler.cpp
fboss/agent/HighresCounterUtil.cpp
fboss/agent/HwSwitch.cpp
fboss/agent/I2c.cpp
fboss/agent/IPHeaderV4.cpp
fboss/agent/IPv4Handler.cpp
fboss/agent/IPv6Handler.cpp
fboss/agent/LldpManager.cpp
fboss/agent/Main.cpp
fboss/agent/NeighborListenerClient.cpp
fboss/agent/NeighborUpdater.cpp
fboss/agent/Platform.cpp
fboss/agent/PortStats.cpp
fboss/agent/RestClient.cpp
fboss/agent/SfpModule.cpp
fboss/agent/SwitchStats.cpp
fboss/agent/SwSwitch.cpp
fboss/agent/ThriftHandler.cpp
fboss/agent/TransceiverMap.cpp
fboss/agent/TunIntf.cpp
fboss/agent/TunManager.cpp
fboss/agent/UDPHeader.cpp
fboss/agent/Utils.cpp
fboss/agent/capture/PcapFile.cpp
fboss/agent/capture/PcapPkt.cpp
fboss/agent/capture/PcapQueue.cpp
fboss/agent/capture/PcapWriter.cpp
fboss/agent/capture/PktCapture.cpp
fboss/agent/capture/PktCaptureManager.cpp
fboss/agent/DHCPv4Handler.cpp
fboss/agent/DHCPv6Handler.cpp
fboss/agent/HighresCounterSubscriptionHandler.cpp
fboss/agent/HighresCounterUtil.cpp
fboss/agent/hw/bcm/BcmAPI.cpp
fboss/agent/hw/bcm/BcmEgress.cpp
fboss/agent/hw/bcm/BcmHost.cpp
fboss/agent/hw/bcm/BcmIntf.cpp
fboss/agent/hw/bcm/BcmPlatform.cpp
fboss/agent/hw/bcm/BcmPort.cpp
fboss/agent/hw/bcm/BcmPortGroup.cpp
fboss/agent/hw/bcm/BcmPortTable.cpp
fboss/agent/hw/bcm/BcmRoute.cpp
fboss/agent/hw/bcm/BcmRxPacket.cpp
fboss/agent/hw/bcm/BcmPlatform.cpp
fboss/agent/hw/bcm/BcmStats.cpp
fboss/agent/hw/bcm/BcmSwitch.cpp
fboss/agent/hw/bcm/BcmSwitchEvent.cpp
fboss/agent/hw/bcm/BcmSwitchEventCallback.cpp
fboss/agent/hw/bcm/BcmSwitchEvent.cpp
fboss/agent/hw/bcm/BcmSwitchEventManager.cpp
fboss/agent/hw/bcm/BcmTxPacket.cpp
fboss/agent/hw/bcm/BcmWarmBootCache.cpp
fboss/agent/hw/bcm/BcmWarmBootHelper.cpp
fboss/agent/hw/bcm/oss/BcmAPI.cpp
fboss/agent/hw/bcm/oss/BcmHost.cpp
fboss/agent/hw/bcm/oss/BcmPort.cpp
fboss/agent/hw/bcm/oss/BcmPortGroup.cpp
fboss/agent/hw/bcm/oss/BcmPortTable.cpp
fboss/agent/hw/bcm/oss/BcmSwitch.cpp
fboss/agent/hw/bcm/oss/BcmUnit.cpp
fboss/agent/hw/bcm/oss/BcmWarmBootHelper.cpp
fboss/agent/hw/bcm/Utils.cpp
fboss/agent/hw/mock/MockRxPacket.cpp
fboss/agent/hw/mock/MockTxPacket.cpp
fboss/agent/hw/sim/SimHandler.cpp
Expand All @@ -122,12 +118,22 @@ add_library(fboss_agent STATIC
fboss/agent/oss/ApplyThriftConfig.cpp
fboss/agent/oss/Main.cpp
fboss/agent/oss/SwSwitch.cpp
fboss/agent/hw/bcm/oss/BcmAPI.cpp
fboss/agent/hw/bcm/oss/BcmHost.cpp
fboss/agent/hw/bcm/oss/BcmPort.cpp
fboss/agent/hw/bcm/oss/BcmSwitch.cpp
fboss/agent/hw/bcm/oss/BcmUnit.cpp
fboss/agent/hw/bcm/oss/BcmWarmBootHelper.cpp
fboss/agent/HwSwitch.cpp
fboss/agent/I2c.cpp
fboss/agent/IPHeaderV4.cpp
fboss/agent/IPv4Handler.cpp
fboss/agent/IPv6Handler.cpp
fboss/agent/lldp/LinkNeighbor.cpp
fboss/agent/lldp/LinkNeighborDB.cpp
fboss/agent/LldpManager.cpp
fboss/agent/Main.cpp
fboss/agent/ndp/IPv6RouteAdvertiser.cpp
fboss/agent/NeighborListenerClient.cpp
fboss/agent/NeighborUpdater.cpp
fboss/agent/NexthopToRouteCount.cpp
fboss/agent/oss/ApplyThriftConfig.cpp
fboss/agent/oss/Main.cpp
fboss/agent/oss/SwSwitch.cpp
fboss/agent/packet/ArpHdr.cpp
fboss/agent/packet/DHCPv4Packet.cpp
fboss/agent/packet/DHCPv6Packet.cpp
Expand All @@ -138,6 +144,23 @@ add_library(fboss_agent STATIC
fboss/agent/packet/LlcHdr.cpp
fboss/agent/packet/NDPRouterAdvertisement.cpp
fboss/agent/packet/PktUtil.cpp
fboss/agent/Platform.cpp
fboss/agent/platforms/wedge/oss/WedgePlatform.cpp
fboss/agent/platforms/wedge/oss/WedgePort.cpp
fboss/agent/platforms/wedge/oss/WedgeProductInfo.cpp
fboss/agent/platforms/wedge/wedge_ctrl.cpp
fboss/agent/platforms/wedge/WedgeI2CBusLock.cpp
fboss/agent/platforms/wedge/WedgePlatform.cpp
fboss/agent/platforms/wedge/WedgePort.cpp
fboss/agent/platforms/wedge/WedgeProductInfo.cpp
fboss/agent/platforms/wedge/WedgeQsfp.cpp
fboss/agent/PortStats.cpp
fboss/agent/QsfpModule.cpp
fboss/agent/RestClient.cpp
fboss/agent/SffFieldInfo.cpp
fboss/agent/SfpModule.cpp
fboss/agent/state/AclEntry.cpp
fboss/agent/state/AclMap.cpp
fboss/agent/state/ArpEntry.cpp
fboss/agent/state/ArpResponseTable.cpp
fboss/agent/state/ArpTable.cpp
Expand All @@ -163,36 +186,75 @@ add_library(fboss_agent STATIC
fboss/agent/state/Vlan.cpp
fboss/agent/state/VlanMap.cpp
fboss/agent/state/VlanMapDelta.cpp
fboss/agent/SwitchStats.cpp
fboss/agent/SwSwitch.cpp
fboss/agent/ThriftHandler.cpp
fboss/agent/TransceiverMap.cpp
fboss/agent/TunIntf.cpp
fboss/agent/TunManager.cpp
fboss/agent/UDPHeader.cpp
fboss/agent/Utils.cpp

fboss/lib/usb/BaseWedgeI2CBus.cpp
fboss/lib/usb/BaseWedgeI2CBus.h
fboss/lib/usb/CP2112.cpp
fboss/lib/usb/CP2112.h
fboss/lib/usb/TARGETS
fboss/lib/usb/TransceiverI2CApi.h
fboss/lib/usb/UsbDevice.cpp
fboss/lib/usb/UsbDevice.h
fboss/lib/usb/UsbError.h
fboss/lib/usb/UsbHandle.cpp
fboss/lib/usb/UsbHandle.h
fboss/lib/usb/Wedge100I2CBus.cpp
fboss/lib/usb/Wedge100I2CBus.h
fboss/lib/usb/WedgeI2CBus.cpp
fboss/lib/usb/WedgeI2CBus.h

# generated sources
${CMAKE_BINARY_DIR}/gen/common/fb303/if/gen-cpp2/FacebookService.cpp
${CMAKE_BINARY_DIR}/gen/common/fb303/if/gen-cpp2/FacebookService_client.cpp
${CMAKE_BINARY_DIR}/gen/common/fb303/if/gen-cpp2/fb303_types.cpp
${CMAKE_BINARY_DIR}/gen/common/network/if/gen-cpp2/Address_types.cpp
${CMAKE_BINARY_DIR}/gen/common/network/if/gen-cpp/Address_types.cpp
${CMAKE_BINARY_DIR}/gen/common/network/if/gen-cpp/Address_constants.cpp
${CMAKE_BINARY_DIR}/gen/common/network/if/gen-cpp/Address_reflection.cpp
${CMAKE_BINARY_DIR}/gen/common/network/if/gen-cpp/Address_types.cpp
${CMAKE_BINARY_DIR}/gen/common/network/if/gen-cpp2/Address_constants.cpp
${CMAKE_BINARY_DIR}/gen/common/network/if/gen-cpp2/Address_types.cpp
${CMAKE_BINARY_DIR}/gen/fboss/agent/gen-cpp/switch_config_reflection.cpp
${CMAKE_BINARY_DIR}/gen/fboss/agent/gen-cpp/switch_config_types.cpp
${CMAKE_BINARY_DIR}/gen/fboss/agent/gen-cpp/switch_config_constants.cpp
${CMAKE_BINARY_DIR}/gen/fboss/agent/hw/sim/gen-cpp2/SimCtrl.cpp
${CMAKE_BINARY_DIR}/gen/fboss/agent/hw/sim/gen-cpp2/sim_ctrl_types.cpp
${CMAKE_BINARY_DIR}/gen/fboss/agent/hw/sim/gen-cpp2/sim_ctrl_constants.cpp
${CMAKE_BINARY_DIR}/gen/fboss/agent/if/gen-cpp2/ctrl_types.cpp
${CMAKE_BINARY_DIR}/gen/fboss/agent/if/gen-cpp2/FbossCtrl.cpp
${CMAKE_BINARY_DIR}/gen/fboss/agent/if/gen-cpp2/NeighborListenerClient_client.cpp
${CMAKE_BINARY_DIR}/gen/fboss/agent/if/gen-cpp2/FbossHighresClient_client.cpp
${CMAKE_BINARY_DIR}/gen/fboss/agent/if/gen-cpp2/fboss_types.cpp
${CMAKE_BINARY_DIR}/gen/fboss/agent/if/gen-cpp2/optic_types.cpp
${CMAKE_BINARY_DIR}/gen/fboss/agent/if/gen-cpp2/optic_constants.cpp
${CMAKE_BINARY_DIR}/gen/fboss/agent/if/gen-cpp2/highres_types.cpp
)
target_link_libraries(fboss_agent
${GLOG}
${SSL}
${PCAP}
${USB}
${ZLIB}
${SNAPPY}
${CRYPTO}
${FOLLY}
${WANGLE}
${GFLAGS}
${GLOG}
${PTHREAD}
${THRIFT}
${THRIFTPROTO}
${THRIFTCPP2}
${OPENNSL}
${IPROUTE2}
${BOOSTFS}
${BOOSTSER}
${BOOSTSYS}
${BOOSTTHREAD}
${DOUBLECONV}
Expand All @@ -218,12 +280,12 @@ function(fboss_add_thrift)
set(services ${services} ${CMAKE_BINARY_DIR}/gen/${dirname}/gen-cpp2/${srv}.cpp)
set(services ${services} ${CMAKE_BINARY_DIR}/gen/${dirname}/gen-cpp2/${srv}.h)
endforeach(srv)
foreach(reflect ${arg_REFLECT})
set(outputs ${outputs}
${CMAKE_BINARY_DIR}/gen/${dirname}/gen-cpp/${reflect}_reflection.h
${CMAKE_BINARY_DIR}/gen/${dirname}/gen-cpp/${reflect}_reflection.cpp)
endforeach(reflect)
foreach(gen cpp cpp2)
foreach(reflect ${arg_REFLECT})
set(outputs ${outputs}
${CMAKE_BINARY_DIR}/gen/${dirname}/gen-${gen}/${reflect}_reflection.h
${CMAKE_BINARY_DIR}/gen/${dirname}/gen-${gen}/${reflect}_reflection.cpp)
endforeach(reflect)
foreach(output constants types)
set(outputs ${outputs}
${CMAKE_BINARY_DIR}/gen/${dirname}/gen-${gen}/${basename}_${output}.h
Expand Down
2 changes: 2 additions & 0 deletions common/stats/ExportedHistogram.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class ExportedHistogram {
public:
ExportedHistogram(int, int, size_t) {}
void addValue(std::chrono::seconds, int, int64_t) {}
int numLevels() {return 1;}
int sum(int numLevels) {return 0;}
};

class ExportedHistogramMap {
Expand Down
2 changes: 2 additions & 0 deletions common/stats/ExportedTimeseries.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ enum ExportType {

struct ExportedStat {
void addValue(std::chrono::seconds, int64_t) {}
int numLevels() {return 1;}
int getSum(int level) {return 0;}
int sum(int level) {return 0;}
};

class ExportedStatMap {
Expand Down
2 changes: 2 additions & 0 deletions common/stats/ServiceData.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class ServiceData {
return ⁢
}
void getCounters(std::map<std::string, int64_t>&) {}
long getCounter(std::string) {return 0;};
long clearCounter(std::string) {return 0;};
void setUseOptionsAsFlags(bool) {}
void setCounter(folly::StringPiece, uint32_t) {}
};
Expand Down
4 changes: 2 additions & 2 deletions fboss/agent/NeighborListenerClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include <gflags/gflags.h>
#include <thrift/lib/cpp2/async/DuplexChannel.h>
#include <folly/SocketAddress.h>
#include <folly/io/async/EventBase.h>
#include <thrift/lib/cpp2/server/ThriftServer.h>
#include <thrift/lib/cpp/util/ScopedServerThread.h>
#include <thrift/lib/cpp/async/TEventBase.h>
#include <thrift/lib/cpp/async/TAsyncSocket.h>

using namespace apache::thrift;
Expand Down Expand Up @@ -38,7 +38,7 @@ class NeighborListenerClientInterface : public NeighborListenerClientSvIf {
};

int main(int argc, char **argv) {
TEventBase base;
folly::EventBase base;

google::ParseCommandLineFlags(&argc, &argv, true);
google::InitGoogleLogging(argv[0]);
Expand Down
35 changes: 23 additions & 12 deletions getdeps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function update() {
(cd $repo && git pull)
else
git clone $1
git checkout $2
[ -z "$2" ] || (cd $repo && git checkout $2)
fi
}

Expand All @@ -22,32 +22,43 @@ function build() {
(
echo "building $1..."
cd $1
if [ ! -x ./configure ]; then
autoreconf --install
if [ -e ./CMakeLists.txt ]; then
mkdir -p build
cd build
echo cmake .. $CMAKEFLAGS
cmake .. $CMAKEFLAGS
make
else
if [ ! -e ./configure ]; then
autoreconf --install
fi
./configure
make -j8
fi
make -j8
)
}

echo "installing packages"
sudo apt-get install -yq autoconf automake libdouble-conversion-dev \
libssl-dev make zip git autoconf libtool g++ libboost-all-dev \
libevent-dev flex bison libgoogle-glog-dev scons libkrb5-dev \
libsnappy-dev libsasl2-dev libnuma-dev libi2c-dev libcurl4-nss-dev
libsnappy-dev libsasl2-dev libnuma-dev libi2c-dev libcurl4-nss-dev \
libusb-1.0-0-dev libpcap-dev

echo "creating external..."
mkdir -p external
(
cd external
update https://github.com/Broadcom-Switch/OpenNSL.git
(cd OpenNSL && update_branch OpenNSL_6.3)
update https://github.com/Broadcom-Switch/OpenNSL.git cf6dc4100bcfc1ffe82da3ba090b504e09e39216
update \
git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git
git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git v3.19.0
update https://github.com/facebook/folly.git
update https://github.com/facebook/wangle.git
update https://github.com/facebook/fbthrift.git
build iproute2 v3.12.0
build folly/folly v0.48.0
export CPPFLAGS=" -I`pwd`/folly/" LDFLAGS="-L`pwd`/folly/folly/.libs/"
build fbthrift/thrift v0.28.0
build iproute2
build folly/folly
export CMAKEFLAGS=-D"FOLLY_INCLUDE_DIR=`pwd`/folly"\ -D"FOLLY_LIBRARY=`pwd`/folly/folly/.libs/libfolly.a"\ -D"BUILD_TESTS=OFF"
build wangle/wangle
export CPPFLAGS=" -I`pwd`/folly -I`pwd`/wangle" LDFLAGS="-L`pwd`/folly/folly/.libs/ -L`pwd`/wangle/wangle/build/lib"
build fbthrift/thrift
)