Skip to content

Commit 2359c32

Browse files
fanc999-1kjellahl
authored andcommitted
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.
1 parent abe3d02 commit 2359c32

File tree

6 files changed

+66
-2
lines changed

6 files changed

+66
-2
lines changed

MSVC_NMake/build-rules-msvc.mak

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ $(LIBSIGC_LIB): $(LIBSIGC_DLL)
3131
{.}.rc{$(CFG)\$(PLAT)\libsigcpp\}.res:
3232
rc /fo$@ $<
3333

34+
{..\untracked\MSVC_NMake\}.rc{$(CFG)\$(PLAT)\libsigcpp\}.res:
35+
rc /fo$@ $<
36+
3437
# Rules for linking DLLs
3538
# Format is as follows (the mt command is needed for MSVC 2005/2008 builds):
3639
# $(dll_name_with_path): $(dependent_libs_files_objects_and_items)

MSVC_NMake/config-msvc.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LIBSIGC_DEBUG_SUFFIX =
1616

1717
LIBSIGCPP_DEFINES = /DSIGC_BUILD /D_WINDLL
1818

19-
SIGCPP_BASE_CFLAGS = /I.. /I. /wd4530 /std:c++17 $(CFLAGS)
19+
SIGCPP_BASE_CFLAGS = /I.. /I. /I..\untracked\MSVC_NMake /wd4530 /std:c++17 /EHsc $(CFLAGS)
2020

2121
LIBSIGC_INT_SOURCES = $(sigc_sources_cc:/=\)
2222
LIBSIGC_INT_HDRS = $(sigc_public_h:/=\)

MSVC_NMake/install.mak

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ install: all
1111
@copy /b $(CFG)\$(PLAT)\$(LIBSIGC_LIBNAME).pdb $(PREFIX)\bin
1212
@copy /b $(CFG)\$(PLAT)\$(LIBSIGC_LIBNAME).lib $(PREFIX)\lib
1313
@for %h in ($(LIBSIGC_INT_HDRS)) do @copy "..\sigc++\%h" "$(PREFIX)\include\sigc++-$(LIBSIGC_MAJOR_VERSION).$(LIBSIGC_MINOR_VERSION)\sigc++\%h"
14-
@copy "sigc++config.h" "$(PREFIX)\lib\sigc++-$(LIBSIGC_MAJOR_VERSION).$(LIBSIGC_MINOR_VERSION)\include\"
14+
@if exist sigc++config.h copy "sigc++config.h" "$(PREFIX)\lib\sigc++-$(LIBSIGC_MAJOR_VERSION).$(LIBSIGC_MINOR_VERSION)\include\"
15+
@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\"

MSVC_NMake/meson.build

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,19 @@ import shutil
1515
shutil.copy2("@0@", "@1@")
1616
'''.format(project_build_root / 'sigc++config.h', project_build_root / 'MSVC_NMake')
1717
meson.add_postconf_script(python3.path(), '-c', cmd_py)
18+
19+
untracked_msvc_nmake = 'untracked' / 'MSVC_NMake'
20+
handle_built_files = project_source_root / 'tools' / 'handle-built-files.py'
21+
22+
if not meson.is_subproject()
23+
# Distribute built files.
24+
# (add_dist_script() is not allowed in a subproject)
25+
26+
meson.add_dist_script(
27+
python3.path(), dist_cmd,
28+
python3.path(), handle_built_files, 'dist_gen_msvc_files',
29+
meson.current_build_dir(),
30+
untracked_msvc_nmake,
31+
project_build_root / 'sigc++config.h', meson.current_build_dir() / 'sigc.rc',
32+
)
33+
endif

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ EXTRA_DIST = \
5656
sigc++/meson.build \
5757
tests/meson.build \
5858
tools/dist-cmd.py \
59+
tools/handle-built-files.py \
5960
tools/tutorial-custom-cmd.py \
6061
untracked/README
6162

tools/handle-built-files.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python3
2+
3+
# External command, intended to be called with run_command(), custom_target(),
4+
# meson.add_install_script() and meson.add_dist_script().
5+
6+
# argv[1] argv[2:]
7+
# handle-built-files.py <subcommand> <xxx>...
8+
9+
import os
10+
import sys
11+
import shutil
12+
import subprocess
13+
from pathlib import Path
14+
15+
subcommand = sys.argv[1]
16+
17+
# Invoked from meson.add_dist_script().
18+
def dist_built_files(is_msvc_files=False):
19+
# argv[2] argv[3] argv[4:]
20+
# <built_h_cc_dir> <dist_dir> <built_files>...
21+
22+
# <built_h_cc_dir> is an absolute path in the build directory or source directory.
23+
# <dist_dir> is a distribution directory, relative to MESON_DIST_ROOT.
24+
built_h_cc_dir = sys.argv[2]
25+
dist_dir_root = os.path.join(os.getenv('MESON_DIST_ROOT'), sys.argv[3])
26+
dist_dir = dist_dir_root
27+
28+
# Distribute .h and .cc files built from .m4 files, or generated MSVC files.
29+
for file in sys.argv[4:]:
30+
if not is_msvc_files:
31+
dist_dir = os.path.join(dist_dir_root, os.path.dirname(file))
32+
33+
# Create the distribution directory, if it does not exist.
34+
os.makedirs(dist_dir, exist_ok=True)
35+
36+
shutil.copy(os.path.join(built_h_cc_dir, file), dist_dir)
37+
return 0
38+
39+
# ----- Main -----
40+
if subcommand == 'dist_gen_msvc_files':
41+
sys.exit(dist_built_files(True))
42+
print(sys.argv[0], ': illegal subcommand,', subcommand)
43+
sys.exit(1)

0 commit comments

Comments
 (0)