Skip to content

Commit

Permalink
Merge pull request #139 from s-vincent/optional-mongoose
Browse files Browse the repository at this point in the history
Option to build FreeLAN with mongoose
  • Loading branch information
ereOn authored Aug 9, 2017
2 parents ba8bcc9 + 0702121 commit d36f18c
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 16 deletions.
4 changes: 2 additions & 2 deletions SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ for x in Glob('libs/*'):
if not sys.platform.startswith('linux'):
if name in 'netlinkplus':
continue
else:
if name in 'mongooseplus':

if env.mongoose == 'no' and name in 'mongooseplus':
continue

library, library_includes = SConscript(sconscript_path, exports='env dirs name')
Expand Down
18 changes: 16 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,23 @@ AddOption(
default='all',
help='The compilation mode.',
)
AddOption(
'--mongoose',
dest='mongoose',
nargs=1,
action='store',
choices=('yes', 'no'),
default='no',
help='Build webserver with mongoose (warning: it will violate GPLv3 license!)',
)


class FreelanEnvironment(Environment):
"""
A freelan specific environment class.
"""

def __init__(self, mode, prefix, bin_prefix=None, **kwargs):
def __init__(self, mode, prefix, bin_prefix=None, mongoose='no', **kwargs):
"""
Initialize the environment.
Expand Down Expand Up @@ -69,6 +78,7 @@ class FreelanEnvironment(Environment):
self.prefix = prefix
self.bin_prefix = bin_prefix if bin_prefix else prefix
self.destdir = self['ENV'].get('DESTDIR', '')
self.mongoose = mongoose

if self.destdir:
self.install_prefix = os.path.normpath(
Expand Down Expand Up @@ -115,6 +125,9 @@ class FreelanEnvironment(Environment):
else:
self.Append(CXXFLAGS='-O3')

if self.mongoose == 'yes':
self.Append(CXXFLAGS=['-DUSE_MONGOOSE'])

self.Append(CPPDEFINES=r'FREELAN_INSTALL_PREFIX="\"%s\""' % self.prefix)

def RGlob(self, path, patterns=None):
Expand Down Expand Up @@ -159,6 +172,7 @@ class FreelanEnvironment(Environment):


mode = GetOption('mode')
mongoose = GetOption('mongoose')
prefix = os.path.normpath(os.path.abspath(ARGUMENTS.get('prefix', './install')))

if 'bin_prefix' in ARGUMENTS:
Expand All @@ -167,7 +181,7 @@ else:
bin_prefix = None

if mode in ('all', 'release'):
env = FreelanEnvironment(mode='release', prefix=prefix, bin_prefix=bin_prefix)
env = FreelanEnvironment(mode='release', prefix=prefix, bin_prefix=bin_prefix, mongoose=mongoose)
libraries, includes, apps, samples, configurations = SConscript('SConscript', exports='env', variant_dir=os.path.join('build', env.mode))
install = env.Install(os.path.join(env.bin_install_prefix, 'bin'), apps)
install.extend(env.Install(os.path.join(env.install_prefix, 'etc', 'freelan'), configurations))
Expand Down
10 changes: 5 additions & 5 deletions apps/freelan/SConscript
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import sys


Import('env dirs name')

libraries = [
Expand Down Expand Up @@ -29,17 +28,18 @@ if sys.platform.startswith('linux'):
'netlinkplus',
])
else:
libraries.extend([
'mongooseplus',
])

if sys.platform.startswith('darwin'):
libraries.extend([
'ldap',
'z',
'iconv',
])

if env.mongoose == 'yes':
libraries.extend([
'mongooseplus',
])

env = env.Clone()
env.Prepend(LIBS=libraries)

Expand Down
4 changes: 2 additions & 2 deletions libs/freelan/include/freelan/server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

#include "os.hpp"

#ifndef LINUX
#ifdef USE_MONGOOSE

#include "configuration.hpp"

Expand Down Expand Up @@ -113,4 +113,4 @@ namespace freelan
};
}

#endif
#endif
7 changes: 4 additions & 3 deletions libs/freelan/src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2358,8 +2358,9 @@ namespace freelan
{
if (m_configuration.server.enabled)
{
#ifdef LINUX
// Due to GPL licensing issues, we can't include that in the LINUX build without violating the GPLv3 license.
#ifndef USE_MONGOOSE
// Due to GPL licensing issues, we can't include that in the build without violating the GPLv3 license.
// If you still want that support, adds USE_MONGOOSE define to the build options.
m_logger(fscp::log_level::warning) << "Web server support is not compiled in this version.";
#else
if (m_configuration.server.protocol == server_configuration::server_protocol_type::https)
Expand Down Expand Up @@ -2427,7 +2428,7 @@ namespace freelan

void core::close_web_server()
{
#ifndef LINUX
#ifdef USE_MONGOOSE
if (m_web_server)
{
m_logger(fscp::log_level::information) << "Closing web server...";
Expand Down
4 changes: 2 additions & 2 deletions libs/freelan/src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

#include "server.hpp"

#ifndef LINUX
#ifdef USE_MONGOOSE

#include "tools.hpp"

Expand Down Expand Up @@ -471,4 +471,4 @@ namespace freelan
}
}

#endif
#endif

0 comments on commit d36f18c

Please sign in to comment.