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-01-23 05:50:30 -06:00
parent e3c669ae56
commit 9b69f67f56
3 changed files with 68 additions and 3 deletions

View File

@ -22,6 +22,7 @@
default : all
USE_PCH ?= 1
PREFIX ?= /usr/local
UNIX_ADAPTER_EXE ?= console.exe
@ -62,11 +63,32 @@ build/$1/%.o : src/%.cc VERSION.txt
@$$(UNIX_CXX) $$(UNIX_CXXFLAGS) $2 -I src/include -c -o $$@ $$<
endef
ifeq "$(USE_PCH)" "1"
PCH_INCLUDE := -include
else
PCH_INCLUDE :=
endif
define def_mingw_target
build/$1/%.o : src/%.cc VERSION.txt
ifeq "$$(USE_PCH)" "1"
H_$(1) := build/$1/PrecompiledHeader.h
H_GCH_$(1) := build/$1/PrecompiledHeader.h.gch
$$(H_$(1)) : src/shared/PrecompiledHeader.h
@echo Copying $$< to $$@
@mkdir -p $$(dir $$@)
@cp $$< $$@
$$(H_GCH_$(1)) : $$(H_$(1))
@echo Compiling $$<
@mkdir -p $$(dir $$@)
@$$(MINGW_CXX) $$(MINGW_CXXFLAGS) $2 -I src/include -c -o $$@ $$<
@$$(MINGW_CXX) $$(MINGW_CXXFLAGS) $2 -c -o $$@ $$<
endif
build/$1/%.o : src/%.cc VERSION.txt $$(H_GCH_$(1))
@echo Compiling $$<
@mkdir -p $$(dir $$@)
@$$(MINGW_CXX) $$(MINGW_CXXFLAGS) $2 $$(PCH_INCLUDE) $$(H_$(1)) -I src/include -c -o $$@ $$<
endef
include src/subdir.mk

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)

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

@ -0,0 +1,43 @@
// 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 <aclapi.h>
#include <sddl.h>
#include <wincrypt.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