diff --git a/build/premake/premake.lua b/build/premake/premake.lua index 305b2a79b8..abc873d51c 100755 --- a/build/premake/premake.lua +++ b/build/premake/premake.lua @@ -1,6 +1,6 @@ addoption("atlas", "Include Atlas scenario editor packages") addoption("collada", "Include COLLADA packages (requires FCollada library)") -addoption("icc", "Use Intel C++ Compiler (Linux only; should set CXX=icpc before calling make)") +addoption("icc", "Use Intel C++ Compiler (Linux only; should use either \"--cc icc\" or --without-pch too, and then set CXX=icpc before calling make)") addoption("outpath", "Location for generated project files") addoption("without-tests", "Disable generation of test projects") addoption("without-pch", "Disable generation and usage of precompiled headers") @@ -26,10 +26,6 @@ else project.cxxtestpath = "../../build/bin/cxxtestgen.pl" end -if OS == "linux" and options["icc"] then - options["without-pch"] = 1 -- ICC9.1 doesn't support GCC-style PCH -end - source_root = "../../../source/" -- default for most projects - overridden by local in others -- Rationale: packages should not have any additional include paths except for @@ -733,11 +729,12 @@ function setup_tests() package_create("test_3_gen", "cxxtestgen") package.files = hdr_files package.rootfile = source_root .. "test_root.cpp" - package.testoptions = "" + package.testoptions = "--have-std" + package.rootoptions = "--have-std" if OS == "windows" then - package.rootoptions = "--gui=Win32Gui --runner=ParenPrinter" + package.rootoptions = package.rootoptions .. " --gui=Win32Gui --runner=ParenPrinter" else - package.rootoptions = "--runner=ErrorPrinter" + package.rootoptions = package.rootoptions .. " --runner=ErrorPrinter" end -- precompiled headers - the header is added to all generated .cpp files -- note that the header isn't actually precompiled here, only #included @@ -757,6 +754,7 @@ function setup_tests() -- note: these are not relative to source_root and therefore can't be included via package_add_contents. listconcat(package.files, src_files) package_add_extern_libs(used_extern_libs) + if OS == "windows" then -- required for win.cpp's init mechanism tinsert(package.linkoptions, "/ENTRY:entry_noSEH") diff --git a/build/premake/src/Src/gnu_cpp.c b/build/premake/src/Src/gnu_cpp.c index c5af8c7ba2..d2b2b851dd 100644 --- a/build/premake/src/Src/gnu_cpp.c +++ b/build/premake/src/Src/gnu_cpp.c @@ -118,7 +118,7 @@ int gnu_cpp() /* Write linker flags */ io_print(" LDFLAGS += -L$(BINDIR) -L$(LIBDIR)"); - if (prj_is_kind("dll") && (g_cc == NULL || matches(g_cc, "gcc"))) + if (prj_is_kind("dll") && (g_cc == NULL || matches(g_cc, "gcc") || matches(g_cc, "icc"))) io_print(" -shared"); if (prj_has_flag("no-symbols")) io_print(" -s"); @@ -175,13 +175,34 @@ int gnu_cpp() print_list(prj_get_files(), "\t$(OBJDIR)/", " \\\n", "", listCppSources); io_print("\n"); - io_print("PCHS := \\\n"); - if (prj_get_pch_header() != NULL) + if (matches(g_cc, "icc")) { - const char *basename = path_getbasename(prj_get_pch_header()); - io_print("\t$(OBJDIR)/%s.h.gch \\\n", basename); + if (prj_get_pch_source() == NULL) + { + io_print("PCHS := \n"); + } + else + { + io_print("PCHS := \\\n"); + const char *basename = path_getbasename(prj_get_pch_source()); + io_print("\t$(OBJDIR)/%s.pchi \\\n", basename); + io_print("\n"); + } + } + else + { + if (prj_get_pch_header() == NULL) + { + io_print("PCHS := \n"); + } + else + { + io_print("PCHS := \\\n"); + const char *basename = path_getbasename(prj_get_pch_header()); + io_print("\t$(OBJDIR)/%s.h.gch \\\n", basename); + io_print("\n"); + } } - io_print("\n"); /* Write out the list of resource files for windows targets */ if (os_is("windows")) @@ -278,6 +299,14 @@ int gnu_cpp() } io_print("\n"); + /* When using ICC, the .pchi is a side-effect of compiling the .o, + * so create a pattern for that rule */ + if (matches(g_cc, "icc") && prj_get_pch_source() != NULL) + { + const char *basename = path_getbasename(prj_get_pch_source()); + io_print("$(OBJDIR)/%s.pchi: $(OBJDIR)/%s.o\n\n", basename, basename); + } + /* Write static patterns for each source file. Note that in earlier * versions I used pattern rules instead of listing each file. It worked * fine but made it more difficult to test and also required the use of @@ -390,6 +419,7 @@ static const char* listCppTargets(const char* name) const char *pchSource = prj_get_pch_source(); int use_pch = pchHeader?1:0, gen_pch=0; + const char* pchExt = (matches(g_cc, "icc") ? "pchi" : "h.gch"); if (pchSource && matches(path_getname(name), pchSource)) { @@ -400,14 +430,23 @@ static const char* listCppTargets(const char* name) if (is_cpp(name)) { const char* basename = path_getbasename(name); - sprintf(g_buffer, "$(OBJDIR)/%s.%s: %s ", - basename, gen_pch?"h.gch":"o", name); + strcpy(g_buffer, ""); + + strcat(g_buffer, "$(OBJDIR)/"); + strcat(g_buffer, basename); + strcat(g_buffer, "."); + strcat(g_buffer, (gen_pch && !matches(g_cc, "icc")) ? pchExt : "o"); // we want ICC to generate the .o + strcat(g_buffer, ": "); + strcat(g_buffer, name); + strcat(g_buffer, " "); + if (use_pch) { basename = path_getbasename(pchHeader); strcat(g_buffer, "$(OBJDIR)/"); strcat(g_buffer, basename); - strcat(g_buffer, ".h.gch"); + strcat(g_buffer, "."); + strcat(g_buffer, pchExt); // static buffer, *sigh* basename = path_getbasename(name); } @@ -418,7 +457,7 @@ static const char* listCppTargets(const char* name) if (!g_verbose) strcat(g_buffer, "\t@echo $(notdir $<)\n"); - + strcat(g_buffer, "\t"); if (!g_verbose) strcat(g_buffer, "@"); @@ -469,15 +508,41 @@ static const char* listCppTargets(const char* name) strcat(g_buffer, ".d -o $@ -c"); if (gen_pch) { - strcat(g_buffer, " -x c++-header"); + if (matches(g_cc, "icc")) + { + basename = path_getbasename(pchSource); + strcat(g_buffer, " -create-pch $(OBJDIR)/"); + strcat(g_buffer, basename); + strcat(g_buffer, ".pchi"); + basename = NULL; + } + else + { + strcat(g_buffer, " -x c++-header"); + } } else if (use_pch) { - basename = path_getbasename(pchHeader); - strcat(g_buffer, " -include $(OBJDIR)/"); - strcat(g_buffer, basename); - strcat(g_buffer, ".h"); - basename = NULL; + if (matches(g_cc, "icc")) + { + basename = path_getbasename(pchSource); + strcat(g_buffer, " -use-pch $(OBJDIR)/"); + strcat(g_buffer, basename); + strcat(g_buffer, ".pchi"); + basename = NULL; + } + else + { + // I don't think this is necessary, since we include precompiled.h + // manually in every source file anyway + /* + basename = path_getbasename(pchHeader); + strcat(g_buffer, " -include $(OBJDIR)/"); + strcat(g_buffer, basename); + strcat(g_buffer, ".h"); + basename = NULL; + */ + } } strcat(g_buffer, " $<\n"); } diff --git a/build/premake/src/Src/premake.c b/build/premake/src/Src/premake.c index 383f0abee4..c783b43791 100644 --- a/build/premake/src/Src/premake.c +++ b/build/premake/src/Src/premake.c @@ -271,6 +271,7 @@ void showUsage() puts(" --cc name Choose a C/C++ compiler, if supported by target; one of:"); puts(" gcc GNU gcc compiler"); puts(" dmc Digital Mars C/C+ compiler (experimental)"); + puts(" icc Intel C++ Compiler (highly experimental)"); puts(""); puts(" --dotnet name Choose a .NET compiler set, if supported by target; one of:"); puts(" ms Microsoft (csc)"); diff --git a/build/workspaces/update-workspaces.sh b/build/workspaces/update-workspaces.sh index 31962929d8..e459e3fd2f 100755 --- a/build/workspaces/update-workspaces.sh +++ b/build/workspaces/update-workspaces.sh @@ -10,7 +10,7 @@ cd $premake_dir # build/premake/ -./premake --target gnu --outpath $workspace_dir --atlas $* +./premake --outpath $workspace_dir --atlas $* --target gnu # These files need to be linked; premake makefiles assume that the # lua file is accessible from the makefile directory diff --git a/source/pch/test/precompiled.cpp b/source/pch/test/precompiled.cpp index 5f656a45da..0d1ddc54e8 100644 --- a/source/pch/test/precompiled.cpp +++ b/source/pch/test/precompiled.cpp @@ -1 +1,8 @@ +// Got to be consistent with what the rest of the source files do before +// including precompiled.h, so that the PCH works correctly +#ifndef CXXTEST_RUNNING +#define CXXTEST_RUNNING +#endif +#define _CXXTEST_HAVE_STD + #include "precompiled.h" diff --git a/source/test_setup.cpp b/source/test_setup.cpp index 320a7562b7..09138fb2e5 100644 --- a/source/test_setup.cpp +++ b/source/test_setup.cpp @@ -1,3 +1,10 @@ +// Got to be consistent with what the rest of the source files do before +// including precompiled.h, so that the PCH works correctly +#ifndef CXXTEST_RUNNING +#define CXXTEST_RUNNING +#endif +#define _CXXTEST_HAVE_STD + #include "precompiled.h" #include