Fix migrator to correctly migrate dynamic linking mode linker_flags

This would have not introduced the osx crosstool bug in 2d0e27e8bc which was then fixed in unknown commit.

RELNOTES: None.
PiperOrigin-RevId: 238699176
This commit is contained in:
hlopko 2019-03-15 13:24:56 -07:00 committed by Copybara-Service
parent b844e0c4b8
commit 10f38e16da
2 changed files with 30 additions and 7 deletions

View File

@ -44,6 +44,8 @@ DYNAMIC_LIBRARY_LINK_ACTIONS = [
NODEPS_DYNAMIC_LIBRARY_LINK_ACTIONS = ["c++-link-nodeps-dynamic-library"]
TRANSITIVE_DYNAMIC_LIBRARY_LINK_ACTIONS = ["c++-link-dynamic-library"]
TRANSITIVE_LINK_ACTIONS = ["c++-link-executable", "c++-link-dynamic-library"]
CC_LINK_EXECUTABLE = ["c++-link-executable"]
@ -329,9 +331,14 @@ def _add_flag_sets(feature, flag_sets):
actions = flag_set[1]
flags = flag_set[2]
expand_if_all_available = flag_set[3]
not_feature = None
if len(flag_set) >= 5:
not_feature = flag_set[4]
flag_set = feature.flag_set.add()
if with_feature is not None:
flag_set.with_feature.add().feature[:] = [with_feature]
if not_feature is not None:
flag_set.with_feature.add().not_feature[:] = [not_feature]
flag_set.action[:] = actions
flag_group = flag_set.flag_group.add()
flag_group.expand_if_all_available[:] = expand_if_all_available
@ -413,6 +420,13 @@ def _extract_legacy_link_flag_sets_for(toolchain):
if mode == "DYNAMIC":
result.append(
[None, NODEPS_DYNAMIC_LIBRARY_LINK_ACTIONS, lmf.linker_flag, []])
result.append([
None,
TRANSITIVE_DYNAMIC_LIBRARY_LINK_ACTIONS,
lmf.linker_flag,
[],
"static_link_cpp_runtimes",
])
result.append([
feature_name,
transitive_link_actions(toolchain), lmf.linker_flag, []

View File

@ -9,6 +9,7 @@ from tools.migration.legacy_fields_migration_lib import ALL_OBJC_LINK_ACTIONS
from tools.migration.legacy_fields_migration_lib import DYNAMIC_LIBRARY_LINK_ACTIONS
from tools.migration.legacy_fields_migration_lib import NODEPS_DYNAMIC_LIBRARY_LINK_ACTIONS
from tools.migration.legacy_fields_migration_lib import TRANSITIVE_LINK_ACTIONS
from tools.migration.legacy_fields_migration_lib import TRANSITIVE_DYNAMIC_LIBRARY_LINK_ACTIONS
from tools.migration.legacy_fields_migration_lib import CC_LINK_EXECUTABLE
from tools.migration.legacy_fields_migration_lib import migrate_legacy_fields
@ -510,23 +511,31 @@ class LegacyFieldsMigrationLibTest(unittest.TestCase):
self.assertEqual(output.feature[0].flag_set[3].action,
NODEPS_DYNAMIC_LIBRARY_LINK_ACTIONS)
self.assertEqual(output.feature[0].flag_set[4].with_feature[0].feature[0],
"dynamic_linking_mode")
self.assertEqual(
output.feature[0].flag_set[4].with_feature[0].not_feature[0],
"static_link_cpp_runtimes")
self.assertEqual(output.feature[0].flag_set[4].flag_group[0].flag,
["lmf-dynamic-flag-4"])
self.assertEqual(output.feature[0].flag_set[4].action,
TRANSITIVE_DYNAMIC_LIBRARY_LINK_ACTIONS)
self.assertEqual(output.feature[0].flag_set[5].with_feature[0].feature[0],
"dynamic_linking_mode")
self.assertEqual(output.feature[0].flag_set[5].flag_group[0].flag,
["lmf-dynamic-flag-4"])
self.assertEqual(output.feature[0].flag_set[5].action,
TRANSITIVE_LINK_ACTIONS)
self.assertEqual(output.feature[0].flag_set[5].flag_group[0].flag,
self.assertEqual(output.feature[0].flag_set[6].flag_group[0].flag,
["dl-flag-5"])
self.assertEqual(output.feature[0].flag_set[5].action,
self.assertEqual(output.feature[0].flag_set[6].action,
DYNAMIC_LIBRARY_LINK_ACTIONS)
self.assertEqual(output.feature[0].flag_set[6].flag_group[0].flag,
self.assertEqual(output.feature[0].flag_set[7].flag_group[0].flag,
["to-flag-6"])
self.assertEqual(output.feature[0].flag_set[6].action, ALL_CC_LINK_ACTIONS)
self.assertEqual(output.feature[0].flag_set[7].action, ALL_CC_LINK_ACTIONS)
self.assertEqual(
output.feature[0].flag_set[6].flag_group[0].expand_if_all_available,
output.feature[0].flag_set[7].flag_group[0].expand_if_all_available,
["is_cc_test"])
def test_all_linker_flag_objc_actions(self):