Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[feature] opa-create: Makefile improved for Windows

  • Loading branch information...
commit 7eb26471ab0ee057a1d6a8338bf7f3df47d3ade1 1 parent 3a1ec75
@cedricss cedricss authored
View
9 tools/opa-create/template/mvc/Makefile
@@ -1,7 +1,12 @@
########################################
# USER VARIABLES
-
EXE = application_name.exe
+ifdef SystemRoot
+ RUN_CMD = $(EXE)
+else
+ RUN_CMD = ./$(EXE)
+endif
+
PACKNAME =
SRC =
PCKDIR = ./plugins/
@@ -21,6 +26,6 @@ RUN_OPT = --db-local db/
default: exe
run: exe
- ./$(EXE) $(RUN_OPT) || true
+ $(RUN_CMD) $(RUN_OPT) || true
include Makefile.common
View
27 tools/opa-create/template/mvc/Makefile.common
@@ -3,7 +3,7 @@
OPACOMPILER ?= opa
OPA = $(OPACOMPILER) $(FLAG) $(OPAOPT)
PWD ?= $(shell pwd)
-BUILDDIR ?= $(PWD)/_build
+BUILDDIR ?= _build
export BUILDDIR
OPAGENAPI ?= $(OPACOMPILER) --api-only
DEPENDS = $(SRC) $(PCK:%=$(BUILDDIR)/%) $(PLUGIN:%=$(BUILDDIR)/%)
@@ -14,13 +14,21 @@ else
CONFIG =
endif
-_ = $(shell mkdir -p $(BUILDDIR))
+ifdef SystemRoot
+ RM = rmdir /s /q
+ RMFILE = del /s /q
+else
+ RM = rm -rf
+ RMFILE = rm
+endif
+
+# Hack to bypass the lack of "make -p" on Windows:
+_ = $(shell mkdir _build 2>/dev/null)
########################################
# MAIN RULE
exe : $(EXE)
pack : $(PACKNAME)
-doc : $(PACKDOC) doc.sub
########################################
# MAIN PACKAGE BUILDING
@@ -28,9 +36,8 @@ $(PACKNAME) : $(BUILDDIR)/$(PACKNAME)
$(BUILDDIR)/$(PACKNAME) : $(DEPENDS)
@echo "### Building package $(PACKNAME)"
- mkdir -p $(BUILDDIR)
$(OPA) --autocompile $(SRC) $(PLUGIN:%=$(BUILDDIR)/%) --build-dir $(BUILDDIR) -I $(BUILDDIR) $(OPAOPT)
- @rm -rf $(BUILDDIR)/$(PACKNAME)
+ $(RM) $(BUILDDIR)/$(PACKNAME)
@mv $(PACKNAME) $(BUILDDIR)/
########################################
@@ -45,7 +52,6 @@ $(BUILDDIR)/%.opp :
# EXECUTABLE BUILDING
$(EXE) : pack $(SRC) $(MAINSRC) $(DEPENDS) $(OTHER_DEPENDS)
@echo "### Building executable $(EXE) "
- mkdir -p $(BUILDDIR)
$(OPA) $(COMPILOPT) $(MAINSRC) $(CONFIG) $(PLUGIN:%=$(BUILDDIR)/%) -o $@ --build-dir $(BUILDDIR)/$(EXE)
$(EXE:%.exe=%.run) : $(EXE)
@@ -60,10 +66,7 @@ pack.depends :
# CLEANING
clean ::
@$(PCK:%.opx=make -C $(PCKDIR)/% clean &&) $(PLUGIN:%.opp=make -C $(PLUGINDIR)/% clean &&) echo "### Cleaning $(BUILDDIR)";
- @rm -rf $(BUILDDIR)/* _tracks/*;
- @if [ -n "$(EXE)" ]; then rm -rf $(EXE); fi
- @if [ -n "$(PACKDOC)" ]; then rm -rf $(PACKDOC); fi
-
-deep-clean :: clean
- @rm -rf opa-debug
+ $(RM) $(BUILDDIR) 2>/dev/null
+ $(RMFILE) $(EXE) 2>/dev/null
+
Please sign in to comment.
Something went wrong with that request. Please try again.