build: On-demand rebuilding and add "devel-install" target

Don't always rebuild on "make" (in the phony "all" target), but
introduce a real file target dist/index.js and its requisites. This gets
rid of the "install-only" target, which is very non-standard and would
not on an unbuilt tree anyway.

Also add a "devel-install" target that does the usual symlinking of the
built source tree into ~/.local/share/cockpit.

Closes #17
This commit is contained in:
Martin Pitt 2018-03-09 11:47:20 +01:00
parent 931e1be3c3
commit 491bb03cd6
2 changed files with 12 additions and 6 deletions

View file

@ -5,21 +5,26 @@ endif
export TEST_OS export TEST_OS
VM_IMAGE=$(CURDIR)/test/images/$(TEST_OS) VM_IMAGE=$(CURDIR)/test/images/$(TEST_OS)
all: node_modules/react-lite all: dist/index.js
dist/index.js: node_modules/react-lite $(wildcard src/*) package.json webpack.config.js
NODE_ENV=$(NODE_ENV) npm run build NODE_ENV=$(NODE_ENV) npm run build
clean: clean:
rm -rf dist/ rm -rf dist/
rm -rf _install rm -rf _install
install: all install-only install: dist/index.js
install-only:
mkdir -p $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME) mkdir -p $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME)
cp -r dist/* $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME) cp -r dist/* $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME)
mkdir -p $(DESTDIR)/usr/share/metainfo/ mkdir -p $(DESTDIR)/usr/share/metainfo/
cp org.cockpit-project.$(PACKAGE_NAME).metainfo.xml $(DESTDIR)/usr/share/metainfo/ cp org.cockpit-project.$(PACKAGE_NAME).metainfo.xml $(DESTDIR)/usr/share/metainfo/
# this requires a built source tree and avoids having to install anything system-wide
devel-install: dist/index.js
mkdir -p ~/.local/share/cockpit
ln -s `pwd`/dist ~/.local/share/cockpit/starter-kit
# when building a distribution tarball, call webpack with a 'production' environment # when building a distribution tarball, call webpack with a 'production' environment
dist-gzip: NODE_ENV=production dist-gzip: NODE_ENV=production
dist-gzip: clean all dist-gzip: clean all
@ -70,4 +75,4 @@ test/common:
node_modules/react-lite: node_modules/react-lite:
npm install npm install
.PHONY: all clean install install-only dist-gzip srpm rpm check .PHONY: all clean install devel-install dist-gzip srpm rpm check

View file

@ -16,9 +16,10 @@ Cockpit Starter Kit Example Module
%setup -n cockpit-starter-kit %setup -n cockpit-starter-kit
%build %build
make
%install %install
make install-only DESTDIR=%{buildroot} make install DESTDIR=%{buildroot}
find %{buildroot} -type f >> files.list find %{buildroot} -type f >> files.list
sed -i "s|%{buildroot}||" *.list sed -i "s|%{buildroot}||" *.list