diff options
-rw-r--r-- | CMakeLists.txt | 18 | ||||
-rw-r--r-- | Config.exe | bin | 19968 -> 18944 bytes | |||
-rw-r--r-- | include/modules.h | 28 | ||||
-rw-r--r-- | src/module.cpp | 5 | ||||
-rw-r--r-- | src/modulemanager.cpp | 2 | ||||
-rw-r--r-- | src/win32/Config.cs | 67 |
6 files changed, 47 insertions, 73 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ff65fd30b..94331ef22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,7 +83,7 @@ set(DEFAULT_LIBRARY_DIRS) set(DEFAULT_INCLUDE_DIRS) # If we are using a GNU compiler (have to use CXX because it seems to fail on C), we will be able to determine it's default paths for libraries and includes -if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") +if(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") # First look for the compiler's default library directories execute_process(COMMAND ${CMAKE_C_COMPILER} -print-search-dirs OUTPUT_VARIABLE LINES OUTPUT_STRIP_TRAILING_WHITESPACE) # Find only the part after "libraries: " @@ -149,7 +149,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if(DEFAULT_INCLUDE_DIRS) remove_list_duplicates(DEFAULT_INCLUDE_DIRS) endif(DEFAULT_INCLUDE_DIRS) -endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") +endif(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") # If we are using Visual Studio, locate the path of the Windows Server 2008 SDK or Windows Server 2003 Platform SDK, depending on which is installed if(MSVC) @@ -411,16 +411,10 @@ endif(NOT LOGS_DIR) read_from_file(${Anope_SOURCE_DIR}/src/version.sh "^VERSION_" VERSIONS) # Iterate through the strings found foreach(VERSION_STR ${VERSIONS}) - # Get the length of the string - string(LENGTH ${VERSION_STR} VERSION_LEN) - # Subtract 16 from the string's length (8 for VERSION_, 5 more for the type, 2 for the space and leading quote, 1 for the trailing quote) - math(EXPR VERSION_NUM_LEN "${VERSION_LEN} - 16") - # Extract the type from the string - string(SUBSTRING ${VERSION_STR} 8 5 VERSION_TYPE) - # Extract the actual value from the string - string(SUBSTRING ${VERSION_STR} 15 ${VERSION_NUM_LEN} VERSION) - # Set the version type to the value extract from above - set(VERSION_${VERSION_TYPE} ${VERSION}) + string(REGEX REPLACE "^VERSION_([A-Z]+)=\"?([^\"]*)\"?$" "\\1;\\2" VERSION_OUT ${VERSION_STR}) + list(GET VERSION_OUT 0 VERSION_TYPE) + list(GET VERSION_OUT 1 VERSION_DATA) + set(VERSION_${VERSION_TYPE} ${VERSION_DATA}) endforeach(VERSION_STR ${VERSIONS}) # Default build version to 0 diff --git a/Config.exe b/Config.exe Binary files differindex e9393e089..d61814427 100644 --- a/Config.exe +++ b/Config.exe diff --git a/include/modules.h b/include/modules.h index 0c10caa7b..69e9e6d27 100644 --- a/include/modules.h +++ b/include/modules.h @@ -42,9 +42,13 @@ { \ delete m; \ } \ - extern "C" DllExport ModuleVersion AnopeVersion() \ + extern "C" DllExport ModuleVersionC AnopeVersion() \ { \ - return ModuleVersion(VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH); \ + ModuleVersionC ver; \ + ver.version_major = VERSION_MAJOR; \ + ver.version_minor = VERSION_MINOR; \ + ver.version_patch = VERSION_PATCH; \ + return ver; \ } #else # define MODULE_INIT(x) \ @@ -56,9 +60,13 @@ { \ delete m; \ } \ - extern "C" DllExport ModuleVersion AnopeVersion() \ + extern "C" DllExport ModuleVersionC AnopeVersion() \ { \ - return ModuleVersion(VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH); \ + ModuleVersionC ver; \ + ver.version_major = VERSION_MAJOR; \ + ver.version_minor = VERSION_MINOR; \ + ver.version_patch = VERSION_PATCH; \ + return ver; \ } #endif @@ -182,6 +190,11 @@ enum }; typedef unsigned short ModType; +struct ModuleVersionC +{ + int version_major, version_minor, version_patch; +}; + /** Returned by Module::GetVersion, used to see what version of Anope * a module is compiled against. */ @@ -193,12 +206,7 @@ class ModuleVersion int version_patch; public: - /** Constructor - * @param major The major version number - * @param minor The minor version number - * @param patch The patch version number - */ - ModuleVersion(int major, int minor, int patch); + ModuleVersion(const ModuleVersionC &); /** Get the major version of Anope this was built against * @return The major version diff --git a/src/module.cpp b/src/module.cpp index 96fa24f6f..3266c955f 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -105,8 +105,11 @@ void Module::Prioritize() { } -ModuleVersion::ModuleVersion(int maj, int min, int pa) : version_major(maj), version_minor(min), version_patch(pa) +ModuleVersion::ModuleVersion(const ModuleVersionC &ver) { + version_major = ver.version_major; + version_minor = ver.version_minor; + version_patch = ver.version_patch; } int ModuleVersion::GetMajor() const diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index 98342b08e..b6df3578a 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -287,7 +287,7 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) ModuleVersion ModuleManager::GetVersion(void *handle) { dlerror(); - ModuleVersion (*func)() = function_cast<ModuleVersion (*)()>(dlsym(handle, "AnopeVersion"));; + ModuleVersionC (*func)() = function_cast<ModuleVersionC (*)()>(dlsym(handle, "AnopeVersion"));; if (!func) { Log() << "No version function found, not an Anope module"; diff --git a/src/win32/Config.cs b/src/win32/Config.cs index 03308fde1..4f611a129 100644 --- a/src/win32/Config.cs +++ b/src/win32/Config.cs @@ -27,7 +27,7 @@ namespace Config {
class Config
{
- static string ExecutablePath, InstallDirectory, VSVersion, VSShortVer, ExtraIncludeDirs, ExtraLibDirs, ExtraArguments;
+ static string ExecutablePath, InstallDirectory, ExtraIncludeDirs, ExtraLibDirs, ExtraArguments;
static bool UseNMake = true, BuildDebug = false;
static bool CheckResponse(string InstallerResponse)
@@ -62,10 +62,6 @@ namespace Config ExtraLibDirs = value;
else if (name == "EXTRAARGS")
ExtraArguments = value;
- else if (name == "VSVERSION")
- VSVersion = value;
- else if (name == "VSSHORTVER")
- VSShortVer = value;
}
return true;
@@ -87,8 +83,6 @@ namespace Config tw.WriteLine("EXTRAINCLUDE={0}", ExtraIncludeDirs);
tw.WriteLine("EXTRALIBS={0}", ExtraLibDirs);
tw.WriteLine("EXTRAARGS={0}", ExtraArguments);
- tw.WriteLine("VSVERSION={0}", VSVersion);
- tw.WriteLine("VSSHORTVER={0}", VSShortVer);
}
}
@@ -103,18 +97,15 @@ namespace Config Console.Write("[{0}] ", UseNMake ? "yes" : "no");
return UseNMake ? "yes" : "no";
case 2:
- Console.Write("[{0}] ", VSShortVer);
- return VSShortVer;
- case 3:
Console.Write("[{0}] ", BuildDebug ? "yes" : "no");
return BuildDebug ? "yes" : "no";
- case 4:
+ case 3:
Console.Write("[{0}] ", ExtraIncludeDirs);
return ExtraIncludeDirs;
- case 5:
+ case 4:
Console.Write("[{0}] ", ExtraLibDirs);
return ExtraLibDirs;
- case 6:
+ case 5:
Console.Write("[{0}] ", ExtraArguments);
return ExtraArguments;
default:
@@ -247,15 +238,14 @@ namespace Config if (!DoQuick)
{
List<string> InstallerQuestions = new List<string>()
- {
- "Where do you want Anope to be installed?",
- "Would you like to build using NMake instead of using Visual Studio?\r\nNOTE: If you decide to use NMake, you must be in an environment where\r\nNMake can function, such as the Visual Studio command line. If you say\r\nyes to this while not in an environment that can run NMake, it can\r\ncause the CMake configuration to enter an endless loop. [y/n]",
- "Are you using Visual Studio 2008, 2010, or 2012? You can leave this blank\nand have CMake try and auto detect it, but this usually doesn't\nwork correctly. [2008/2010/2012]",
- "Would you like to build a debug version of Anope? [y/n]",
- "Are there any extra include directories you wish to use?\nYou may only need to do this if CMake is unable to locate missing dependencies without hints.\nSeparate directories with semicolons and use slashes (aka /) instead of backslashes (aka \\).\nIf you need no extra include directories, enter NONE in all caps.",
- "Are there any extra library directories you wish to use?\nYou may only need to do this if CMake is unable to locate missing dependencies without hints.\nSeparate directories with semicolons and use slashes (aka /) instead of backslashes (aka \\).\nIf you need no extra library directories, enter NONE in all caps.",
- "Are there any extra arguments you wish to pass to CMake?\nIf you need no extra arguments to CMake, enter NONE in all caps."
- };
+ {
+ "Where do you want Anope to be installed?",
+ "Would you like to build using NMake instead of using Visual Studio?\r\nNOTE: If you decide to use NMake, you must be in an environment where\r\nNMake can function, such as the Visual Studio command line. If you say\r\nyes to this while not in an environment that can run NMake, it can\r\ncause the CMake configuration to enter an endless loop. [y/n]",
+ "Would you like to build a debug version of Anope? [y/n]",
+ "Are there any extra include directories you wish to use?\nYou may only need to do this if CMake is unable to locate missing dependencies without hints.\nSeparate directories with semicolons and use slashes (aka /) instead of backslashes (aka \\).\nIf you need no extra include directories, enter NONE in all caps.",
+ "Are there any extra library directories you wish to use?\nYou may only need to do this if CMake is unable to locate missing dependencies without hints.\nSeparate directories with semicolons and use slashes (aka /) instead of backslashes (aka \\).\nIf you need no extra library directories, enter NONE in all caps.",
+ "Are there any extra arguments you wish to pass to CMake?\nIf you need no extra arguments to CMake, enter NONE in all caps."
+ };
for (int i = 0; i < InstallerQuestions.Count; ++i)
{
@@ -269,8 +259,8 @@ namespace Config if (!string.IsNullOrWhiteSpace(CacheResponse) && string.IsNullOrWhiteSpace(InstallerResponse))
InstallerResponse = CacheResponse;
- // Question 5-7 are optional
- if (i < 4 && string.IsNullOrWhiteSpace(InstallerResponse))
+ // Question 4+ are optional
+ if (i < 3 && string.IsNullOrWhiteSpace(InstallerResponse))
{
Console.WriteLine("Invalid option");
--i;
@@ -309,38 +299,21 @@ namespace Config ++i;
break;
case 2:
- if (InstallerResponse == "2012")
- {
- VSVersion = "-G\"Visual Studio 11\" ";
- VSShortVer = "2012";
- }
- else if (InstallerResponse == "2010")
- {
- VSVersion = "-G\"Visual Studio 10\" ";
- VSShortVer = "2010";
- }
- else if (InstallerResponse == "2008")
- {
- VSVersion = "-G\"Visual Studio 9 2008\" ";
- VSShortVer = "2008";
- }
- break;
- case 3:
BuildDebug = CheckResponse(InstallerResponse);
break;
- case 4:
+ case 3:
if (InstallerResponse == "NONE")
ExtraIncludeDirs = null;
else
ExtraIncludeDirs = InstallerResponse;
break;
- case 5:
+ case 4:
if (InstallerResponse == "NONE")
ExtraLibDirs = null;
else
ExtraLibDirs = InstallerResponse;
break;
- case 6:
+ case 5:
if (InstallerResponse == "NONE")
ExtraArguments = null;
else
@@ -355,10 +328,6 @@ namespace Config Console.WriteLine("Anope will be compiled with the following options:");
Console.WriteLine("Install directory: {0}", InstallDirectory);
Console.WriteLine("Use NMake: {0}", UseNMake ? "Yes" : "No");
- if (!string.IsNullOrWhiteSpace(VSShortVer))
- Console.WriteLine("Using Visual Studio: {0}", VSShortVer);
- else
- Console.WriteLine("Using Visual Studio: No");
Console.WriteLine("Build debug: {0}", BuildDebug ? "Yes" : "No");
Console.WriteLine("Anope Version: {0}", AnopeVersion);
Console.WriteLine("Extra Include Directories: {0}", ExtraIncludeDirs);
@@ -385,7 +354,7 @@ namespace Config InstallDirectory = "-DINSTDIR:STRING=\"" + InstallDirectory.Replace('\\', '/') + "\" ";
string NMake = UseNMake ? "-G\"NMake Makefiles\" " : "";
string Debug = BuildDebug ? "-DCMAKE_BUILD_TYPE:STRING=DEBUG " : "-DCMAKE_BUILD_TYPE:STRING=RELEASE ";
- string cMake = InstallDirectory + NMake + Debug + VSVersion + ExtraIncludeDirs + ExtraLibDirs + ExtraArguments + "\"" + ExecutablePath.Replace('\\', '/') + "\"";
+ string cMake = InstallDirectory + NMake + Debug + ExtraIncludeDirs + ExtraLibDirs + ExtraArguments + "\"" + ExecutablePath.Replace('\\', '/') + "\"";
RunCMake(cMake);
return 0;
|