Skip to content

Commit

Permalink
OCD cleanup of cmdline Makefile and .net blink1lib, added build resul…
Browse files Browse the repository at this point in the history
…ts dirs to .gitignore
  • Loading branch information
todbot committed Dec 20, 2012
1 parent 949e732 commit 1065cf0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -35,6 +35,11 @@ local.properties
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

bin/
obj/
Debug/
Release/

# User-specific files
*.suo
*.user
Expand Down
32 changes: 22 additions & 10 deletions commandline/Makefile
Expand Up @@ -26,6 +26,11 @@
# - apt-get install libusb-1.0-0-dev
# - make
#
# FreeBSD
# - libusb is part of the OS so no pkg-config needed.
# - No -ldl on FreeBSD necessary.
# - iconv is a package that needs to be installed; it lives in /usr/local/lib/
#
# Linux Ubuntu 32-bit cross-compile on 64-bit
# To build 32-bit on 64-bit Ubuntu, try a chrooted build:
# (warning this will use up a lot of disk space)
Expand Down Expand Up @@ -87,7 +92,7 @@ CFLAGS += -pthread
LIBS += -framework IOKit -framework CoreFoundation
OBJS = ./hidapi/mac/hid.o

EXEFLAGS =
EXEFLAGS =
LIBFLAGS = -bundle -o $(LIBTARGET) -Wl,-search_paths_first $(LIBS)

EXE=
Expand All @@ -107,7 +112,7 @@ LIBFLAGS = -shared -o $(LIBTARGET) -Wl,--add-stdcall-alias -Wl,--export-all-symb
EXE= .exe
endif

################# Linux ###################################################
################# Linux ####################################################
ifeq "$(OS)" "linux"
LIBTARGET = blink1-lib.so
CFLAGS += `pkg-config libusb-1.0 --cflags` -fPIC
Expand All @@ -121,7 +126,7 @@ LIBFLAGS = -shared -o $(LIBTARGET) $(LIBS)
EXE=
endif

################# Freebsd ###################################################
################ FreeBSD ###################################################
ifeq "$(OS)" "freebsd"
LIBTARGET = blink1-lib.so
LIBS += -L/usr/local/lib -lusb -lrt -lpthread -liconv -static
Expand All @@ -132,7 +137,7 @@ EXE=
endif


##################### Common ##############################################
##################### Common ###############################################

CC = gcc

Expand All @@ -155,8 +160,9 @@ help:
@echo "This Makefile works on multiple archs. Use one of the following:"
@echo "make OS=windows ... build Windows blink1-lib and blink1-tool"
@echo "make OS=linux ... build Linux blink1-lib and blink1-tool"
@echo "make OS=freebsd ... build FreeBSD blink1-lib and blink1-tool"
@echo "make OS=freebsd ... build FreeBSD blink1-lib and blink1-tool"
@echo "make OS=macosx ... build Mac OS X blink1-lib and blink1-tool"
@echo "make lib ... build blink1-lib shared library"
@echo "make package PKGOS=mac ... zip up build, give it a name 'mac' "
@echo "make clean ..... to delete objects and hex file"
@echo
Expand All @@ -176,10 +182,6 @@ blink1-server-simple: $(OBJS) blink1-server-simple.c
lib: $(OBJS)
$(CC) $(LIBFLAGS) $(CFLAGS) $(OBJS)

# FIXME: only works for windows, and even then only inside
# Start->All Programs-> MS Visual Studio 2012 -> VS Tools -> Devel. Cmd Prompt
dumplib:
dumpbin.exe /exports $(LIBTARGET)

package: blink1-tool
@echo "Zipping up blink1-tool for '$(PKGOS)'"
Expand All @@ -193,10 +195,20 @@ clean:
distclean: clean
rm -f blink1-tool$(EXE)
rm -f blink1-server-simple$(EXE)
rm -f $(LIBTARGET) $(LIBTARGET).a

# shows shared lib usage on Mac OS X
otool:
otool -L $(TARGET)
otool -L blink1-tool
# show shared lib usage on Linux
ldd:
ldd blink1-tool
# show shared lib usage on Windows
# FIXME: only works inside command prompt from
# Start->All Programs-> MS Visual Studio 2012 -> VS Tools -> Devel. Cmd Prompt
dumpbin:
dumpbin.exe /exports $(LIBTARGET)
dumpbin.exe /exports blink1-tool.exe

foo:
@echo "OS=$(OS), USBFLAGS=$(USBFLAGS)"
Expand Down
4 changes: 3 additions & 1 deletion windows/Blink1Lib/Blink1Lib/Blink1.cs
Expand Up @@ -87,13 +87,15 @@ public int enumerate()

public string getCachedSerial(int i)
{
//Marshal.PtrToStringAuto
IntPtr wcstr = blink1_getCachedSerial(i);
string result = Marshal.PtrToStringAuto(wcstr);
return result;
}

// see: http://msdn.microsoft.com/en-us/magazine/cc164123.aspx#S7
// and: http://msdn.microsoft.com/en-us/library/aa446532.aspx
// and: http://www.codeguru.com/csharp/csharp/cs_data/article.php/c4217/Calling-Unmanaged-Code-Part-1--simple-DLLImport.htm

private const string DllName = "blink1-lib.dll";
private System.IntPtr dev;

Expand Down

0 comments on commit 1065cf0

Please sign in to comment.