Use precompiled headers when compiling with GCC.

The unix-adapter doesn't use PCH, because MSYS1's compiler doesn't support
them.
This commit is contained in:
Ryan Prichard 2016-02-29 04:33:42 -06:00
parent 6c65edb0e4
commit adc1a5adbf
3 changed files with 60 additions and 2 deletions

View File

@ -30,6 +30,7 @@ default : all
PREFIX := /usr/local
UNIX_ADAPTER_EXE := console.exe
MINGW_ENABLE_CXX11_FLAG := -std=c++11
USE_PCH := 1
COMMON_CXXFLAGS :=
UNIX_CXXFLAGS :=
@ -64,6 +65,23 @@ MINGW_CXXFLAGS += \
MINGW_LDFLAGS += -static -static-libgcc -static-libstdc++
UNIX_LDFLAGS += $(UNIX_LDFLAGS_STATIC)
ifeq "$(USE_PCH)" "1"
MINGW_CXXFLAGS += -include build/mingw/PrecompiledHeader.h
PCH_DEP := build/mingw/PrecompiledHeader.h.gch
else
PCH_DEP :=
endif
build/mingw/PrecompiledHeader.h : src/shared/PrecompiledHeader.h | $$(@D)/.mkdir
$(info Copying $< to $@)
@cp $< $@
build/mingw/PrecompiledHeader.h.gch : build/mingw/PrecompiledHeader.h | $$(@D)/.mkdir
$(info Compiling $<)
@$(MINGW_CXX) $(MINGW_CXXFLAGS) -c -o $@ $<
-include build/mingw/PrecompiledHeader.h.d
define def_unix_target
build/$1/%.o : src/%.cc VERSION.txt | $$$$(@D)/.mkdir
$$(info Compiling $$<)
@ -71,7 +89,7 @@ build/$1/%.o : src/%.cc VERSION.txt | $$$$(@D)/.mkdir
endef
define def_mingw_target
build/$1/%.o : src/%.cc VERSION.txt | $$$$(@D)/.mkdir
build/$1/%.o : src/%.cc VERSION.txt $$(PCH_DEP) | $$$$(@D)/.mkdir
$$(info Compiling $$<)
@$$(MINGW_CXX) $$(MINGW_CXXFLAGS) $2 -I src/include -c -o $$@ $$<
endef

View File

@ -97,7 +97,7 @@ def buildTarget(target):
os.environ["PATH"] = target["path"] + ";" + oldPath
subprocess.check_call(["sh.exe", "configure"])
subprocess.check_call(["make.exe", "clean"])
buildArgs = ["make.exe", "all", "tests"]
buildArgs = ["make.exe", "USE_PCH=0", "all", "tests"]
if target.get("allow_parallel_make", True):
buildArgs += ["-j8"]
subprocess.check_call(buildArgs)

40
src/shared/PrecompiledHeader.h Executable file
View File

@ -0,0 +1,40 @@
// Copyright (c) 2016 Ryan Prichard
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
#ifndef WINPTY_PRECOMPILED_HEADER_H
#define WINPTY_PRECOMPILED_HEADER_H
#include <windows.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <array>
#include <memory>
#include <new>
#include <string>
#include <utility>
#include <vector>
#endif // WINPTY_PRECOMPILED_HEADER_H