[gjs: 1/6] build: Support building with precompiled headers




commit e5691801fc34fcca4747ae0700e88ac75b47e65c
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Thu May 6 21:51:47 2021 +0200

    build: Support building with precompiled headers
    
    Pre-compiled headers can save some compilation time, and we do include
    quite a lot of them, so let's add an unique header to be used to speedup
    compilation.

 .gitlab-ci.yml |   2 +
 gjs/gjs_pch.hh | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 meson.build    |   4 ++
 3 files changed, 136 insertions(+)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 14d76d27..5a9c2308 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -247,6 +247,8 @@ iwyu:
   when: on_success
   stage: source_check
   image: registry.gitlab.gnome.org/gnome/gjs:fedora.mozjs78-debug
+  variables:
+    CONFIG_OPTS: -Db_pch=false
   script:
     - test/test-ci.sh UPSTREAM_BASE
     - meson setup _build
diff --git a/gjs/gjs_pch.hh b/gjs/gjs_pch.hh
new file mode 100644
index 00000000..b64fd3a5
--- /dev/null
+++ b/gjs/gjs_pch.hh
@@ -0,0 +1,130 @@
+/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
+// SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
+// SPDX-FileCopyrightText: 2021 Canonical Ltd.
+// SPDX-FileContributor: Authored by: Marco Trevisan <marco trevisan canonical com>
+
+#include "config.h"
+
+#include <algorithm>
+#include <atomic>
+#include <codecvt>
+#include <cstddef>
+#include <deque>
+#include <forward_list>
+#include <functional>
+#include <limits>
+#include <locale>
+#include <memory>
+#include <new>
+#include <sstream>
+#include <string>
+#include <string_view>
+#include <thread>
+#include <time.h>
+#include <tuple>
+#include <type_traits>
+#include <unordered_map>
+#include <unordered_set>
+#include <utility>
+#include <vector>
+
+#include <alloca.h>
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <ffi.h>
+#include <gio/gio.h>
+#include <girepository.h>
+#include <girffi.h>
+#include <gjs/context.h>
+#include <gjs/coverage.h>
+#include <gjs/error-types.h>
+#include <gjs/gjs.h>
+#include <gjs/jsapi-util.h>
+#include <gjs/macros.h>
+#include <gjs/mem.h>
+#include <gjs/profiler.h>
+#include <glib-object.h>
+#include <glib.h>
+#ifdef G_OS_UNIX
+#include <glib-unix.h>
+#endif
+#include <inttypes.h>
+#include <iomanip>
+#include <js/AllocPolicy.h>
+#include <js/Array.h>
+#include <js/ArrayBuffer.h>
+#include <js/CallArgs.h>
+#include <js/CharacterEncoding.h>
+#include <js/Class.h>
+#include <js/ComparisonOperators.h>
+#include <js/CompilationAndEvaluation.h>
+#include <js/CompileOptions.h>
+#include <js/ContextOptions.h>
+#include <js/Conversions.h>
+#include <js/ErrorReport.h>
+#include <js/Exception.h>
+#include <js/GCAPI.h>
+#include <js/GCHashTable.h>
+#include <js/GCPolicyAPI.h>
+#include <js/GCVector.h>
+#include <js/HashTable.h>
+#include <js/Id.h>
+#include <js/Initialization.h>
+#include <js/MemoryFunctions.h>
+#include <js/Modules.h>
+#include <js/ProfilingStack.h>
+#include <js/Promise.h>
+#include <js/PropertyDescriptor.h>
+#include <js/PropertySpec.h>
+#include <js/Realm.h>
+#include <js/RealmOptions.h>
+#include <js/RootingAPI.h>
+#include <js/SavedFrameAPI.h>
+#include <js/SourceText.h>
+#include <js/Symbol.h>
+#include <js/TracingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/UniquePtr.h>
+#include <js/Utility.h>
+#include <js/Value.h>
+#include <js/ValueArray.h>
+#include <js/Warnings.h>
+#include <js/Wrapper.h>
+#include <js/experimental/CodeCoverage.h>
+#include <js/experimental/SourceHook.h>
+#include <jsapi.h>
+#include <jsfriendapi.h>
+#include <jspubtd.h>
+#include <locale.h>
+#include <mozilla/Atomics.h>
+#include <mozilla/CheckedInt.h>
+#include <mozilla/HashFunctions.h>
+#include <mozilla/HashTable.h>
+#include <mozilla/Likely.h>
+#include <mozilla/UniquePtr.h>
+#ifdef HAVE_READLINE_READLINE_H
+#include <readline/history.h>
+#include <readline/readline.h>
+#endif
+#ifndef _WIN32
+#include <signal.h>
+#endif
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <syscall.h>
+#include <sysprof-capture.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef _WIN32
+#include <windows.h>
+#    include <io.h>
+# include <process.h>
+#endif
diff --git a/meson.build b/meson.build
index 8d11ec84..92dff728 100644
--- a/meson.build
+++ b/meson.build
@@ -500,6 +500,7 @@ libgjs_jsapi = static_library(meson.project_name() + '-jsapi',
     libgjs_jsapi_sources, probes_header, probes_objfile,
     cpp_args: libgjs_cpp_args,
     dependencies: libgjs_dependencies,
+    cpp_pch: 'gjs/gjs_pch.hh',
     install: false)
 
 link_args = []
@@ -519,6 +520,7 @@ libgjs = shared_library(meson.project_name(),
     link_args: link_args, link_depends: [symbol_map, symbol_list],
     link_with: libgjs_jsapi,
     dependencies: libgjs_dependencies,
+    cpp_pch: 'gjs/gjs_pch.hh',
     version: '0.0.0', soversion: '0',
     gnu_symbol_visibility: 'hidden',
     install: true)
@@ -712,4 +714,6 @@ message('\n'.join([
     'Use readline for input in interactive shell and debugger: @0@'.format(
         build_readline),
     'Build profiler (Linux only): @0@'.format(build_profiler),
+    'Build with precompiled headers: @0@'.format(get_option('b_pch') and
+        pch_headers.length() > 0),
 ]))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]