diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2016-04-20 18:02:27 +0800 |
---|---|---|
committer | Chun-wei Fan <fanchunwei@src.gnome.org> | 2016-04-20 18:02:27 +0800 |
commit | 77f85f7cd9d2cbb6e05cd9139741dbd06b110d0e (patch) | |
tree | 3f7c0481c9a86737f96d318cea23493bdedce9b1 | |
parent | 03fe9395290be5b49a17594e918f062cab45655e (diff) | |
download | atk-77f85f7cd9d2cbb6e05cd9139741dbd06b110d0e.tar.gz |
Visual Studio builds: Generate atk.pc
...if Python can be found via $(PythonPath) (x86 builds) or
$(PythonPathX64) (x64 builds). This makes it easier for packages that
requires atk.pc for introspection.
-rw-r--r-- | build/win32/Makefile.am | 3 | ||||
-rw-r--r-- | build/win32/atkpc.py | 31 | ||||
-rw-r--r-- | build/win32/pc_base.py | 107 | ||||
-rw-r--r-- | build/win32/replace.py | 109 | ||||
-rw-r--r-- | build/win32/vs10/Makefile.am | 1 | ||||
-rw-r--r-- | build/win32/vs10/atk-install.propsin | 9 | ||||
-rw-r--r-- | build/win32/vs10/atk-install.vcxproj | 18 | ||||
-rw-r--r-- | build/win32/vs10/atk-install.vcxproj.filters | 13 | ||||
-rw-r--r-- | build/win32/vs10/atk-version-paths.props.in | 8 | ||||
-rw-r--r-- | build/win32/vs11/Makefile.am | 1 | ||||
-rw-r--r-- | build/win32/vs12/Makefile.am | 1 | ||||
-rw-r--r-- | build/win32/vs14/Makefile.am | 1 | ||||
-rw-r--r-- | build/win32/vs9/atk-install.vcproj | 40 | ||||
-rw-r--r-- | build/win32/vs9/atk-install.vspropsin | 10 | ||||
-rw-r--r-- | build/win32/vs9/atk-version-paths.vsprops.in | 8 |
15 files changed, 359 insertions, 1 deletions
diff --git a/build/win32/Makefile.am b/build/win32/Makefile.am index 39eca58..4d0a309 100644 --- a/build/win32/Makefile.am +++ b/build/win32/Makefile.am @@ -30,4 +30,7 @@ EXTRA_DIST = \ detectenv-msvc.mak \ introspection-msvc.mak \ atk-introspection-msvc.mak \ + atkpc.py \ + pc_base.py \ + replace.py \ $(GENERATED_ITEMS) diff --git a/build/win32/atkpc.py b/build/win32/atkpc.py new file mode 100644 index 0000000..d6c6fdb --- /dev/null +++ b/build/win32/atkpc.py @@ -0,0 +1,31 @@ +#!/usr/bin/python +# +# Utility script to generate .pc files for ATK +# for Visual Studio builds, to be used for +# building introspection files + +# Author: Fan, Chun-wei +# Date: April 20, 2016 + +import os +import sys + +from replace import replace_multi +from pc_base import BasePCItems + +def main(argv): + base_pc = BasePCItems() + + base_pc.setup(argv) + pkg_replace_items = {'@GLIB_PACKAGES@': 'gobject-2.0,glib-2.0', + '@ATK_API_VERSION@': '1.0'} + + pkg_replace_items.update(base_pc.base_replace_items) + + # Generate atk.pc + replace_multi(base_pc.top_srcdir + '/atk.pc.in', + base_pc.srcdir + '/atk.pc', + pkg_replace_items) + +if __name__ == '__main__': + sys.exit(main(sys.argv)) diff --git a/build/win32/pc_base.py b/build/win32/pc_base.py new file mode 100644 index 0000000..80f9884 --- /dev/null +++ b/build/win32/pc_base.py @@ -0,0 +1,107 @@ +#!/usr/bin/python +# +# Simple utility script to generate the basic info +# needed in a .pc (pkg-config) file, used especially +# for introspection purposes + +# This can be used in various projects where +# there is the need to generate .pc files, +# and is copied from GLib's $(srcroot)/build/win32 + +# Author: Fan, Chun-wei +# Date: March 10, 2016 + +import os +import sys +import argparse + +class BasePCItems: + def __init__(self): + self.base_replace_items = {} + self.exec_prefix = '' + self.includedir = '' + self.libdir = '' + self.prefix = '' + self.srcdir = os.path.dirname(__file__) + self.top_srcdir = self.srcdir + '\\..\\..' + self.version = '' + + def setup(self, argv): + parser = argparse.ArgumentParser(description='Setup basic .pc file info') + parser.add_argument('--prefix', help='prefix of the installed library', + required=True) + parser.add_argument('--exec-prefix', + help='prefix of the installed programs, \ + if different from the prefix') + parser.add_argument('--includedir', + help='includedir of the installed library, \ + if different from ${prefix}/include') + parser.add_argument('--libdir', + help='libdir of the installed library, \ + if different from ${prefix}/lib') + parser.add_argument('--version', help='Version of the package', + required=True) + args = parser.parse_args() + + self.version = args.version + + # 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 and setup the exec_prefix + if getattr(args, 'exec_prefix', None) is None: + input_exec_prefix = args.prefix + else: + input_exec_prefix = args.exec_prefix + if not os.path.exists(input_exec_prefix): + raise SystemExit('Specified exec-prefix \'%s\' is invalid' % + input_exec_prefix) + + + # check and setup the includedir + if getattr(args, 'includedir', None) is None: + self.includedir = '${prefix}/include' + else: + if args.includedir.startswith('${prefix}'): + includedir_use_shorthand = True + input_includedir = args.prefix + args.includedir[len('${prefix}'):] + else: + includedir_use_shorthand = False + input_includedir = args.includedir + if not os.path.exists(input_includedir): + raise SystemExit('Specified includedir \'%s\' is invalid' % + args.includedir) + if includedir_use_shorthand is True: + self.includedir = args.includedir.replace('\\','/') + else: + self.includedir = os.path.abspath(input_includedir).replace('\\','/') + + # check and setup the libdir + if getattr(args, 'libdir', None) is None: + self.libdir = '${prefix}/lib' + else: + if args.libdir.startswith('${prefix}'): + libdir_use_shorthand = True + input_libdir = args.prefix + args.libdir[len('${prefix}'):] + else: + libdir_use_shorthand = False + input_libdir = args.libdir + if not os.path.exists(input_libdir): + raise SystemExit('Specified libdir \'%s\' is invalid' % + args.libdir) + if libdir_use_shorthand is True: + self.libdir = args.libdir.replace('\\','/') + else: + self.libdir = os.path.abspath(input_libdir).replace('\\','/') + + # use absolute paths for prefix and exec_prefix + self.prefix = os.path.abspath(args.prefix).replace('\\','/') + self.exec_prefix = os.path.abspath(input_exec_prefix).replace('\\','/') + + # setup dictionary for replacing items in *.pc.in + self.base_replace_items.update({'@VERSION@': self.version}) + self.base_replace_items.update({'@prefix@': self.prefix}) + self.base_replace_items.update({'@exec_prefix@': self.exec_prefix}) + self.base_replace_items.update({'@libdir@': self.libdir}) + self.base_replace_items.update({'@includedir@': self.includedir}) diff --git a/build/win32/replace.py b/build/win32/replace.py new file mode 100644 index 0000000..a81bab9 --- /dev/null +++ b/build/win32/replace.py @@ -0,0 +1,109 @@ +#!/usr/bin/python +# +# Simple utility script to manipulate +# certain types of strings in a file + +# This can be used in various projects where +# there is the need to replace strings in files, +# and is copied from GLib's $(srcroot)/build/win32 + +# Author: Fan, Chun-wei +# Date: September 03, 2014 + +import os +import sys +import re +import string +import argparse + +valid_actions = ['remove-prefix', + 'replace-var', + 'replace-str', + 'remove-str'] + +def replace_multi(src, dest, replace_items): + with open(src, 'r') as s: + with open(dest, 'w') as d: + for line in s: + replace_dict = dict((re.escape(key), value) \ + for key, value in replace_items.items()) + replace_pattern = re.compile("|".join(replace_dict.keys())) + d.write(replace_pattern.sub(lambda m: \ + replace_dict[re.escape(m.group(0))], line)) + +def replace(src, dest, instring, outstring): + replace_item = {instring: outstring} + replace_multi(src, dest, replace_item) + +def check_required_args(args, params): + for param in params: + if getattr(args, param, None) is None: + raise SystemExit('%s: error: --%s argument is required' % (__file__, param)) + +def warn_ignored_args(args, params): + for param in params: + if getattr(args, param, None) is not None: + print('%s: warning: --%s argument is ignored' % (__file__, param)) + +def main(argv): + + parser = argparse.ArgumentParser(description='Process strings in a file.') + parser.add_argument('-a', + '--action', + help='Action to carry out. Can be one of:\n' + 'remove-prefix\n' + 'replace-var\n' + 'replace-str\n' + 'remove-str', + choices=valid_actions) + parser.add_argument('-i', '--input', help='Input file') + parser.add_argument('-o', '--output', help='Output file') + parser.add_argument('--instring', help='String to replace or remove') + parser.add_argument('--var', help='Autotools variable name to replace') + parser.add_argument('--outstring', + help='New String to replace specified string or variable') + parser.add_argument('--removeprefix', help='Prefix of string to remove') + + args = parser.parse_args() + + input_string = '' + output_string = '' + + # We must have action, input, output for all operations + check_required_args(args, ['action','input','output']) + + # Build the arguments by the operation that is to be done, + # to be fed into replace() + + # Get rid of prefixes from a string + if args.action == 'remove-prefix': + check_required_args(args, ['instring','removeprefix']) + warn_ignored_args(args, ['outstring','var']) + input_string = args.removeprefix + args.instring + output_string = args.instring + + # Replace an m4-style variable (those surrounded by @...@) + if args.action == 'replace-var': + check_required_args(args, ['var','outstring']) + warn_ignored_args(args, ['instring','removeprefix']) + input_string = '@' + args.var + '@' + output_string = args.outstring + + # Replace a string + if args.action == 'replace-str': + check_required_args(args, ['instring','outstring']) + warn_ignored_args(args, ['var','removeprefix']) + input_string = args.instring + output_string = args.outstring + + # Remove a string + if args.action == 'remove-str': + check_required_args(args, ['instring']) + warn_ignored_args(args, ['var','outstring','removeprefix']) + input_string = args.instring + output_string = '' + + replace(args.input, args.output, input_string, output_string) + +if __name__ == '__main__': + sys.exit(main(sys.argv)) diff --git a/build/win32/vs10/Makefile.am b/build/win32/vs10/Makefile.am index 98a8598..8a3f7c4 100644 --- a/build/win32/vs10/Makefile.am +++ b/build/win32/vs10/Makefile.am @@ -9,6 +9,7 @@ EXTRA_DIST = \ atk.vcxprojin \ atk.vcxproj.filtersin \ atk-install.vcxproj \ + atk-install.vcxproj.filters \ atk-build-defines.props \ atk-gen-src.props \ atk-install.propsin \ diff --git a/build/win32/vs10/atk-install.propsin b/build/win32/vs10/atk-install.propsin index 96236e8..b790fa8 100644 --- a/build/win32/vs10/atk-install.propsin +++ b/build/win32/vs10/atk-install.propsin @@ -16,9 +16,13 @@ mkdir $(CopyDir)\lib copy $(BinDir)\atk-$(ApiVersion).lib $(CopyDir)\lib mkdir $(CopyDir)\include\atk-$(ApiVersion)\atk - #include "atk.vs10.headers" + +if exist ..\atk.pc (mkdir $(CopyDir)\lib\pkgconfig & copy ..\atk.pc $(CopyDir)\lib\pkgconfig) </AtkDoInstall> + <AtkGenPC>if exist $(PythonPath)\python.exe $(PythonPath)\python.exe ..\atkpc.py --prefix=$(CopyDir) --version=$(AtkMajorVersion).$(AtkMinorVersion).$(AtkMicroVersion)</AtkGenPC> + <AtkGenPCX64>if exist $(PythonPathX64)\python.exe $(PythonPathX64)\python.exe ..\atkpc.py --prefix=$(CopyDir) --version=$(AtkMajorVersion).$(AtkMinorVersion).$(AtkMicroVersion)</AtkGenPCX64> + <AtkPCFiles>..\atk.pc</AtkPCFiles> </PropertyGroup> <ItemGroup> <BuildMacro Include="BinDir"> @@ -30,5 +34,8 @@ mkdir $(CopyDir)\include\atk-$(ApiVersion)\atk <BuildMacro Include="AtkDoInstall"> <Value>$(AtkDoInstall)</Value> </BuildMacro> + <BuildMacro Include="AtkPCFiles"> + <Value>$(AtkPCFiles)</Value> + </BuildMacro> </ItemGroup> </Project> diff --git a/build/win32/vs10/atk-install.vcxproj b/build/win32/vs10/atk-install.vcxproj index eaecd21..cd50bde 100644 --- a/build/win32/vs10/atk-install.vcxproj +++ b/build/win32/vs10/atk-install.vcxproj @@ -87,18 +87,36 @@ <ItemGroup> <CustomBuild Include="..\..\..\config.h.win32"> <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Installing Build Results...</Message> + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(AtkPCFiles)</AdditionalInputs> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(AtkDoInstall)</Command> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(InstalledDlls);%(Outputs)</Outputs> <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Installing Build Results...</Message> + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(AtkPCFiles)</AdditionalInputs> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(AtkDoInstall)</Command> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(InstalledDlls);%(Outputs)</Outputs> <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Installing Build Results...</Message> + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(AtkPCFiles)</AdditionalInputs> <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(AtkDoInstall)</Command> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(InstalledDlls);%(Outputs)</Outputs> <Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Installing Build Results...</Message> + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(AtkPCFiles)</AdditionalInputs> <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(AtkDoInstall)</Command> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(InstalledDlls);%(Outputs)</Outputs> </CustomBuild> + <CustomBuild Include="..\..\..\atk.pc.in"> + <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Generating atk.pc...</Message> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(AtkGenPC)</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(AtkPCFiles);%(Outputs)</Outputs> + <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Generating atk.pc...</Message> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(AtkGenPCX64)</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(AtkPCFiles);%(Outputs)</Outputs> + <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Generating atk.pc...</Message> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(AtkGenPC)</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(AtkPCFiles);%(Outputs)</Outputs> + <Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Generating atk.pc...</Message> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(AtkGenPCX64)</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(AtkPCFiles);%(Outputs)</Outputs> + </CustomBuild> </ItemGroup> <ItemGroup> <ProjectReference Include="atk.vcxproj"> diff --git a/build/win32/vs10/atk-install.vcxproj.filters b/build/win32/vs10/atk-install.vcxproj.filters new file mode 100644 index 0000000..946051b --- /dev/null +++ b/build/win32/vs10/atk-install.vcxproj.filters @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <CustomBuild Include="..\..\..\config.h.win32"><Filter>Resource Files</Filter></CustomBuild> + <CustomBuild Include="..\..\..\atk.pc.in"><Filter>Resource Files</Filter></CustomBuild> + </ItemGroup> +</Project> diff --git a/build/win32/vs10/atk-version-paths.props.in b/build/win32/vs10/atk-version-paths.props.in index 6ea7baf..1c862a0 100644 --- a/build/win32/vs10/atk-version-paths.props.in +++ b/build/win32/vs10/atk-version-paths.props.in @@ -14,6 +14,8 @@ <AtkSeparateVSDllSuffix>-1-vs$(VSVer)</AtkSeparateVSDllSuffix> <AtkDllPrefix>$(AtkSeparateVSDllPrefix)</AtkDllPrefix> <AtkDllSuffix>$(AtkSeparateVSDllSuffix)</AtkDllSuffix> + <PythonPath>c:\python34</PythonPath> + <PythonPathX64>$(PythonPath).x64</PythonPathX64> </PropertyGroup> <PropertyGroup> <_PropertySheetDisplayName>atkversionpathsprops</_PropertySheetDisplayName> @@ -55,5 +57,11 @@ <BuildMacro Include="AtkDllSuffix"> <Value>$(AtkDllSuffix)</Value> </BuildMacro> + <BuildMacro Include="PythonPath"> + <Value>$(PythonPath)</Value> + </BuildMacro> + <BuildMacro Include="PythonPathX64"> + <Value>$(PythonPathX64)</Value> + </BuildMacro> </ItemGroup> </Project> diff --git a/build/win32/vs11/Makefile.am b/build/win32/vs11/Makefile.am index f31c518..0942dbd 100644 --- a/build/win32/vs11/Makefile.am +++ b/build/win32/vs11/Makefile.am @@ -4,6 +4,7 @@ EXTRA_DIST = \ atk.vcxproj \ atk.vcxproj.filters \ atk-install.vcxproj \ + atk-install.vcxproj.filters \ atk-build-defines.props \ atk-install.props \ atk-version-paths.props \ diff --git a/build/win32/vs12/Makefile.am b/build/win32/vs12/Makefile.am index c9330db..f81187a 100644 --- a/build/win32/vs12/Makefile.am +++ b/build/win32/vs12/Makefile.am @@ -4,6 +4,7 @@ EXTRA_DIST = \ atk.vcxproj \ atk.vcxproj.filters \ atk-install.vcxproj \ + atk-install.vcxproj.filters \ atk-build-defines.props \ atk-install.props \ atk-version-paths.props \ diff --git a/build/win32/vs14/Makefile.am b/build/win32/vs14/Makefile.am index 140e7c5..683b602 100644 --- a/build/win32/vs14/Makefile.am +++ b/build/win32/vs14/Makefile.am @@ -4,6 +4,7 @@ EXTRA_DIST = \ atk.vcxproj \ atk.vcxproj.filters \ atk-install.vcxproj \ + atk-install.vcxproj.filters \ atk-build-defines.props \ atk-install.props \ atk-version-paths.props \ diff --git a/build/win32/vs9/atk-install.vcproj b/build/win32/vs9/atk-install.vcproj index a956dfc..2254f8b 100644 --- a/build/win32/vs9/atk-install.vcproj +++ b/build/win32/vs9/atk-install.vcproj @@ -76,6 +76,46 @@ <References> </References> <Files> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" + > + <File RelativePath="..\..\..\atk.pc.in"> + <FileConfiguration Name="Debug|Win32"> + <Tool + Name="VCCustomBuildTool" + Description="Generating atk.pc..." + CommandLine="$(AtkGenPC)" + Outputs="..\atk.pc" + /> + </FileConfiguration> + <FileConfiguration Name="Release|Win32"> + <Tool + Name="VCCustomBuildTool" + Description="Generating atk.pc..." + CommandLine="$(AtkGenPC)" + Outputs="..\atk.pc" + /> + </FileConfiguration> + <FileConfiguration Name="Debug|x64"> + <Tool + Name="VCCustomBuildTool" + Description="Generating atk.pc..." + CommandLine="$(AtkGenPCX64)" + Outputs="..\atk.pc" + /> + </FileConfiguration> + <FileConfiguration Name="Release|x64"> + <Tool + Name="VCCustomBuildTool" + Description="Generating atk.pc..." + CommandLine="$(AtkGenPCX64)" + Outputs="..\atk.pc" + /> + </FileConfiguration> + </File> + </Filter> </Files> <Globals> </Globals> diff --git a/build/win32/vs9/atk-install.vspropsin b/build/win32/vs9/atk-install.vspropsin index 4a44d5a..aed8fd5 100644 --- a/build/win32/vs9/atk-install.vspropsin +++ b/build/win32/vs9/atk-install.vspropsin @@ -18,6 +18,16 @@ copy $(SolutionDir)$(ConfigurationName)\$(PlatformName)\bin\atk-$(ApiVersion).li mkdir $(CopyDir)\include\atk-$(ApiVersion)\atk
 #include "atk.headers" + +if exist ..\atk.pc (mkdir $(CopyDir)\lib\pkgconfig & copy ..\atk.pc $(CopyDir)\lib\pkgconfig)
 " /> + <UserMacro + Name="AtkGenPC" + Value="if exist $(PythonPath)\python.exe $(PythonPath)\python.exe ..\atkpc.py --prefix=$(CopyDir) --version=$(AtkMajorVersion).$(AtkMinorVersion).$(AtkMicroVersion)" + /> + <UserMacro + Name="AtkGenPCX64" + Value="if exist $(PythonPathX64)\python.exe $(PythonPathX64)\python.exe ..\atkpc.py --prefix=$(CopyDir) --version=$(AtkMajorVersion).$(AtkMinorVersion).$(AtkMicroVersion)" + /> </VisualStudioPropertySheet> diff --git a/build/win32/vs9/atk-version-paths.vsprops.in b/build/win32/vs9/atk-version-paths.vsprops.in index c7c570a..c56b0ac 100644 --- a/build/win32/vs9/atk-version-paths.vsprops.in +++ b/build/win32/vs9/atk-version-paths.vsprops.in @@ -58,4 +58,12 @@ Name="AtkDllSuffix" Value="$(AtkSeparateVSDllSuffix)" /> + <UserMacro + Name="PythonPath" + Value="c:\python27" + /> + <UserMacro + Name="PythonPathX64" + Value="$(PythonPath).x64" + /> </VisualStudioPropertySheet> |