Skip to content

Commit

Permalink
Make the Windows binaries build.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgiven committed Oct 25, 2023
1 parent c7f22c0 commit 26bd467
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 6 deletions.
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ LDFLAGS =

OBJ = .obj

# Special Windows settings.

ifeq ($(OS), Windows_NT)
MINGWBIN = /mingw32/bin
CCPREFIX = $(MINGWBIN)/
PKG_CONFIG = $(MINGWBIN)/pkg-config
WX_CONFIG = /usr/bin/sh $(MINGWBIN)/wx-config --static=yes
PROTOC = $(MINGWBIN)/protoc
LDFLAGS += \
-static
CXXFLAGS += \
-fext-numeric-literals \
-Wno-deprecated-enum-float-conversion \
-Wno-deprecated-enum-enum-conversion

# Required to get the gcc run - time libraries on the path.
export PATH := $(PATH):$(MINGWBIN)
EXT ?= .exe
endif

# Special OSX settings.

ifeq ($(shell uname),Darwin)
Expand Down
5 changes: 5 additions & 0 deletions build/ab.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ hide = @
PKG_CONFIG ?= pkg-config
ECHO ?= echo

ifeq ($(OS), Windows_NT)
EXT ?= .exe
endif
EXT ?=

include $(OBJ)/build.mk

.PHONY: update-ab
Expand Down
11 changes: 6 additions & 5 deletions build/c.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,12 @@ def findsources(name, srcs, deps, cflags, filerule):
return objs


def libraryimpl(self, name, srcs, deps, hdrs, cflags, commands, label, kind):
def libraryimpl(self, name, srcs, deps, hdrs, cflags, ldflags, commands, label, kind):
if not srcs and not hdrs:
raise ABException(
"clibrary contains no sources and no exported headers"
)

ldflags = []
libraries = [d for d in deps if hasattr(d, "clibrary")]
for library in libraries:
if library.clibrary.cflags:
Expand Down Expand Up @@ -162,11 +161,12 @@ def clibrary(
deps: Targets = [],
hdrs: TargetsMap = {},
cflags=[],
ldflags=[],
commands=["$(AR) cqs {outs[0]} {ins}"],
label="LIB",
):
return libraryimpl(
self, name, srcs, deps, hdrs, cflags, commands, label, cfile
self, name, srcs, deps, hdrs, cflags, ldflags, commands, label, cfile
)


Expand All @@ -178,11 +178,12 @@ def cxxlibrary(
deps: Targets = [],
hdrs: TargetsMap = {},
cflags=[],
ldflags=[],
commands=["$(AR) cqs {outs[0]} {ins}"],
label="LIB",
):
return libraryimpl(
self, name, srcs, deps, hdrs, cflags, commands, label, cxxfile
self, name, srcs, deps, hdrs, cflags, ldflags, commands, label, cxxfile
)


Expand All @@ -202,7 +203,7 @@ def programimpl(
normalrule(
replaces=self,
ins=(findsources(name, srcs, deps, cflags, filerule) + ars + ars),
outs=[basename(name)],
outs=[basename(name)+"$(EXT)"],
deps=deps,
label=label,
commands=commands,
Expand Down
9 changes: 9 additions & 0 deletions dep/emu/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from build.c import clibrary

clibrary(
name="emu",
srcs=["./fnmatch.c"],
hdrs={
"fnmatch.h": "./fnmatch.h"
}
)
6 changes: 5 additions & 1 deletion dep/libusbp/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from build.ab import emit
from build.c import clibrary
from build.pkg import package
from config import windows, osx, unix
Expand All @@ -15,6 +16,7 @@
"./include/libusbp.h",
]
deps = []
ldflags = []

if windows:
srcs += [
Expand All @@ -28,6 +30,7 @@
"./src/windows/list_windows.c",
"./src/windows/serial_port_windows.c",
]
ldflags += ["-lsetupapi", "-lwinusb", "-lole32", "-luuid"]
elif osx:
srcs += [
"./src/mac/async_in_transfer_mac.c",
Expand Down Expand Up @@ -57,7 +60,8 @@
clibrary(
name="libusbp",
srcs=srcs,
cflags=["-Idep/libusbp/include", "-Idep/libusbp/src"],
cflags =["-Idep/libusbp/include", "-Idep/libusbp/src"],
ldflags=ldflags,
deps=deps,
hdrs={
"libusbp_internal.h": "./src/libusbp_internal.h",
Expand Down

0 comments on commit 26bd467

Please sign in to comment.