Switch to CMake

This commit is contained in:
Erik Zandvliet 2015-03-16 17:17:46 +01:00
parent dff9c193d3
commit 9b6312ca01
10 changed files with 486 additions and 15 deletions

101
src/CMakeLists.txt Normal file
View file

@ -0,0 +1,101 @@
macro(makeAnalyser analyserName format)
add_executable( MistAnalyser${analyserName} analysers/${format}_analyser.cpp )
target_link_libraries( MistAnalyser${analyserName} mist )
endmacro()
macro(makeInput inputName format)
add_executable( MistIn${inputName} input/mist_in.cpp input/input.cpp input/input_${format}.cpp )
set_target_properties( MistIn${inputName} PROPERTIES COMPILE_DEFINITIONS INPUTTYPE=\"input_${format}.h\")
target_link_libraries( MistIn${inputName} mist )
endmacro()
macro(makeOutput outputName format)
#check if 'http' is one of the argyments, if yes, this is an http output
if (";${ARGN};" MATCHES ";http;")
SET(httpOutput output/output_http.cpp)
if (";${ARGN};" MATCHES ";ts;")
SET(tsBaseClass HTTPOutput)
else()
SET(tsBaseClass Output)
endif()
endif()
if (";${ARGN};" MATCHES ";ts;")
SET(tsOutput output/output_ts_base.cpp)
endif()
add_executable( MistOut${outputName} output/mist_out.cpp output/output.cpp ${httpOutput} ${tsOutput} output/output_${format}.cpp )
set_target_properties( MistOut${outputName} PROPERTIES COMPILE_DEFINITIONS "OUTPUTTYPE=\"output_${format}.h\";TS_BASECLASS=${tsBaseClass}")
target_link_libraries( MistOut${outputName} mist )
endmacro()
makeAnalyser(RTMP rtmp)
makeAnalyser(FLV flv)
makeAnalyser(DTSC dtsc)
makeAnalyser(AMF amf)
makeAnalyser(MP4 mp4)
makeAnalyser(OGG ogg)
makeInput(DTSC dtsc)
makeInput(MP3 mp3)
makeInput(FLV flv)
makeInput(OGG ogg)
makeInput(Buffer buffer)
makeOutput(RTMP rtmp)
makeOutput(OGG progressive_ogg http)
makeOutput(FLV progressive_flv http)
makeOutput(MP4 progressive_mp4 http)
makeOutput(MP3 progressive_mp3 http)
makeOutput(HSS hss http)
makeOutput(HDS hds http)
makeOutput(SRT srt http)
makeOutput(JSON json http)
makeOutput(TS ts ts)
makeOutput(HTTPTS httpts http ts)
makeOutput(HLS hls http ts)
#get the bitlength of this system
execute_process(COMMAND getconf LONG_BIT OUTPUT_VARIABLE RELEASE_RAW )
#strip off the trailing spaces and newline
string(STRIP ${RELEASE_RAW} RELEASE)
set(RELEASE \"${RELEASE}\" )
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable( sourcery sourcery.cpp )
add_custom_target( embedcode
ALL
./sourcery ${CMAKE_CURRENT_SOURCE_DIR}/embed.js embed_js ${CMAKE_CURRENT_BINARY_DIR}/embed.js.h
DEPENDS sourcery ${CMAKE_CURRENT_SOURCE_DIR}/embed.js
VERBATIM
)
add_custom_target( localSettingsPage
ALL
./sourcery ${BINARY_DIR}/lsp/server.html server_html ${CMAKE_CURRENT_BINARY_DIR}/server.html.h
DEPENDS sourcery lsp
VERBATIM
)
add_executable( MistOutHTTP output/mist_out.cpp output/output.cpp output/output_http.cpp output/output_http_internal.cpp)
set_target_properties( MistOutHTTP PROPERTIES COMPILE_DEFINITIONS "OUTPUTTYPE=\"output_http_internal.h\"")
add_dependencies(MistOutHTTP embedcode)
target_link_libraries( MistOutHTTP mist )
add_executable( MistController
controller/controller.cpp
controller/controller_api.h
controller/controller_api.cpp
controller/controller_capabilities.h
controller/controller_capabilities.cpp
controller/controller_connectors.h
controller/controller_connectors.cpp
controller/controller_statistics.h
controller/controller_statistics.cpp
controller/controller_storage.h
controller/controller_storage.cpp
controller/controller_streams.h
controller/controller_streams.cpp
)
set_target_properties( MistController PROPERTIES COMPILE_DEFINITIONS RELEASE=${RELEASE})
target_link_libraries( MistController mist )
add_dependencies(MistController localSettingsPage)

View file

@ -365,7 +365,7 @@ namespace Mist {
response = json_resp.toString();
}
if (rURL.substr(0, 7) == "/embed_" && !json_resp.isMember("error")){
#include "../embed.js.h"
#include "embed.js.h"
response.append("\n(");
if (embed_js[embed_js_len - 2] == ';'){//check if we have a trailing ;\n or just \n
response.append((char*)embed_js, (size_t)embed_js_len - 2); //remove trailing ";\n" from xxd conversion

View file

@ -5,10 +5,11 @@
#include <fstream>
int main(int argc, char* argv[]){
if (argc < 3) {
std::cerr << "Usage: " << argv[0] << " <inputFile> <variableName>" << std::endl;
if (argc < 4) {
std::cerr << "Usage: " << argv[0] << " <inputFile> <variableName> <outputFile>" << std::endl;
}
std::cout << "const char *" << argv[2] << " = " << std::endl << " \"";
std::ofstream tmp(argv[3]);
tmp << "const char *" << argv[2] << " = " << std::endl << " \"";
int i = 0;
int total = 0;
std::ifstream inFile(argv[1]);
@ -17,27 +18,28 @@ int main(int argc, char* argv[]){
if (!inFile.good()){break;}
switch (thisChar){
//Filter special characters.
case '\n': std::cout << "\\n"; i += 2; total--; break;
case '\r': std::cout << "\\r"; i += 2; total--; break;
case '\t': std::cout << "\\t"; i += 2; total--; break;
case '\\': std::cout << "\\\\"; i += 2; total --; break;
case '\"': std::cout << "\\\""; i += 2; total --; break;
case '\n': tmp << "\\n"; i += 2; total--; break;
case '\r': tmp << "\\r"; i += 2; total--; break;
case '\t': tmp << "\\t"; i += 2; total--; break;
case '\\': tmp << "\\\\"; i += 2; total --; break;
case '\"': tmp << "\\\""; i += 2; total --; break;
default:
if (thisChar < 32 || thisChar > 126){
//Convert to octal.
std::cout << '\\' << std::oct << std::setw(3) << std::setfill('0') << (unsigned int)thisChar << std::dec;
tmp << '\\' << std::oct << std::setw(3) << std::setfill('0') << (unsigned int)thisChar << std::dec;
i += 4;
}else{
std::cout << thisChar;
tmp << thisChar;
i ++;
}
}
if (i >= 80){
std::cout << "\" \\" << std::endl << " \"";
tmp << "\" \\" << std::endl << " \"";
total += i;
i = 0;
}
}
std::cout << "\";" << std::endl << "unsigned int " << argv[2] << "_len = " << i + total << ";" << std::endl;
tmp << "\";" << std::endl << "unsigned int " << argv[2] << "_len = " << i + total << ";" << std::endl;
tmp.close();
return 0;
}