方案1:命令行
#!/bin/sh #file name: erl.sh #author: stars #time:2015.06.05 #eg: ./erl.sh hello.erl start 2 #full name for erl name. erlFileName=$1 #the function in erl file. func=$2 # params params=$3 erlFileSize=`expr length "$erlFileName"` subSize=`expr $erlFileSize - 4` erlFileBaseName=`expr substr "$erlFileName" 1 $subSize` erlc $erlFileName erl -noshell -s $erlFileBaseName $func $params -s init stop
方案2:escript
#!/usr/bin/env escript main(_) -> io:format("Hello World\n").
方案3:makefile
#makefile for erl #author: stars #time: 2015.06.05 .SUFFIXES: .erl .beam ERL = erl -noshell ERL_DIR = . BEAM_DIR = . MODULES = $(patsubst $(ERL_DIR)/%.erl, $(BEAM_DIR)/%.beam, $(wildcard $(ERL_DIR)/*.erl)) all: compile $(ERL) -s hello start -s init stop compile: $(MODULES) %.beam: %.erl erlc -W $< .PHONY: clean clean: rm -rf $(MODULES) *.dump
时间: 2024-10-13 10:29:26