220 24706 <a9ff0d91-dea2-49f1-8285-072732360d60@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Abyx <fl.lllj@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Modules are hard for build tools
Date: Fri, 26 Feb 2016 07:23:56 -0800 (PST)
Lines: 454
Approved: news@gmane.org
Message-ID: <a9ff0d91-dea2-49f1-8285-072732360d60@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_99_1784697087.1456500236418"
X-Trace: ger.gmane.org 1456500265 21755 80.91.229.3 (26 Feb 2016 15:24:25 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 26 Feb 2016 15:24:25 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCE4FQ4JYQLBBDO4YG3AKGQEOG4OWUY@isocpp.org Fri Feb 26 16:24:07 2016
Return-path: <std-proposals+bncBCE4FQ4JYQLBBDO4YG3AKGQEOG4OWUY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-io0-f197.google.com ([209.85.223.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCE4FQ4JYQLBBDO4YG3AKGQEOG4OWUY@isocpp.org>)
	id 1aZKFQ-0003oR-97
	for gclcip-std-proposals@m.gmane.org; Fri, 26 Feb 2016 16:24:04 +0100
Original-Received: by mail-io0-f197.google.com with SMTP id t64sf156611848ioe.0
        for <gclcip-std-proposals@m.gmane.org>; Fri, 26 Feb 2016 07:23:59 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:x-spam-checked-in-group
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=OFXeDDGuVFEePZ4l3i3/83aH072raTpsfY4CRrAW9zg=;
        b=pRArtLzTSzSCPa2ZAac7JHxlWkBk3opJbYvuUSdkx7xs9K6EqziKopzB7hfoTq23Xh
         Wvm5Qc3sUk5EtTU49Pwy/UQACnaMkxOmf6pA9DpnvbIDEQd+E1fk5ig0OJ8nk6xyFZS5
         FIBn8TDgCw6xE5sCXNmiRtpI3UXfnBMcqs7AI33leoF/svLzd8WRFuEdCADYgSCahNsf
         NFx0lrXXqBLvMQYWo+mnLRXYxYaX62UKnlY2O19bnxJdd0uBPSHZU9nRLAEJw4snYGlx
         CPlc0Hi3Quodpb6w12KVM44iQNDdJBYr9EChMF/P9FVq3tCTfSDcq9feSQm48TvS4RCx
         E+yw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:x-spam-checked-in-group
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=OFXeDDGuVFEePZ4l3i3/83aH072raTpsfY4CRrAW9zg=;
        b=u/lARxIYIKtU1EkV1usZmtyyinZq4+SlzoH1i/sedVVfvzyzEx78ljup/FQk6hy/Jn
         AmHR8QG1XTRu7wvJTr4bsxqObj93eXBmAebSEhVRBPLUKZeYLXGRqs/xl3J1Ib1EFh3S
         St0lKI2rkxclkgGqjL8z5b1xVwF8VHsU62Ghj7JKLoN5WEmOcX5SbxlEFmhAj5I++v1r
         2XlD4olOOgB0pi1fwiwfphDaTOS/Hn4O1h9zCPwnGXqXZ+Toxu8FLEUBz38OJ0wlk9dn
         4FzB86vm0uPNtJ4PHX+C9Cbnk3CblbmSO3yQ2P4VrMqxOnQkbeluz5y3cwMTGuO01OWh
         Pymw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=OFXeDDGuVFEePZ4l3i3/83aH072raTpsfY4CRrAW9zg=;
        b=IQRUOCETKYc4LjOo0+0/DegUXLlZc/jVRuU8/YLHM6dibcsc+bou3333DDqowbc+9f
         aiFU6mv02wPf5r9PJ8obPX/l+UNbXylYiMU1MNNadPDGA4Ehw73vbRyIEinzZETIgyH0
         CKWDhbzG003NqgV9AxwgtStrJ+p1gCt4rqzf29pp40Wz7WIKVNM+WhWsneipJcWlOIWO
         zFxdSC9967G30okE/zLpr17b9MaMy93EEE6Xgsy6UCIgzkm9ijemQzKRQJA11tdfdsaY
         QYD+k6IT9Z9mW4LD+U7Smkw4l39V7zpV8UQn4b6cexS9mQI3HcmvXhIhHwBT5GU79XfB
         hJ3A==
X-Gm-Message-State: AD7BkJKe8wE6SJzyvQA/onCsS5vcg0Y5DnU1pr3PZ+B4zmLz+24mMSomVPjM8YZuli3NbA==
X-Received: by 10.50.47.40 with SMTP id a8mr2605202ign.6.1456500238476;
        Fri, 26 Feb 2016 07:23:58 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.108.20 with SMTP id hg20ls552225igb.39.canary; Fri, 26 Feb
 2016 07:23:57 -0800 (PST)
X-Received: by 10.50.183.36 with SMTP id ej4mr56326igc.1.1456500237420;
        Fri, 26 Feb 2016 07:23:57 -0800 (PST)
X-Original-Sender: fl.lllj@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:24706
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/24706>

------=_Part_99_1784697087.1456500236418
Content-Type: multipart/alternative; 
	boundary="----=_Part_100_446552970.1456500236420"

------=_Part_100_446552970.1456500236420
Content-Type: text/plain; charset=UTF-8

Without modules we have the following situation:

There is a bunch of source files with code -

    tu1.cpp, tu2.cpp, ..., tuN.cpp,
    h1.hpp, h2.hpp, ..., hM.hpp,

And a build tool script (*make, gyp, gn, etc)

    add_executable(my_app, tu1.cpp, tu2.cpp, ..., tuN.cpp)

The build tool have to preprocess all the .cpp files, find all the 
"#include" directives and generate the build rules:

    # target    dependencies
    tu1.cpp.o : tu1.cpp, hA.hpp, ..., hX.hpp
    ...
    tuN.cpp.o : tuN.cpp, hB.hpp, ..., hY.hpp
    my_app    : tu1.cpp.o, ..., tuN.cpp.o

Note that the *.o targets don't depend on each other and can be compiled 
in-parallel.

--------------------------------------------

Modules add the module interface translation units (I'll call it an *.ixx 
file) and compiled module exports (an *.ifc file) 
If a translation unit A.cpp imports a module B, then it depends on B.ifc 
which depends on B.ixx.

So if we have the following source files (for simplicity let's not use 
header files)

    a_tu1.ixx, a_tu2.cpp (imports B), ..., a_tuN.cpp // module A
    b_tu1.ixx (imports A), b_tu2.cpp, ..., b_tuM.cpp // module B
    ...
    m_tu1.ixx, m_tu2.cpp, ..., m_tuM.cpp // module M

This means that a build tool have to produce the following build rules:

    # targets             dependencies
    a_tu1.ixx.o, A.ifc  : a_tu1.ixx
    b_tu1.ixx.o, B.ifc  : b_tu1.ixx, A.ifc
    ...
    m_tu1.ixx.o, M.ifc  : m_tu1.ixx, X.ifc, ..., Y.ifc
    a_tu2.cpp.o         : a_tu2.cpp, B.ifc
    ...
    m_tuN.cpp.o         : m_tuN.cpp, X.ifc, ..., Y.ifc
    my_app              : a_tu1.ixx.o, ..., m_tuN.cpp.o

And now we have *.o targets which depend on *.ifc targets, and *.ifc 
targets which depend on other *.ifc targets.

So what should we write in our build tool script, so it would generate such 
build rules?

It would be great if we could just write down all the translation units:

    add_executable(my_app, a_tu1.ixx.o, ..., a_tuN.cpp.o)

But then the build tool would have to not only preprocess C++ code (to find 
all the #include directives), but also parse it, in order to find the 
import statements.

It's not practical to manually write all the dependencies in the build 
script, because this would just duplicate the import statements in the code:

    add_module_dependencies(A, b_tu1.ixx, ..., x_tuX.cpp)
    add_module_dependencies(B, a_tu2.cpp, ..., y_tuY.cpp)
    -- or --
    add_module_dependencies(b_tu1.ixx, A)
    add_module_dependencies(a_tu2.cpp, B)


-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a9ff0d91-dea2-49f1-8285-072732360d60%40isocpp.org.

------=_Part_100_446552970.1456500236420
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Without modules we have the following situation:<br><br>Th=
ere is a bunch of source files with code -<br><br><div class=3D"prettyprint=
" style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187=
, 187); border-style: solid; border-width: 1px; word-wrap: break-word;"><co=
de class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color=
: #000;" class=3D"styled-by-prettify">=C2=A0 =C2=A0 tu1</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">cpp</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> tu2</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">cpp</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">...,</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> tuN</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">cpp</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 h1</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">hpp</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> h2</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">hpp</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">...,</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> hM</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">hpp</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br></span></div></code></div><br>And a build tool script (*make, gyp,=
 gn, etc)<br><br><div class=3D"prettyprint" style=3D"background-color: rgb(=
250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bord=
er-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div cla=
ss=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">=C2=A0 =C2=A0 add_executable</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">my_app</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> tu1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">cpp</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> tu2</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">cpp</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">...,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> tuN</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">cpp</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">)</span></div></code>=
</div><br>The build tool have to preprocess all the .cpp files, find all th=
e &quot;#include&quot; directives and generate the build rules:<br><br><div=
 class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); borde=
r-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-w=
rap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"=
><span style=3D"color: #000;" class=3D"styled-by-prettify">=C2=A0 =C2=A0 </=
span><span style=3D"color: #800;" class=3D"styled-by-prettify"># target =C2=
=A0 =C2=A0dependencies</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>=C2=A0 =C2=A0 tu1</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">cpp</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">o=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> tu1</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">cpp</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> hA</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">hpp</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">...,</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> hX</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">hpp<br>=C2=A0 =C2=A0 </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">...</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 tuN</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">cpp</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">o </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> tuN</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">cpp<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> hB</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">hpp</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">...,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> hY</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">hpp<br>=
=C2=A0 =C2=A0 my_app =C2=A0 =C2=A0</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> tu1</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
cpp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">o</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">...,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> tuN</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">cpp</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">o<br>=
</span></div></code></div><br>Note that the *.o targets don&#39;t depend on=
 each other and can be compiled in-parallel.<br><br>-----------------------=
---------------------<br><br>Modules add the module interface translation u=
nits (I&#39;ll call it an *.ixx file) and compiled module exports (an *.ifc=
 file) <br>If a translation unit A.cpp imports a module B, then it depends =
on B.ifc which depends on B.ixx.<br><br>So if we have the following source =
files (for simplicity let&#39;s not use header files)<br><br><div class=3D"=
prettyprint" style=3D"background-color: rgb(250, 250, 250); border-color: r=
gb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: break=
-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">=C2=A0 =C2=A0 a_tu1</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">ixx</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> a_tu2</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">cpp </span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">imports B</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">),</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">...,</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> a_tuN</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">cpp </span><span style=3D"color:=
 #800;" class=3D"styled-by-prettify">// module A</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 b_tu1</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">ixx </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">imports A</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">),</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> b_tu2</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">cpp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">...,</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> b_tuM</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">cpp </span><span style=3D"color: #800=
;" class=3D"styled-by-prettify">// module B</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">...</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 m_tu1</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">ixx</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> m_tu2</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">cpp</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">...,</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> m_tuM</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">cpp </span><span style=3D"color: =
#800;" class=3D"styled-by-prettify">// module M</span></div></code></div><b=
r>This means that a build tool have to produce the following build rules:<b=
r><br><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 2=
50); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1=
px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpr=
ettyprint"><span style=3D"color: #000;" class=3D"styled-by-prettify">=C2=A0=
 =C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify"># =
targets =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dependencies</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 a_tu1=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">ixx</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">o</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> A</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">ifc =C2=A0</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a=
_tu1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">ixx<br>=C2=A0 =
=C2=A0 b_tu1</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">ixx</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">o</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> B</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">ifc =C2=A0</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> b_tu1</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">ixx</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> A</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">ifc<br>=C2=A0 =C2=A0 </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">...</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 m_tu1</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">ixx</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">o</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> M</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">if=
c =C2=A0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> m_tu1</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">ixx</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> X</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">ifc</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">...,</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> Y</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">ifc<br>=C2=A0 =C2=A0 a_tu2</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">cpp</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">o =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> a_tu2</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">cpp</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> B</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">ifc<br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">...</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br>=C2=A0 =C2=A0 m_tuN</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">cpp</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">o=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> m_tuN</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">cpp=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> X</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">ifc</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">...,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> Y</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">ifc<br>=
=C2=A0 =C2=A0 my_app =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> a_tu1</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">ixx</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">o</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">...=
,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> m_tuN</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">cpp</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">o<br></span></div></code></div><br>An=
d now we have *.o targets which depend on *.ifc targets, and *.ifc targets =
which depend on other *.ifc targets.<br><br>So what should we write in our =
build tool script, so it would generate such build rules?<br><br>It would b=
e great if we could just write down all the translation units:<br><br><div =
class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border=
-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wr=
ap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint">=
<span style=3D"color: #000;" class=3D"styled-by-prettify">=C2=A0 =C2=A0 add=
_executable</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">my_app</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> a_tu1</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">ixx</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">o</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">..=
..,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a_tuN</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">cpp</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">o</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">)</span></div></code></div><br>But then the bu=
ild tool would have to not only preprocess C++ code (to find all the #inclu=
de directives), but also parse it, in order to find the import statements.<=
br><br>It&#39;s not practical to manually write all the dependencies in the=
 build script, because this would just duplicate the import statements in t=
he code:<br><br><div class=3D"prettyprint" style=3D"background-color: rgb(2=
50, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; borde=
r-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div clas=
s=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">=C2=A0 =C2=A0 add_module_dependencies</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">A</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> b_tu1</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">ixx</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">...,</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> x_tuX</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">cpp</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>=C2=A0 =C2=A0 add_module_dependencies</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">B</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> a_tu2</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">c=
pp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">...,</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> y_tuY</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">cpp</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">--</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">or</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">--</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
add_module_dependencies</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">b_tu1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">ixx</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> A</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 add_module_dependencies</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">a_tu2</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">cpp</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> B</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br><br></span></div></code></div><br></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/a9ff0d91-dea2-49f1-8285-072732360d60%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a9ff0d91-dea2-49f1-8285-072732360d60=
%40isocpp.org</a>.<br />

------=_Part_100_446552970.1456500236420--
------=_Part_99_1784697087.1456500236418--

.
