Skip to content

Commit 9d5bbf6

Browse files
committed
Merge master -> feature/ninja-exporter
2 parents a0e9d3d + ef05390 commit 9d5bbf6

File tree

17 files changed

+180
-48
lines changed

17 files changed

+180
-48
lines changed

.github/workflows/ci-workflow.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ jobs:
177177
- name: Checkout
178178
uses: actions/checkout@v5
179179
- name: Start FreeBSD VM
180-
uses: vmactions/[email protected].3
180+
uses: vmactions/[email protected].4
181181
with:
182182
usesh: true
183183
sync: sshfs
@@ -255,7 +255,7 @@ jobs:
255255
- name: Checkout
256256
uses: actions/checkout@v5
257257
- name: Build on NetBSD VM
258-
uses: vmactions/netbsd-vm@v1.1.9
258+
uses: vmactions/netbsd-vm@v1.2.0
259259
with:
260260
usesh: true
261261
prepare: |

BUILD.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,15 @@ BUILDING FROM THE REPOSITORY
3939

4040
Alternatively, you may call the Makefile directly:
4141

42-
$ make -f Bootstrap.mak PLATFORM
42+
$ make -f Bootstrap.mak HOST_PLATFORM
43+
44+
Where HOST_PLATFORM can be osx or linux.
45+
46+
The target architecture for the Makefile defaults to x86. If you are building
47+
for something else you can set PLATFORM explicitly e.g. for Apple Silicon:
48+
49+
$ make -f Bootstrap.mak osx PLATFORM=ARM64
4350

44-
Where PLATFORM can be osx or linux.
4551
On Windows with Visual Studio use nmake:
4652

4753
$ nmake -f Bootstrap.mak windows

Bootstrap.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ done
1414
PLATFORM_ARG=""
1515
CONFIG_ARG=""
1616
PREMAKE_OPTS_ARG=""
17+
SYSTEM=$(uname -s)
18+
19+
# If the user has not explicitly selected an architecture, select one automatically
20+
if [ -z "$PLATFORM" ] && [ "$SYSTEM" = "Darwin" ] && [ "$(uname -m)" = "arm64" ]; then
21+
PLATFORM="ARM64"
22+
fi
1723

1824
if [ -n "$PLATFORM" ]; then
1925
PLATFORM_ARG="PLATFORM=$PLATFORM"
@@ -29,7 +35,6 @@ else
2935
PREMAKE_OPTS_ARG="PREMAKE_OPTS="
3036
fi
3137

32-
SYSTEM=$(uname -s)
3338
case "${SYSTEM}" in
3439
Linux)
3540
NPROC=$(nproc --all)

modules/gmake/gmake_cpp.lua

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,33 @@
5858
function cpp.initialize()
5959
rule 'cpp'
6060
fileExtension { ".cc", ".cpp", ".cxx", ".mm" }
61-
buildoutputs { "$(OBJDIR)/%{file.objname}.o" }
61+
buildoutputs { "$(OBJDIR)/%{file.objname}%{premake.modules.gmake.cpp.gettooloutputext('cxx', cfg)}" }
6262
buildmessage '$(notdir $<)'
6363
buildcommands {'$(CXX) %{premake.modules.gmake.cpp.fileFlags(cfg, file)} $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"'}
6464

6565
rule 'cc'
6666
fileExtension {".c", ".s", ".m"}
67-
buildoutputs { "$(OBJDIR)/%{file.objname}.o" }
67+
buildoutputs { "$(OBJDIR)/%{file.objname}%{premake.modules.gmake.cpp.gettooloutputext('cc', cfg)}" }
6868
buildmessage '$(notdir $<)'
6969
buildcommands {'$(CC) %{premake.modules.gmake.cpp.fileFlags(cfg, file)} $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"'}
7070

7171
rule 'resource'
7272
fileExtension ".rc"
73-
buildoutputs { "$(OBJDIR)/%{file.objname}.res" }
73+
buildoutputs { "$(OBJDIR)/%{file.objname}%{premake.modules.gmake.cpp.gettooloutputext('rc', cfg)}" }
7474
buildmessage '$(notdir $<)'
7575
buildcommands {'$(RESCOMP) $< -O coff -o "$@" $(ALL_RESFLAGS)'}
7676

7777
global(nil)
7878
end
7979

80+
function cpp.gettooloutputext(tool, cfg)
81+
local toolset = gmake.getToolSet(cfg)
82+
if toolset.gettooloutputext ~= nil then
83+
return toolset.gettooloutputext(tool)
84+
end
85+
86+
return iif(tool == "rc", ".res", ".o")
87+
end
8088

8189
function cpp.createRuleTable(prj)
8290
local rules = {}
@@ -690,7 +698,7 @@
690698
_p('\t$(SILENT) rm -rf $(OBJDIR)')
691699
_p('else')
692700
_p('\t$(SILENT) if exist $(subst /,\\\\,$(TARGET)) del $(subst /,\\\\,$(TARGET))')
693-
_p('\t$(SILENT) if exist $(subst /,\\\\,$(GENERATED)) del /s /q $(subst /,\\\\,$(GENERATED))')
701+
_p('\t$(SILENT) $(foreach f,$(subst /,\\\\,$(GENERATED)),if exist $(f) del /s /q $(f) >nul &)')
694702
_p('\t$(SILENT) if exist $(subst /,\\\\,$(OBJDIR)) rmdir /s /q $(subst /,\\\\,$(OBJDIR))')
695703
_p('endif')
696704
_p('')

modules/gmake/tests/test_gmake_file_rules.lua

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,46 @@
8181
end
8282

8383

84+
--
85+
-- Object filenames use correct extension based on toolset
86+
--
87+
88+
function suite.objectNameExtensions_onDefault()
89+
files { "src/hello.cpp", "src/test.c" }
90+
prepare()
91+
test.capture [[
92+
# File Rules
93+
# #############################################
94+
95+
$(OBJDIR)/hello.o: src/hello.cpp
96+
@echo "$(notdir $<)"
97+
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
98+
$(OBJDIR)/test.o: src/test.c
99+
@echo "$(notdir $<)"
100+
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
101+
102+
]]
103+
end
104+
105+
function suite.objectNameExtensions_onMSC()
106+
toolset "msc"
107+
files { "src/hello.cpp", "src/test.c" }
108+
prepare()
109+
test.capture [[
110+
# File Rules
111+
# #############################################
112+
113+
$(OBJDIR)/hello.obj: src/hello.cpp
114+
@echo "$(notdir $<)"
115+
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
116+
$(OBJDIR)/test.obj: src/test.c
117+
@echo "$(notdir $<)"
118+
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
119+
120+
]]
121+
end
122+
123+
84124
--
85125
-- Two files with the same base name should have different object files.
86126
--

modules/gmake/tests/test_gmake_tools.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,19 @@ endif
5959
RESCOMP = windres
6060
]]
6161
end
62+
63+
function suite.usesCorrectTools_msc()
64+
gmake.cpp.tools(cfg, p.tools.msc)
65+
test.capture [[
66+
ifeq ($(origin CC), default)
67+
CC = cl
68+
endif
69+
ifeq ($(origin CXX), default)
70+
CXX = cl
71+
endif
72+
ifeq ($(origin AR), default)
73+
AR = lib
74+
endif
75+
RESCOMP = rc
76+
]]
77+
end

src/base/_foundation.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
premake.MACOSX = "macosx"
4242
premake.MAKEFILE = "Makefile"
4343
premake.MBCS = "MBCS"
44+
premake.MSC = "msc"
4445
premake.NONE = "None"
4546
premake.DEFAULT = "Default"
4647
premake.OBJECTIVEC = "Objective-C"

src/tools/clang.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,3 +364,7 @@
364364
end
365365
return value
366366
end
367+
368+
function clang.gettooloutputext(tool)
369+
return gcc.gettooloutputext(tool)
370+
end

src/tools/gcc.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,3 +724,7 @@
724724
end
725725
return (cfg.gccprefix or "") .. gcc.tools[tool] .. version
726726
end
727+
728+
function gcc.gettooloutputext(tool)
729+
return iif(tool == "rc", ".res", ".o")
730+
end

src/tools/msc.lua

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -308,15 +308,15 @@
308308
local result = {}
309309
for _, dir in ipairs(dirs) do
310310
dir = p.tools.getrelative(cfg.project, dir)
311-
table.insert(result, '-I' .. p.quoted(dir))
311+
table.insert(result, '/I' .. p.quoted(dir))
312312
end
313313

314314
for _, dir in ipairs(extdirs or {}) do
315315
dir = p.tools.getrelative(cfg.project, dir)
316316
if isVersionGreaterOrEqualTo(cfg.toolset, "msc-v142") then
317317
table.insert(result, '/external:I' .. p.quoted(dir))
318318
else
319-
table.insert(result, '-I' .. p.quoted(dir))
319+
table.insert(result, '/I' .. p.quoted(dir))
320320
end
321321
end
322322

@@ -325,7 +325,7 @@
325325
if isVersionGreaterOrEqualTo(cfg.toolset, "msc-v142") then
326326
table.insert(result, '/external:I' .. p.quoted(dir))
327327
else
328-
table.insert(result, '-I' .. p.quoted(dir))
328+
table.insert(result, '/I' .. p.quoted(dir))
329329
end
330330
end
331331

@@ -467,6 +467,13 @@
467467
end
468468

469469

470+
msc.tools = {
471+
cc = "cl",
472+
cxx = "cl",
473+
ar = "lib",
474+
rc = "rc"
475+
}
476+
470477
--
471478
-- Retrieves the executable command name for a tool, based on the
472479
-- provided configuration and the operating environment.
@@ -481,18 +488,17 @@
481488
-- default value should be used.
482489
--
483490

484-
msc.tools = {
485-
cc = "cl",
486-
cxx = "cl",
487-
ar = "lib",
488-
rc = "rc",
489-
}
490-
491491
function msc.gettoolname(cfg, tool)
492+
local toolset, version = p.tools.canonical(cfg.toolset or p.MSC)
493+
-- TODO: Support versioning?
492494
return msc.tools[tool]
493495
end
494496

495497

498+
function msc.gettooloutputext(tool)
499+
return iif(tool == "rc", ".res", ".obj")
500+
end
501+
496502

497503
function msc.getwarnings(cfg)
498504
local result = {}

0 commit comments

Comments
 (0)