diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2014-08-25 14:57:30 +0800 |
---|---|---|
committer | Chun-wei Fan <fanchunwei@src.gnome.org> | 2015-04-08 10:14:33 +0800 |
commit | b5519c3a59e6c9b091f1389403c982871f93972b (patch) | |
tree | 7667e5b447afda7b298b3bfe16a4fa271722db50 /build | |
parent | e57c5221426fb80afd1544edb79241331f7654ab (diff) | |
download | pango-b5519c3a59e6c9b091f1389403c982871f93972b.tar.gz |
build: Add Common Autotools Module for MSVC Projects
This adds a common autotools module that can be used by various projects to
generate the Visual Studio projects as needed, and if necessary, generate
the headers listings to "install" for that project, based on items passed
in to this. This is modelled on the Makefile.introspection autotools file
that is used by many GNOME projects to generate the introspection files.
https://bugzilla.gnome.org/show_bug.cgi?id=735039
Diffstat (limited to 'build')
-rw-r--r-- | build/Makefile.msvcproj | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/build/Makefile.msvcproj b/build/Makefile.msvcproj new file mode 100644 index 00000000..0fe31071 --- /dev/null +++ b/build/Makefile.msvcproj @@ -0,0 +1,107 @@ +# Author: Fan, Chun-wei +# Common Autotools file used to generate Visual Studio 2008+ +# Projects from their templates + +# * Input variables: +# +# MSVCPROJS - List of Projects that should be generated +# +# * Simple tutorial +# +# Add this to Makefile.am where your library/program is built: +# include $(top_srcdir)/build/Makefile.msvcproj +# MSVCPROJS = YourProject +# YourProject_FILES = $(libyourlib_1_0_SOURCES) +# YourProject_EXCLUDES = ... # list of sources to exclude, separated by '|', wildcards allowed; use random unsed value if none +# YourProject_HEADERS_DIR = $(libyourlibincludedir) +# YourProject_HEADERS_INST = $(libyourlib_1_0_HEADERS) +# YourProject_HEADERS_EXCLUDES = ... # <list of headers to exclude from installation, separated by '|', wildcards allowed; use random unsed value if none> +# +# dist-hook: \ # (or add to it if it is already there) +# $(top_builddir)/build/win32/vs9/YourProject.vcproj \ +# $(top_builddir)/build/win32/vs9/YourProject.headers \ +# $(top_builddir)/build/win32/vs10/YourProject.vcxproj \ +# $(top_builddir)/build/win32/vs10/YourProject.vcxproj.filters \ +# $(top_builddir)/build/win32/vs9/YourProject.vs10.headers + + +# Private functions + +## Transform the MSVC project filename (no filename extensions) to something which can reference through a variable +## without automake/make complaining, eg Gtk-2.0 -> Gtk_2_0 +_proj_name=$(subst /,_,$(subst -,_,$(subst .,_,$(1)))) +_proj_path_raw:=$(shell realpath --relative-to=$(top_srcdir) $(srcdir)) +_proj_path=$(subst /,\\,$(_proj_path_raw)) +_proj_subdir_int=$(if $(ifeq $(_proj_path),\.),\\,\\$(_proj_path)\\) +_proj_subdir=$(subst \\.\\,\\,$(_proj_subdir_int)) + +_proj_files_raw=$(subst /,\\,$($(_proj_name)_FILES)) +_proj_files=$(subst $(srcdir)\\,,$(subst $(builddir)\\,,$(subst $(top_builddir)\\$(_proj_path)\\,\\,$(_proj_files_raw)))) +_proj_filters=$($(_proj_name)_EXCLUDES) + +_proj_headers_raw=$(subst /,\\,$($(_proj_name)_HEADERS_INST)) +_proj_headers=$(subst $(srcdir)\\,,$(subst $(builddir)\\,,$(subst $(top_builddir)\\$(_proj_path)\\,\\,$(_proj_headers_raw)))) +_proj_headers_excludes=$($(_proj_name)_HEADERS_EXCLUDES) + +empty:= +_headers_dest_posix=$(subst $(includedir),$(empty),$($(_proj_name)_HEADERS_DIR)) +_headers_destdir=$(subst /,\\,$(_headers_dest_posix)) + +# +# Creates Visual Studio 2008/2010 projects from items passed in from autotools files +# $(1) - Base Name of the MSVC project files (outputs) +# + +define msvcproj-builder + +$(top_builddir)/build/win32/vs10/$(1).vcxproj: $(top_builddir)/build/win32/vs9/$(1).vcproj +$(top_builddir)/build/win32/vs10/$(1).vcxproj.filters: $(top_builddir)/build/win32/vs9/$(1).vcproj +$(1).sourcefiles: $(top_builddir)/build/win32/vs9/$(1).vcproj +$(1).vs10.sourcefiles: $(top_builddir)/build/win32/vs9/$(1).vcproj +$(1).vs10.sourcefiles.filters: $(top_builddir)/build/win32/vs9/$(1).vcproj + +$(top_builddir)/build/win32/vs9/$(1).vcproj: + -$(RM) $(top_builddir)/build/win32/vs9/$(1).vcproj + -$(RM) $(top_builddir)/build/win32/vs10/$(1).vcxproj + -$(RM) $(top_builddir)/build/win32/vs10/$(1).vcxproj.filters + + for F in $(_proj_files); do \ + case $$$$F in \ + $(_proj_filters)) \ + ;; \ + *.c|*.cpp|*.cc|*.cxx) \ + echo ' <File RelativePath="..\..\..'$(_proj_subdir)$$$$F'" />' >>$(1).sourcefiles && \ + echo ' <ClCompile Include="..\..\..'$(_proj_subdir)$$$$F'" />' >>$(1).vs10.sourcefiles && \ + echo ' <ClCompile Include="..\..\..'$(_proj_subdir)$$$$F'"><Filter>Source Files</Filter></ClCompile>' >>$(1).vs10.sourcefiles.filters \ + ;; \ + esac; \ + done + + + $(CPP) -P - <$(top_srcdir)/build/win32/vs9/$(1).vcprojin >$(top_builddir)/build/win32/vs9/$(1).vcproj + $(CPP) -P - <$(top_srcdir)/build/win32/vs10/$(1).vcxprojin >$(top_builddir)/build/win32/vs10/$(1).vcxproj + $(CPP) -P - <$(top_srcdir)/build/win32/vs10/$(1).vcxproj.filtersin >$(top_builddir)/build/win32/vs10/$(1).vcxproj.filters + $(RM) $(1).sourcefiles + $(RM) $(1).vs10.sourcefiles + $(RM) $(1).vs10.sourcefiles.filters + +$(top_builddir)/build/win32/vs10/$(1).vs10.headers: $(top_builddir)/build/win32/vs9/$(1).headers + +$(top_builddir)/build/win32/vs9/$(1).headers: + -$(RM) $(top_builddir)/build/win32/vs9/$(1).headers + -$(RM) $(top_builddir)/build/win32/vs10/$(1).vs10.headers + + for F in $(_proj_headers); do \ + case $$$$F in \ + $(_proj_headers_excludes)) \ + ;; \ + *.h|*.hpp|*.hh|*.hxx) \ + echo 'copy ..\..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F'
' >>$(top_builddir)/build/win32/vs9/$(1).headers && \ + echo 'copy ..\..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F >>$(top_builddir)/build/win32/vs10/$(1).vs10.headers \ + ;; \ + esac; \ + done + +endef + +$(foreach proj,$(MSVCPROJS),$(eval $(call msvcproj-builder,$(proj)))) |