From d7b6636e5ebf1ddf7d7a04007ffbc411cf7e462e Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 3 Nov 2015 19:00:42 +0800 Subject: [PATCH] build: Support Visual Studio builds using NMake This adds a set of NMake Makefiles that can be used to build HarfBuzz, from the standard basic build building the minimal HarfBuzz DLL (consisting of OpenType, fallback and Uniscribe support only), to a full fledged build consisting of GLib and FreeType support, as well as building the utilities, the test programs in src/ and test/api, and HarfBuzz-ICU and HarfBuzz-GObject, and up to building the introspection files. This means a flexible build mechanism is supported here, so anything that is supported for a Windows build (code-wise), should all be supported by this build system. As in an earlier commit, the source listings are shared with the autotools builds with the various Makefile.sources in src/, src/hb-ucdn and util/, and this set of NMake Makefiles will transform these lists into the form they want. In the current form, all the test programs in test/api pass, and this has been checked successfully with 'make -j8 distcheck'. --- BUILD.md | 4 +- Makefile.am | 2 +- configure.ac | 2 + win32/Makefile.am | 14 +++ win32/Makefile.vc | 52 +++++++++ win32/README.txt | 75 +++++++++++++ win32/build-rules-msvc.mak | 140 ++++++++++++++++++++++++ win32/config-msvc.mak | 188 ++++++++++++++++++++++++++++++++ win32/create-lists-msvc.mak | 151 +++++++++++++++++++++++++ win32/create-lists.bat | 42 +++++++ win32/detectenv-msvc.mak | 136 +++++++++++++++++++++++ win32/generate-msvc.mak | 26 +++++ win32/hb-introspection-msvc.mak | 42 +++++++ win32/info-msvc.mak | 130 ++++++++++++++++++++++ win32/install.mak | 29 +++++ win32/introspection-msvc.mak | 73 +++++++++++++ 16 files changed, 1104 insertions(+), 2 deletions(-) create mode 100644 win32/Makefile.am create mode 100644 win32/Makefile.vc create mode 100644 win32/README.txt create mode 100644 win32/build-rules-msvc.mak create mode 100644 win32/config-msvc.mak create mode 100644 win32/create-lists-msvc.mak create mode 100644 win32/create-lists.bat create mode 100644 win32/detectenv-msvc.mak create mode 100644 win32/generate-msvc.mak create mode 100644 win32/hb-introspection-msvc.mak create mode 100644 win32/info-msvc.mak create mode 100644 win32/install.mak create mode 100644 win32/introspection-msvc.mak diff --git a/BUILD.md b/BUILD.md index e9d7d4d5d..86285c648 100644 --- a/BUILD.md +++ b/BUILD.md @@ -15,7 +15,9 @@ or using Homebrew: If you are using a tarball, you can now proceed to running configure and make as with any other standard package. That should leave you with a shared library in src/, and a few utility programs including hb-view and hb-shape -under util/. +under util/. From the tarball, NMake Makefiles are also provided in win32/, +which supports building HarfBuzz using Visual Studio, with a README.txt that +gives instructions on building using NMake. If you are bootstraping from git, you need a few more tools before you can run autogen.sh for the first time. Namely, pkg-config and ragel. Again, on Ubuntu / Debian: diff --git a/Makefile.am b/Makefile.am index 3c1e7a27c..8987d5749 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,7 +4,7 @@ NULL = ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = src util test docs +SUBDIRS = src util test docs win32 EXTRA_DIST = \ autogen.sh \ diff --git a/configure.ac b/configure.ac index 764211553..d14e0fc76 100644 --- a/configure.ac +++ b/configure.ac @@ -444,6 +444,8 @@ test/fuzzing/Makefile test/shaping/Makefile docs/Makefile docs/version.xml +win32/Makefile +win32/config.h.win32 ]) AC_OUTPUT diff --git a/win32/Makefile.am b/win32/Makefile.am new file mode 100644 index 000000000..be7a477af --- /dev/null +++ b/win32/Makefile.am @@ -0,0 +1,14 @@ +EXTRA_DIST = \ + build-rules-msvc.mak \ + config-msvc.mak \ + config.h.win32 \ + create-lists.bat \ + create-lists-msvc.mak \ + detectenv-msvc.mak \ + generate-msvc.mak \ + hb-introspection-msvc.mak \ + info-msvc.mak \ + install.mak \ + introspection-msvc.mak \ + Makefile.vc \ + README.txt diff --git a/win32/Makefile.vc b/win32/Makefile.vc new file mode 100644 index 000000000..fdde7a7d4 --- /dev/null +++ b/win32/Makefile.vc @@ -0,0 +1,52 @@ +# NMake Makefile for building HarfBuzz as a DLL on Windows + +# The items below this line should not be changed, unless one is maintaining +# the NMake Makefiles. Customizations can be done in the following NMake Makefile +# portions (please see comments in the these files to see what can be customized): +# +# detectenv-msvc.mak +# config-msvc.mak + +!include detectenv-msvc.mak + +# Include the Makefile portions with the source listings +!include ..\src\Makefile.sources +!include ..\src\hb-ucdn\Makefile.sources +!include ..\util\Makefile.sources + +# Include the Makefile portion that enables features based on user input +!include config-msvc.mak + +!if "$(VALID_CFGSET)" == "TRUE" + +# Include the Makefile portion to convert the source and header lists +# into the lists we need for compilation and introspection +!include create-lists-msvc.mak + +all: $(HB_LIBS) $(HB_UTILS) $(EXTRA_TARGETS) all-build-info + +tests: all $(HB_TESTS) + +# Include the build rules for sources, DLLs and executables +!include build-rules-msvc.mak + +# Include the rules for build directory creation and code generation +!include generate-msvc.mak + +# Generate the introspection files + +!if "$(INTROSPECTION)" == "1" +# Include the rules for building the introspection files +!include introspection-msvc.mak +!include hb-introspection-msvc.mak +!endif + +!include install.mak + +!else +all: help + @echo You need to specify a valid configuration, via + @echo CFG=release or CFG=debug +!endif + +!include info-msvc.mak diff --git a/win32/README.txt b/win32/README.txt new file mode 100644 index 000000000..1cb965c3d --- /dev/null +++ b/win32/README.txt @@ -0,0 +1,75 @@ +Instructions for building HarfBuzz on Visual Studio +=================================================== +Building the HarfBuzz DLL on Windows is now also supported using Visual Studio +versions 2008 through 2015, in both 32-bit and 64-bit (x64) flavors, via NMake +Makefiles. + +The following are instructions for performing such a build, as there is a +number of build configurations supported for the build. Note that for all +build configurations, the OpenType and Simple TrueType layout (fallback) +backends are enabled, as well as the Uniscribe platform shaper, and this +is the base configuration that is built if no options (see below) are +specified. A 'clean' target is provided-it is recommended that one cleans +the build and redo the build if any configuration option changed. An +'install' target is also provided to copy the built items in their appropriate +locations under $(PREFIX), which is described below. + +Invoke the build by issuing the command: +nmake /f Makefile.vc CFG=[release|debug] [PREFIX=...] +where: + +CFG: Required. Choose from a release or debug build. Note that + all builds generate a .pdb file for each .dll and .exe built--this refers + to the C/C++ runtime that the build uses. + +PREFIX: Optional. Base directory of where the third-party headers, libraries + and needed tools can be found, i.e. headers in $(PREFIX)\include, + libraries in $(PREFIX)\lib and tools in $(PREFIX)\bin. If not + specified, $(PREFIX) is set as $(srcroot)\..\vs$(X)\$(platform), where + $(platform) is win32 for 32-bit builds or x64 for 64-bit builds, and + $(X) is the short version of the Visual Studio used, as follows: + 2008: 9 + 2010: 10 + 2012: 11 + 2013: 12 + 2015: 14 + +Explanation of options, set by