Skip to content

Commit

Permalink
PCBC-859: Windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
avsej committed Apr 4, 2024
1 parent d04dd33 commit d549210
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
39 changes: 26 additions & 13 deletions config.w32
Original file line number Diff line number Diff line change
@@ -1,35 +1,47 @@
// vim:ft=javascript
ARG_ENABLE("couchbase", "weather to enable Couchbase support", "no");
ARG_ENABLE("couchbase", "whether to enable Couchbase support", "no");
if (PHP_COUCHBASE != "no") {
var CMAKE = PATH_PROG("cmake");
// we prefer standalone CMake, as the one that comes with MSVS might be too old
var CMAKE = PATH_PROG("cmake", PROGRAM_FILES + "\\CMake\\bin;" + PROGRAM_FILESx86 + "\\CMake\\bin");
if (!CMAKE) {
ERROR("cmake is required");
}
var LOCALAPPDATA = WshShell.Environment("Process").Item("LOCALAPPDATA");
var NASM = PATH_PROG("nasm", LOCALAPPDATA + "\\bin\\nasm");
if (!NASM) {
ERROR("nasm is required for BoringSSL");
}
ADD_FLAG("CFLAGS", "/std:c++17");

var COUCHBASE_CMAKE_SOURCE_DIRECTORY = FSO.GetAbsolutePathName(configure_module_dirname + "\\src");
var COUCHBASE_CMAKE_BUILD_DIRECTORY = get_define("BUILD_DIR") + "\\cmake-build";
var COUCHBASE_PHP_CFLAGS = (get_define("CFLAGS_PHP") + " " + get_define("CFLAGS"))
// TODO: we don't seem to need this: get_define("CFLAGS_PHP")
var COUCHBASE_PHP_CFLAGS = get_define("CFLAGS")
.replace('$(BASE_INCLUDES)', '')
.replace(new RegExp('"', 'g'), '\\"')
.replace(new RegExp('\\s+', 'g'), ' ')
.replace(new RegExp('/D ', 'g'), '/D')
.replace(new RegExp('/I ', 'g'), '/I');

STDOUT.WriteLine('MODE_PHPIZE=' + MODE_PHPIZE);
STDOUT.WriteLine('PHP_DIR="' + PHP_DIR + '"');
STDOUT.WriteLine('PHP_SRC_DIR="' + PHP_SRC_DIR + '"');
var php_src_prefix = MODE_PHPIZE ? PHP_DIR + "\\include" : PHP_SRC_DIR;
STDOUT.WriteLine('BUILD_DIR="' + get_define("BUILD_DIR") + '"');
if (MODE_PHPIZE) {
STDOUT.WriteLine('PHP_DIR="' + PHP_DIR + '"');
}
var php_src_prefix = MODE_PHPIZE ? (PHP_DIR + "\\include") : PHP_SRC_DIR;
var COUCHBASE_PHP_INCLUDES =
php_src_prefix + " " +
php_src_prefix + "\\main " +
php_src_prefix + "\\Zend " +
php_src_prefix + "\\TSRM " +
php_src_prefix + "\\ext";
var COUCHBASE_PHP_LIB =
MODE_PHPIZE ? PHP_DIR + "\\lib" : get_define("BUILD_DIR") +
(MODE_PHPIZE ? PHP_DIR + "\\lib" : get_define("BUILD_DIR")) +
"\\" + get_define("PHPLIB");

STDOUT.WriteLine('CMAKE="' + CMAKE + '" # version: ' + probe_binary(CMAKE, "longversion"));
STDOUT.WriteLine('NASM="' + NASM + '" # version: ' + probe_binary(NASM, "version"));
STDOUT.WriteLine('COUCHBASE_CMAKE_SOURCE_DIRECTORY="' + COUCHBASE_CMAKE_SOURCE_DIRECTORY + '"');
STDOUT.WriteLine('COUCHBASE_CMAKE_BUILD_DIRECTORY="' + COUCHBASE_CMAKE_BUILD_DIRECTORY + '"');
STDOUT.WriteLine('COUCHBASE_PHP_CFLAGS="' + COUCHBASE_PHP_CFLAGS + '"');
Expand All @@ -40,25 +52,26 @@ if (PHP_COUCHBASE != "no") {
DEFINE("DEPS_COUCHBASE", get_define("LIBS_COUCHBASE"));
EXTENSION("couchbase", "src\\php_couchbase.cxx", true);

MFO.WriteLine("$(BUILD_DIR)\\couchbase_php_wrapper.lib: $(BUILD_DIR)\\$(PHPDLL)");
MFO.WriteLine("\t" + CMAKE + " --build " + COUCHBASE_CMAKE_BUILD_DIRECTORY + " --parallel 4 --verbose");
MFO.WriteLine("$(BUILD_DIR)\\couchbase_php_wrapper.lib: " + (MODE_PHPIZE ? "" : "$(BUILD_DIR)\\$(PHPDLL)"));
MFO.WriteLine("\t\"" + CMAKE + "\" --build \"" + COUCHBASE_CMAKE_BUILD_DIRECTORY + "\" --verbose");
MFO.WriteLine("couchbase_php_wrapper.lib: $(BUILD_DIR)\\couchbase_php_wrapper.lib");
MFO.WriteLine("\t@echo EXT couchbase wrapper build complete");

cmake_command =
'cmd /c ' + CMAKE +
' -S ' + COUCHBASE_CMAKE_SOURCE_DIRECTORY +
' -B ' + COUCHBASE_CMAKE_BUILD_DIRECTORY +
' -G ' + '"NMake Makefiles"' +
'cmd /c ""' + CMAKE + '"' +
' -S "' + COUCHBASE_CMAKE_SOURCE_DIRECTORY + '"' +
' -B "' + COUCHBASE_CMAKE_BUILD_DIRECTORY + '"' +
' -G "NMake Makefiles"' +
' -D CMAKE_BUILD_TYPE=RelWithDebInfo' +
' -D CMAKE_ASM_NASM_COMPILER:PATH="' + NASM + '"' +
' -D COUCHBASE_PHP_CFLAGS="' + COUCHBASE_PHP_CFLAGS + '"' +
' -D COUCHBASE_PHP_INCLUDES="' + COUCHBASE_PHP_INCLUDES + '"' +
' -D COUCHBASE_PHP_LIB="' + COUCHBASE_PHP_LIB + '"' +
' -D COUCHBASE_PHP_LIBDIR="' + get_define("BUILD_DIR") + '"' +
' -D COUCHBASE_CXX_CLIENT_BUILD_EXAMPLES=OFF ' +
' -D COUCHBASE_CXX_CLIENT_BUILD_TOOLS=OFF ' +
' -D COUCHBASE_CXX_CLIENT_BUILD_DOCS=OFF ' +
' -D COUCHBASE_CXX_CLIENT_BUILD_TESTS=OFF 2>&1';
' -D COUCHBASE_CXX_CLIENT_BUILD_TESTS=OFF" 2>&1';
STDOUT.WriteLine(cmake_command);
cmake_output = execute(cmake_command);
STDOUT.WriteLine(cmake_output);
Expand Down
7 changes: 6 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
cmake_minimum_required(VERSION 3.19)
cmake_minimum_required(VERSION 3.27)
if(POLICY CMP0149)
# BoringSSL requires at least WindowsSDKVersion=10.0.20348.0
cmake_policy(SET CMP0149 NEW)
endif()

project(couchbase C CXX)

set(CMAKE_CXX_STANDARD 17)
Expand Down

0 comments on commit d549210

Please sign in to comment.