From c3725000182ef974e1e120c299adaa0377284dc9 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 14 Nov 2018 14:51:58 -0800 Subject: [PATCH] update for nuget/core Signed-off-by: Nikolaj Bjorner --- scripts/mk_util.py | 103 ++++++++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 43 deletions(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 4037b3996..bd455b95e 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -562,6 +562,11 @@ def set_version(major, minor, build, revision): def get_version(): return (VER_MAJOR, VER_MINOR, VER_BUILD, VER_REVISION) +def get_version_string(n): + if n == 3: + return "{}.{}.{}".format(VER_MAJOR,VER_MINOR,VER_BUILD) + return "{}.{}.{}.{}".format(VER_MAJOR,VER_MINOR,VER_BUILD,VER_REVISION) + def build_static_lib(): return STATIC_LIB @@ -1639,11 +1644,7 @@ class DotNetDLLComponent(Component): pkg_config_template = os.path.join(self.src_dir, '{}.pc.in'.format(self.gac_pkg_name())) substitutions = { 'PREFIX': PREFIX, 'GAC_PKG_NAME': self.gac_pkg_name(), - 'VERSION': "{}.{}.{}.{}".format( - VER_MAJOR, - VER_MINOR, - VER_BUILD, - VER_REVISION) + 'VERSION': get_version_string(4) } pkg_config_output = os.path.join(BUILD_DIR, self.build_dir, @@ -1838,30 +1839,14 @@ class DotNetCoreDLLComponent(Component): self.assembly_info_dir = assembly_info_dir self.key_file = default_key_file - def mk_pkg_config_file(self): + def mk_nuget_config_file(self): # TBD revise """ - Create pkgconfig file for the dot net bindings. These + Create nuget file for the dot net bindings. These are needed by Monodevelop. """ - pkg_config_template = os.path.join(self.src_dir, '{}.pc.in'.format(self.gac_pkg_name())) - substitutions = { 'PREFIX': PREFIX, - 'GAC_PKG_NAME': self.gac_pkg_name(), - 'VERSION': "{}.{}.{}.{}".format( - VER_MAJOR, - VER_MINOR, - VER_BUILD, - VER_REVISION) - } - pkg_config_output = os.path.join(BUILD_DIR, - self.build_dir, - '{}.pc'.format(self.gac_pkg_name())) - - # FIXME: Why isn't the build directory available? - mk_dir(os.path.dirname(pkg_config_output)) - # Configure file that will be installed by ``make install``. - configure_file(pkg_config_template, pkg_config_output, substitutions) - + return + def mk_makefile(self, out): global DOTNET_KEY_FILE if not is_dotnet_core_enabled(): @@ -1879,26 +1864,55 @@ class DotNetCoreDLLComponent(Component): out.write(cs_file) out.write('\n') - csproj = os.path.join(self.to_src_dir, "core", "core.csproj") + if VS_X64: + platform = 'x64' + elif VS_ARM: + platform = 'ARM' + else: + platform = 'x86' + + version = get_version_string(3) + + core_csproj_str = """ + + + netcoreapp1.0 + %s + $(DefineConstants);DOTNET_CORE + portable + Microsoft.Z3 + Library + Microsoft.Z3 + $(PackageTargetFallback);dnxcore50 + 1.0.4 + %s + true + Microsoft + Microsoft + Z3 is a satisfiability modulo theories solver from Microsoft Research. + © Microsoft Corporation. All rights reserved. + smt constraint solver theorem prover + + + + + + +""" % (platform, version, self.to_src_dir) + + mk_dir(os.path.join(BUILD_DIR, 'dotnet')) + csproj = os.path.join('dotnet', 'z3.csproj') + with open(os.path.join(BUILD_DIR, csproj), 'w') as ous: + ous.write(core_csproj_str) + dotnetCmdLine = [DOTNET, "build", csproj] - # TBD: select build configurations also based on architecture - # Debug|x86, Debug|x64, Debug|arm - # Release|x86, Release|x64, Release|arm dotnetCmdLine.extend(['-c']) if DEBUG_MODE: dotnetCmdLine.extend(['Debug']) else: dotnetCmdLine.extend(['Release']) - if IS_WINDOWS: - runtime = "win-" + ("x64" if VS_X64 else "x86") - elif IS_LINUX: - runtime = "linux-x64" if LINUX_X64 else "" - elif IS_OSX: - runtime = "osx-x64" if LINUX_X64 else "" - if runtime != "": - dotnetCmdLine.extend(['-r', runtime]) path = os.path.abspath(BUILD_DIR) dotnetCmdLine.extend(['-o', path]) @@ -1911,8 +1925,8 @@ class DotNetCoreDLLComponent(Component): out.write('\n') out.write('%s: %s\n\n' % (self.name, dllfile)) - # Create pkg-config file - self.mk_pkg_config_file() + # Create nuget file + self.mk_nuget_config_file() return def main_component(self): @@ -1926,8 +1940,8 @@ class DotNetCoreDLLComponent(Component): mk_dir(os.path.join(dist_path, INSTALL_BIN_DIR)) shutil.copy('%s.dll' % os.path.join(build_path, self.dll_name), '%s.dll' % os.path.join(dist_path, INSTALL_BIN_DIR, self.dll_name)) - shutil.copy('%s.xml' % os.path.join(build_path, self.dll_name), - '%s.xml' % os.path.join(dist_path, INSTALL_BIN_DIR, self.dll_name)) + shutil.copy('%s.deps.json' % os.path.join(build_path, self.dll_name), + '%s.deps.json' % os.path.join(dist_path, INSTALL_BIN_DIR, self.dll_name)) if DEBUG_MODE: shutil.copy('%s.pdb' % os.path.join(build_path, self.dll_name), '%s.pdb' % os.path.join(dist_path, INSTALL_BIN_DIR, self.dll_name)) @@ -1937,8 +1951,8 @@ class DotNetCoreDLLComponent(Component): mk_dir(os.path.join(dist_path, INSTALL_BIN_DIR)) shutil.copy('%s.dll' % os.path.join(build_path, self.dll_name), '%s.dll' % os.path.join(dist_path, INSTALL_BIN_DIR, self.dll_name)) - shutil.copy('%s.xml' % os.path.join(build_path, self.dll_name), - '%s.xml' % os.path.join(dist_path, INSTALL_BIN_DIR, self.dll_name)) + shutil.copy('%s.deps.json' % os.path.join(build_path, self.dll_name), + '%s.deps.json' % os.path.join(dist_path, INSTALL_BIN_DIR, self.dll_name)) def mk_install_deps(self, out): if not is_dotnet_core_enabled(): @@ -1949,6 +1963,7 @@ class DotNetCoreDLLComponent(Component): return "{}.Sharp".format(self.dll_name) def _install_or_uninstall_to_gac(self, out, install): + # TBD revise for nuget gacUtilFlags = ['/package {}'.format(self.gac_pkg_name()), '/root', '{}{}'.format(MakeRuleCmd.install_root(), INSTALL_LIB_DIR) @@ -1967,6 +1982,7 @@ class DotNetCoreDLLComponent(Component): flags=' '.join(gacUtilFlags))) def mk_install(self, out): + # TBD revise for nuget if not is_dotnet_core_enabled(): return self._install_or_uninstall_to_gac(out, install=True) @@ -1978,6 +1994,7 @@ class DotNetCoreDLLComponent(Component): MakeRuleCmd.install_files(out, pkg_config_output, INSTALL_PKGCONFIG_DIR) def mk_uninstall(self, out): + # TBD revise for nuget if not is_dotnet_core_enabled(): return self._install_or_uninstall_to_gac(out, install=False)