Re: Dub and it's build directory

2018-08-21 Thread Seb via Digitalmars-d-learn
On Tuesday, 21 August 2018 at 12:31:20 UTC, Petar Kirov 
[ZombineDev] wrote:
What Dub does is what it calls "platform probing" [3]. It 
creates a temporary .d file containing various `pragma (msg, 
..)` statements that output information to stderr during 
compilation. Of course the question is then: which compiler is 
used to compile the platform probe file? AFAICS, it uses either 
the one requested for on the command-line (via --compiler=... ) 
or via an internal heuristic which is a bit involved [4].


FYI: the plan is to use the new JSON interface (e.g. `dmd 
-Xi=compilerInfo -Xf=-) soon.


See also: https://github.com/dlang/dub/pull/1316


Re: Dub and it's build directory

2018-08-21 Thread Petar via Digitalmars-d-learn

On Monday, 20 August 2018 at 18:59:23 UTC, Russel Winder wrote:

Hi,

[...]


Hi Russel,


So the questions are:

1. How does Dub find the compiler version number, in this case 
2.081, given that neither DMD or LDC seem to have a way of 
delivering only the version number.


The __VERSION__ [1] special token gives you an integer like 2081 
at compile-time. For DMD, LDC and GDC this is the version of the 
DMD frontend they are based on. Obviously, for other compilers 
(not based on the DMD frontend like SDC) there would be no 
equivalent integer, but since there's no other mature alternative 
D implementations this is not a problem in practice. Since the 
__VERSION__ token is replaced with an integer literal at 
compile-time, it can be used for things like conditional 
compilation (e.g. when you want support multiple versions of a 
dmd+druntime+phobos release, for exmaple: [2]).


What Dub does is what it calls "platform probing" [3]. It creates 
a temporary .d file containing various `pragma (msg, ..)` 
statements that output information to stderr during compilation. 
Of course the question is then: which compiler is used to compile 
the platform probe file? AFAICS, it uses either the one requested 
for on the command-line (via --compiler=... ) or via an internal 
heuristic which is a bit involved [4].



2. What is the pseudo-random number, and how is it calculated?


It's an MD5 hash of all the various parameters of a dub build 
(aka the build settings). It's calculated here: [5].


Perhaps some of the information is documented somewhere (if not 
it should be), but I found it easier to search through the code.


Petar

[1]: https://dlang.org/spec/lex.html#specialtokens
[2]: 
https://github.com/dlang/dub/blob/520d527fb11811c8f60b29a0ad15e6f48cf9f9d0/source/dub/internal/utils.d#L263
[3]: 
https://github.com/dlang/dub/blob/1ca0ad263bb364f66f71642152420dd1dce43ce2/source/dub/compilers/compiler.d#L119
[4]: 
https://github.com/dlang/dub/blob/1ca0ad263bb364f66f71642152420dd1dce43ce2/source/dub/dub.d#L1296
[5]: 
https://github.com/dlang/dub/blob/1ca0ad263bb364f66f71642152420dd1dce43ce2/source/dub/generators/build.d#L320


Dub and it's build directory

2018-08-20 Thread Russel Winder via Digitalmars-d-learn
Hi,

Given a package X, let us assume it's a library such that X = unit-
threaded, we find that in the ~/.dub/packages directory there is:

.dub/packages/unit-threaded-0.7.51/unit-threaded/gen_ut_main*
.dub/packages/unit-threaded-0.7.51/unit-threaded/libunit-threaded.a

These are the compilation products from the last undertaken compilation
and therefore more or less totally useless for anyone using more than
one D compiler.
Fortunately we find that there is a .dub directory with:

unit-threaded-0.7.51/unit-threaded/.dub
├── build
│   ├── 
gen_ut_main-debug-linux.posix-x86_64-dmd_2081-5610CAAD59972DC7A3346FE37EEC66C8
│   │   ├── gen_ut_main
│   │   └── gen_ut_main.o
│   ├── 
gen_ut_main-debug-linux.posix-x86_64-ldc_2081-02C0EA3AA341F3D071FE5E15E09EC021
│   │   └── gen_ut_main
│   ├── 
gen_ut_main-release-linux.posix-x86_64-dmd_2081-A8C2C7980309FFAFE08C15D3B29DE3CC
│   │   ├── gen_ut_main
│   │   └── gen_ut_main.o
│   ├── 
gen_ut_main-release-linux.posix-x86_64-ldc_2081-78BBAEC37FCFC878CC8215379A7D854B
│   │   └── gen_ut_main
│   ├── 
library-debug-linux.posix-x86_64-dmd_2081-5610CAAD59972DC7A3346FE37EEC66C8
│   │   └── libunit-threaded.a
│   ├── 
library-debug-linux.posix-x86_64-ldc_2081-02C0EA3AA341F3D071FE5E15E09EC021
│   │   └── libunit-threaded.a
│   ├── 
library-release-linux.posix-x86_64-dmd_2081-A8C2C7980309FFAFE08C15D3B29DE3CC
│   │   └── libunit-threaded.a
│   └── 
library-release-linux.posix-x86_64-ldc_2081-78BBAEC37FCFC878CC8215379A7D854B
│   └── libunit-threaded.a
└── dub.json

OK, so this is now actually useful stuff for people using Dub.

Clearly the directory names are dash separated components:

· configuration
· build type
· dot separated platform specification
· architecture
· underscore separated compiler name and major/minor version number
· some bizarre psuedo-random number

So the questions are:

1. How does Dub find the compiler version number, in this case 2.081,
given that neither DMD or LDC seem to have a way of delivering only the
version number.

2. What is the pseudo-random number, and how is it calculated?
 
-- 
Russel.
===
Dr Russel Winder  t: +44 20 7585 2200
41 Buckmaster Roadm: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk



signature.asc
Description: This is a digitally signed message part