Skip to content

Commit

Permalink
Adds manpage generation (#157)
Browse files Browse the repository at this point in the history
* Adds generation of manpage in scons.

* Updates RPM spec files to depends on help2man for build.

* Uses a more classic way to see if binary exists with scons (CheckProg feature is a bit recent).

* Adds help2man dependency for Vagrant provisioning.
  • Loading branch information
s-vincent authored and ereOn committed Aug 15, 2017
1 parent f804124 commit fe60128
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 283 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ addons:
- libminiupnpc-dev
- gcc
- g++
- help2man
before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew list scons &>/dev/null || brew install scons ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew list boost &>/dev/null || brew install boost ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew list openssl &>/dev/null || brew install openssl ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew list miniupnpc &>/dev/null || brew install miniupnpc ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew list help2man &>/dev/null || brew install help2man ; fi
cache:
apt: true
script: scons install apps samples
Expand Down
6 changes: 4 additions & 2 deletions SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dirs = {
'include': Dir('include'),
'lib': Dir('lib'),
'bin': Dir('bin'),
'man': Dir('man'),
}

env.Append(CPPPATH=[dirs['include']])
Expand Down Expand Up @@ -51,13 +52,14 @@ for x in Glob('libs/*'):

apps = []
configurations = []
help = []

for x in Glob('apps/*'):
sconscript_path = x.File('SConscript')

if sconscript_path.exists():
name = os.path.basename(str(x))
app, configuration = SConscript(sconscript_path, exports='env dirs name')
app, configuration, help = SConscript(sconscript_path, exports='env dirs name')
apps.extend(app)
configurations.extend(configuration)

Expand Down Expand Up @@ -87,4 +89,4 @@ if env.mode != 'retail':
else:
samples.extend(env.SymLink(y.File('%sd' % os.path.basename(str(y))).srcnode(), sample))

Return('libraries includes apps samples configurations')
Return('libraries includes apps samples configurations help')
17 changes: 9 additions & 8 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -216,27 +216,28 @@ else:

if mode in ('all', 'release'):
env = FreelanEnvironment(mode='release', prefix=prefix, bin_prefix=bin_prefix, mongoose=mongoose, upnp=upnp)
libraries, includes, apps, samples, configurations = SConscript('SConscript', exports='env', variant_dir=os.path.join('build', env.mode))
libraries, includes, apps, samples, configurations, help = 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 = env.Install(os.path.join(env.bin_install_prefix, 'man', 'man1'), help)
install.extend(env.Install(os.path.join(env.install_prefix, 'etc', 'freelan'), configurations))

Alias('install', install)
Alias('apps', apps)
Alias('apps', apps + help)
Alias('samples', samples)
Alias('all', install + apps + samples)
Alias('all', install + apps + help + samples)

if mode in ('all', 'debug'):
env = FreelanEnvironment(mode='debug', prefix=prefix, mongoose=mongoose, upnp=upnp)
libraries, includes, apps, samples, configurations = SConscript('SConscript', exports='env', variant_dir=os.path.join('build', env.mode))
Alias('apps', apps)
libraries, includes, apps, samples, configurations, help = SConscript('SConscript', exports='env', variant_dir=os.path.join('build', env.mode))
Alias('apps', apps + help)
Alias('samples', samples)
Alias('all', apps + samples)
Alias('all', apps + help + samples)

if sys.platform.startswith('darwin'):
retail_prefix = '/usr/local'
env = FreelanEnvironment(mode='retail', prefix=retail_prefix, mongoose=mongoose, upnp=upnp)
libraries, includes, apps, samples, configurations = SConscript('SConscript', exports='env', variant_dir=os.path.join('build', env.mode))
package = SConscript('packaging/osx/SConscript', exports='env apps configurations retail_prefix')
libraries, includes, apps, samples, configurations, help = SConscript('SConscript', exports='env', variant_dir=os.path.join('build', env.mode))
package = SConscript('packaging/osx/SConscript', exports='env apps configurations retail_prefix help')
install_package = env.Install('.', package)
Alias('package', install_package)

Expand Down
8 changes: 7 additions & 1 deletion apps/freelan/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,11 @@ env.Prepend(LIBS=libraries)
sources = list(sorted(set(env.RGlob('src', '*.cpp')) - set(env.RGlob(os.path.join('src', 'windows'), '*.cpp'))))
app = env.Program(target=os.path.join(str(dirs['bin']), name), source=sources)
configuration = env.File(env.RGlob('config', '*.cfg'))
help = []

Return('app configuration')
h2m = env.WhereIs('help2man', os.environ['PATH'])
if h2m:
env['HELP2MAN'] = h2m
help = env.Command(target=os.path.join(str(dirs['man']), name + '.1'), source=os.path.join(str(dirs['bin']), name), action ='$HELP2MAN $SOURCE > $TARGET')

Return('app configuration help')
267 changes: 0 additions & 267 deletions packaging/rpm/freelan.1

This file was deleted.

3 changes: 2 additions & 1 deletion packaging/rpm/freelan.spec
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ BuildRequires: openssl-devel
BuildRequires: boost-devel
BuildRequires: libcurl-devel
BuildRequires: miniupnpc-devel
BuildRequires: help2man
Requires: openssl
Requires: boost
Requires: libcurl
Expand Down Expand Up @@ -47,7 +48,7 @@ mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/freelan
cp -a apps/freelan/config/freelan.cfg $RPM_BUILD_ROOT/%{_sysconfdir}/freelan/
# manpage
mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man1
cp packaging/rpm/freelan.1 $RPM_BUILD_ROOT/%{_mandir}/man1/freelan.1
cp build/release/man/freelan.1 $RPM_BUILD_ROOT/%{_mandir}/man1/freelan.1
# systemd unit
mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
cp -p packaging/rpm/[email protected] $RPM_BUILD_ROOT/%{_unitdir}/
Expand Down
Loading

0 comments on commit fe60128

Please sign in to comment.