rename some of the new Environment methods, make PocoDoc config changes backwards-compatible, revert PocoDoc config changes, make doc build scripts work on macos

This commit is contained in:
Guenter Obiltschnig 2017-11-08 14:37:53 +01:00
parent f0a79015f7
commit 079c9a6263
7 changed files with 100 additions and 145 deletions

View File

@ -30,28 +30,28 @@ class Foundation_API Environment
{
public:
typedef UInt8 NodeId[6]; /// Ethernet address.
static std::string get(const std::string& name);
/// Returns the value of the environment variable
/// with the given name. Throws a NotFoundException
/// if the variable does not exist.
static std::string get(const std::string& name, const std::string& defaultValue);
/// Returns the value of the environment variable
/// with the given name. If the environment variable
/// is undefined, returns defaultValue instead.
static bool has(const std::string& name);
/// Returns true iff an environment variable
/// with the given name is defined.
static void set(const std::string& name, const std::string& value);
/// Sets the environment variable with the given name
/// to the given value.
static std::string osName();
/// Returns the operating system name.
static std::string osDisplayName();
/// Returns the operating system name in a
/// "user-friendly" way.
@ -61,33 +61,33 @@ public:
/// "Windows XP" or "Windows 7/Server 2008 SP2".
/// On other platforms, returns the same as
/// osName().
static std::string osVersion();
/// Returns the operating system version.
static std::string osArchitecture();
/// Returns the operating system architecture.
static std::string nodeName();
/// Returns the node (or host) name.
static void nodeId(NodeId& id);
/// Returns the Ethernet address of the first Ethernet
/// adapter found on the system.
///
/// Throws a SystemException if no Ethernet adapter is available.
static std::string nodeId();
/// Returns the Ethernet address (format "xx:xx:xx:xx:xx:xx")
/// of the first Ethernet adapter found on the system.
///
/// Throws a SystemException if no Ethernet adapter is available.
static unsigned processorCount();
/// Returns the number of processors installed in the system.
///
/// If the number of processors cannot be determined, returns 1.
static Poco::UInt32 libraryVersion();
/// Returns the POCO C++ Libraries version as a hexadecimal
/// number in format 0xAABBCCDD, where
@ -105,19 +105,15 @@ public:
/// Return the operating system as defined
/// in the include Foundation/Platform.h (POCO_OS)
static Poco::Int32 cpu();
/// Return the underlying cpu that runs this operating system
static Poco::Int32 arch();
/// Return the underlying cpu architecture that runs this operating system
/// as defined in Foundation/Platform (POCO_ARCH)
static bool osFamilyUnix();
static bool isUnix();
/// Return true if the operating system belongs to the Linux family
static bool osFamilyWindows();
static bool isWindows();
/// Return true if the operating system belongs to the Windows family
static bool osFamilyVms();
/// Return true if the operating system belongs to the VMS family
};

View File

@ -50,13 +50,13 @@ std::string Environment::get(const std::string& name, const std::string& default
return defaultValue;
}
bool Environment::has(const std::string& name)
{
return EnvironmentImpl::hasImpl(name);
}
void Environment::set(const std::string& name, const std::string& value)
{
EnvironmentImpl::setImpl(name, value);
@ -74,18 +74,18 @@ std::string Environment::osDisplayName()
return EnvironmentImpl::osDisplayNameImpl();
}
std::string Environment::osVersion()
{
return EnvironmentImpl::osVersionImpl();
}
std::string Environment::osArchitecture()
{
return EnvironmentImpl::osArchitectureImpl();
}
std::string Environment::nodeName()
{
@ -126,17 +126,20 @@ Poco::UInt32 Environment::libraryVersion()
return POCO_VERSION;
}
Poco::Int32 Environment::os()
{
return POCO_OS;
}
Poco::Int32 Environment::cpu()
Poco::Int32 Environment::arch()
{
return POCO_ARCH;
}
bool Environment::osFamilyUnix()
bool Environment::isUnix()
{
#if defined(POCO_OS_FAMILY_UNIX)
return true;
@ -145,7 +148,8 @@ bool Environment::osFamilyUnix()
#endif
}
bool Environment::osFamilyWindows()
bool Environment::isWindows()
{
#if defined(POCO_OS_FAMILY_WINDOWS)
return true;
@ -154,13 +158,5 @@ bool Environment::osFamilyWindows()
#endif
}
bool Environment::osFamilyVms()
{
#if defined(POCO_OS_FAMILY_VMS)
return true;
#else
return false;
#endif
}
} // namespace Poco

View File

@ -13,13 +13,6 @@
expat*.h,
zconf.h,
zlib.h,
Alignment.h,
QName.h,
CppUnitException.h,
Constants.h,
inffast.h,
PDF/include/*.h,
CppParser/include/*.h
</exclude>
</files>
<pages>
@ -35,41 +28,21 @@
${PocoBuild}/*/doc/images
</resources>
<compiler>
<windows>
<exec>cl.exe</exec>
<options>
${Includes},
/I${PocoBase}/openssl/include
/I${VC}/include,
/I${WDK}/shared
/I${WDK}/um
/I${WDK}/ucrt
/nologo,
/D_DEBUG,
/E,
/C,
/DPOCO_NO_GCC_API_ATTRIBUTE
/DPOCO_NO_WINDOWS_H
</options>
<path>${VC}/bin</path>
<usePipe>true</usePipe>
</windows>
<unix>
<exec>${CXX} ${CXXFLAGS}</exec>
<options>
${Includes},
-I/usr/local/mysql/include,
-I/usr/include/mysql,
-I/usr/include/postgresql,
-D_DEBUG,
-E,
-C,
-DPOCO_NO_GCC_API_ATTRIBUTE
-DPOCO_NO_WINDOWS_H
</options>
<path></path>
<usePipe>true</usePipe>
</unix>
<exec>clang++</exec>
<options>
${Includes},
-I/usr/local/mysql/include,
-I/usr/include/mysql,
-D_DEBUG,
-E,
-C,
-DPOCO_NO_GCC_API_ATTRIBUTE,
-xc++
-std=c++11,
-stdlib=libc++
</options>
<path></path>
<usePipe>true</usePipe>
</compiler>
<language>EN</language>
<charset>utf-8</charset>

View File

@ -13,9 +13,7 @@
expat*.h,
zconf.h,
zlib.h,
XMLStreamParser.h,
CppUnitException.h,
RepeatedTest.h,
${PocoBuild}/Util/include/Poco/Util/Units.h
</exclude>
</files>
<pages>
@ -31,23 +29,15 @@
${PocoBuild}/*/doc/images
</resources>
<compiler>
<exec>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe</exec>
<exec>g++</exec>
<options>
${Includes},
-I/usr/local/mysql/include,
-I/usr/include/mysql,
-I/usr/include/postgresql,
/I${PocoBase}/openssl/include
/IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include,
/IC:\Program Files (x86)\Windows Kits\8.1\Include\shared,
/IC:\Program Files (x86)\Windows Kits\8.1\Include\um,
/IC:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt,
/nologo,
-D_DEBUG,
-E,
-C,
-DPOCO_NO_GCC_API_ATTRIBUTE
-DPOCO_NO_WINDOWS_H
</options>
<path></path>
<usePipe>true</usePipe>
@ -104,7 +94,7 @@
<loggers>
<root>
<channel>c1</channel>
<level>information</level>
<level>warning</level>
</root>
</loggers>
<channels>

View File

@ -60,7 +60,6 @@ using Poco::Util::OptionCallback;
using Poco::Util::HelpFormatter;
using Poco::Util::AbstractConfiguration;
static std::string osName = Environment::osName();
class Preprocessor
{
@ -77,12 +76,12 @@ public:
_file(file)
{
}
std::istream& stream()
{
return *_pStream;
}
~Preprocessor()
{
int c = _pStream->get();
@ -101,7 +100,7 @@ public:
}
}
}
private:
ProcessHandle _proc;
std::istream* _pStream;
@ -112,7 +111,7 @@ private:
class PocoDocApp: public Application
{
public:
PocoDocApp():
PocoDocApp():
_helpRequested(false),
_writeEclipseTOC(false)
{
@ -123,23 +122,23 @@ public:
{
}
protected:
protected:
void initialize(Application& self)
{
loadConfiguration(); // load default configuration files, if present
Application::initialize(self);
}
void uninitialize()
{
Application::uninitialize();
}
void reinitialize(Application& self)
{
Application::reinitialize(self);
}
void defineOptions(OptionSet& options)
{
Application::defineOptions(options);
@ -163,14 +162,14 @@ protected:
.repeatable(false)
.callback(OptionCallback<PocoDocApp>(this, &PocoDocApp::handleEclipse)));
}
void handleHelp(const std::string& name, const std::string& value)
{
_helpRequested = true;
displayHelp();
stopOptionsProcessing();
}
void handleEclipse(const std::string& name, const std::string& value)
{
_writeEclipseTOC = true;
@ -180,7 +179,7 @@ protected:
{
loadConfiguration(value, -200);
}
void displayHelp()
{
HelpFormatter helpFormatter(options());
@ -189,7 +188,7 @@ protected:
helpFormatter.setHeader("Applied Informatics' super duper documentation builder.");
helpFormatter.format(std::cout);
}
void buildFileList(std::set<std::string>& files)
{
std::set<std::string> temp;
@ -215,20 +214,23 @@ protected:
files.insert(*it);
}
}
Preprocessor* preprocess(const std::string& file)
{
Path pp(file);
pp.setExtension("i");
std::string comp = "PocoDoc.compiler";
if (Environment::osFamilyWindows())
comp += ".windows";
std::string platformComp(comp);
if (Environment::isWindows())
platformComp += ".windows";
else
comp += ".unix";
std::string exec = config().getString(comp + ".exec");
std::string opts = config().getString(comp + ".options");
std::string path = config().getString(comp + ".path", "");
bool usePipe = config().getBool(comp + ".usePipe", false);
platformComp += ".unix";
std::string exec = config().getString(platformComp + ".exec", config().getString(comp + ".exec"));
std::string opts = config().getString(platformComp + ".options", config().getString(comp + ".options"));
std::string path = config().getString(platformComp + ".path", config().getString(comp + ".path", ""));
bool usePipe = config().getBool(platformComp + ".usePipe", config().getBool(comp + ".usePipe", false));
std::string popts;
for (std::string::const_iterator it = opts.begin(); it != opts.end(); ++it)
@ -241,7 +243,7 @@ protected:
StringTokenizer tokenizer(popts, ",\n", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
std::vector<std::string> args(tokenizer.begin(), tokenizer.end());
args.push_back(file);
if (!path.empty())
{
std::string newPath(Environment::get("PATH"));
@ -249,16 +251,16 @@ protected:
newPath += path;
Environment::set("PATH", path);
}
if (usePipe)
{
Poco::Pipe inPipe;
ProcessHandle proc = Process::launch(exec, args, 0, &inPipe, 0);
ProcessHandle proc = Process::launch(exec, args, 0, &inPipe, 0);
return new Preprocessor(proc, new Poco::PipeInputStream(inPipe));
}
else
{
ProcessHandle proc = Process::launch(exec, args);
ProcessHandle proc = Process::launch(exec, args);
proc.wait();
return new Preprocessor(proc, new std::ifstream(pp.getFileName().c_str()), pp.getFileName());
}
@ -300,7 +302,7 @@ protected:
}
return errors;
}
void fixup()
{
logger().information("Fixing-up class hierarchies");
@ -313,7 +315,7 @@ protected:
}
}
}
void writeDoc()
{
logger().information("Generating documentation");
@ -321,9 +323,9 @@ protected:
path.makeDirectory();
File file(path);
file.createDirectories();
DocWriter writer(_gst, path.toString(), config().getBool("PocoDoc.prettifyCode", false), _writeEclipseTOC);
if (config().hasProperty("PocoDoc.pages"))
{
std::string pages = config().getString("PocoDoc.pages");
@ -339,13 +341,13 @@ protected:
}
}
writer.write();
if (_writeEclipseTOC)
{
writer.writeEclipseTOC();
}
}
void copyResources()
{
logger().information("Copying resources");
@ -373,7 +375,7 @@ protected:
}
}
}
void copyResource(const Path& source, const Path& dest)
{
logger().information(std::string("Copying resource ") + source.toString() + " to " + dest.toString());
@ -383,7 +385,7 @@ protected:
else
copyFile(source, dest);
}
void copyFile(const Path& source, const Path& dest)
{
Path dd(dest);
@ -409,7 +411,7 @@ protected:
sf.copyTo(dd.toString());
}
}
void copyDirectory(const Path& source, const Path& dest)
{
Path src(source);
@ -453,7 +455,7 @@ protected:
}
return Application::EXIT_OK;
}
std::string generateGoogleAnalyticsCode()
{
std::stringstream ostr;
@ -474,7 +476,7 @@ protected:
}
return ostr.str();
}
private:
bool _helpRequested;
bool _writeEclipseTOC;

View File

@ -3,7 +3,7 @@ AAAIntroduction
!!!Introduction
Starting with release 1.4.2 the POCO C++ Libraries can be used on
Starting with release 1.4.2 the POCO C++ Libraries can be used on
Android, using the NDK r6. The gmake-based build system (also used
for Mac OS X, Linux, etc.) is used to build the libraries.
A standalone "customized" toolchain for Android (see below) is required.
@ -18,7 +18,7 @@ Please refer to the Android NDK Dev Guide document "Standalone Toolchain", secti
Typically, you'll run a command like:
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-8 --install-dir=$HOME/my-android-toolchain
$NDK/build/tools/make-standalone-toolchain.sh --arch arm --install-dir=$HOME/my-android-toolchain/arm
----
Then, add the directory containing the toolchain executables to your <[$PATH]>:
@ -33,7 +33,7 @@ When compiling the POCO C++ Libraries for a Android target, as well as
when including POCO C++ Libraries headers in a project for a Android
target, the preprocessor macro <[POCO_ANDROID]> must be defined. This is
because the Android NDK GCC compiler does not provide a predefined macro that
allows for reliable detection of an Android target.
allows for reliable detection of an Android target.
!!!Restrictions
@ -43,19 +43,19 @@ However, there are a few restrictions due to the Binoic C library used by Androi
!!Poco::NamedEvent and Poco::NamedMutex
These classes are not supported on Android. While Poco::NamedEvent and
These classes are not supported on Android. While Poco::NamedEvent and
Poco::NamedMutex objects can be created, any attempt to call a method
of these classes will result in a Poco::NotImplementedException being thrown.
!!Poco::SharedMemory
Shared memory is not supported on Android.
Shared memory is not supported on Android.
!!Poco::FPEnvironment
The Poco::FPEnvironment class is not available on Android and
cannot be used.
cannot be used.
!!Poco::RWLock
On Android, Poco::RWLock is an ordinary mutex.
@ -65,24 +65,22 @@ On Android, Poco::RWLock is an ordinary mutex.
!!Using POCO's GNU Make-based Build System
The <*Android*> build configuration (located in <*$POCO_BASE/build/config/Android*>)
The <*Android*> build configuration (located in <*$POCO_BASE/build/config/Android*>)
is used to cross-build for Android from a Linux or Mac OS X host.
To build the POCO C++ Libraries (static) on a Linux or Mac OS X host:
./configure --config=Android --no-samples --no-tests
./make -s -j4
make -s -j4
----
The default configuration builds for the <*armeabi*> platform ABI. To build for
<*armeabi-v7a*>, set the <[ANDROID_ABI]> make variable to <[armeabi-v7a]>:
./make -s -j4 ANDROID_ABI=armeabi-v7a
make -s -j4 ANDROID_ABI=armeabi-v7a
----
The build configuration also supports setting the <[ANDROID_ABI]> to <[x86]>,
but the NDK r6 standalone toolchain for x86 generated by <*make-standalone-toolchain.sh*>
lacks the C++ STL headers, so this does not work.
The build configuration also supports setting the <[ANDROID_ABI]> to <[x86]>.
Depending on your specific requirements (e.g., no ARM architecture, etc.), it may be necessary
to modify the Android build configuration, or create a new one based on it.
@ -100,15 +98,15 @@ POCO C++ Libraries. A sample makefile for the Foundation library is shown below.
#
# POCO Foundation
#
include $(CLEAR_VARS)
LOCAL_MODULE := PocoFoundation
LOCAL_PATH := $(call my-dir)/src
LOCAL_CFLAGS := -DPOCO_ANDROID -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -DPOCO_NO_SHAREDMEMORY
LOCAL_CPPFLAGS := -frtti -fexceptions
LOCAL_C_INCLUDES := $(call my-dir)/include
LOCAL_SRC_FILES := \
AbstractObserver.cpp \
ActiveDispatcher.cpp \
@ -271,6 +269,6 @@ POCO C++ Libraries. A sample makefile for the Foundation library is shown below.
Void.cpp \
Windows1252Encoding.cpp \
zutil.c
include $(BUILD_STATIC_LIBRARY)
----

View File

@ -1,4 +1,4 @@
#! /bin/bash
#! /bin/sh
#
# mkdoc
#