Add config.h wrapper to simplify test automation
Test code which wants to customize config.h can do so without touching config.h itself by wrapping config.h in a macro variable which is passed in to the compiler. It defaults to "config.h" if no override is provided. This change would break makefile dependency checking since the selection of a different header file on the command line is not noticed by make as a build-trigger. To solve this, we add a layer to the BUILDDIR path so build products are now specific to the USER_CONFIG choice if it is not "config.h".
This commit is contained in:
parent
08179ccbbe
commit
21e5343552
|
|
@ -32,7 +32,13 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
BUILDDIR = build
|
BUILDDIR = build
|
||||||
CFLAGS += -save-temps=obj
|
USER_CONFIG ?= config.h
|
||||||
|
|
||||||
|
ifneq ($(USER_CONFIG),config.h)
|
||||||
|
BUILDDIR := $(BUILDDIR)/$(USER_CONFIG:.h=)
|
||||||
|
endif
|
||||||
|
|
||||||
|
CFLAGS += -save-temps=obj -DUSER_CONFIG='"$(USER_CONFIG)"'
|
||||||
|
|
||||||
CC = $(TOOLCHAIN)gcc
|
CC = $(TOOLCHAIN)gcc
|
||||||
OBJDUMP = $(TOOLCHAIN)objdump
|
OBJDUMP = $(TOOLCHAIN)objdump
|
||||||
|
|
|
||||||
4
analog.c
4
analog.c
|
|
@ -19,7 +19,7 @@
|
||||||
#else
|
#else
|
||||||
static const uint8_t analog_mask = 0
|
static const uint8_t analog_mask = 0
|
||||||
#endif
|
#endif
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
;
|
;
|
||||||
#undef DEFINE_TEMP_SENSOR
|
#undef DEFINE_TEMP_SENSOR
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ static volatile uint16_t adc_result[NUM_TEMP_SENSORS] __attribute__ ((__section_
|
||||||
((type == TT_THERMISTOR) || (type == TT_AD595)) ? (pin ## _ADC) : 255,
|
((type == TT_THERMISTOR) || (type == TT_AD595)) ? (pin ## _ADC) : 255,
|
||||||
static uint8_t adc_channel[NUM_TEMP_SENSORS] =
|
static uint8_t adc_channel[NUM_TEMP_SENSORS] =
|
||||||
{
|
{
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
};
|
};
|
||||||
#undef DEFINE_TEMP_SENSOR
|
#undef DEFINE_TEMP_SENSOR
|
||||||
|
|
||||||
|
|
|
||||||
2
analog.h
2
analog.h
|
|
@ -13,7 +13,7 @@
|
||||||
#define REFERENCE_2V56 192
|
#define REFERENCE_2V56 192
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
|
|
||||||
#ifndef REFERENCE
|
#ifndef REFERENCE
|
||||||
#warning define REFERENCE as one of
|
#warning define REFERENCE as one of
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
|
|
||||||
#ifdef ACCELERATION_REPRAP
|
#ifdef ACCELERATION_REPRAP
|
||||||
#ifdef ACCELERATION_RAMPING
|
#ifdef ACCELERATION_RAMPING
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
/*
|
||||||
|
* This wrapper config header is used to allow makefiles and test scripts to
|
||||||
|
* replace or augment the user's 'config.h' file in a controlled manner. A
|
||||||
|
* makefile may add CFLAGS+=-DUSER_CONFIG=alternate_config.h to cause Teacup
|
||||||
|
* to build with a different config header.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef USER_CONFIG
|
||||||
|
#define USER_CONFIG "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include USER_CONFIG
|
||||||
2
dda.h
2
dda.h
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
|
|
||||||
#ifdef ACCELERATION_REPRAP
|
#ifdef ACCELERATION_REPRAP
|
||||||
#ifdef ACCELERATION_RAMPING
|
#ifdef ACCELERATION_RAMPING
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define DDA_LOOKAHEAD_H_
|
#define DDA_LOOKAHEAD_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
#include "dda.h"
|
#include "dda.h"
|
||||||
|
|
||||||
#ifndef ACCELERATION_RAMPING
|
#ifndef ACCELERATION_RAMPING
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
|
|
||||||
// return rounded result of multiplicand * multiplier / divisor
|
// return rounded result of multiplicand * multiplier / divisor
|
||||||
// this version is with quotient and remainder precalculated elsewhere
|
// this version is with quotient and remainder precalculated elsewhere
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
#include "sermsg.h"
|
#include "sermsg.h"
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
//! automagically generate analog_mask from DEFINE_TEMP_SENSOR entries in config.h
|
//! automagically generate analog_mask from DEFINE_TEMP_SENSOR entries in config.h
|
||||||
#define DEFINE_TEMP_SENSOR(name, type, pin, additional) | (((type == TT_THERMISTOR) || (type == TT_AD595)) ? 1 << (pin) : 0)
|
#define DEFINE_TEMP_SENSOR(name, type, pin, additional) | (((type == TT_THERMISTOR) || (type == TT_AD595)) ? 1 << (pin) : 0)
|
||||||
static const uint8_t analog_mask = 0
|
static const uint8_t analog_mask = 0
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
;
|
;
|
||||||
#undef DEFINE_TEMP_SENSOR
|
#undef DEFINE_TEMP_SENSOR
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
#define REFERENCE_2V56 192
|
#define REFERENCE_2V56 192
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
|
|
||||||
#ifndef REFERENCE
|
#ifndef REFERENCE
|
||||||
#warning define REFERENCE as one of
|
#warning define REFERENCE as one of
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "intercom.h"
|
#include "intercom.h"
|
||||||
#include "analog.h"
|
#include "analog.h"
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
#include "watchdog.h"
|
#include "watchdog.h"
|
||||||
#include "heater.h"
|
#include "heater.h"
|
||||||
#include "temp.h"
|
#include "temp.h"
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ typedef struct {
|
||||||
#define DEFINE_HEATER(name, pin) { &(pin ## _WPORT), pin ## _PIN, (pin ## _PWM) },
|
#define DEFINE_HEATER(name, pin) { &(pin ## _WPORT), pin ## _PIN, (pin ## _PWM) },
|
||||||
static const heater_definition_t heaters[NUM_HEATERS] =
|
static const heater_definition_t heaters[NUM_HEATERS] =
|
||||||
{
|
{
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
};
|
};
|
||||||
#undef DEFINE_HEATER
|
#undef DEFINE_HEATER
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _HEATER_H
|
#ifndef _HEATER_H
|
||||||
#define _HEATER_H
|
#define _HEATER_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "temp.h"
|
#include "temp.h"
|
||||||
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
#define DEFINE_HEATER(name, pin) HEATER_ ## name,
|
#define DEFINE_HEATER(name, pin) HEATER_ ## name,
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
NUM_HEATERS,
|
NUM_HEATERS,
|
||||||
HEATER_noheater
|
HEATER_noheater
|
||||||
} heater_t;
|
} heater_t;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
#include "delay.h"
|
#include "delay.h"
|
||||||
|
|
||||||
#if (defined TEMP_INTERCOM) || (defined EXTRUDER)
|
#if (defined TEMP_INTERCOM) || (defined EXTRUDER)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define _INTERCOM_H
|
#define _INTERCOM_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
|
|
||||||
#ifdef HOST
|
#ifdef HOST
|
||||||
#define enable_transmit() do { WRITE(TX_ENABLE_PIN,1); UCSR1B &=~MASK(RXEN1); } while(0)
|
#define enable_transmit() do { WRITE(TX_ENABLE_PIN,1); UCSR1B &=~MASK(RXEN1); } while(0)
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ typedef struct {
|
||||||
#define DEFINE_TEMP_SENSOR(name, type, pin, additional) { (type), (pin), (HEATER_ ## name), (additional) },
|
#define DEFINE_TEMP_SENSOR(name, type, pin, additional) { (type), (pin), (HEATER_ ## name), (additional) },
|
||||||
static const temp_sensor_definition_t temp_sensors[NUM_TEMP_SENSORS] =
|
static const temp_sensor_definition_t temp_sensors[NUM_TEMP_SENSORS] =
|
||||||
{
|
{
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
};
|
};
|
||||||
#undef DEFINE_TEMP_SENSOR
|
#undef DEFINE_TEMP_SENSOR
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _TEMP_H
|
#ifndef _TEMP_H
|
||||||
#define _TEMP_H
|
#define _TEMP_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -15,7 +15,7 @@ we still need to specify which analog pins we use in machine.h for the analog se
|
||||||
#undef DEFINE_TEMP_SENSOR
|
#undef DEFINE_TEMP_SENSOR
|
||||||
#define DEFINE_TEMP_SENSOR(name, type, pin, additional) TEMP_SENSOR_ ## name,
|
#define DEFINE_TEMP_SENSOR(name, type, pin, additional) TEMP_SENSOR_ ## name,
|
||||||
typedef enum {
|
typedef enum {
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
NUM_TEMP_SENSORS,
|
NUM_TEMP_SENSORS,
|
||||||
TEMP_SENSOR_none
|
TEMP_SENSOR_none
|
||||||
} temp_sensor_t;
|
} temp_sensor_t;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
|
|
||||||
#include "arduino.h"
|
#include "arduino.h"
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
|
|
||||||
#ifdef HOST
|
#ifdef HOST
|
||||||
#include "dda_queue.h"
|
#include "dda_queue.h"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _WATCHDOG_H
|
#ifndef _WATCHDOG_H
|
||||||
#define _WATCHDOG_H
|
#define _WATCHDOG_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
|
|
||||||
#ifdef USE_WATCHDOG
|
#ifdef USE_WATCHDOG
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#include "pinio.h"
|
#include "pinio.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "clock.h"
|
#include "clock.h"
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
#include "home.h"
|
#include "home.h"
|
||||||
|
|
||||||
/// the current tool
|
/// the current tool
|
||||||
|
|
|
||||||
4
heater.c
4
heater.c
|
|
@ -32,7 +32,7 @@ typedef struct {
|
||||||
pwm ? (pin ## _PWM) : NULL},
|
pwm ? (pin ## _PWM) : NULL},
|
||||||
static const heater_definition_t heaters[NUM_HEATERS] =
|
static const heater_definition_t heaters[NUM_HEATERS] =
|
||||||
{
|
{
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
};
|
};
|
||||||
#undef DEFINE_HEATER
|
#undef DEFINE_HEATER
|
||||||
|
|
||||||
|
|
@ -271,7 +271,7 @@ void heater_init() {
|
||||||
do {
|
do {
|
||||||
#undef DEFINE_HEATER
|
#undef DEFINE_HEATER
|
||||||
#define DEFINE_HEATER(name, pin, pwm) WRITE(pin, 0); SET_OUTPUT(pin);
|
#define DEFINE_HEATER(name, pin, pwm) WRITE(pin, 0); SET_OUTPUT(pin);
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
#undef DEFINE_HEATER
|
#undef DEFINE_HEATER
|
||||||
} while (0);
|
} while (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4
heater.h
4
heater.h
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _HEATER_H
|
#ifndef _HEATER_H
|
||||||
#define _HEATER_H
|
#define _HEATER_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "simulator.h"
|
#include "simulator.h"
|
||||||
#include "temp.h"
|
#include "temp.h"
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
#define DEFINE_HEATER(name, pin, pwm) HEATER_ ## name,
|
#define DEFINE_HEATER(name, pin, pwm) HEATER_ ## name,
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
NUM_HEATERS,
|
NUM_HEATERS,
|
||||||
HEATER_noheater
|
HEATER_noheater
|
||||||
} heater_t;
|
} heater_t;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include "memory_barrier.h"
|
#include "memory_barrier.h"
|
||||||
|
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
#include "delay.h"
|
#include "delay.h"
|
||||||
|
|
||||||
#if (defined TEMP_INTERCOM) || (defined EXTRUDER)
|
#if (defined TEMP_INTERCOM) || (defined EXTRUDER)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define _INTERCOM_H
|
#define _INTERCOM_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
|
|
||||||
#ifndef enable_transmit
|
#ifndef enable_transmit
|
||||||
#ifdef MOTHERBOARD
|
#ifdef MOTHERBOARD
|
||||||
|
|
|
||||||
2
mendel.c
2
mendel.c
|
|
@ -29,7 +29,7 @@
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
#include "fuses.h"
|
#include "fuses.h"
|
||||||
|
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
|
|
|
||||||
2
pinio.h
2
pinio.h
|
|
@ -5,7 +5,7 @@
|
||||||
#ifndef _PINIO_H
|
#ifndef _PINIO_H
|
||||||
#define _PINIO_H
|
#define _PINIO_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
|
|
||||||
#ifdef SIMULATOR
|
#ifdef SIMULATOR
|
||||||
#include "simulator.h"
|
#include "simulator.h"
|
||||||
|
|
|
||||||
2
serial.h
2
serial.h
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _SERIAL_H
|
#ifndef _SERIAL_H
|
||||||
#define _SERIAL_H
|
#define _SERIAL_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
|
|
||||||
2
temp.c
2
temp.c
|
|
@ -57,7 +57,7 @@ typedef struct {
|
||||||
#endif
|
#endif
|
||||||
static const temp_sensor_definition_t temp_sensors[NUM_TEMP_SENSORS] =
|
static const temp_sensor_definition_t temp_sensors[NUM_TEMP_SENSORS] =
|
||||||
{
|
{
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
};
|
};
|
||||||
#undef DEFINE_TEMP_SENSOR
|
#undef DEFINE_TEMP_SENSOR
|
||||||
|
|
||||||
|
|
|
||||||
4
temp.h
4
temp.h
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _TEMP_H
|
#ifndef _TEMP_H
|
||||||
#define _TEMP_H
|
#define _TEMP_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -15,7 +15,7 @@ we still need to specify which analog pins we use in machine.h for the analog se
|
||||||
#undef DEFINE_TEMP_SENSOR
|
#undef DEFINE_TEMP_SENSOR
|
||||||
#define DEFINE_TEMP_SENSOR(name, type, pin, additional) TEMP_SENSOR_ ## name,
|
#define DEFINE_TEMP_SENSOR(name, type, pin, additional) TEMP_SENSOR_ ## name,
|
||||||
typedef enum {
|
typedef enum {
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
NUM_TEMP_SENSORS,
|
NUM_TEMP_SENSORS,
|
||||||
TEMP_SENSOR_none
|
TEMP_SENSOR_none
|
||||||
} temp_sensor_t;
|
} temp_sensor_t;
|
||||||
|
|
|
||||||
2
timer.c
2
timer.c
|
|
@ -16,7 +16,7 @@
|
||||||
#include "memory_barrier.h"
|
#include "memory_barrier.h"
|
||||||
|
|
||||||
#include "arduino.h"
|
#include "arduino.h"
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
|
|
||||||
#ifdef MOTHERBOARD
|
#ifdef MOTHERBOARD
|
||||||
#include "dda_queue.h"
|
#include "dda_queue.h"
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
// Version 1.7: fix usb_serial_set_control
|
// Version 1.7: fix usb_serial_set_control
|
||||||
// 2012-10-17: Import to Teacup firmware
|
// 2012-10-17: Import to Teacup firmware
|
||||||
|
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
#include "simulator.h"
|
#include "simulator.h"
|
||||||
|
|
||||||
/* protect this file from Arduino IDE */
|
/* protect this file from Arduino IDE */
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _WATCHDOG_H
|
#ifndef _WATCHDOG_H
|
||||||
#define _WATCHDOG_H
|
#define _WATCHDOG_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config_wrapper.h"
|
||||||
|
|
||||||
#ifdef USE_WATCHDOG
|
#ifdef USE_WATCHDOG
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue