Skip to content

Commit 3a787aa

Browse files
committed
Second round of makefile/build.d consolidation
1 parent 5bfa3a2 commit 3a787aa

3 files changed

Lines changed: 61 additions & 245 deletions

File tree

src/build.d

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,10 @@ DFLAGS=-I%@P%/../../../../../druntime/import -I%@P%/../../../../../phobos -L-L%@
236236
});
237237

238238
/// Returns: the dependencies that build the D backend
239-
alias dBackend = memoize!(function () {
239+
alias backendObj = memoize!(function () {
240240
Dependency dependency = {
241-
name: "dbackend",
242-
target: env["G"].buildPath("dbackend").objName,
241+
name: "backendObj",
242+
target: env["G"].buildPath("backend").objName,
243243
sources: sources.backend,
244244
msg: "(DC) D_BACK_OBJS %-(%s, %)".format(sources.backend.map!(e => e.baseName).array),
245245
command: [
@@ -258,9 +258,9 @@ alias backend = memoize!(function() {
258258
Dependency dependency = {
259259
name: "backend",
260260
msg: "(LIB) %s".format("BACKEND".libName),
261-
sources: [ env["G"].buildPath("dbackend").objName ],
261+
sources: [ env["G"].buildPath("backend").objName ],
262262
target: env["G"].buildPath("backend").libName,
263-
deps: [dBackend],
263+
deps: [backendObj],
264264
command: [env["HOST_DMD_RUN"], env["MODEL_FLAG"], "-lib", "-of$@", "$<"]
265265
};
266266
return new DependencyRef(dependency);
@@ -307,11 +307,12 @@ Params:
307307
*/
308308
alias dmdExe = memoize!(function(string targetSuffix, string[] extraFlags...) {
309309
// Main DMD build dependency
310+
const dmdSources = sources.dmd.chain(sources.root).array;
310311
Dependency dependency = {
311312
// newdelete.o + lexer.a + backend.a
312-
sources: sources.dmd.chain(sources.root, lexer.targets, backend.targets).array,
313+
sources: dmdSources.chain(lexer.targets, backend.targets).array,
313314
target: env["DMD_PATH"] ~ targetSuffix,
314-
msg: "(DC) DMD%s %-(%s, %)".format(targetSuffix, sources.dmd.map!(e => e.baseName).array),
315+
msg: "(DC) DMD%s %-(%s, %)".format(targetSuffix, dmdSources.map!(e => e.baseName).array),
315316
deps: [versionFile, sysconfDirFile, lexer, backend],
316317
command: [
317318
env["HOST_DMD_RUN"],
@@ -368,6 +369,7 @@ alias clean = memoize!(function() {
368369
return new DependencyRef(dependency);
369370
});
370371

372+
371373
/**
372374
Goes through the target list and replaces short-hand targets with their expanded version.
373375
Special targets:
@@ -492,6 +494,31 @@ struct DependencyRange
492494
/// Sets the environment variables
493495
void parseEnvironment()
494496
{
497+
// This block is temporary until we can remove the windows make files
498+
{
499+
const ddebug = env.get("DDEBUG", null);
500+
if (ddebug.length)
501+
{
502+
writefln("WARNING: the DDEBUG variable is deprecated");
503+
if (ddebug == "-debug -g -unittest -cov")
504+
{
505+
environment["ENABLE_DEBUG"] = "1";
506+
environment["ENABLE_UNITTEST"] = "1";
507+
environment["ENABLE_COVERAGE"] = "1";
508+
}
509+
else if (ddebug == "-debug -g -unittest")
510+
{
511+
environment["ENABLE_DEBUG"] = "1";
512+
environment["ENABLE_UNITTEST"] = "1";
513+
}
514+
else
515+
{
516+
writefln("Error: DDEBUG is not an expected value '%s'", ddebug);
517+
exit(1);
518+
}
519+
}
520+
}
521+
495522
env.getDefault("TARGET_CPU", "X86");
496523
version (Windows)
497524
{
@@ -726,16 +753,23 @@ auto sourceFiles()
726753
.map!(e => e.name)
727754
.filter!(e => !lexerRootFiles.canFind(e.baseName.stripExtension))
728755
.array,
729-
backend:
730-
dirEntries(env["C"], "*.d", SpanMode.shallow)
731-
.map!(e => e.name)
732-
.filter!(e => !e.baseName.among("dt.d", "obj.d"))
733-
.array,
734-
backendHeaders: [
735-
// can't be built with -betterC
736-
"dt",
737-
"obj",
738-
].map!(e => env["C"].buildPath(e ~ ".d")).array,
756+
backend: ("
757+
bcomplex.d evalu8.d divcoeff.d dvec.d go.d gsroa.d glocal.d gdag.d gother.d gflow.d
758+
out.d
759+
gloop.d compress.d cgelem.d cgcs.d ee.d cod4.d cod5.d nteh.d blockopt.d mem.d cg.d cgreg.d
760+
dtype.d debugprint.d fp.d symbol.d elem.d dcode.d cgsched.d cg87.d cgxmm.d cgcod.d cod1.d cod2.d
761+
cod3.d cv8.d dcgcv.d pdata.d util2.d var.d md5.d backconfig.d ph2.d drtlsym.d dwarfeh.d ptrntab.d
762+
dvarstats.d dwarfdbginf.d cgen.d os.d goh.d barray.d cgcse.d elpicpie.d
763+
".split
764+
~ ( (env["OS"] == "osx") ? ["machobj.d"] : ["elfobj.d"] )
765+
~ ( (env["OS"] == "windows") ? "cgobj.d filespec.d mscoffobj.d newman.d".split : ["aarray.d"] )
766+
).map!(e => env["C"].buildPath(e)).array,
767+
backendHeaders: "
768+
cc.d cdef.d cgcv.d code.d cv4.d dt.d el.d global.d
769+
obj.d oper.d outbuf.d rtlsym.d code_x86.d iasm.d codebuilder.d
770+
ty.d type.d exh.d mach.d mscoff.d dwarf.d dwarf2.d xmm.d
771+
dlist.d melf.d varstats.di
772+
".split.map!(e => env["C"].buildPath(e)).array,
739773
};
740774
sources.dmd = sources.frontend ~ sources.backendHeaders;
741775

src/posix.mak

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -338,21 +338,6 @@ GLUE_SRCS=$(addsuffix .d, $(addprefix $D/,irstate toctype glue gluelayer todt to
338338

339339
DMD_SRCS=$(FRONT_SRCS) $(GLUE_SRCS) $(BACK_HDRS)
340340

341-
BACK_DOBJS = bcomplex.o evalu8.o divcoeff.o dvec.o go.o gsroa.o glocal.o gdag.o gother.o gflow.o \
342-
out.o \
343-
gloop.o compress.o cgelem.o cgcs.o ee.o cod4.o cod5.o nteh.o blockopt.o mem.o cg.o cgreg.o \
344-
dtype.o debugprint.o fp.o symbol.o elem.o dcode.o cgsched.o cg87.o cgxmm.o cgcod.o cod1.o cod2.o \
345-
cod3.o cv8.o dcgcv.o pdata.o util2.o var.o md5.o backconfig.o ph2.o drtlsym.o dwarfeh.o ptrntab.o \
346-
aarray.o dvarstats.o dwarfdbginf.o elfobj.o cgen.o os.o goh.o barray.o cgcse.o elpicpie.o
347-
348-
G_DOBJS = $(addprefix $G/, $(BACK_DOBJS))
349-
350-
ifeq (osx,$(OS))
351-
BACK_DOBJS += machobj.o
352-
else
353-
# BACK_DOBJS += elfobj.o
354-
endif
355-
356341
######## DMD glue layer and backend
357342

358343
GLUE_SRC = \
@@ -406,7 +391,7 @@ SRC_MAKE = posix.mak osmodel.mak
406391

407392
STRING_IMPORT_FILES = $G/VERSION $G/SYSCONFDIR.imp $(RES)/default_ddoc_theme.ddoc
408393

409-
DEPS = $(patsubst %.o,%.deps,$(DMD_OBJS) $(BACK_OBJS) $(BACK_DOBJS))
394+
DEPS = $(patsubst %.o,%.deps,$(DMD_OBJS))
410395

411396
RUN_BUILD = $(GENERATED)/build HOST_DMD="$(HOST_DMD)" OS=$(OS) BUILD=$(BUILD) MODEL=$(MODEL) AUTO_BOOTSTRAP="$(AUTO_BOOTSTRAP)" --called-from-make
412397

@@ -438,21 +423,13 @@ toolchain-info:
438423
@echo '==== Toolchain Information ===='
439424
@echo
440425

441-
$G/backend.a: $(G_DOBJS) $(SRC_MAKE)
442-
$(AR) rcs $@ $(G_DOBJS)
443-
444426
$G/dmd_frontend: $(FRONT_SRCS) $D/gluelayer.d $(ROOT_SRCS) $G/lexer.a $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
445427
$(HOST_DMD_RUN) -of$@ $(MODEL_FLAG) -vtls -J$G -J$(RES) $(DFLAGS) $(filter-out $(STRING_IMPORT_FILES) $(HOST_DMD_PATH),$^) -version=NoBackend
446428

447-
ifdef ENABLE_LTO
448-
$G/dmd: $(DMD_SRCS) $(ROOT_SRCS) $G/lexer.a $(G_DOBJS) $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
449-
$(HOST_DMD_RUN) -of$@ $(MODEL_FLAG) -vtls -J$G -J$(RES) $(DFLAGS) $(filter-out $(STRING_IMPORT_FILES) $(HOST_DMD_PATH),$^)
450-
else
451-
$G/dmd: $(DMD_SRCS) $(ROOT_SRCS) $G/backend.a $G/lexer.a $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
429+
$G/dmd: $(DMD_SRCS) $(ROOT_SRCS) $G/lexer.a $G/backend.o $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
452430
$(HOST_DMD_RUN) -of$@ $(MODEL_FLAG) -vtls -J$G -J$(RES) $(DFLAGS) $(filter-out $(STRING_IMPORT_FILES) $(HOST_DMD_PATH) $(LEXER_ROOT),$^)
453-
endif
454431

455-
$G/dmd-unittest: $(DMD_SRCS) $(ROOT_SRCS) $(LEXER_SRCS) $(G_DOBJS) $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
432+
$G/dmd-unittest: $(DMD_SRCS) $(ROOT_SRCS) $(LEXER_SRCS) $G/backend.o $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
456433
$(HOST_DMD_RUN) -of$@ $(MODEL_FLAG) -vtls -J$G -J$(RES) $(DFLAGS) -g -unittest -main -version=NoMain $(filter-out $(STRING_IMPORT_FILES) $(HOST_DMD_PATH),$^)
457434

458435
unittest: $G/dmd-unittest
@@ -525,10 +502,6 @@ FORCE: ;
525502

526503
-include $(DEPS)
527504

528-
$(G_DOBJS): $G/%.o: $C/%.d posix.mak $(HOST_DMD_PATH)
529-
@echo " (HOST_DMD_RUN) BACK_DOBJS $<"
530-
$(HOST_DMD_RUN) -c -of$@ $(DFLAGS) $(MODEL_FLAG) $(BACK_BETTERC) $(BACK_DFLAGS) $<
531-
532505
################################################################################
533506
# Generate the man pages
534507
################################################################################
@@ -584,7 +557,7 @@ dscanner: $(DSCANNER_DIR)/dsc
584557
$G/cxxfrontend.o: $G/%.o: tests/%.c $(SRC) $(ROOT_SRC) $(SRC_MAKE)
585558
$(CXX) -c -o$@ $(CXXFLAGS) $(DMD_FLAGS) $(MMD) $<
586559

587-
$G/cxx-unittest: $G/cxxfrontend.o $(DMD_SRCS) $(ROOT_SRCS) $G/lexer.a $(G_DOBJS) $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
560+
$G/cxx-unittest: $G/cxxfrontend.o $(DMD_SRCS) $(ROOT_SRCS) $G/lexer.a $G/backend.o $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
588561
CC=$(HOST_CXX) $(HOST_DMD_RUN) -of$@ $(MODEL_FLAG) -vtls -J$G -J$(RES) -L-lstdc++ $(DFLAGS) -version=NoMain $(filter-out $(STRING_IMPORT_FILES) $(HOST_DMD_PATH),$^)
589562

590563
cxx-unittest: $G/cxx-unittest

0 commit comments

Comments
 (0)