Skip to content

Commit

Permalink
Update ab.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgiven committed Oct 9, 2024
1 parent f5b14ca commit 4c2fa27
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 23 deletions.
9 changes: 6 additions & 3 deletions build/_progress.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import sys

(_, current, max) = sys.argv
percent = int(100 * float(current) / float(max))
print(f"[{percent:>3}%]")
try:
(_, current, max) = sys.argv
percent = int(100 * float(current) / float(max))
print(f"[{percent:>3}%]")
except ValueError:
print(f"[{sys.argv}]")
15 changes: 15 additions & 0 deletions build/ab.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ else
endif
endif

WINDOWS := no
OSX := no
LINUX := no
ifeq ($(OS),Windows_NT)
WINDOWS := yes
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
LINUX := yes
endif
ifeq ($(UNAME_S),Darwin)
OSX := yes
endif
endif

ifeq ($(OS), Windows_NT)
EXT ?= .exe
endif
Expand Down
36 changes: 16 additions & 20 deletions build/c.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,33 @@
filenamesof,
flatten,
simplerule,
emit,
)
from build.utils import filenamesmatchingof, stripext, collectattrs
from os.path import *

emit(
"""
ifeq ($(OSX),no)
START-GROUP ?= -Wl,--start-group
END-GROUP ?= -Wl,--end-group
endif
"""
)


class Toolchain:
label = ""
cfile = ["$(CC) -c -o {outs[0]} {ins[0]} $(CFLAGS) {cflags}"]
cxxfile = ["$(CXX) -c -o {outs[0]} {ins[0]} $(CFLAGS) {cflags}"]
clibrary = ["$(AR) cqs {outs[0]} {ins}"]
cxxlibrary = ["$(AR) cqs {outs[0]} {ins}"]
clibraryt = ["$(AR) cqs --thin {outs[0]} {ins}"]
cxxlibraryt = ["$(AR) cqs --thin {outs[0]} {ins}"]
cprogram = ["$(CC) -o {outs[0]} {ins} {ldflags} $(LDFLAGS)"]
cxxprogram = ["$(CXX) -o {outs[0]} {ins} {ldflags} $(LDFLAGS)"]
cprogram = [
"$(CC) -o {outs[0]} $(START-GROUP) {ins} $(END-GROUP) {ldflags} $(LDFLAGS)"
]
cxxprogram = [
"$(CXX) -o {outs[0]} $(START-GROUP) {ins} $(END-GROUP) {ldflags} $(LDFLAGS)"
]


class HostToolchain:
Expand All @@ -29,8 +41,6 @@ class HostToolchain:
cxxfile = ["$(HOSTCXX) -c -o {outs[0]} {ins[0]} $(HOSTCFLAGS) {cflags}"]
clibrary = ["$(HOSTAR) cqs {outs[0]} {ins}"]
cxxlibrary = ["$(HOSTAR) cqs {outs[0]} {ins}"]
clibraryt = ["$(HOSTAR) cqs --thin {outs[0]} {ins}"]
cxxlibraryt = ["$(HOSTAR) cqs --thin {outs[0]} {ins}"]
cprogram = ["$(HOSTCC) -o {outs[0]} {ins} {ldflags} $(HOSTLDFLAGS)"]
cxxprogram = ["$(HOSTCXX) -o {outs[0]} {ins} {ldflags} $(HOSTLDFLAGS)"]

Expand Down Expand Up @@ -316,7 +326,6 @@ def programimpl(
label,
filerule,
kind,
libaggrule,
):
cfiles = findsources(
self.localname, srcs, deps, cflags, toolchain, filerule, self.cwd
Expand All @@ -330,17 +339,6 @@ def programimpl(
targets=lib_deps, name="caller_ldflags", initial=ldflags
)

if len(libs) > 1:
libs = [
simplerule(
name=f"{self.localname}_libs",
ins=libs,
outs=[f"={self.localname}.a"],
commands=libaggrule,
label="LIBT",
)
]

simplerule(
replaces=self,
ins=cfiles + libs,
Expand Down Expand Up @@ -381,7 +379,6 @@ def cprogram(
label,
cfile,
"cprogram",
toolchain.clibraryt,
)


Expand Down Expand Up @@ -411,5 +408,4 @@ def cxxprogram(
label,
cxxfile,
"cxxprogram",
toolchain.cxxlibraryt,
)

0 comments on commit 4c2fa27

Please sign in to comment.