Skip to content

Commit dff77b9

Browse files
authored
Merge pull request #678 from ocsigen/static
Static linking without config file
2 parents b50323b + 2caf9d4 commit dff77b9

22 files changed

+306
-135
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ install: all META
174174
cp $(SERVER_CMI) $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/server
175175
cp $(SERVER_CMX) $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/server
176176
cp $(LIBDIR)/$(PKG_NAME).client.cma $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/client
177+
cp $(LIBDIR)/$(PKG_NAME).server.a $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/server
177178
cp $(LIBDIR)/$(PKG_NAME).server.cm* $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/server
178179
scripts/install.sh $(TEMPLATE_DIR) $(TEMPLATE_NAME)
179180

opam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
opam-version: "2.0"
22
name: "ocsigen-start"
3-
version: "6.3.0"
3+
version: "7.0.0"
44
55
maintainer: "[email protected]"
66
synopsis: "Higher-level library for developing Web and mobile applications with users, registration, notifications, etc"
@@ -23,7 +23,7 @@ depends: [
2323
"pgocaml_ppx" {>= "4.0"}
2424
"safepass" {>= "3.0"}
2525
"ocsigen-i18n" {>= "4.0.0"}
26-
"eliom" {>= "10.4.0" & < "11.0.0"}
26+
"eliom" {>= "11.0.0" & < "12.0.0"}
2727
"ocsigen-toolkit" {>= "2.7.0"}
2828
"ocsigen-ppx-rpc"
2929
"ocsigen-i18n" {>= "3.7.0"}

template.distillery/.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ cordova
1616
# Style
1717
.sass-cache
1818

19-
static/css/%%%PROJECT_NAME%%%.css.map
20-
static/css/%%%PROJECT_NAME%%%.css
19+
static/css/project_name.css.map
20+
static/css/project_name.css
2121

2222
# Dune
2323
_build

template.distillery/Makefile.options

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,15 @@ USE_NPM := yes
2626
##----------------------------------------------------------------------
2727
## The following part contains the configuration for the ocsigenserver.
2828

29-
# User to run server with (make run.*)
30-
WWWUSER := www-data
31-
WWWGROUP := www-data
32-
3329
# Port for running the server (make run.*)
34-
PORT := 80
30+
PORT := 8080
3531

3632
# Port for testing (make test.*)
3733
TEST_PORT := 8080
3834

3935
# Root of installation (must end with /)
40-
PREFIX := /usr/local/
36+
#PREFIX := /usr/local/
37+
PREFIX := ${OPAM_SWITCH_PREFIX}/
4138

4239
# Local folder for make test.* (must end with /)
4340
TEST_PREFIX := local/

template.distillery/Makefile.os

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ all byte opt:: ${VOLATILE_SCHEMA}
4747

4848
DIST_FILES = $(ELIOMSTATICDIR)/$(PROJECT_NAME).js $(LIBDIR)/$(PROJECT_NAME).cma
4949

50-
.PHONY: test.byte test.opt staticfiles
50+
.PHONY: test.byte test.opt staticfiles byte opt
5151

5252
test.byte:: byte | $(addprefix $(TEST_PREFIX),$(DIST_DIRS)) staticfiles
5353
@echo "==== The website is available at http://localhost:$(TEST_PORT) ===="
@@ -56,30 +56,52 @@ test.opt:: opt | $(addprefix $(TEST_PREFIX),$(DIST_DIRS)) staticfiles
5656
@echo "==== The website is available at http://localhost:$(TEST_PORT) ===="
5757
$(OCSIGENSERVER.OPT) $(RUN_DEBUG) -c $(patsubst %.conf.in,$(TEST_PREFIX)$(ETCDIR)/%-test.conf,$(CONF_IN))
5858

59+
test.static.byte: static.byte | $(addprefix $(TEST_PREFIX),$(DIST_DIRS)) staticfiles
60+
@echo "==== The website is available at http://localhost:$(TEST_PORT) ===="
61+
dune exec ./$(PROJECT_NAME)_main.bc
62+
test.static.opt: static.opt | $(addprefix $(TEST_PREFIX),$(DIST_DIRS)) staticfiles
63+
@echo "==== The website is available at http://localhost:$(TEST_PORT) ===="
64+
dune exec ./$(PROJECT_NAME)_main.exe
65+
5966
$(addprefix $(TEST_PREFIX), $(DIST_DIRS)):
6067
mkdir -p $@
6168

6269
staticfiles:
6370
cp -rf $(LOCAL_STATIC_CSS) $(LOCAL_STATIC_IMAGES) $(LOCAL_STATIC_FONTS) $(TEST_PREFIX)$(ELIOMSTATICDIR)
6471

72+
##----------------------------------------------------------------------
73+
## Static executable
74+
75+
static.byte: byte
76+
dune build $(PROJECT_NAME)_main.bc
77+
78+
static.opt: opt
79+
dune build $(PROJECT_NAME)_main.exe
80+
6581
##----------------------------------------------------------------------
6682
## Installing & Running
6783

68-
.PHONY: install install.byte install.byte install.opt install.static install.etc install.lib install.lib.byte install.lib.opt run.byte run.opt
84+
.PHONY: install install.exe install.byte install.byte install.opt install.static install.etc install.lib install.lib.byte install.lib.opt run.byte run.opt
6985
install: install.byte install.opt
86+
install.exe: install.etc install.static
87+
dune install
7088
install.byte: install.lib.byte install.etc install.static | $(addprefix $(PREFIX),$(DATADIR) $(LOGDIR) $(shell dirname $(CMDPIPE)))
7189
install.opt: install.lib.opt install.etc install.static | $(addprefix $(PREFIX),$(DATADIR) $(LOGDIR) $(shell dirname $(CMDPIPE)))
7290
install.lib: install.lib.byte install.lib.opt
73-
install.lib.byte: $(TEST_PREFIX)$(LIBDIR)/$(PROJECT_NAME).cma | $(PREFIX)$(LIBDIR)
74-
install $< $(PREFIX)$(LIBDIR)
75-
install.lib.opt: $(TEST_PREFIX)$(LIBDIR)/$(PROJECT_NAME).cmxs | $(PREFIX)$(LIBDIR)
76-
install $< $(PREFIX)$(LIBDIR)
91+
install.lib.byte: byte | $(PREFIX)$(LIBDIR)
92+
install $(TEST_PREFIX)$(LIBDIR)/$(PROJECT_NAME).cma $(PREFIX)$(LIBDIR)
93+
install.lib.opt: opt | $(PREFIX)$(LIBDIR)
94+
install $(TEST_PREFIX)$(LIBDIR)/$(PROJECT_NAME).cmxs $(PREFIX)$(LIBDIR)
7795
install.static: $(TEST_PREFIX)$(ELIOMSTATICDIR)/$(PROJECT_NAME).js | $(PREFIX)$(STATICDIR) $(PREFIX)$(ELIOMSTATICDIR)
78-
cp -r $(LOCAL_STATIC_CSS) $(PREFIX)$(FILESDIR)
7996
cp -r $(LOCAL_STATIC_IMAGES) $(PREFIX)$(FILESDIR)
8097
cp -r $(LOCAL_STATIC_FONTS) $(PREFIX)$(FILESDIR)
8198
[ -z $(WWWUSER) ] || chown -R $(WWWUSER) $(PREFIX)$(FILESDIR)
82-
install $(addprefix -o ,$(WWWUSER)) $< $(PREFIX)$(ELIOMSTATICDIR)
99+
HASH=`md5sum _build/default/client/$(PROJECT_NAME).bc.js | cut -d ' ' -f 1` && \
100+
install $(addprefix -o ,$(WWWUSER)) $(JS_PREFIX)_$$HASH.js $(PREFIX)$(ELIOMSTATICDIR) && \
101+
ln -sf $(PROJECT_NAME)_$$HASH.js $(PREFIX)$(ELIOMSTATICDIR)/$(PROJECT_NAME).js
102+
HASH=`cat $(LOCAL_CSS) | md5sum | cut -d ' ' -f 1` && \
103+
install $(addprefix -o ,$(WWWUSER)) $(CSS_PREFIX)_$$HASH.css $(PREFIX)$(ELIOMSTATICDIR)/css && \
104+
ln -sf $(PROJECT_NAME)_$$HASH.css $(PREFIX)$(ELIOMSTATICDIR)/css/$(PROJECT_NAME).css
83105
install.etc: $(TEST_PREFIX)$(ETCDIR)/$(PROJECT_NAME).conf | $(PREFIX)$(ETCDIR)
84106
install $< $(PREFIX)$(ETCDIR)/$(PROJECT_NAME).conf
85107

@@ -95,12 +117,19 @@ $(addprefix $(PREFIX),$(DATADIR) $(LOGDIR) $(ELIOMSTATICDIR) $(shell dirname $(C
95117
install $(addprefix -o ,$(WWWUSER)) -d $@
96118

97119
run.byte:
120+
@echo "==== Running ocsigenserver with configuration file ===="
98121
@echo "==== The website is available at http://localhost:$(PORT) ===="
99122
$(OCSIGENSERVER) $(RUN_DEBUG) -c ${PREFIX}${ETCDIR}/${PROJECT_NAME}.conf
100123
run.opt:
124+
@echo "==== Running ocsigenserver with configuration file ===="
101125
@echo "==== The website is available at http://localhost:$(PORT) ===="
102126
$(OCSIGENSERVER.OPT) $(RUN_DEBUG) -c ${PREFIX}${ETCDIR}/${PROJECT_NAME}.conf
103127

128+
run.static:
129+
@echo "==== Running static executable ===="
130+
@echo "==== The website is available at http://localhost:$(PORT) ===="
131+
${PROJECT_NAME}
132+
104133
##----------------------------------------------------------------------
105134

106135
##----------------------------------------------------------------------
@@ -155,7 +184,7 @@ $(TEST_CONFIG_FILES): $(TEST_PREFIX)$(ETCDIR)/%-test.conf: %.conf.in $(JS_AND_CS
155184
##----------------------------------------------------------------------
156185
## Compilation
157186

158-
.PHONY: gen-dune config-files
187+
.PHONY: config-files
159188

160189
config-files: | $(TEST_PREFIX)$(ELIOMSTATICDIR) $(TEST_PREFIX)$(LIBDIR)
161190
HASH=`md5sum _build/default/client/$(PROJECT_NAME).bc.js | cut -d ' ' -f 1` && \
@@ -164,20 +193,17 @@ config-files: | $(TEST_PREFIX)$(ELIOMSTATICDIR) $(TEST_PREFIX)$(LIBDIR)
164193
cp -f _build/default/$(PROJECT_NAME).cm* $(TEST_PREFIX)$(LIBDIR)/
165194
$(MAKE) $(CONFIG_FILES) $(TEST_CONFIG_FILES) PROJECT_NAME=$(PROJECT_NAME)
166195

167-
all:: gen-dune
196+
all::
168197
$(ENV_PSQL) dune build $(DUNE_OPTIONS) @install @$(PROJECT_NAME) $(PROJECT_NAME).cmxs
169198

170-
byte:: gen-dune
199+
byte::
171200
$(ENV_PSQL) dune build $(DUNE_OPTIONS) @$(PROJECT_NAME)
172201
make config-files PROJECT_NAME=$(PROJECT_NAME)
173202

174-
opt:: gen-dune
203+
opt::
175204
$(ENV_PSQL) dune build $(DUNE_OPTIONS) $(PROJECT_NAME).cmxs @$(PROJECT_NAME)
176205
make config-files PROJECT_NAME=$(PROJECT_NAME)
177206

178-
gen-dune:
179-
@ocaml tools/gen_dune.ml > client/dune.client
180-
181207
##----------------------------------------------------------------------
182208

183209
##----------------------------------------------------------------------

template.distillery/Makefile.style

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ ifeq ($(shell which sassc),)
7171
[ -d $(SASSDIR) ] && \
7272
SASS_PATH=$(SASS_PATH) sass --style compressed $(SASS_SRC) $@
7373
else
74-
[ -d $(SASSDIR) ] && \
74+
[ -d $(SASSDIR) ] &&
7575
sassc -t compressed $(addprefix -I ,$(subst :, ,$(SASS_PATH))) $(SASS_SRC) $@
7676
endif
7777
$(POSTCSS) --use autoprefixer --replace $@

template.distillery/PROJECT_NAME.conf.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@
2121
<!-- we use the PostgreSQL backend for ocsipersist,
2222
but there is also a DBM and an SQLite backend -->
2323
<!--
24-
<extension findlib-package="ocsipersist.dbm">
24+
<extension findlib-package="ocsipersist-dbm-config">
2525
<delayloading val="false"/>
2626
<store dir="%%DATADIR%%"/>
2727
<ocsidbm name="ocsidbm"/>
2828
</extension>
2929
-->
3030
<!--
31-
<extension findlib-package="ocsipersist.sqlite">
31+
<extension findlib-package="ocsipersist-sqlite-config">
3232
<database file="%%DATADIR%%/ocsidb"/>
3333
</extension>
3434
-->
35-
<extension findlib-package="ocsipersist.pgsql">
35+
<extension findlib-package="ocsipersist-pgsql-config">
3636
<database
3737
host="%%DB_HOST%%"
3838
port="%%DB_PORT%%"

template.distillery/PROJECT_NAME.eliom

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ module Demo_timepicker = Demo_timepicker
9595
module Demo_tips = Demo_tips
9696
module Demo_tongue = Demo_tongue
9797
module Demo_users = Demo_users
98+
module %%%MODULE_NAME%%%_config = %%%MODULE_NAME%%%_config
9899

99100
[%%client.start]
100101

101-
module %%%MODULE_NAME%%%_config = %%%MODULE_NAME%%%_config
102102
module %%%MODULE_NAME%%%_language = %%%MODULE_NAME%%%_language
103+
module %%%MODULE_NAME%%%_mobile = %%%MODULE_NAME%%%_mobile
104+
module %%%MODULE_NAME%%%_phone_connect = %%%MODULE_NAME%%%_phone_connect
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
opam-version: "2.0"
22
name: "%%%PROJECT_NAME%%%"
33
version: "0.1"
4-
synopsis: "Pseudo package for defining project dependencies"
4+
synopsis: "%%%PROJECT_NAME%%%"
55

66
depends: [
7-
"eliom" {>= "10.0.0" & < "11.0.0"}
8-
"ocsipersist-pgsql" {>= "1.0" & < "2.0"}
9-
"ocsigen-start"
7+
"eliom" {>= "11.0.0" & < "12.0.0"}
8+
"ocsipersist-pgsql-config" {>= "2.0" & < "3.0"}
9+
"ocsigen-start" {>= "7.0.0" & < "8.0.0"}
1010
]

template.distillery/PROJECT_NAME_base.eliom

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(* This file was generated by Ocsigen Start.
22
Feel free to use it, modify it, and redistribute it as you wish. *)
33

4+
let%server () = %%%MODULE_NAME%%%_static_config.set_static_config ()
45
let%server application_name = !%%%MODULE_NAME%%%_config.app_name
56
let%client application_name = Eliom_client.get_application_name ()
67
let%shared displayed_app_name = "%%%PROJECT_NAME%%%"

0 commit comments

Comments
 (0)