C++ Makefile自定义变量
我有一个带WIFI屏蔽的arduino板。我正在家里组装和测试我的单元,并在测试现场部署它们 以下是我现在使用的参数集:C++ Makefile自定义变量,c++,c,makefile,arduino,C++,C,Makefile,Arduino,我有一个带WIFI屏蔽的arduino板。我正在家里组装和测试我的单元,并在测试现场部署它们 以下是我现在使用的参数集: Home: String WIFI_SSID = "myssid"; String WIFI_PASSWORD = "123"; bool USE_IP = true; int PORT = 8080; String IP = "192.168.1.140"; String DOMAIN = null; Test-site: String WIFI_SSID = "Tes
Home:
String WIFI_SSID = "myssid";
String WIFI_PASSWORD = "123";
bool USE_IP = true;
int PORT = 8080;
String IP = "192.168.1.140";
String DOMAIN = null;
Test-site:
String WIFI_SSID = "Test-siteSSID";
String WIFI_PASSWORD = "456";
bool USE_IP = false;
int PORT = 80;
String IP = null;
String DOMAIN = "www.google.com";
每当我切换位置时(这种情况经常发生),我都必须在ArduinoIDE中手动更改这些变量,这让我感到非常恼火。所以我看了一下哪个可以让我使用命令行来构建和编译arduino代码
这就是我计划做的:
make HOME
或make DEPLOY
HOME
或DEPLOY
李>
这将放在您的makefile中:
TARGET?=DEPLOY
all: build ...
build:
\tgcc ... -D$(TARGET) ...
.PHONY: all build ...
这将包含在您的源代码中:
#ifdef DEPLOY
#include "defs_deploy.h"
#else
#ifdef HOME
#include "defs_home.h"
#else
#error Neither DEPLOY nor HOME is defined
#endif /* HOME */
#endif /* DEPLOY */
命令行上会显示以下命令之一:
make TARGET=DEPLOY
make TARGET=HOME
不太好看,但它会起作用。@MikeW我要特别问的是如何传入附加参数HOME和DEPLOY,并在运行时使用一些代码来决定要包含什么。这怎么还不够具体?