diff --git a/.gitignore b/.gitignore index 7cf319231..649e8d638 100644 --- a/.gitignore +++ b/.gitignore @@ -1,26 +1,6 @@ -*.annot -*.cmo -*.cma -*.cmi -*.a -*.o -*.cmx -*.cmxs -*.cmxa - - -# ocsigen data -.depend -_client/ -_deps/ -_server/ +_build +_opam local/ doc/client doc/server - .*.sw* - -META -Makefile.depend - -_opam diff --git a/META.in b/META.in deleted file mode 100644 index 73f3b2743..000000000 --- a/META.in +++ /dev/null @@ -1,19 +0,0 @@ -names = "@@PKG_NAME@@" -version = "@@PKG_VERS@@" -description = "@@PKG_DESC@@" - -package "server" ( - requires = "@@SERVER_REQUIRES@@" - directory = "server" - archive(byte) = "@@SERVER_ARCHIVES_BYTE@@" - archive(byte, plugin) = "@@SERVER_ARCHIVES_BYTE@@" - archive(native) = "@@SERVER_ARCHIVES_NATIVE@@" - archive(native, plugin) = "@@SERVER_ARCHIVES_NATIVE_PLUGIN@@" -) - -package "client" ( - requires = "@@CLIENT_REQUIRES@@" - directory = "client" - archive(byte) = "@@CLIENT_ARCHIVES_BYTE@@" - archive(byte, plugin) = "@@CLIENT_ARCHIVES_BYTE@@" -) diff --git a/Makefile b/Makefile deleted file mode 100644 index 30f3e9779..000000000 --- a/Makefile +++ /dev/null @@ -1,277 +0,0 @@ - -##---------------------------------------------------------------------- -## DISCLAIMER -## -## This file contains the rules to make an ocsigen package. The project -## is configured through the variables in the file Makefile.options. -##---------------------------------------------------------------------- - -include Makefile.options - -##---------------------------------------------------------------------- -## Internals - -## Required binaries -ELIOMC := eliomc ${WARNING_FLAGS} -ELIOMOPT := eliomopt ${WARNING_FLAGS} -JS_OF_ELIOM := js_of_eliom -ppx ${WARNING_FLAGS} -ELIOMDEP := eliomdep -OCAMLFIND := ocamlfind - -## Where to put intermediate object files. -## - ELIOM_{SERVER,CLIENT}_DIR must be distinct -## - ELIOM_CLIENT_DIR must not be the local dir. -## - ELIOM_SERVER_DIR could be ".", but you need to -## remove it from the "clean" rules... -export ELIOM_SERVER_DIR := _server -export ELIOM_CLIENT_DIR := _client -export ELIOM_TYPE_DIR := _server -export OCAMLFIND_DESTDIR := $(shell $(OCAMLFIND) printconf destdir) - -ifeq ($(DEBUG),yes) - GENERATE_DEBUG ?= -g -endif - -ifeq ($(NATIVE),yes) - OPT_RULE = opt -endif - -##---------------------------------------------------------------------- -## General - -.PHONY: all byte opt doc -all: byte $(OPT_RULE) -byte:: $(LIBDIR)/${PKG_NAME}.server.cma $(LIBDIR)/${PKG_NAME}.client.cma -opt:: $(LIBDIR)/${PKG_NAME}.server.cmxs - -rebuild-os-db: - [ ! -z "$(PGHOST)" ] || exit 1 - (echo '(* GENERATED CODE, DO NOT EDIT! *)'; \ - `ocamlfind query -format "%d/ppx.exe" pgocaml_ppx` \ - src/os_db.ppx.ml ) > src/os_db.ml - -##---------------------------------------------------------------------- -## Aux - -# Use `eliomdep -sort' only in OCaml>4 -# Removing this to make it work with mixed ppx/camlp4: -# ifeq ($(shell ocamlc -version|cut -c1),4) -# eliomdep=$(shell $(ELIOMDEP) $(1) -ppx -sort $(2) $(filter %.eliom %.ml,$(3)))) -# else -eliomdep=$(3) -# endif -objs=$(patsubst %.ml,$(1)/%.$(2),$(patsubst %.eliom,$(1)/%.$(2),$(filter %.eliom %.ml,$(3)))) -#depsort=$(call objs,$(1),$(2),$(call eliomdep,$(3),$(4),$(5))) -depsort=$(shell ocaml tools/sort_deps.ml .depend $(patsubst %.ml,$(1)/%.$(2),$(patsubst %.eliom,$(1)/%.$(2),$(filter %.eliom %.ml,$(5))))) - -$(LIBDIR): - mkdir $(LIBDIR) - -##---------------------------------------------------------------------- -## Server side compilation - -## make it more elegant ? -SERVER_DIRS := $(shell echo $(foreach f, $(SERVER_FILES), $(dir $(f))) | tr ' ' '\n' | sort -u | tr '\n' ' ') -SERVER_DEP_DIRS := ${addprefix -eliom-inc ,${SERVER_DIRS}} -SERVER_INC_DIRS := ${addprefix -I $(ELIOM_SERVER_DIR)/, ${SERVER_DIRS}} - -SERVER_INC := ${addprefix -package ,${SERVER_PACKAGES} ${SERVER_PPX_PACKAGES}} -SERVER_DB_INC := ${addprefix -package ,${SERVER_DB_PACKAGES} ${SERVER_DB_PPX_PACKAGES}} - -${ELIOM_TYPE_DIR}/%.type_mli: %.eliom - ${ELIOMC} -ppx -infer ${SERVER_INC} ${SERVER_INC_DIRS} $< - -$(LIBDIR)/$(PKG_NAME).server.cma: $(call objs,$(ELIOM_SERVER_DIR),cmo,$(SERVER_FILES)) | $(LIBDIR) - ${ELIOMC} -a -o $@ $(GENERATE_DEBUG) \ - $(call depsort,$(ELIOM_SERVER_DIR),cmo,-server,$(SERVER_INC),$(SERVER_FILES)) - -$(LIBDIR)/$(PKG_NAME).server.cmxa: $(call objs,$(ELIOM_SERVER_DIR),cmx,$(SERVER_FILES)) | $(LIBDIR) - ${ELIOMOPT} -a -o $@ $(GENERATE_DEBUG) \ - $(call depsort,$(ELIOM_SERVER_DIR),cmx,-server,$(SERVER_INC),$(SERVER_FILES)) - -%.cmxs: %.cmxa - $(ELIOMOPT) -ppx -shared -linkall -o $@ $(GENERATE_DEBUG) $< - -${ELIOM_SERVER_DIR}/%_db.cmi: %_db.mli - ${ELIOMC} -ppx -c ${SERVER_DB_INC} ${SERVER_INC_DIRS} $(GENERATE_DEBUG) $< -${ELIOM_SERVER_DIR}/%.cmi: %.mli - ${ELIOMC} -ppx -c ${SERVER_INC} ${SERVER_INC_DIRS} $(GENERATE_DEBUG) $< - -${ELIOM_SERVER_DIR}/%.cmi: %.eliomi - ${ELIOMC} -ppx -c ${SERVER_INC} ${SERVER_INC_DIRS} $(GENERATE_DEBUG) $< - -${ELIOM_SERVER_DIR}/%_db.cmo: %_db.ml - ${ELIOMC} -ppx -c ${SERVER_DB_INC} ${SERVER_INC_DIRS} $(GENERATE_DEBUG) $< -${ELIOM_SERVER_DIR}/%.cmo: %.ml - ${ELIOMC} -ppx -c ${SERVER_INC} ${SERVER_INC_DIRS} $(GENERATE_DEBUG) $< -${ELIOM_SERVER_DIR}/%.cmo: %.eliom - ${ELIOMC} -ppx -c ${SERVER_INC} ${SERVER_INC_DIRS} $(GENERATE_DEBUG) $< - -${ELIOM_SERVER_DIR}/%_db.cmx: %_db.ml - ${ELIOMOPT} -ppx -c ${SERVER_DB_INC} ${SERVER_INC_DIRS} $(GENERATE_DEBUG) $< -${ELIOM_SERVER_DIR}/%.cmx: %.ml - ${ELIOMOPT} -ppx -c ${SERVER_INC} ${SERVER_INC_DIRS} $(GENERATE_DEBUG) $< -${ELIOM_SERVER_DIR}/%.cmx: %.eliom - ${ELIOMOPT} -ppx -c ${SERVER_INC} ${SERVER_INC_DIRS} $(GENERATE_DEBUG) $< - - -##---------------------------------------------------------------------- -## Client side compilation - -## make it more elegant ? -CLIENT_DIRS := $(shell echo $(foreach f, $(CLIENT_FILES), $(dir $(f))) | tr ' ' '\n' | sort -u | tr '\n' ' ') -CLIENT_DEP_DIRS := ${addprefix -eliom-inc ,${CLIENT_DIRS}} -CLIENT_INC_DIRS := ${addprefix -I $(ELIOM_CLIENT_DIR)/,${CLIENT_DIRS}} - -CLIENT_LIBS := ${addprefix -package ,${CLIENT_PACKAGES} ${CLIENT_PPX_PACKAGES}} -CLIENT_INC := ${addprefix -package ,${CLIENT_PACKAGES} ${CLIENT_PPX_PACKAGES}} - -CLIENT_OBJS := $(filter %.eliom %.ml, $(CLIENT_FILES)) -CLIENT_OBJS := $(patsubst %.eliom,${ELIOM_CLIENT_DIR}/%.cmo, ${CLIENT_OBJS}) -CLIENT_OBJS := $(patsubst %.ml,${ELIOM_CLIENT_DIR}/%.cmo, ${CLIENT_OBJS}) - -$(LIBDIR)/$(PKG_NAME).client.cma: $(call objs,$(ELIOM_CLIENT_DIR),cmo,$(CLIENT_FILES)) | $(LIBDIR) - ${JS_OF_ELIOM} -a -o $@ $(GENERATE_DEBUG) \ - $(call depsort,$(ELIOM_CLIENT_DIR),cmo,-client,$(CLIENT_INC),$(CLIENT_FILES)) - -${ELIOM_CLIENT_DIR}/%.cmi: %.mli - ${JS_OF_ELIOM} -c ${CLIENT_INC} ${CLIENT_INC_DIRS} $(GENERATE_DEBUG) $< - -${ELIOM_CLIENT_DIR}/%.cmo: %.eliom - ${JS_OF_ELIOM} -c ${CLIENT_INC} ${CLIENT_INC_DIRS} $(GENERATE_DEBUG) $< -${ELIOM_CLIENT_DIR}/%.cmo: %.ml - ${JS_OF_ELIOM} -c ${CLIENT_INC} ${CLIENT_INC_DIRS} $(GENERATE_DEBUG) $< - -${ELIOM_CLIENT_DIR}/%.cmi: %.eliomi - ${JS_OF_ELIOM} -c ${CLIENT_INC} ${CLIENT_INC_DIRS} $(GENERATE_DEBUG) $< - -##---------------------------------------------------------------------- -## Installation - -CLIENT_CMO=$(wildcard $(addsuffix /*.cmo,$(addprefix $(ELIOM_CLIENT_DIR)/,$(CLIENT_DIRS)))) -CLIENT_CMO_FILENAMES=$(foreach f, $(call depsort,$(ELIOM_CLIENT_DIR),cmo,-client,$(CLIENT_INC),$(CLIENT_FILES)), $(patsubst $(dir $(f))%,%,$(f))) -META: META.in - sed -e 's#@@PKG_NAME@@#$(PKG_NAME)#g' \ - -e 's#@@PKG_VERS@@#$(PKG_VERS)#g' \ - -e 's#@@PKG_DESC@@#$(PKG_DESC)#g' \ - -e 's#@@CLIENT_REQUIRES@@#$(CLIENT_PACKAGES)#g' \ - -e 's#@@CLIENT_ARCHIVES_BYTE@@#$(CLIENT_CMO_FILENAMES)#g' \ - -e 's#@@SERVER_REQUIRES@@#$(SERVER_PACKAGES) $(SERVER_DB_PACKAGES)#g' \ - -e 's#@@SERVER_ARCHIVES_BYTE@@#$(PKG_NAME).server.cma#g' \ - -e 's#@@SERVER_ARCHIVES_NATIVE@@#$(PKG_NAME).server.cmxa#g' \ - -e 's#@@SERVER_ARCHIVES_NATIVE_PLUGIN@@#$(PKG_NAME).server.cmxs#g' \ - $< > $@ - -CLIENT_CMI=$(wildcard $(addsuffix /os_*.cmi,$(addprefix $(ELIOM_CLIENT_DIR)/,$(CLIENT_DIRS)))) -SERVER_CMI=$(wildcard $(addsuffix /os_*.cmi,$(addprefix $(ELIOM_SERVER_DIR)/,$(SERVER_DIRS)))) -SERVER_CMX=$(wildcard $(addsuffix /os_*.cmx,$(addprefix $(ELIOM_SERVER_DIR)/,$(SERVER_DIRS)))) -install: all META - $(OCAMLFIND) install $(PKG_NAME) META - mkdir -p $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/client - mkdir -p $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/server - cp $(CLIENT_CMO) $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/client - cp $(CLIENT_CMI) $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/client - cp $(SERVER_CMI) $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/server - cp $(SERVER_CMX) $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/server - cp $(LIBDIR)/$(PKG_NAME).client.cma $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/client - cp $(LIBDIR)/$(PKG_NAME).server.a $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/server - cp $(LIBDIR)/$(PKG_NAME).server.cm* $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/server - scripts/install.sh $(TEMPLATE_DIR) $(TEMPLATE_NAME) - -##---------------------------------------------------------------------- -## Dependencies - -DEPSDIR := _deps - -ifneq ($(MAKECMDGOALS),distclean) -ifneq ($(MAKECMDGOALS),clean) -ifneq ($(MAKECMDGOALS),depend) - include .depend -endif -endif -endif - -.depend: $(patsubst %,$(DEPSDIR)/%.server,$(SERVER_FILES)) $(patsubst %,$(DEPSDIR)/%.client,$(CLIENT_FILES)) - cat $^ > $@ - -$(DEPSDIR)/%.server: % | $(DEPSDIR) - $(ELIOMDEP) -server -ppx $(SERVER_INC) $(SERVER_DEP_DIRS) $< > $@ - -$(DEPSDIR)/%.client: % | $(DEPSDIR) - $(ELIOMDEP) -client -ppx $(CLIENT_INC) $(CLIENT_DEP_DIRS) $< > $@ - -$(DEPSDIR): - mkdir -p $@ - mkdir -p $(addprefix $@/, ${CLIENT_DIRS}) - mkdir -p $(addprefix $@/, ${SERVER_DIRS}) - -##---------------------------------------------------------------------- -## Generate CSS from SASS in the template. - -## A temporary filename and project name are mandatory because SASS files -## contain %%%PROJECT_NAME%%% as ID which is not available in SCSS. -## For the moment, no external SCSS files are used to generate the CSS. - -.PHONY: generate_css - -generate_css: $(CSS_FILES) - -$(TEMPLATE_DIR)/static\!defaultcss\!%.css: $(TEMPLATE_DIR)/sass!%.scss - sed s/%%%PROJECT_NAME%%%/$(SASS_TEMPORARY_PROJECT_NAME)/g $< > \ - $(SASS_TEMPORARY_FILENAME).scss - sass $(SASS_TEMPORARY_FILENAME).scss $(SASS_TEMPORARY_FILENAME).css - sed s/$(SASS_TEMPORARY_PROJECT_NAME)/%%%PROJECT_NAME%%%/g \ - $(SASS_TEMPORARY_FILENAME).css > $@ - -##---------------------------------------------------------------------- -## Documentation - -COMMON_OPTIONS := -colorize-code -stars -sort - -eliomdoc_wiki = ODOC_WIKI_SUBPROJECT="$(1)" \ - eliomdoc \ - -$(1) \ - -ppx -package resource-pooling,pgocaml,yojson,calendar,ocsigen-toolkit.$(1) \ - -intro doc/indexdoc.$(1) $(COMMON_OPTIONS) \ - -i $(shell ocamlfind query wikidoc) \ - -g odoc_wiki.cma \ - -d doc/$(1)/wiki \ - -hide-warnings \ - $(2) - -eliomdoc_html = ODOC_WIKI_SUBPROJECT="$(1)" \ - eliomdoc \ - -$(1) \ - -ppx -package resource-pooling,pgocaml,yojson,calendar,ocsigen-toolkit.$(1) \ - -intro doc/indexdoc.$(1) \ - $(COMMON_OPTIONS) \ - -html \ - -d doc/$(1)/html \ - -hide-warnings \ - $(2) - -doc: - rm -rf doc/client - rm -rf doc/server - mkdir -p doc/client/html - mkdir -p doc/client/wiki - mkdir -p doc/server/html - mkdir -p doc/server/wiki - $(call eliomdoc_html,client, $(CLIENT_INC_DIRS) $(CLIENT_FILES_DOC)) - $(call eliomdoc_wiki,client, $(CLIENT_INC_DIRS) $(CLIENT_FILES_DOC)) - $(call eliomdoc_html,server, $(SERVER_INC_DIRS) $(SERVER_FILES_DOC)) - $(call eliomdoc_wiki,server, $(SERVER_INC_DIRS) $(SERVER_FILES_DOC)) - -##---------------------------------------------------------------------- -## Clean up - -clean: - -rm -f *.cm[ioax] *.cmxa *.cmxs *.o *.a *.annot - -rm -f *.type_mli - -rm -f META - -rm -rf ${ELIOM_CLIENT_DIR} ${ELIOM_SERVER_DIR} ${LIBDIR} - -rm -f $(SASS_TEMPORARY_FILENAME).* - -rm -rf .sass-cache - -distclean: clean - -rm -rf $(DEPSDIR) .depend diff --git a/Makefile.options b/Makefile.options deleted file mode 100644 index be7406c24..000000000 --- a/Makefile.options +++ /dev/null @@ -1,80 +0,0 @@ - -#---------------------------------------------------------------------- -# SETTINGS FOR YOUR PACKAGE -#---------------------------------------------------------------------- - -# Package name for your -PKG_NAME := ocsigen-start -PKG_VERS := 1.1.0 -PKG_DESC := Skeleton for building your own Eliom application - -# Source files for the server -SERVER_FILES := $(filter-out %.ppx.ml,$(wildcard \ - src/*.ml* \ - src/*.eliom* \ - src/view/*.eliom* \ -)) -# Source files for the client -CLIENT_FILES := $(wildcard \ - src/*.eliom* \ - src/view/*.eliom* \ -) - -# Source files for the server -SERVER_FILES_DOC := $(wildcard \ - src/*.eliomi \ - src/*.mli \ - src/view/*.eliomi \ -) -# Source files for the client -CLIENT_FILES_DOC := $(wildcard \ - src/*.eliomi \ - src/view/*.eliomi \ -) - -# Template directory (used when installing template with distillery) -TEMPLATE_DIR := template.distillery - -# Template name (name used by distillery) -TEMPLATE_NAME := os.pgocaml - -##---------------------------------------------------------------------- -## Generate CSS from SASS files in the template. - -SCSS_FILES := $(TEMPLATE_DIR)/sass\!os.scss \ - $(TEMPLATE_DIR)/sass\!demo.scss - -CSS_FILES := $(TEMPLATE_DIR)/static\!defaultcss\!os.css \ - $(TEMPLATE_DIR)/static\!defaultcss\!demo.css - -SASS_TEMPORARY_FILENAME := .os_temporary_filename - -SASS_TEMPORARY_PROJECT_NAME := os_temporary_project_name - -##---------------------------------------------------------------------- - -# OCamlfind packages for the server -SERVER_PACKAGES := calendar safepass \ - ocsigen-toolkit.server yojson re.str cohttp-lwt-unix - -SERVER_PPX_PACKAGES := js_of_ocaml-ppx_deriving_json ocsigen-ppx-rpc - -SERVER_DB_PACKAGES := pgocaml calendar safepass resource-pooling - -SERVER_DB_PPX_PACKAGES := pgocaml_ppx - -# OCamlfind packages for the client -CLIENT_PACKAGES := calendar ocsigen-toolkit.client re.str - -CLIENT_PPX_PACKAGES := js_of_ocaml-ppx_deriving_json js_of_ocaml-ppx ocsigen-ppx-rpc - -# Debug package (yes/no): Debugging info in compilation -DEBUG := yes - -# Native mode (yes/no): Compile also with native mode (it will always compile with byte mode) -NATIVE := yes - -# Package's library $(PKG_NAME).{client,server}.cma (a,cmxa,cmxs only server side) -LIBDIR := lib/ - -WARNING_FLAGS=-w +A@3-4@5..15-9@20..68-37-39-44-48-69-34 diff --git a/dune b/dune new file mode 100644 index 000000000..59a829dbe --- /dev/null +++ b/dune @@ -0,0 +1,9 @@ +(vendored_dirs ocsigen-dune-rules) + +(data_only_dirs template.distillery) + +(install + (section lib_root) + (files + (glob_files_rec + (template.distillery/* with_prefix eliom/templates/os.pgocaml)))) diff --git a/dune-project b/dune-project new file mode 100644 index 000000000..b93df334a --- /dev/null +++ b/dune-project @@ -0,0 +1,69 @@ +(lang dune 3.18) + +(name ocsigen-start) + +(generate_opam_files true) + +(using dune_site 0.1) + +(source + (github ocsigen/ocsigen-start)) + +(homepage "https://ocsigen.org/ocsigen-start/") + +(authors "dev@ocsigen.org") + +(maintainers "dev@ocsigen.org") + +(license "LGPL-2.1-only WITH OCaml-LGPL-linking-exception") + +(maintenance_intent "(latest)") + +(dialect + (name "eliom-server") + (implementation + (extension "eliom")) + (interface + (extension "eliomi"))) + +(package + (name ocsigen-start) + (synopsis + "Higher-level library for developing Web and mobile applications with users, registration, notifications, etc") + (description + "Ocsigen Start is a set of higher-level libraries for building client-server Web and mobile applications with Ocsigen (Js_of_ocaml and Eliom).\nIt provides modules for user management (session management, registration, activation keys, ...), managing groups of users, displaying tips, and easily sending notifications to the users.\nOcsigen Start comes with an eliom-distillery template for an app with a database, user management, and session management.\nThis template is intended to serve as a basis for quickly building the Minimum Viable Product for Web and mobile applications with users.\nThe goal is to enable the programmer to concentrate on the core of the app, and not on user management.") + (depends + (ocaml + (>= "4.10")) + (pgocaml + (>= "4.0")) + (pgocaml_ppx + (>= "4.0")) + (safepass + (>= "3.0")) + (ocsigen-i18n + (>= "4.0.0")) + (eliom + (and + (>= "12.0.0") + (< "13.0.0"))) + (ocsigen-toolkit + (>= "2.7.0")) + (ocsigen-ppx-rpc + (>= "1.1")) + (yojson + (>= "1.6.0")) + (resource-pooling + (and + (>= "1.0") + (< "2.0"))) + cohttp-lwt-unix + (js_of_ocaml + (>= "6.3.2")) + (re + (>= "1.7.2")) + (ocsipersist-pgsql-config + (and + (>= "2.0") + (< "3.0"))) + conf-postgresql)) diff --git a/ocsigen-dune-rules/.gitignore b/ocsigen-dune-rules/.gitignore new file mode 100644 index 000000000..e35d8850c --- /dev/null +++ b/ocsigen-dune-rules/.gitignore @@ -0,0 +1 @@ +_build diff --git a/ocsigen-dune-rules/.ocamlformat b/ocsigen-dune-rules/.ocamlformat new file mode 100644 index 000000000..dbc03d392 --- /dev/null +++ b/ocsigen-dune-rules/.ocamlformat @@ -0,0 +1 @@ +version = 0.28.1 diff --git a/ocsigen-dune-rules/LICENSE b/ocsigen-dune-rules/LICENSE new file mode 100644 index 000000000..877734eb3 --- /dev/null +++ b/ocsigen-dune-rules/LICENSE @@ -0,0 +1,21 @@ +# MIT License + +Copyright (c) 2026 Tarides, Jules Aguillon + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/ocsigen-dune-rules/README.md b/ocsigen-dune-rules/README.md new file mode 100644 index 000000000..f204f9c1c --- /dev/null +++ b/ocsigen-dune-rules/README.md @@ -0,0 +1,58 @@ +# ocsigen-dune-rules + +Generate Dune rules for building a client/server application or library. + +## Usage + +The following `dune` file builds the client and server parts of your library. +Place it in a directory containing `*.eliom` files. + +`lib/dune`: +```dune +(library + (public_name my_lib.server) + (name my_lib) + (modes byte native) + (wrapped false) + (preprocess + (pps + eliom.ppx.server + ocsigen-ppx-rpc + --rpc-raw)) + (libraries eliom.server js_of_ocaml)) + +(subdir + client + (library + (public_name my_lib.client) + (name my_lib) + (modes byte) + (wrapped false) + (preprocess + (pps eliom.ppx.client js_of_ocaml-ppx)) + (libraries eliom.client js_of_ocaml js_of_ocaml-lwt)) + (dynamic_include ../dune.client)) + +(rule + (deps + (glob_files *.eliom) + (glob_files *.eliomi)) + (action + (with-stdout-to + dune.client + (run ocsigen-dune-rules .)))) +``` + +You must also tell Dune that `*.eliom` files contain source code by adding this to your `dune-project` file: + +`dune-project`: +```dune +(dialect + (name "eliom-server") + (implementation + (extension "eliom")) + (interface + (extension "eliomi"))) +``` + +See [ocsigen-toolkit](https://github.com/ocsigen/ocsigen-toolkit/tree/master) for a working example. diff --git a/ocsigen-dune-rules/dune-project b/ocsigen-dune-rules/dune-project new file mode 100644 index 000000000..313fc1ce9 --- /dev/null +++ b/ocsigen-dune-rules/dune-project @@ -0,0 +1,19 @@ +(lang dune 3.14) + +(name ocsigen-dune-rules) + +(cram enable) + +(generate_opam_files true) + +(authors "Jules Aguillon ") + +(maintainers "Jules Aguillon ") + +(license MIT) + +(package + (name ocsigen-dune-rules) + (synopsis + "Generate Dune rules for building a client/server application or library.") + (depends ocaml cmdliner ocsigen-ppx-rpc eliom)) diff --git a/ocsigen-dune-rules/ocsigen-dune-rules.opam b/ocsigen-dune-rules/ocsigen-dune-rules.opam new file mode 100644 index 000000000..8914b4cd1 --- /dev/null +++ b/ocsigen-dune-rules/ocsigen-dune-rules.opam @@ -0,0 +1,29 @@ +# This file is generated by dune, edit dune-project instead +opam-version: "2.0" +synopsis: + "Generate Dune rules for building a client/server application or library." +maintainer: ["Jules Aguillon "] +authors: ["Jules Aguillon "] +license: "MIT" +depends: [ + "dune" {>= "3.14"} + "ocaml" + "cmdliner" + "ocsigen-ppx-rpc" + "eliom" + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] diff --git a/ocsigen-dune-rules/ocsigen-dune-rules/dune b/ocsigen-dune-rules/ocsigen-dune-rules/dune new file mode 100644 index 000000000..778b68e6b --- /dev/null +++ b/ocsigen-dune-rules/ocsigen-dune-rules/dune @@ -0,0 +1,4 @@ +(executable + (public_name ocsigen-dune-rules) + (name main) + (libraries cmdliner)) diff --git a/ocsigen-dune-rules/ocsigen-dune-rules/gen_rules.ml b/ocsigen-dune-rules/ocsigen-dune-rules/gen_rules.ml new file mode 100644 index 000000000..ff0049663 --- /dev/null +++ b/ocsigen-dune-rules/ocsigen-dune-rules/gen_rules.ml @@ -0,0 +1,38 @@ +let pf = Printf.printf +let spf = Printf.sprintf + +let gen_eliom_ppx_rule ~target ~input ~args = + (* The [chdir] instruction is needed to obtain the correct path for + [-loc-filename] to be used in error messages. *) + pf + {|(rule + (with-stdout-to %s + (chdir %%{workspace_root} + (run ocsigen-ppx-client -as-pp -loc-filename %%{dep:%s} %s %%{dep:%s})))) +|} + target input (String.concat " " args) input + +let gen_rule_for_module ~server_rel_prefix ~impl fname = + let target = Filename.basename fname in + let fname_no_ext = Filename.remove_extension fname in + let input = Filename.concat server_rel_prefix fname in + if Filename.extension fname_no_ext = ".pp" then () + else + let args = + if impl then + let server_cmo = Filename.concat server_rel_prefix fname_no_ext in + [ "--impl"; "-server-cmo"; spf "%%{cmo:%s}" server_cmo ] + else [ "--intf" ] + in + gen_eliom_ppx_rule ~target ~input ~args + +(** Relative path to server modules from the generated client modules. *) +let server_rel_prefix = ".." + +let gen_rule_for_file fname = + match Filename.extension fname with + | ".eliom" -> gen_rule_for_module ~server_rel_prefix ~impl:true fname + | ".eliomi" -> gen_rule_for_module ~server_rel_prefix ~impl:false fname + | _ -> () + +let run files = List.iter gen_rule_for_file files diff --git a/ocsigen-dune-rules/ocsigen-dune-rules/main.ml b/ocsigen-dune-rules/ocsigen-dune-rules/main.ml new file mode 100644 index 000000000..7b608f240 --- /dev/null +++ b/ocsigen-dune-rules/ocsigen-dune-rules/main.ml @@ -0,0 +1,20 @@ +let run dir = + let files = Utils.list_dir dir in + let files = List.filter (Fun.negate Utils.is_dir) files in + Gen_rules.run files + +open Cmdliner + +let arg_dir = + let doc = "Directory containing the Eliom modules." in + Arg.(required & pos 0 (some dir) None & info ~doc ~docv:"DIR" []) + +let cmd = + let term = Term.(const run $ arg_dir) in + let doc = + "Generate dune rules for building an ocsigen application or library." + in + let info = Cmd.info "ocsigen-dune-rules" ~version:"%%VERSION%%" ~doc in + Cmd.v info term + +let () = exit (Cmd.eval cmd) diff --git a/ocsigen-dune-rules/ocsigen-dune-rules/utils.ml b/ocsigen-dune-rules/ocsigen-dune-rules/utils.ml new file mode 100644 index 000000000..0b9e1825a --- /dev/null +++ b/ocsigen-dune-rules/ocsigen-dune-rules/utils.ml @@ -0,0 +1,13 @@ +(** List the content of a directory. Returns qualified paths. Returned path + doesn't contain [./] if [p] is equal to ["."]. *) +let list_dir p = + (* Let [Sys_error] escape. *) + let files = Sys.readdir p in + (* Sorted for reproducibility. *) + Array.sort String.compare files; + let concat_p = if p = "." then Fun.id else Filename.concat p in + Array.iteri (fun i fname -> files.(i) <- concat_p fname) files; + Array.to_list files + +(** Do not raise. *) +let is_dir p = try Sys.is_directory p with Sys_error _ -> false diff --git a/ocsigen-dune-rules/ocsigen-ppx-client/dune b/ocsigen-dune-rules/ocsigen-ppx-client/dune new file mode 100644 index 000000000..ff7a6d26c --- /dev/null +++ b/ocsigen-dune-rules/ocsigen-ppx-client/dune @@ -0,0 +1,5 @@ +(executable + (public_name ocsigen-ppx-client) + (package ocsigen-dune-rules) + (name main) + (libraries ocsigen-ppx-rpc eliom.ppx.client)) diff --git a/ocsigen-dune-rules/ocsigen-ppx-client/main.ml b/ocsigen-dune-rules/ocsigen-ppx-client/main.ml new file mode 100644 index 000000000..e3cba4049 --- /dev/null +++ b/ocsigen-dune-rules/ocsigen-ppx-client/main.ml @@ -0,0 +1 @@ +let () = Ppxlib.Driver.standalone () diff --git a/ocsigen-dune-rules/test/dune b/ocsigen-dune-rules/test/dune new file mode 100644 index 000000000..58b3ec1e9 --- /dev/null +++ b/ocsigen-dune-rules/test/dune @@ -0,0 +1,2 @@ +(cram + (deps %{bin:ocsigen-dune-rules})) diff --git a/ocsigen-dune-rules/test/rules.t/a.eliom b/ocsigen-dune-rules/test/rules.t/a.eliom new file mode 100644 index 000000000..e69de29bb diff --git a/ocsigen-dune-rules/test/rules.t/b.eliom b/ocsigen-dune-rules/test/rules.t/b.eliom new file mode 100644 index 000000000..e69de29bb diff --git a/ocsigen-dune-rules/test/rules.t/b.eliomi b/ocsigen-dune-rules/test/rules.t/b.eliomi new file mode 100644 index 000000000..e69de29bb diff --git a/ocsigen-dune-rules/test/rules.t/not_eliom.ml b/ocsigen-dune-rules/test/rules.t/not_eliom.ml new file mode 100644 index 000000000..e69de29bb diff --git a/ocsigen-dune-rules/test/rules.t/run.t b/ocsigen-dune-rules/test/rules.t/run.t new file mode 100644 index 000000000..cd8b0a53b --- /dev/null +++ b/ocsigen-dune-rules/test/rules.t/run.t @@ -0,0 +1,13 @@ + $ ocsigen-dune-rules . + (rule + (with-stdout-to a.eliom + (chdir %{workspace_root} + (run ocsigen-ppx-client -as-pp -loc-filename %{dep:../a.eliom} --impl -server-cmo %{cmo:../a} %{dep:../a.eliom})))) + (rule + (with-stdout-to b.eliom + (chdir %{workspace_root} + (run ocsigen-ppx-client -as-pp -loc-filename %{dep:../b.eliom} --impl -server-cmo %{cmo:../b} %{dep:../b.eliom})))) + (rule + (with-stdout-to b.eliomi + (chdir %{workspace_root} + (run ocsigen-ppx-client -as-pp -loc-filename %{dep:../b.eliomi} --intf %{dep:../b.eliomi})))) diff --git a/ocsigen-dune-rules/test/rules.t/subdir/.keep b/ocsigen-dune-rules/test/rules.t/subdir/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/opam b/ocsigen-start.opam similarity index 64% rename from opam rename to ocsigen-start.opam index be6df0a6c..3eb530408 100644 --- a/opam +++ b/ocsigen-start.opam @@ -1,28 +1,25 @@ +# This file is generated by dune, edit dune-project instead opam-version: "2.0" -name: "ocsigen-start" -version: "8.0.0" -authors: "dev@ocsigen.org" -maintainer: "dev@ocsigen.org" -synopsis: "Higher-level library for developing Web and mobile applications with users, registration, notifications, etc" +synopsis: + "Higher-level library for developing Web and mobile applications with users, registration, notifications, etc" description: """ Ocsigen Start is a set of higher-level libraries for building client-server Web and mobile applications with Ocsigen (Js_of_ocaml and Eliom). It provides modules for user management (session management, registration, activation keys, ...), managing groups of users, displaying tips, and easily sending notifications to the users. Ocsigen Start comes with an eliom-distillery template for an app with a database, user management, and session management. This template is intended to serve as a basis for quickly building the Minimum Viable Product for Web and mobile applications with users. -The goal is to enable the programmer to concentrate on the core of the app, and not on user management. -""" +The goal is to enable the programmer to concentrate on the core of the app, and not on user management.""" +maintainer: ["dev@ocsigen.org"] +authors: ["dev@ocsigen.org"] +license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" homepage: "https://ocsigen.org/ocsigen-start/" bug-reports: "https://github.com/ocsigen/ocsigen-start/issues" -dev-repo: "git+https://github.com/ocsigen/ocsigen-start.git" -license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" -build: [ make "-j%{jobs}%" ] -install: [ make "install" ] depends: [ - "ocaml" {>= "4.10.0"} + "dune" {>= "3.18"} + "ocaml" {>= "4.10"} "pgocaml" {>= "4.0"} "pgocaml_ppx" {>= "4.0"} "safepass" {>= "3.0"} - "ocsigen-i18n" {>= "5.0.0" & < "6.0.0"} + "ocsigen-i18n" {>= "4.0.0"} "eliom" {>= "12.0.0" & < "13.0.0"} "ocsigen-toolkit" {>= "2.7.0"} "ocsigen-ppx-rpc" {>= "1.1"} @@ -33,9 +30,30 @@ depends: [ "re" {>= "1.7.2"} "ocsipersist-pgsql-config" {>= "2.0" & < "3.0"} "conf-postgresql" + "odoc" {with-doc} ] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "--promote-install-files=false" + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] + ["dune" "install" "-p" name "--create-install-files" name] +] +dev-repo: "git+https://github.com/ocsigen/ocsigen-start.git" +x-maintenance-intent: ["(latest)"] depexts: [ ["imagemagick" "ruby-sass"] {os-family = "debian"} ["md5sha1sum" "sassc"] {os = "macos" & os-distribution = "homebrew"} ] -x-maintenance-intent: ["(latest)" ] +pin-depends: [ + ["ocsigen-toolkit.dev" "git+https://github.com/ocsigen/ocsigen-toolkit.git#d3361b2969cc94a9fdc3e5bc0282184777894b98"] +] diff --git a/ocsigen-start.opam.template b/ocsigen-start.opam.template new file mode 100644 index 000000000..c238ae6a6 --- /dev/null +++ b/ocsigen-start.opam.template @@ -0,0 +1,7 @@ +depexts: [ + ["imagemagick" "ruby-sass"] {os-family = "debian"} + ["md5sha1sum" "sassc"] {os = "macos" & os-distribution = "homebrew"} +] +pin-depends: [ + ["ocsigen-toolkit.dev" "git+https://github.com/ocsigen/ocsigen-toolkit.git#d3361b2969cc94a9fdc3e5bc0282184777894b98"] +] diff --git a/scripts/2distillery.sh b/scripts/2distillery.sh deleted file mode 100755 index 794a4aa92..000000000 --- a/scripts/2distillery.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh - -usage() { - echo "usage: $0