Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge v0.5 into master #17

Merged
merged 3 commits into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
* Copyright (c) 2005-2013 Arduino Team
*/

#ifndef UNIX_HOST_DUINO_ARDUINO_H
#define UNIX_HOST_DUINO_ARDUINO_H
#ifndef EPOXY_DUINO_ARDUINO_H
#define EPOXY_DUINO_ARDUINO_H

#include "Print.h"
#include "StdioSerial.h"

// xx.yy.zz => xxyyzz (without leading 0)
#define UNIX_HOST_DUINO_VERSION 400
#define UNIX_HOST_DUINO_VERSION_STRING "0.4"
#define EPOXY_DUINO_VERSION 500
#define EPOXY_DUINO_VERSION_STRING "0.5"

// Used by digitalRead() and digitalWrite()
#define HIGH 0x1
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Changelog

* Unreleased
* 0.5 (2021-01-21)
* **Breaking Change** Change project name to "EpoxyDuino". The
`UNIX_HOST_DUINO` macro is replaced with `EPOXY_DUINO`, and the
`UnixHostDuino.mk` file is now `EpoxyDuino.mk`. The old macro and file are
retained for backwards compatibility, but the GitHub repo name has
changed. See
[Issue #15](https://github.com/bxparks/UnixHostDuino/issues/15).
* 0.4 (2021-01-21)
* Wrap `#ifdef` around `main()` to avoid conflict when compiling other
Arduino cores with UnixHostDuino inside the `libraries/` directory.
Expand Down
4 changes: 2 additions & 2 deletions EEPROM.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef UNIX_HOST_DUINO_EEPROM_H
#define UNIX_HOST_DUINO_EEPROM_H
#ifndef EPOXY_DUINO_EEPROM_H
#define EPOXY_DUINO_EEPROM_H

#include <inttypes.h>
/*
Expand Down
127 changes: 127 additions & 0 deletions EpoxyDuino.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Include this Makefile to compile an Arduino *.ino file on Linux or MacOS.
#
# Create a 'Makefile' in the sketch folder. For example, for the
# Blink/Blink.ino program, the makefile will be 'Blink/Makefile'.
# The content will look like this:
#
# APP_NAME := {name of *.ino file}
# ARDUINO_LIBS := AUnit AceTime {... additional Arduino libraries}
# include ../../../EpoxyDuino/EpoxyDuino.mk
#
# The 2 required parameters are:
#
# * APP_NAME: base name of the Arduino sketch file,
# e.g. 'Blink' not 'Blink.ino'
# * ARDUINO_LIBS: list of dependent Arduino libraries in sibling directories
# to EpoxyDuino (e.g. AUnit). The EpoxyDuino directory is
# automatically included.
#
# Optional parameters are:
#
# * ARDUINO_LIB_DIRS: List of additional locations of Arduino libs, for
# example, $(ARDUINO_IDE_DIR)/libraries,
# $(ARDUINO_IDE_DIR)/hardware/arduino/avr/libraries,
# $(ARDUINO_IDE_DIR)/portable/packages/arduino/hardware/avr/1.8.2/libraries.
# (The $(ARDUINO_IDE_DIR) is an example temporary variable containing the
# install location of the Arduino IDE. It is not used by EpoxyDuino.mk.)
# * OBJS: Additional object (*.o) files needed by the binary
# * GENERATED: A list of files which are generated by a script, and therefore
# can be deleted by 'make clean'
# * MORE_CLEAN: Optional user-supplied make-target that performs
# additional cleanup (i.e. removing generated directories).
#
# Type 'make -n' to verify.
#
# Type 'make' to create the $(APP_NAME).out program.
#
# Type 'make clean' to remove intermediate files.

# Detect Linux or MacOS
UNAME := $(shell uname)

# EpoxyDuino module directory.
EPOXY_DUINO_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
# Assume that there are other libs are siblings to EpoxyDuino
EPOXY_DUINO_LIB_DIR := $(abspath $(EPOXY_DUINO_DIR)/..)

# List of Arduino IDE library folders, both built-in to the Arduino IDE
# and those downloaded later, e.g. in the portable/ directory or .arduino15/
# directory.
ARDUINO_LIB_DIRS ?=

# Default modules which are automatically linked in: EpoxyDuino/
DEFAULT_MODULES := $(EPOXY_DUINO_DIR)

# Look for the ARDUINO_LIBS modules under each of the ARDUINO_LIB_DIRS and
# EPOXY_DUINO_LIB_DIR.
APP_MODULES := $(foreach lib,$(ARDUINO_LIBS),${EPOXY_DUINO_LIB_DIR}/${lib})
APP_MODULES += \
$(foreach lib_dir,$(ARDUINO_LIB_DIRS),\
$(foreach lib,$(ARDUINO_LIBS),\
${lib_dir}/${lib}\
)\
)

# All dependent modules.
ALL_MODULES := $(DEFAULT_MODULES) $(APP_MODULES)

# Compiler and settings
ifeq ($(UNAME), Linux)
CXX ?= g++
CXXFLAGS ?= -Wall -std=gnu++11 -fno-exceptions -fno-threadsafe-statics -flto
else ifeq ($(UNAME), Darwin)
CXX ?= clang++
CXXFLAGS ?= -std=c++11 -stdlib=libc++ # -Weverything
endif

# pre-processor (-I, -D, etc)
CPPFLAGS_EXPANSION = -I$(module) -I$(module)/src
CPPFLAGS ?=
CPPFLAGS += $(foreach module,$(ALL_MODULES),$(CPPFLAGS_EXPANSION))

# Define a macro to indicate that EpoxyDuino is being used. Defined here
# instead of Arduino.h so that files like 'compat.h' can determine the
# compile-time environment without having to include <Arduino.h>.
# Also define UNIX_HOST_DUINO for backwards compatibility.
CPPFLAGS += -DUNIX_HOST_DUINO -DEPOXY_DUINO

# linker settings (e.g. -lm)
LDFLAGS ?=

# C++ srcs. Old Arduino libraries place the source files at the top level.
# Later Arduino libraries put the source files under the src/ directory.
# Support subdirectory expansions up to 3 levels below 'src/'.
# (There might be a better way to do this using GNU Make but I can't find a
# mechanism that doesn't barf when the 'src/' directory doesn't exist.)
SRCS_EXPANSION = $(wildcard $(module)/*.cpp) \
$(wildcard $(module)/src/*.cpp) \
$(wildcard $(module)/src/*/*.cpp) \
$(wildcard $(module)/src/*/*/*.cpp) \
$(wildcard $(module)/src/*/*/*/*.cpp)
SRCS := $(foreach module,$(ALL_MODULES),$(SRCS_EXPANSION))
SRCS := ${SRCS} $(wildcard *.cpp) $(wildcard */*.cpp)

# Objects including *.o from *.ino
OBJS += $(SRCS:%.cpp=%.o) $(APP_NAME).o

$(APP_NAME).out: $(OBJS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)

$(APP_NAME).o: $(APP_NAME).ino
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -x c++ -c $<

%.o: %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@

# This simple rule does not capture all header dependencies of a given cpp
# file. Maybe it's better to make each cpp to depend on all headers of a given
# module, and force a recompilation of all cpp files. As far as I understand,
# this is what the Arduino IDE does upon each compile iteration.
%.cpp: %.h

.PHONY: all clean $(MORE_CLEAN)

all: $(APP_NAME).out

clean: $(MORE_CLEAN)
rm -f $(OBJS) $(APP_NAME).out $(GENERATED)
4 changes: 2 additions & 2 deletions Print.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef UNIX_HOST_DUINO_PRINT_H
#define UNIX_HOST_DUINO_PRINT_H
#ifndef EPOXY_DUINO_PRINT_H
#define EPOXY_DUINO_PRINT_H

#include <inttypes.h>
#include <string.h> // strlen()
Expand Down
4 changes: 2 additions & 2 deletions Printable.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef UNIX_HOST_DUINO_PRINTABLE_H
#define UNIX_HOST_DUINO_PRINTABLE_H
#ifndef EPOXY_DUINO_PRINTABLE_H
#define EPOXY_DUINO_PRINTABLE_H

#include <stdlib.h>

Expand Down
Loading