From 83a469f261ff5dee6dd796f7d058ed474f675b22 Mon Sep 17 00:00:00 2001 From: krolli Date: Sat, 2 Mar 2019 12:25:01 +0100 Subject: [PATCH] MSVC version Added required files for building using MSVC. Currently doesn't build due to compiler bugs and different naming of std modules. --- AbstractBowl.ixx | 1 + AbstractFruit.ixx | 1 + Apple.ixx | 1 + FruitBowl.ixx | 1 + Grape.ixx | 1 + SaladBowl.ixx | 1 + Tomato.ixx | 1 + build-cl.bat | 58 +++++++++++++++++++++++++++++++++++++++++++++++ std.ixx | 6 +++++ 9 files changed, 71 insertions(+) create mode 100644 AbstractBowl.ixx create mode 100644 AbstractFruit.ixx create mode 100644 Apple.ixx create mode 100644 FruitBowl.ixx create mode 100644 Grape.ixx create mode 100644 SaladBowl.ixx create mode 100644 Tomato.ixx create mode 100644 build-cl.bat create mode 100644 std.ixx diff --git a/AbstractBowl.ixx b/AbstractBowl.ixx new file mode 100644 index 0000000..5b7012e --- /dev/null +++ b/AbstractBowl.ixx @@ -0,0 +1 @@ +#include "AbstractBowl.cppm" diff --git a/AbstractFruit.ixx b/AbstractFruit.ixx new file mode 100644 index 0000000..3369e47 --- /dev/null +++ b/AbstractFruit.ixx @@ -0,0 +1 @@ +#include "./AbstractFruit.cppm" diff --git a/Apple.ixx b/Apple.ixx new file mode 100644 index 0000000..81b2b8c --- /dev/null +++ b/Apple.ixx @@ -0,0 +1 @@ +#include "Apple.cppm" diff --git a/FruitBowl.ixx b/FruitBowl.ixx new file mode 100644 index 0000000..54c298f --- /dev/null +++ b/FruitBowl.ixx @@ -0,0 +1 @@ +#include "FruitBowl.cppm" diff --git a/Grape.ixx b/Grape.ixx new file mode 100644 index 0000000..09e278e --- /dev/null +++ b/Grape.ixx @@ -0,0 +1 @@ +#include "Grape.cppm" diff --git a/SaladBowl.ixx b/SaladBowl.ixx new file mode 100644 index 0000000..094015a --- /dev/null +++ b/SaladBowl.ixx @@ -0,0 +1 @@ +#include "SaladBowl.cppm" diff --git a/Tomato.ixx b/Tomato.ixx new file mode 100644 index 0000000..f48d12b --- /dev/null +++ b/Tomato.ixx @@ -0,0 +1 @@ +#include "Tomato.cppm" diff --git a/build-cl.bat b/build-cl.bat new file mode 100644 index 0000000..ee0add1 --- /dev/null +++ b/build-cl.bat @@ -0,0 +1,58 @@ +@echo off +rem This must be run from Developer Command Prompt or by initializing current using vcvarsall.bat. I'm not sure +rem how it can be referenced in a general way, so this is just an example where you might be able to find it. +rem call "c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 + +rem '/module:interface' tells compiler to compile file as module interface file +rem '/module:output ' will write module interface file into specific location +rem '/module:reference ' will reference single module interface file +rem '/module:search ' will search for module interface files in given directory +rem '/module:export ' Helper for automatically creating module interface file to source file. +rem '/module:name ' Set module name of module in automatically created module interface file. +rem '/module:wrapper
' Possibly variation of /module:export for headers. +rem '/module:exportActiveMacros' Creates wrapper header with an import and macros. +rem '/module:exportMacro ' For selective version of /module:exportActiveMacros +rem '/module:stdIfcDir ' For working with standard library modules. +rem Module definition name in code doesn't need to match file names. + +rem .ixx extension is required by cl.exe +rem /MD and /EHsc required to use standard library modules bundled with visual studio, otherwise we get warnings about compile flags not matching. + +rem Note: You can also reference each ifc separately, it's just easier to use search path instead. Problems with dependencies between ifc-s still apply. + +set flags_common=/nologo /c /std:c++latest /experimental:module /module:search ifc\ /MD /EHsc + +if not exist bin mkdir bin +if not exist ifc mkdir ifc +if not exist obj mkdir obj + +rem In theory, it should be possible to re-export and hide the fact that there is no std module. Unfortunately, it doesn't seem to work right on MSVC. +rem I think it's because the compiler detects module name starting with 'std' and ignores normal module references and uses /module:stdIfcDir instead. +rem When I copied std.ifc to MSVC dir with std.core.ifc and other ifc-s, it worked as expected. Specifying /module:stdIfcDir will overwrite default +rem location and I'm not sure it's possible to just append an extra path to it. +cl %flags_common% /module:interface /module:output ifc\std.ifc /Fo: obj\std.ifc.obj std.ixx + +cl %flags_common% /Dabstractfruit_EXPORTS /module:interface /module:output ifc\AbstractFruit.ifc /Fo: obj\AbstractFruit.ifc.obj AbstractFruit.ixx + +cl %flags_common% /Dfruitsalad_EXPORTS /module:interface /module:output ifc\Apple.ifc /Fo: obj\Apple.ifc.obj Apple.ixx +cl %flags_common% /Dfruitsalad_EXPORTS /module:interface /module:output ifc\Grape.ifc /Fo: obj\Grape.ifc.obj Grape.ixx + +cl %flags_common% /Dnotfruitsalad_EXPORTS /module:interface /module:output ifc\Tomato.ifc /Fo: obj\Tomato.ifc.obj Tomato.ixx + +cl %flags_common% /Dbowls_EXPORTS /module:interface /module:output ifc\AbstractBowl.ifc /Fo: obj\AbstractBowl.ifc.obj AbstractBowl.ixx +cl %flags_common% /Dbowls_EXPORTS /module:interface /module:output ifc\FruitBowl.ifc /Fo: obj\FruitBowl.ifc.obj FruitBowl.ixx +cl %flags_common% /Dbowls_EXPORTS /module:interface /module:output ifc\SaladBowl.ifc /Fo: obj\SaladBowl.ifc.obj SaladBowl.ixx + +cl %flags_common% /Fo: obj\AbstractFruit.obj AbstractFruit.cpp +cl %flags_common% /Fo: obj\Apple.obj Apple.cpp +cl %flags_common% /Fo: obj\Grape.obj Grape.cpp +cl %flags_common% /Fo: obj\Tomato.obj Tomato.cpp + +cl %flags_common% /Fo: obj\AbstractBowl.obj AbstractBowl.cpp +cl %flags_common% /Fo: obj\FruitBowl.obj FruitBowl.cpp +cl %flags_common% /Fo: obj\SaladBowl.obj SaladBowl.cpp + +link /nologo /DLL /OUT:bin\AbstractFruit.dll obj\AbstractFruit.obj obj\AbstractFruit.ifc.obj +link /nologo /DLL /OUT:bin\FruitSalad.dll obj\Apple.obj obj\Apple.ifc.obj obj\Grape.obj obj\Grape.ifc.obj bin\AbstractFruit.lib +link /nologo /DLL /OUT:bin\NotFruitSalad.dll obj\Tomato.obj obj\Tomato.ifc.obj bin\AbstractFruit.lib +link /nologo /DLL /OUT:bin\Bowls.dll obj\AbstractBowl.obj obj\FruitBowl.obj obj\SaladBowl.obj obj\AbstractBowl.ifc.obj obj\FruitBowl.ifc.obj obj\SaladBowl.ifc.obj bin\FruitSalad.lib bin\AbstractFruit.lib diff --git a/std.ixx b/std.ixx new file mode 100644 index 0000000..fe2e143 --- /dev/null +++ b/std.ixx @@ -0,0 +1,6 @@ +export module std; +export +{ + import std.core; + import std.memory; +}