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 building on MacOS #32

Open
wants to merge 7 commits into
base: development
Choose a base branch
from
Open
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
35 changes: 32 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ if (NOT DEBUG)
endif()

option(NOSHM "Disabled shared memory (falling back to shared temporary files)")

if (APPLE)
set(NOSHM 1)
endif()

if (NOT NOSHM)
add_definitions(-DSHM_ENABLED=1)
else()
Expand Down Expand Up @@ -298,6 +303,7 @@ add_library (mist
lib/url.cpp
lib/urireader.cpp
)

if (NOT APPLE)
set (LIBRT -lrt)
endif()
Expand All @@ -306,7 +312,14 @@ target_link_libraries(mist
${LIBRT}
)
if (NOT NOSSL)
target_link_libraries(mist mbedtls mbedx509 mbedcrypto srtp2)
find_library(MBEDTLS_LIB mbedtls)
find_library(MBEDX509_LIB mbedx509)
find_library(MBEDCRYPTO_LIB mbedcrypto)
find_library(SRTP2_LIB srtp2)
target_link_libraries(mist ${MBEDTLS_LIB} ${MBEDX509_LIB} ${MBEDCRYPTO_LIB} ${SRTP2_LIB})
find_path(MBEDTLS_HEADER_DIR "mbedtls/net.h")
find_path(SRTP2_HEADER_DIR "srtp2/srtp.h")
include_directories(${MBEDTLS_HEADER_DIR} ${SRTP2_HEADER_DIR})
endif()
install(
FILES ${libHeaders}
Expand All @@ -320,7 +333,9 @@ install(

if(SRT_LIB)
add_library(mist_srt lib/socket_srt.h lib/socket_srt.cpp)
target_link_libraries(mist_srt mist srt)
target_link_libraries(mist_srt mist ${SRT_LIB})
find_path(SRT_HEADER_DIR "srt/srt.h")
include_directories(${SRT_HEADER_DIR})
install(
TARGETS mist_srt
DESTINATION lib
Expand Down Expand Up @@ -534,7 +549,7 @@ macro(makeOutput outputName format)
target_link_libraries(MistOut${outputName} rist cjson)
endif()
target_link_libraries(MistOut${outputName} mist )
install(
install(
TARGETS MistOut${outputName}
DESTINATION bin
)
Expand Down Expand Up @@ -593,6 +608,10 @@ add_executable(MistProcFFMPEG
src/io.cpp
)
target_link_libraries(MistProcFFMPEG mist)
install(
TARGETS MistProcFFMPEG
DESTINATION bin
)

add_executable(MistProcMKVExec
${BINARY_DIR}/mist/.headers
Expand All @@ -605,6 +624,10 @@ add_executable(MistProcMKVExec
src/io.cpp
)
target_link_libraries(MistProcMKVExec mist)
install(
TARGETS MistProcMKVExec
DESTINATION bin
)

add_executable(MistProcLivepeer
${BINARY_DIR}/mist/.headers
Expand All @@ -616,6 +639,10 @@ add_executable(MistProcLivepeer
src/io.cpp
)
target_link_libraries(MistProcLivepeer mist)
install(
TARGETS MistProcLivepeer
DESTINATION bin
)

if (NOT NOSSL)
makeOutput(HTTPS https)#LTS
Expand Down Expand Up @@ -875,6 +902,8 @@ install(
TARGETS MistController
DESTINATION bin
)
# Needed to make parallel builds work well
add_dependencies(MistOutHTTP MistController)

########################################
# Make Clean #
Expand Down
2 changes: 1 addition & 1 deletion lib/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static const char *DBG_LVL_LIST[] ={"NONE", "FAIL", "ERROR", "WARN", "IN
#if DEBUG >= DLVL_DEVEL
#define DEBUG_MSG(lvl, msg, ...) \
if (Util::printDebugLevel >= lvl){\
fprintf(stderr, "%s|MistProcess|%d|%s:%d|%s|" msg "\n", DBG_LVL_LIST[lvl], getpid(), __FILE__, \
fprintf(stderr, "%s|%s|%d|%s:%d|%s|" msg "\n", DBG_LVL_LIST[lvl], getprogname(), getpid(), __FILE__, \
__LINE__, Util::streamName, ##__VA_ARGS__); \
}
#else
Expand Down
16 changes: 16 additions & 0 deletions lib/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,15 @@ JSON::Value::Value(uint64_t val){
myType = INTEGER;
intVal = val;
}

#if defined(__APPLE__)
/// Sets this JSON::Value to the given integer.
JSON::Value::Value(unsigned long val){
myType = INTEGER;
intVal = val;
}
#endif

/// Sets this JSON::Value to the given integer.
JSON::Value::Value(int32_t val){
myType = INTEGER;
Expand Down Expand Up @@ -684,6 +693,13 @@ JSON::Value &JSON::Value::operator=(const uint64_t &rhs){
return ((*this) = (int64_t)rhs);
}

#if defined(__APPLE__)
/// Sets this JSON::Value to the given integer.
JSON::Value &JSON::Value::operator=(const unsigned long &rhs){
return ((*this) = (int64_t)rhs);
}
#endif

/// Sets this JSON::Value to the given double.
JSON::Value &JSON::Value::operator=(const double &rhs){
null();
Expand Down
6 changes: 6 additions & 0 deletions lib/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ namespace JSON{
Value(int64_t val);
Value(uint32_t val);
Value(uint64_t val);
#if defined(__APPLE__)
Value(unsigned long val);
#endif
Value(double val);
Value(bool val);
// comparison operators
Expand All @@ -62,6 +65,9 @@ namespace JSON{
Value &operator=(const int64_t &rhs);
Value &operator=(const int32_t &rhs);
Value &operator=(const uint64_t &rhs);
#if defined(__APPLE__)
Value &operator=(const unsigned long &rhs);
#endif
Value &operator=(const uint32_t &rhs);
Value &operator=(const double &rhs);
Value &operator=(const bool &rhs);
Expand Down
6 changes: 5 additions & 1 deletion lib/shared_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,11 @@ namespace IPC{
unmap();
if (handle > 0){
::close(handle);
if (master && name != ""){unlink(name.c_str());}
if (master && name != ""){
std::string remove(Util::getTmpFolder() + name);
DONTEVEN_MSG("Unlinking %s", remove.c_str());
unlink(remove.c_str());
}
handle = 0;
}
}
Expand Down
11 changes: 8 additions & 3 deletions src/controller/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ int main_loop(int argc, char **argv){
// reload config from config file
Controller::Storage = JSON::fromFile(Controller::conf.getString("configFile"));

// start push checking thread
tthread::thread pushThread(Controller::pushCheckLoop, 0);

{// spawn thread that reads stderr of process
std::string logPipe = Util::getTmpFolder() + "MstLog";
if (mkfifo(logPipe.c_str(), S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH) != 0){
Expand Down Expand Up @@ -265,7 +268,11 @@ int main_loop(int argc, char **argv){
msghandler.detach();
// Attempt to open and redirect log messages to named pipe
int outFD = -1;
if ((outFD = open(logPipe.c_str(), O_WRONLY)) == -1){
if (getenv("MIST_NO_PRETTY_LOGGING")) {
WARN_MSG(
"MIST_NO_PRETTY_LOGGING is active, printing lots of pipes");
}
else if ((outFD = open(logPipe.c_str(), O_WRONLY)) == -1){
ERROR_MSG(
"Could not open log message pipe %s for writing! %s; falling back to standard error",
logPipe.c_str(), strerror(errno));
Expand Down Expand Up @@ -565,8 +572,6 @@ int main_loop(int argc, char **argv){
tthread::thread UDPAPIThread(Controller::handleUDPAPI, 0);
// start monitoring thread /*LTS*/
tthread::thread uplinkThread(Controller::uplinkConnection, 0); /*LTS*/
// start push checking thread
tthread::thread pushThread(Controller::pushCheckLoop, 0);
#ifdef UPDATER
// start updater thread
tthread::thread updaterThread(Controller::updateThread, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/controller/controller_connectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ namespace Controller{

// used for building args
int err = fileno(stderr);
char *argarr[15]; // approx max # of args (with a wide margin)
char *argarr[30]; // approx max # of args (with a wide margin)
int i;

std::string tmp;
Expand Down