summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2019-12-27 15:16:49 +0800
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2019-12-29 18:11:52 +0100
commit2359c3243cd6aa7e1c3f1e54197351f9249e4ab6 (patch)
tree699640f408a32a25c658eeb65f77da4f4f9bd800
parentabe3d02ba618431dd4ac6ac3e463727db1239084 (diff)
downloadsigc++-2359c3243cd6aa7e1c3f1e54197351f9249e4ab6.tar.gz
build: Support NMake builds from Meson tarballs
This adds the MSVC files in MSVC_NMake/ that are generated during Meson's configure step to the generated release tarball. The NMake Makefiles are updated so that they will be able to find files that are now in untracked/MSVC_NMake, when a release tarball is generated with Meson.
-rw-r--r--MSVC_NMake/build-rules-msvc.mak3
-rw-r--r--MSVC_NMake/config-msvc.mak2
-rw-r--r--MSVC_NMake/install.mak3
-rw-r--r--MSVC_NMake/meson.build16
-rw-r--r--Makefile.am1
-rw-r--r--tools/handle-built-files.py43
6 files changed, 66 insertions, 2 deletions
diff --git a/MSVC_NMake/build-rules-msvc.mak b/MSVC_NMake/build-rules-msvc.mak
index 47d385d..6097d07 100644
--- a/MSVC_NMake/build-rules-msvc.mak
+++ b/MSVC_NMake/build-rules-msvc.mak
@@ -31,6 +31,9 @@ $(LIBSIGC_LIB): $(LIBSIGC_DLL)
{.}.rc{$(CFG)\$(PLAT)\libsigcpp\}.res:
rc /fo$@ $<
+{..\untracked\MSVC_NMake\}.rc{$(CFG)\$(PLAT)\libsigcpp\}.res:
+ rc /fo$@ $<
+
# Rules for linking DLLs
# Format is as follows (the mt command is needed for MSVC 2005/2008 builds):
# $(dll_name_with_path): $(dependent_libs_files_objects_and_items)
diff --git a/MSVC_NMake/config-msvc.mak b/MSVC_NMake/config-msvc.mak
index b091de0..c3d957c 100644
--- a/MSVC_NMake/config-msvc.mak
+++ b/MSVC_NMake/config-msvc.mak
@@ -16,7 +16,7 @@ LIBSIGC_DEBUG_SUFFIX =
LIBSIGCPP_DEFINES = /DSIGC_BUILD /D_WINDLL
-SIGCPP_BASE_CFLAGS = /I.. /I. /wd4530 /std:c++17 $(CFLAGS)
+SIGCPP_BASE_CFLAGS = /I.. /I. /I..\untracked\MSVC_NMake /wd4530 /std:c++17 /EHsc $(CFLAGS)
LIBSIGC_INT_SOURCES = $(sigc_sources_cc:/=\)
LIBSIGC_INT_HDRS = $(sigc_public_h:/=\)
diff --git a/MSVC_NMake/install.mak b/MSVC_NMake/install.mak
index 4903a25..eea2682 100644
--- a/MSVC_NMake/install.mak
+++ b/MSVC_NMake/install.mak
@@ -11,4 +11,5 @@ install: all
@copy /b $(CFG)\$(PLAT)\$(LIBSIGC_LIBNAME).pdb $(PREFIX)\bin
@copy /b $(CFG)\$(PLAT)\$(LIBSIGC_LIBNAME).lib $(PREFIX)\lib
@for %h in ($(LIBSIGC_INT_HDRS)) do @copy "..\sigc++\%h" "$(PREFIX)\include\sigc++-$(LIBSIGC_MAJOR_VERSION).$(LIBSIGC_MINOR_VERSION)\sigc++\%h"
- @copy "sigc++config.h" "$(PREFIX)\lib\sigc++-$(LIBSIGC_MAJOR_VERSION).$(LIBSIGC_MINOR_VERSION)\include\"
+ @if exist sigc++config.h copy "sigc++config.h" "$(PREFIX)\lib\sigc++-$(LIBSIGC_MAJOR_VERSION).$(LIBSIGC_MINOR_VERSION)\include\"
+ @if exist ..\untracked\MSVC_NMake\sigc++config.h copy "..\untracked\MSVC_NMake\sigc++config.h" "$(PREFIX)\lib\sigc++-$(LIBSIGC_MAJOR_VERSION).$(LIBSIGC_MINOR_VERSION)\include\"
diff --git a/MSVC_NMake/meson.build b/MSVC_NMake/meson.build
index 510daa4..a799535 100644
--- a/MSVC_NMake/meson.build
+++ b/MSVC_NMake/meson.build
@@ -15,3 +15,19 @@ import shutil
shutil.copy2("@0@", "@1@")
'''.format(project_build_root / 'sigc++config.h', project_build_root / 'MSVC_NMake')
meson.add_postconf_script(python3.path(), '-c', cmd_py)
+
+untracked_msvc_nmake = 'untracked' / 'MSVC_NMake'
+handle_built_files = project_source_root / 'tools' / 'handle-built-files.py'
+
+if not meson.is_subproject()
+ # Distribute built files.
+ # (add_dist_script() is not allowed in a subproject)
+
+ meson.add_dist_script(
+ python3.path(), dist_cmd,
+ python3.path(), handle_built_files, 'dist_gen_msvc_files',
+ meson.current_build_dir(),
+ untracked_msvc_nmake,
+ project_build_root / 'sigc++config.h', meson.current_build_dir() / 'sigc.rc',
+ )
+endif
diff --git a/Makefile.am b/Makefile.am
index 76d0482..80b4136 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -56,6 +56,7 @@ EXTRA_DIST = \
sigc++/meson.build \
tests/meson.build \
tools/dist-cmd.py \
+ tools/handle-built-files.py \
tools/tutorial-custom-cmd.py \
untracked/README
diff --git a/tools/handle-built-files.py b/tools/handle-built-files.py
new file mode 100644
index 0000000..d6957ef
--- /dev/null
+++ b/tools/handle-built-files.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+
+# External command, intended to be called with run_command(), custom_target(),
+# meson.add_install_script() and meson.add_dist_script().
+
+# argv[1] argv[2:]
+# handle-built-files.py <subcommand> <xxx>...
+
+import os
+import sys
+import shutil
+import subprocess
+from pathlib import Path
+
+subcommand = sys.argv[1]
+
+# Invoked from meson.add_dist_script().
+def dist_built_files(is_msvc_files=False):
+ # argv[2] argv[3] argv[4:]
+ # <built_h_cc_dir> <dist_dir> <built_files>...
+
+ # <built_h_cc_dir> is an absolute path in the build directory or source directory.
+ # <dist_dir> is a distribution directory, relative to MESON_DIST_ROOT.
+ built_h_cc_dir = sys.argv[2]
+ dist_dir_root = os.path.join(os.getenv('MESON_DIST_ROOT'), sys.argv[3])
+ dist_dir = dist_dir_root
+
+ # Distribute .h and .cc files built from .m4 files, or generated MSVC files.
+ for file in sys.argv[4:]:
+ if not is_msvc_files:
+ dist_dir = os.path.join(dist_dir_root, os.path.dirname(file))
+
+ # Create the distribution directory, if it does not exist.
+ os.makedirs(dist_dir, exist_ok=True)
+
+ shutil.copy(os.path.join(built_h_cc_dir, file), dist_dir)
+ return 0
+
+# ----- Main -----
+if subcommand == 'dist_gen_msvc_files':
+ sys.exit(dist_built_files(True))
+print(sys.argv[0], ': illegal subcommand,', subcommand)
+sys.exit(1)