[librsvg/cargo-c] NMake Makefiles: Update for cargo-c usage
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/cargo-c] NMake Makefiles: Update for cargo-c usage
- Date: Fri, 9 Jul 2021 23:50:36 +0000 (UTC)
commit 9ffd61284364ec69a7d2f17f3cc9f350ab379729
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Fri Jul 9 12:38:50 2021 +0800
NMake Makefiles: Update for cargo-c usage
This updates the Visual Studio build files to build librsvg after it has
been updated to use cargo-c to build the C libraries, and, as a
side-effect, static builds are now supported as well at the same time.
As a convenience, we still provide rsvg-2.0-vsXX.dll resulting from the
builds for people that aren't able to re-link their applications against
rsvg-2.dll (the DLL file name that results from the cargo-c updates),
but a warning message is shown upon 'install' that people are advised to
re-compile their applications if possible, since rsvg-2.0.lib now links
to rsvg-2.dll.
win32/Makefile.vc | 2 +-
win32/build-rules-msvc.mak | 30 ++++++++++++------------------
win32/config-msvc.mak.in | 4 ++--
win32/create-lists-msvc.mak | 9 ---------
win32/generate-msvc.mak | 14 ++------------
win32/install-msvc.mak | 21 ++++++++++++++++-----
win32/pc_base.py | 13 ++++++++++++-
win32/rsvg-rust.mak | 14 +++++++-------
win32/rsvgpc.py | 9 +++------
9 files changed, 55 insertions(+), 61 deletions(-)
---
diff --git a/win32/Makefile.vc b/win32/Makefile.vc
index 80d27c0a..3f96cfef 100644
--- a/win32/Makefile.vc
+++ b/win32/Makefile.vc
@@ -32,7 +32,7 @@ VALID_MSC = TRUE
# Include the Makefile portion to convert the source and header lists
# into the lists we need for compilation and introspection
-all: $(RSVG_TOOLS) $(EXTRA_TARGETS) build-info-librsvg
+all: $(LIBRSVG_LIB) $(RSVG_TOOLS) $(EXTRA_TARGETS) build-info-librsvg
# Include the build rules for Rust builds, sources, DLLs and executables
!include rsvg-rust.mak
diff --git a/win32/build-rules-msvc.mak b/win32/build-rules-msvc.mak
index a1ec221c..7af562df 100644
--- a/win32/build-rules-msvc.mak
+++ b/win32/build-rules-msvc.mak
@@ -13,13 +13,9 @@
# $(CC)|$(CXX) $(cflags) /Fo$(destdir) /c @<<
# $<
# <<
-{$(OUTDIR)\librsvg\}.c{$(OUTDIR)\librsvg\}.obj:
- $(CC) $(LIBRSVG_CFLAGS) $(LIBRSVG_INCLUDES) /Fo$(@D)\ /Fd$(@D)\ /c @<<
-$<
-<<
-
{..\gdk-pixbuf-loader\}.c{$(OUTDIR)\rsvg-gdk-pixbuf-loader\}.obj:
@if not exist $(@D)\ mkdir $(@D)
+ @if not exist $(@D)\..\librsvg mkdir $(@D)\..\librsvg
@if not exist $(@D)\..\librsvg\config.h copy .\config.h.win32 $(@D)\..\librsvg\config.h
$(CC) $(RSVG_PIXBUF_LOADER_CFLAGS) $(TOOLS_DEP_INCLUDES) /Fo$(@D)\ /Fd$(@D)\ /c @<<
$<
@@ -27,6 +23,7 @@ $<
{..\tests\}.c{$(OUTDIR)\rsvg-tests\}.obj:
@if not exist $(@D)\ mkdir $(@D)
+ @if not exist $(@D)\..\librsvg mkdir $(@D)\..\librsvg
@if not exist $(@D)\..\librsvg\config.h copy .\config.h.win32 $(@D)\..\librsvg\config.h
$(CC) $(TEST_CFLAGS) $(LIBRSVG_LOG_DOMAIN) $(TOOLS_DEP_INCLUDES) /Fo$(@D)\ /Fd$(@D)\ /c @<<
$<
@@ -42,16 +39,16 @@ $(LIBRSVG_LIB): $(LIBRSVG_DLL)
# $(dependent_objects)
# <<
# @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
-$(LIBRSVG_DLL): $(RSVG_INTERNAL_LIB) $(librsvg_OBJS) $(LIBRSVG_DEF)
- link /DLL $(LDFLAGS) $(LIBRSVG_DEP_LIBS) \
- /implib:$(LIBRSVG_LIB) \
- -out:$@ /def:$(LIBRSVG_DEF) @<<
-$(librsvg_OBJS)
-<<
- @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
+$(LIBRSVG_DLL): $(RSVG_INTERNAL_LIB)
+ @copy /b $(RSVG_INTERNAL_LIB:.dll.lib=.dll) $(OUTDIR)
+ @copy /b $(RSVG_INTERNAL_LIB:.dll.lib=.dll) $@
+ @copy /b $(RSVG_INTERNAL_LIB:.dll.lib=.lib) $(OUTDIR)\rsvg-2-static.lib
+ @copy /b $(RSVG_INTERNAL_LIB) $(OUTDIR)\rsvg-2.0.lib
+ @copy /b $(RUST_OUTDIR)\rsvg_2.pdb $(OUTDIR)
+ @copy /b $(RUST_OUTDIR)\librsvg-2.0.pc $(OUTDIR)
$(GDK_PIXBUF_SVG_LOADER): \
-$(LIBRSVG_LIB) \
+$(RSVG_INTERNAL_LIB) \
$(OUTDIR)\rsvg-gdk-pixbuf-loader\io-svg.obj
link /DLL $(LDFLAGS) $** $(BASE_DEP_LIBS) /out:$@
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
@@ -79,7 +76,7 @@ $(rsvg_tests):
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
!ifdef INTROSPECTION
-$(OUTDIR)\Rsvg-$(RSVG_API_VER).gir: $(LIBRSVG_LIB) $(OUTDIR)\librsvg\Rsvg_2_0_gir_list
+$(OUTDIR)\Rsvg-$(RSVG_API_VER).gir: $(RSVG_INTERNAL_LIB) $(OUTDIR)\librsvg\Rsvg_2_0_gir_list
@-echo Generating $@...
@set PATH=$(BINDIR);$(PATH)
$(PYTHON) $(G_IR_SCANNER) \
@@ -87,7 +84,7 @@ $(OUTDIR)\Rsvg-$(RSVG_API_VER).gir: $(LIBRSVG_LIB) $(OUTDIR)\librsvg\Rsvg_2_0_gi
--namespace=Rsvg \
--nsversion=2.0 \
--pkg=pango --extra-library=libxml2 \
- --library=rsvg-2.0 \
+ --library=$(RSVG_INTERNAL_LIB:.dll.lib=.dll) \
--add-include-path=$(G_IR_INCLUDEDIR) \
--include=GLib-2.0 --include=GObject-2.0 \
--include=Gio-2.0 --include=cairo-1.0 \
@@ -124,9 +121,6 @@ clean:
@-del /s /q $(OUTDIR)\rsvg-gdk-pixbuf-loader\*.obj
@-del /s /q $(OUTDIR)\rsvg-gdk-pixbuf-loader\*.pdb
@-del /s /q $(OUTDIR)\librsvg\Rsvg_2_0_gir_list
- @-del /s /q $(OUTDIR)\librsvg\*.obj
- @-del /s /q $(OUTDIR)\librsvg\*.pdb
- @-del /s /q $(OUTDIR)\librsvg\_rsvg_dummy.c
@-del /s /q $(OUTDIR)\librsvg\config.h
@-rmdir /s /q $(OUTDIR)\output
@-rmdir /s /q output
diff --git a/win32/config-msvc.mak.in b/win32/config-msvc.mak.in
index 4c42f753..b71b09a3 100644
--- a/win32/config-msvc.mak.in
+++ b/win32/config-msvc.mak.in
@@ -106,7 +106,8 @@ TEST_DEP_LIBS = \
fontconfig.lib
!endif
-RSVG_INTERNAL_LIB = $(OUTDIR)\obj\rsvg_c_api\$(RUST_TARGET)-pc-windows-msvc\$(CFG)\librsvg.lib
+RUST_OUTDIR = $(OUTDIR)\obj\rsvg_c_api\$(RUST_TARGET)-pc-windows-msvc\$(CFG)
+RSVG_INTERNAL_LIB = $(RUST_OUTDIR)\rsvg-2.dll.lib
LIBRSVG_DEP_LIBS = \
$(RSVG_INTERNAL_LIB) \
@@ -133,7 +134,6 @@ LIBRSVG_DLL_FILENAME = $(OUTDIR)\rsvg-$(RSVG_API_VER)-vs$(VSVER)
LIBRSVG_DLL = $(LIBRSVG_DLL_FILENAME).dll
LIBRSVG_LIB = $(OUTDIR)\rsvg-$(RSVG_API_VER).lib
-LIBRSVG_DEF = $(OUTDIR)\librsvg\librsvg.def
GDK_PIXBUF_SVG_LOADER = $(OUTDIR)\libpixbufloader-svg.dll
diff --git a/win32/create-lists-msvc.mak b/win32/create-lists-msvc.mak
index 97087fdf..6fb7ffc3 100644
--- a/win32/create-lists-msvc.mak
+++ b/win32/create-lists-msvc.mak
@@ -44,15 +44,6 @@ NULL=
!if [call create-lists.bat footer rsvg_objs.mak]
!endif
-!if [call create-lists.bat header rsvg_objs.mak librsvg_OBJS]
-!endif
-
-!if [for %c in ($(OUTDIR)\librsvg\_rsvg_dummy.c) do @if "%~xc" == ".c" @call create-lists.bat file
rsvg_objs.mak ^$(OUTDIR)\librsvg\%~nc.obj]
-!endif
-
-!if [call create-lists.bat footer rsvg_objs.mak]
-!endif
-
!if [call create-lists.bat header rsvg_objs.mak rsvg_tests]
!endif
diff --git a/win32/generate-msvc.mak b/win32/generate-msvc.mak
index 2acbd65a..fbf4b52b 100644
--- a/win32/generate-msvc.mak
+++ b/win32/generate-msvc.mak
@@ -3,18 +3,8 @@
# Items in here should not need to be edited unless
# one is maintaining the NMake build files.
-$(OUTDIR)\librsvg\_rsvg_dummy.c:
- @echo Generating dummy source file...
- @if not exist $(@D)\ mkdir $(@D)
- echo static int __rsvg_dummy; > $@
-
-$(OUTDIR)\librsvg\librsvg.def: .\librsvg.symbols
- @echo Generating $@...
- @if not exist $(@D)\ mkdir $(@D)
- @echo EXPORTS>$@
- $(CC) /EP $**>>$@
-
# Generate listing file for introspection
$(OUTDIR)\librsvg\Rsvg_2_0_gir_list: $(librsvg_real_pub_HDRS)
+ @if not exist $(@D)\ mkdir $(@D)
@if exist $@ del $@
- @for %%s in ($**) do echo %%s >> $@
+ @for %%s in ($**) do @echo %%s >> $@
diff --git a/win32/install-msvc.mak b/win32/install-msvc.mak
index 0b541bd9..09416830 100644
--- a/win32/install-msvc.mak
+++ b/win32/install-msvc.mak
@@ -5,8 +5,10 @@ install: all
@if not exist $(PREFIX)\bin\ mkdir $(PREFIX)\bin
@if not exist $(PREFIX)\lib\gdk-pixbuf-2.0\2.10.0\loaders\ mkdir
$(PREFIX)\lib\gdk-pixbuf-2.0\2.10.0\loaders
@if not exist $(PREFIX)\include\librsvg-$(RSVG_API_VER)\librsvg @mkdir
$(PREFIX)\include\librsvg-$(RSVG_API_VER)\librsvg
- @for %%x in (dll pdb) do @copy /b $(LIBRSVG_DLL_FILENAME).%%x $(PREFIX)\bin
+ @copy /b $(OUTDIR)\rsvg-2*.dll $(PREFIX)\bin
+ @copy /b $(OUTDIR)\rsvg_2.pdb $(PREFIX)\bin
@copy /b $(LIBRSVG_LIB) $(PREFIX)\lib
+ @copy /b $(LIBRSVG_LIB:-2.0=-2-static) $(PREFIX)\lib
@for %%x in (dll pdb) do @copy /b $(OUTDIR)\libpixbufloader-svg.%%x
$(PREFIX)\lib\gdk-pixbuf-2.0\2.10.0\loaders
@copy $(OUTDIR)\rsvg-convert.exe $(PREFIX)\bin
@-copy $(OUTDIR)\rsvg_convert.pdb $(PREFIX)\bin
@@ -21,7 +23,16 @@ install: all
@if exist $(OUTDIR)\Rsvg-$(RSVG_API_VER).gir copy $(OUTDIR)\Rsvg-$(RSVG_API_VER).gir
$(PREFIX)\share\gir-1.0
@if exist $(OUTDIR)\Rsvg-$(RSVG_API_VER).typelib if not exist $(PREFIX)\lib\girepository-1.0\ mkdir
$(PREFIX)\lib\girepository-1.0
@if exist $(OUTDIR)\Rsvg-$(RSVG_API_VER).typelib copy /b $(OUTDIR)\Rsvg-$(RSVG_API_VER).typelib
$(PREFIX)\lib\girepository-1.0
- @-$(PYTHON) rsvgpc.py --version=$(RSVG_PKG_VERSION) --prefix=$(PREFIX)
- @if not exist librsvg-2.0.pc echo *** librsvg-2.0.pc is not generated! Generate it later using
^$(PYTHON) --version=$(RSVG_PKG_VERSION) --prefix=^$(PREFIX)
- @if exist librsvg-2.0.pc if not exist $(PREFIX)\lib\pkgconfig mkdir $(PREFIX)\lib\pkgconfig
- @if exist librsvg-2.0.pc move librsvg-2.0.pc $(PREFIX)\lib\pkgconfig
+ @-$(PYTHON) rsvgpc.py --version=$(RSVG_PKG_VERSION) --prefix=$(PREFIX)
--source=$(OUTDIR)\librsvg-2.0.pc -o $(OUTDIR)\librsvg-2.0.pc.real
+ @if not exist $(OUTDIR)\librsvg-2.0.pc.real echo *** librsvg-2.0.pc may not contain a ^$prefix that
matches your build config. Please check it.
+ @if not exist $(PREFIX)\lib\pkgconfig mkdir $(PREFIX)\lib\pkgconfig
+ @if exist $(OUTDIR)\librsvg-2.0.pc.real copy $(OUTDIR)\librsvg-2.0.pc.real
$(PREFIX)\lib\pkgconfig\librsvg-2.0.pc
+ @if not exist $(OUTDIR)\librsvg-2.0.pc.real copy $(OUTDIR)\librsvg-2.0.pc $(PREFIX)\lib\pkgconfig
+ @echo.
+ @echo ******* WARNING *******
+ @echo People upgrading from librsvg-2.50.x or earlier
+ @echo may want to consider recompiling their application
+ @echo against this build of librsvg, as $(LIBRSVG_DLL)
+ @echo is provided as a convenience and linking against
+ @echo rsvg-2.0.lib will now always link to rsvg-2.dll.
+ @echo ******* WARNING *******
diff --git a/win32/pc_base.py b/win32/pc_base.py
index a65955d8..e6e89363 100644
--- a/win32/pc_base.py
+++ b/win32/pc_base.py
@@ -23,7 +23,8 @@ class BasePCItems:
self.libdir = ''
self.prefix = ''
self.srcdir = os.path.dirname(__file__)
- self.top_srcdir = self.srcdir + os.sep + '..'
+ self.source = ''
+ self.output = ''
self.version = ''
def setup(self, argv, parser=None):
@@ -42,14 +43,24 @@ class BasePCItems:
if different from ${prefix}/lib')
parser.add_argument('--version', help='Version of the package',
required=True)
+ parser.add_argument('--source', help='Base pc file template',
+ required=True)
+ parser.add_argument( '-o', '--output', help='Output of processed pc file',
+ required=True)
args = parser.parse_args()
self.version = args.version
+ self.source = args.source
+ self.output = args.output
# check whether the prefix and exec_prefix are valid
if not os.path.exists(args.prefix):
raise SystemExit('Specified prefix \'%s\' is invalid' % args.prefix)
+ # check whether output directory is valid
+ if not os.path.exists(os.path.dirname(self.output)):
+ raise SystemExit('Specified path for output \'%s\' is invalid' % self.output)
+
# use absolute paths for prefix
self.prefix = os.path.abspath(args.prefix).replace('\\','/')
diff --git a/win32/rsvg-rust.mak b/win32/rsvg-rust.mak
index 722f1eec..e38afb94 100644
--- a/win32/rsvg-rust.mak
+++ b/win32/rsvg-rust.mak
@@ -100,16 +100,16 @@ build-$(PLAT)-$(CFG).pre.bat:
build-$(PLAT)-$(CFG)-lib.bat: build-$(PLAT)-$(CFG).pre.bat
@type $**>$@
- @echo $(CARGO_CMD) --verbose --lib>>$@
+ @echo $(CARGO_CMD: build = cbuild )>>$@
build-$(PLAT)-$(CFG)-bin.bat: build-$(PLAT)-$(CFG).pre.bat
@type $**>$@
- @echo $(CARGO_CMD) --verbose --bin rsvg-convert>>$@
+ @echo $(CARGO_CMD) --bin rsvg-convert>>$@
-vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_c_api\$(RUST_TARGET)-pc-windows-msvc\$(CFG)\librsvg.lib:
build-$(PLAT)-$(CFG)-lib.bat
+vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_c_api\$(RUST_TARGET)-pc-windows-msvc\$(CFG)\rsvg-2.dll.lib:
build-$(PLAT)-$(CFG)-lib.bat
vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_c_api\$(RUST_TARGET)-pc-windows-msvc\$(CFG)\rsvg-convert.exe:
build-$(PLAT)-$(CFG)-bin.bat
-vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_c_api\$(RUST_TARGET)-pc-windows-msvc\$(CFG)\librsvg.lib \
+vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_c_api\$(RUST_TARGET)-pc-windows-msvc\$(CFG)\rsvg-2.dll.lib \
vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_c_api\$(RUST_TARGET)-pc-windows-msvc\$(CFG)\rsvg-convert.exe:
@echo Please do not manually close the command window that pops up...
@echo.
@@ -120,7 +120,7 @@ vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_c_api\$(RUST_TARGET)-pc-windows-msvc\$(CFG)\r
@start "Building the Rust bits for $(PLAT) Windows MSVC Build, please do not close this console
window..." /wait /i cmd /c $**
!else
-vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_c_api\$(RUST_TARGET)-pc-windows-msvc\$(CFG)\librsvg.lib:
+vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_c_api\$(RUST_TARGET)-pc-windows-msvc\$(CFG)\rsvg-2.dll.lib:
@set PATH=%PATH%;%HOMEPATH%\.cargo\bin
@set CARGO_TARGET_DIR=win32\vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_c_api
@set GTK_LIB_DIR=$(LIBDIR);$(LIB)
@@ -129,7 +129,7 @@ vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_c_api\$(RUST_TARGET)-pc-windows-msvc\$(CFG)\l
@if not "$(PKG_CONFIG)" == "" set PKG_CONFIG=$(PKG_CONFIG)
$(RUSTUP_CMD)
@cd ..
- $(CARGO_CMD) --verbose --lib
+ $(CARGO_CMD: build = cbuild )
@cd win32
@set GTK_LIB_DIR=
@set CARGO_TARGET_DIR=
@@ -143,7 +143,7 @@ vs$(VSVER)\$(CFG)\$(PLAT)\obj\rsvg_c_api\$(RUST_TARGET)-pc-windows-msvc\$(CFG)\r
@if not "$(PKG_CONFIG)" == "" set PKG_CONFIG=$(PKG_CONFIG)
$(RUSTUP_CMD)
@cd ..
- $(CARGO_CMD) --verbose --bin $(@B)
+ $(CARGO_CMD) --bin $(@B)
@cd win32
@set GTK_LIB_DIR=
@set CARGO_TARGET_DIR=
diff --git a/win32/rsvgpc.py b/win32/rsvgpc.py
index d913352e..24466345 100644
--- a/win32/rsvgpc.py
+++ b/win32/rsvgpc.py
@@ -18,16 +18,13 @@ def main(argv):
base_pc = BasePCItems()
base_pc.setup(argv)
- pkg_replace_items = {'@RSVG_API_MAJOR_VERSION@': rsvg_api_ver,
- '@RSVG_API_VERSION@': rsvg_api_ver,
- ' cairo': '',
- '-lm': '-lcairo'}
+ pkg_replace_items = {'prefix=/usr/local': 'prefix=' + base_pc.prefix}
pkg_replace_items.update(base_pc.base_replace_items)
# Generate librsvg-$(rsvg_api_ver).pc
- replace_multi(base_pc.top_srcdir + '/librsvg.pc.in',
- base_pc.srcdir + '/librsvg-' + rsvg_api_ver + '.pc',
+ replace_multi(base_pc.source,
+ base_pc.output,
pkg_replace_items)
if __name__ == '__main__':
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]