Просмотр исходного кода

Add an option --allow-shared-static that enables link=shared, runtime-link=static; refactor and reword warning message

Peter Dimov 5 лет назад
Родитель
Сommit
976deac5cb
2 измененных файлов с 35 добавлено и 11 удалено
  1. 8 11
      Jamroot
  2. 27 0
      boostcpp.jam

+ 8 - 11
Jamroot

@@ -213,18 +213,15 @@ rule handle-static-runtime ( properties * )
     # dangerous on Windows. Therefore, we disallow it. This might be drastic,
     # but it was disabled for a while without anybody complaining.
 
-    # For CW, static runtime is needed so that std::locale works.
-    if <link>shared in $(properties) && <runtime-link>static in $(properties) &&
-        ! ( <toolset>cw in $(properties) )
-    {
-        if ! $(.shared-static-warning-emitted)
-        {
-            ECHO "warning: skipping configuration link=shared, runtime-link=static" ;
-            ECHO "warning: this combination is either impossible or too dangerous" ;
-            ECHO "warning: to be of any use" ;
-            .shared-static-warning-emitted = 1 ;
-        }
+    local argv = [ modules.peek : ARGV ] ;
 
+    if <link>shared in $(properties)
+        && <runtime-link>static in $(properties)
+        # For CW, static runtime is needed so that std::locale works.
+        && ! ( <toolset>cw in $(properties) )
+        && ! --allow-shared-static in $(argv)
+    {
+        boostcpp.emit-shared-static-warning ;
         return <build>no ;
     }
 }

+ 27 - 0
boostcpp.jam

@@ -278,9 +278,24 @@ rule declare_install_and_stage_proper_targets ( libraries * )
 #
 ################################################################################
 
+rule emit-shared-static-warning ( )
+{
+    if ! $(.shared-static-warning-emitted)
+    {
+        ECHO "" ;
+        ECHO "warning: The configuration link=shared, runtime-link=static is disabled" ;
+        ECHO "warning: by default as being too dangerous to use, and will not be built." ;
+        ECHO "warning: To enable it, use --allow-shared-static." ;
+        ECHO "" ;
+
+        .shared-static-warning-emitted = 1 ;
+    }
+}
+
 class top-level-target : alias-target-class
 {
     import modules ;
+    import boostcpp ;
 
     rule __init__ ( name : project : sources * : requirements *
         : default-build * : usage-requirements * )
@@ -374,15 +389,22 @@ class top-level-target : alias-target-class
                 : $(build-type-set) ] ;
 
             # Filter inappopriate combinations.
+
             local filtered ;
+            local skipped ;
+
+            local argv = [ modules.peek : ARGV ] ;
+
             for local p in $(expanded)
             {
                 # See comment in handle-static-runtime regarding this logic.
                 if [ $(p).get <link> ] = shared
                     && [ $(p).get <runtime-link> ] = static
                     && [ $(p).get <toolset> ] != cw
+                    && ! --allow-shared-static in $(argv)
                 {
                     # Skip this.
+                    skipped += $(p) ;
                 }
                 else
                 {
@@ -390,6 +412,11 @@ class top-level-target : alias-target-class
                 }
             }
 
+            if $(expanded) = $(skipped)
+            {
+                boostcpp.emit-shared-static-warning ;
+            }
+
             return [ build-multiple $(filtered) ] ;
         }
     }

粤ICP备19079148号