mirror of
https://github.com/boostorg/build.git
synced 2026-01-19 04:02:14 +00:00
test suite: msys/cygwin fixes (#253)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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("\\", "/")
|
||||
|
||||
@@ -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")))
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
22
test/link.py
22
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()
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user