diff --git a/bootstrap.sh b/bootstrap.sh index fbf577e62..00dba3eb2 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -17,7 +17,8 @@ if [ $? -ne 0 ]; then exit 1 fi cd "$pwd" -cp "./src/engine/b2" . +cp "./src/engine/b2" . 2>/dev/null +cp "./src/engine/b2.exe" . 2>/dev/null cat << EOF diff --git a/src/tools/link.jam b/src/tools/link.jam index e9e8851fe..fa4070e34 100644 --- a/src/tools/link.jam +++ b/src/tools/link.jam @@ -229,8 +229,8 @@ class symlink-target-class : basic-target rule do-file-link { - local target = [ path.native [ path.relative-to [ path.pwd ] $(<) ] ] ; - local source = [ path.native [ path.relative-to [ path.pwd ] $(>) ] ] ; + local target = [ path.relative-to [ path.pwd ] $(<) ] ; + local source = [ path.relative-to [ path.pwd ] $(>) ] ; local old-source = [ on $(target) return $(LINK-SOURCE) ] ; if $(old-source) { @@ -240,6 +240,8 @@ rule do-file-link Link previously defined to another file, $(old-source[1]). ; } LINK-SOURCE on $(target) = $(source) $(.current-target) ; + target = [ path.native $(target) ] ; + source = [ path.native $(source) ] ; LOCATE on $(target) = . ; DEPENDS $(.current-target) : $(target) ; if $(.can-symlink) = true diff --git a/test/BoostBuild.py b/test/BoostBuild.py index 786ec392b..ff205f5b1 100644 --- a/test/BoostBuild.py +++ b/test/BoostBuild.py @@ -112,12 +112,9 @@ def get_toolset(): # Detect the host OS. -cygwin = hasattr(os, "uname") and os.uname()[0].lower().startswith("cygwin") -windows = cygwin or os.environ.get("OS", "").lower().startswith("windows") - -if cygwin: +if sys.platform == "cygwin": default_os = "cygwin" -elif windows: +elif sys.platform == "win32": default_os = "windows" elif hasattr(os, "uname"): default_os = os.uname()[0].lower() @@ -158,7 +155,7 @@ def prepare_suffix_map(toolset, target_os=default_os): if target_os == "cygwin": suffixes[".lib"] = ".a" suffixes[".obj"] = ".o" - suffixes[".implib"] = ".lib.a" + suffixes[".implib"] = ".dll.a" elif target_os == "windows": if toolset == "gcc": # MinGW @@ -196,6 +193,11 @@ def prepare_library_prefix(toolset, target_os=default_os): else: dll_prefix = "lib" + global implib_prefix + implib_prefix = None + if toolset == "gcc": + implib_prefix = "lib" + def re_remove(sequence, regex): me = re.compile(regex) @@ -268,7 +270,7 @@ class Tester(TestCmd.TestCmd): if not executable: executable = os.getenv('B2') if not executable: - executable = 'b2' if os.name != 'nt' else 'b2.exe' + executable = 'b2' if sys.platform not in ['win32', 'cygwin'] else 'b2.exe' assert arguments.__class__ is not str self.original_workdir = os.path.dirname(__file__) @@ -280,6 +282,7 @@ class Tester(TestCmd.TestCmd): self.translate_suffixes = translate_suffixes self.use_test_config = use_test_config + self.target_os = default_os self.toolset = get_toolset() self.expanded_toolset = expand_toolset(self.toolset) self.pass_toolset = pass_toolset @@ -341,11 +344,14 @@ class Tester(TestCmd.TestCmd): pass def set_toolset(self, toolset, target_os=default_os): + self.target_os = target_os self.toolset = toolset self.expanded_toolset = expand_toolset(toolset, target_os) self.pass_toolset = True prepare_prefixes_and_suffixes(toolset, target_os) + def is_implib_expected(self): + return self.target_os in ["windows", "cygwin"] and not self.toolset.startswith("clang-linux") # # Methods that change the working directory's content. @@ -741,7 +747,7 @@ class Tester(TestCmd.TestCmd): def __ignore_junk(self): # Not totally sure about this change, but I do not see a good # alternative. - if windows: + if self.target_os == "windows": self.ignore("*.ilk") # MSVC incremental linking files. self.ignore("*.pdb") # MSVC program database files. self.ignore("*.rsp") # Response files. @@ -838,21 +844,21 @@ class Tester(TestCmd.TestCmd): def adjust_lib_name(self, name): global lib_prefix global dll_prefix + global implib_prefix result = name pos = name.rfind(".") if pos != -1: suffix = name[pos:] - if suffix == ".lib": - (head, tail) = os.path.split(name) - if lib_prefix: - tail = lib_prefix + tail - result = os.path.join(head, tail) - elif suffix == ".dll" or suffix == ".implib": - (head, tail) = os.path.split(name) - if dll_prefix: - tail = dll_prefix + tail - result = os.path.join(head, tail) + prefix = { + ".lib": lib_prefix, + ".dll": dll_prefix, + ".implib": implib_prefix, + }.get(suffix) + (head, tail) = os.path.split(name) + if prefix: + tail = prefix + tail + result = os.path.join(head, tail) # If we want to use this name in a Jamfile, we better convert \ to /, # as otherwise we would have to quote \. result = result.replace("\\", "/") diff --git a/test/TestToolset.py b/test/TestToolset.py index a1d5167ef..4ae3b2af9 100644 --- a/test/TestToolset.py +++ b/test/TestToolset.py @@ -119,7 +119,7 @@ def test_toolset(toolset, version, property_sets): t.run_build_system(["--user-config=", "-sPYTHON_CMD=%s" % sys.executable] + properties) t.expect_addition("bin/%s/lib.obj" % (path("obj"))) if "link=static" not in properties: - if get_target_os(properties) in ["cygwin", "windows"] and toolset != "clang-linux": + if t.is_implib_expected(): t.expect_addition("bin/%s/l1.implib" % (path("dll"))) t.expect_addition("bin/%s/l1.dll" % (path("dll"))) t.ignore_addition("bin/%s/*l1.*.rsp" % (path("dll"))) diff --git a/test/builtin_readlink.py b/test/builtin_readlink.py index ea6dadf9a..a76c9a5c2 100755 --- a/test/builtin_readlink.py +++ b/test/builtin_readlink.py @@ -7,12 +7,14 @@ import BoostBuild import os import sys +from unittest.mock import patch t = BoostBuild.Tester(pass_toolset=0) t.write("link-target", "") try: - os.symlink("link-target", "link") + with patch.dict(os.environ, {var: "winsymlinks:nativestrict" for var in ["MSYS", "CYGWIN"]}): + os.symlink("link-target", "link") except (AttributeError, OSError) as e: # Either OS does not support symlinks or not enough privilege print("XFAIL: %s" % e) diff --git a/test/library_chain.py b/test/library_chain.py index f8d9dccb6..d4291c318 100644 --- a/test/library_chain.py +++ b/test/library_chain.py @@ -117,7 +117,7 @@ void a() {} t.run_build_system(subdir="a") t.expect_addition("a/dist/a.dll") -if sys.platform == 'win32': +if t.is_implib_expected(): # This is a Windows import library. file = t.adjust_name("a.implib") else: diff --git a/test/link.py b/test/link.py index 70a3d05c7..b2cfd1837 100755 --- a/test/link.py +++ b/test/link.py @@ -8,6 +8,8 @@ # common boost/ directory in the new git layout. import BoostBuild +import os +from unittest.mock import patch def ignore_config(t): """These files are created by the configuration logic in link.jam @@ -339,12 +341,14 @@ def test_error_duplicate(): t.cleanup() -test_basic() -test_merge_two() -test_merge_existing_all() -test_merge_recursive() -test_merge_recursive_existing_all() -test_include_scan() -test_include_scan_merge_existing() -test_update_file_link_all() -test_error_duplicate() + +with patch.dict(os.environ, {var: "winsymlinks:nativestrict" for var in ["MSYS", "CYGWIN"]}): + test_basic() + test_merge_two() + test_merge_existing_all() + test_merge_recursive() + test_merge_recursive_existing_all() + test_include_scan() + test_include_scan_merge_existing() + test_update_file_link_all() + test_error_duplicate() diff --git a/test/prebuilt/ext/jamfile2.jam b/test/prebuilt/ext/jamfile2.jam index 6481808c6..4c95a78d7 100644 --- a/test/prebuilt/ext/jamfile2.jam +++ b/test/prebuilt/ext/jamfile2.jam @@ -18,7 +18,7 @@ if [ os.name ] in NT } else if [ os.name ] in CYGWIN { - dll-suffix = dll ; + dll-suffix = dll.a ; } else if [ os.name ] in MACOSX { diff --git a/test/prebuilt/ext/jamfile3.jam b/test/prebuilt/ext/jamfile3.jam index be2257fa2..f90fc4486 100644 --- a/test/prebuilt/ext/jamfile3.jam +++ b/test/prebuilt/ext/jamfile3.jam @@ -22,7 +22,7 @@ if [ os.name ] in NT } else if [ os.name ] in CYGWIN { - dll-suffix = dll ; + dll-suffix = dll.a ; } else if [ os.name ] in MACOSX { diff --git a/test/searched_lib.py b/test/searched_lib.py index 6b84964d8..dee2b7298 100644 --- a/test/searched_lib.py +++ b/test/searched_lib.py @@ -31,8 +31,8 @@ t.expect_addition("lib/bin/$toolset/debug*/test_lib.dll") # Auto adjusting of suffixes does not work, since we need to # change dll to lib. -if ( ( os.name == "nt" ) or os.uname()[0].lower().startswith("cygwin") ) and \ - ( BoostBuild.get_toolset() != "gcc" ): +if t.is_implib_expected(): + t.expect_addition("lib/bin/$toolset/debug*/test_lib.implib") t.copy("lib/bin/$toolset/debug*/test_lib.implib", "lib/test_lib.implib") t.copy("lib/bin/$toolset/debug*/test_lib.dll", "lib/test_lib.dll") else: