Skip to content

Commit

Permalink
Merge pull request #37 from cgay/registry
Browse files Browse the repository at this point in the history
A rewrite of workspaces, essentially.
  • Loading branch information
cgay authored Jan 1, 2025
2 parents 5206c11 + 4a0ae00 commit 2dfb5c1
Show file tree
Hide file tree
Showing 55 changed files with 977 additions and 1,262 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# To actually use this filter you must run the following commands in the top-level Def directory.
# git config filter.version.smudge ./scripts/version-smudge.sh
# git config filter.version.clean ./scripts/version-clean.sh
# There is no way to configure that for all users of the repo.
sources/commands/utils.dylan filter=version
25 changes: 9 additions & 16 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,25 @@ jobs:
- uses: dylan-lang/install-opendylan@v3

- name: Build and run test suite
env:
DYLAN_CATALOG: ext/pacman-catalog
DYLAN: dylan-root
run: |
export DYLAN="$(realpath dylan-root)"
mkdir -p ${DYLAN}
make test
- name: Install
env:
DYLAN_CATALOG: ext/pacman-catalog
DYLAN: dylan-root
run: |
export DYLAN="$(realpath dylan-root)"
mkdir -p ${DYLAN}
make install
- name: Exercise deft
env:
DYLAN_CATALOG: ext/pacman-catalog
DYLAN: dylan-root
run: |
exe="$(realpath ${DYLAN}/bin/deft)"
export DYLAN_CATALOG="$(realpath ${DYLAN_CATALOG})"
${exe} new library --force-package abc strings@1.1
export DYLAN="$(realpath dylan-root)"
export PATH="${DYLAN}/bin:${PATH}"
deft new library --force-package abc strings@1.1
cd abc
${exe} update
${exe} status
${exe} list
${exe} build abc-test-suite
deft update
deft status
deft list
deft build abc-test-suite
_build/bin/abc-test-suite
24 changes: 0 additions & 24 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,24 +0,0 @@
[submodule "ext/sphinx-extensions"]
path = ext/sphinx-extensions
url = https://github.com/dylan-lang/sphinx-extensions.git
[submodule "ext/command-line-parser"]
path = ext/command-line-parser
url = https://github.com/dylan-lang/command-line-parser
[submodule "ext/json"]
path = ext/json
url = https://github.com/dylan-lang/json
[submodule "ext/logging"]
path = ext/logging
url = https://github.com/dylan-lang/logging
[submodule "ext/regular-expressions"]
path = ext/regular-expressions
url = https://github.com/dylan-lang/regular-expressions
[submodule "ext/uncommon-dylan"]
path = ext/uncommon-dylan
url = https://github.com/cgay/uncommon-dylan
[submodule "ext/testworks"]
path = ext/testworks
url = https://github.com/dylan-lang/testworks
[submodule "ext/pacman-catalog"]
path = ext/pacman-catalog
url = https://github.com/dylan-lang/pacman-catalog
80 changes: 30 additions & 50 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,63 +1,43 @@
# Low-tech Makefile to build and install deft.
# Low-tech Makefile to build and install deft. You will need a working "dylan" binary on
# your PATH somewhere.

DYLAN ?= $${HOME}/dylan
install_dir = $(DYLAN)/install/deft
install_bin = $(install_dir)/bin
install_lib = $(install_dir)/lib
link_target = $(install_bin)/deft-app
link_source = $(DYLAN)/bin/dylan

git_version := "$(shell git describe --tags --always --match 'v*')"

.PHONY: build build-with-version clean install install-debug really-install remove-deft-artifacts test dist distclean

build: remove-deft-artifacts
OPEN_DYLAN_USER_REGISTRIES=${PWD}/registry dylan-compiler -build -unify deft-app

# Hack to add the version to the binary with git tag info. Don't want this to
# be the normal build because it causes unnecessary rebuilds.
build-with-version: remove-deft-artifacts
file="sources/commands/utils.dylan"; \
orig=$$(mktemp); \
temp=$$(mktemp); \
cp -p $${file} $${orig}; \
cat $${file} | sed "s,/.__./.*/.__./,/*__*/ \"${git_version}\" /*__*/,g" > $${temp}; \
mv $${temp} $${file}; \
OPEN_DYLAN_USER_REGISTRIES=${PWD}/registry \
dylan-compiler -build -unify deft-app; \
cp -p $${orig} $${file}

# Until the install-deft GitHub Action is no longer referring to deft-app
# we also create a link named deft-app.
really-install:
mkdir -p $(DYLAN)/bin
cp _build/sbin/deft-app $(DYLAN)/bin/deft
ln -f $(DYLAN)/bin/deft $(DYLAN)/bin/deft-app

install: build-with-version really-install
.PHONY: build clean install remove-deft-artifacts test dist distclean

# Build and install without the version hacking above.
install-debug: build really-install
build:
dylan update
dylan build deft-app

# Deft needs to be buildable with submodules so that it can be built on
# new platforms without having to manually install deps.
test: build
OPEN_DYLAN_USER_REGISTRIES=${PWD}/registry \
dylan-compiler -build deft-test-suite \
&& DYLAN_CATALOG=ext/pacman-catalog _build/bin/deft-test-suite
install: build
mkdir -p $(DYLAN)/bin
mkdir -p $(DYLAN)/install/deft/bin
mkdir -p $(DYLAN)/install/deft/lib
cp _build/bin/deft-app $(DYLAN)/install/deft/bin/deft
cp -r _build/lib/lib* $(DYLAN)/install/deft/lib/
# For unified exe these could be hard links but for now they must be symlinks so
# that the relative paths to ../lib are correct. With --unify I ran into the
# "libunwind.so not found" bug.
ln -s -f $$(realpath $(DYLAN)/install/deft/bin/deft) $(DYLAN)/bin/deft
# For temp backward compatibility...
ln -s -f $$(realpath $(DYLAN)/install/deft/bin/deft) $(DYLAN)/bin/deft-app
ln -s -f $$(realpath $(DYLAN)/install/deft/bin/deft) $(DYLAN)/bin/dylan

test:
dylan update
dylan build deft-test-suite && _build/bin/deft-test-suite

dist: distclean install

# Sometimes I use deft to develop deft, so this makes sure to clean
# up its artifacts.
remove-deft-artifacts:
clean:
rm -rf _packages
find registry -not -path '*/generic/*' -type f -exec rm {} \;

clean: remove-deft-artifacts
rm -rf registry
rm -rf _build
rm -rf _test
rm -rf *~

distclean: clean
rm -rf $(install_dir)
rm -f $(link_source)
rm -rf $(DYLAN)/install/deft
rm -f $(DYLAN)/bin/deft
rm -f $(DYLAN)/bin/deft-app
rm -f $(DYLAN)/bin/dylan
8 changes: 4 additions & 4 deletions dylan-package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "deft",
"version": "0.12.0",
"version": "0.13.0",
"license": "MIT",
"category": "language-tools",
"category": "development tools",
"contact": "dylan-lang@googlegroups.com",
"description": "Manage Dylan workspaces, packages, and registries",
"keywords": ["workspace", "package"],
"dependencies": [
"command-line-parser@3.1.1",
"json@1.0",
"logging@2.1",
"json@1.1",
"logging@2.2",
"regular-expressions@0.2",
"uncommon-dylan@0.2"
],
Expand Down
1 change: 0 additions & 1 deletion ext/command-line-parser
Submodule command-line-parser deleted from b2f184
1 change: 0 additions & 1 deletion ext/json
Submodule json deleted from d6dabb
1 change: 0 additions & 1 deletion ext/logging
Submodule logging deleted from e0e87f
1 change: 0 additions & 1 deletion ext/pacman-catalog
Submodule pacman-catalog deleted from 8b4088
1 change: 0 additions & 1 deletion ext/regular-expressions
Submodule regular-expressions deleted from 5fd7d3
1 change: 0 additions & 1 deletion ext/sphinx-extensions
Submodule sphinx-extensions deleted from 05804f
1 change: 0 additions & 1 deletion ext/testworks
Submodule testworks deleted from c149c1
1 change: 0 additions & 1 deletion ext/uncommon-dylan
Submodule uncommon-dylan deleted from e38f97
1 change: 0 additions & 1 deletion registry/generic/command-line-parser

This file was deleted.

1 change: 0 additions & 1 deletion registry/generic/command-line-parser-test-suite

This file was deleted.

1 change: 0 additions & 1 deletion registry/generic/command-line-parser-test-suite-app

This file was deleted.

1 change: 0 additions & 1 deletion registry/generic/deft

This file was deleted.

1 change: 0 additions & 1 deletion registry/generic/deft-app

This file was deleted.

1 change: 0 additions & 1 deletion registry/generic/deft-test-suite

This file was deleted.

1 change: 0 additions & 1 deletion registry/generic/json

This file was deleted.

1 change: 0 additions & 1 deletion registry/generic/json-test-suite

This file was deleted.

1 change: 0 additions & 1 deletion registry/generic/logging

This file was deleted.

1 change: 0 additions & 1 deletion registry/generic/logging-test-suite

This file was deleted.

1 change: 0 additions & 1 deletion registry/generic/regular-expressions

This file was deleted.

1 change: 0 additions & 1 deletion registry/generic/regular-expressions-test-suite

This file was deleted.

1 change: 0 additions & 1 deletion registry/generic/testworks

This file was deleted.

1 change: 0 additions & 1 deletion registry/generic/uncommon-dylan

This file was deleted.

1 change: 0 additions & 1 deletion registry/generic/uncommon-dylan-tests

This file was deleted.

4 changes: 4 additions & 0 deletions scripts/version-clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

echo "$(date -Iseconds) clean $(pwd)" >> /tmp/version.log
sed "s,\"v.*built on.*\",\"DEVELOPMENT_VERSION\",g"
6 changes: 6 additions & 0 deletions scripts/version-smudge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

git_version="$(git describe --tags --always --match 'v*')"
date="$(date -Iseconds)"
echo "$(date -Iseconds) smudge $(pwd)" >> /tmp/version.log
sed "s,DEVELOPMENT_VERSION,${git_version} built on ${date},g"
4 changes: 2 additions & 2 deletions sources/app-library.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ define library deft-app
end library;

define module deft-app
use common-dylan;
use command-line-parser;
use common-dylan;
use deft-shared;
use deft;
use format-out;
use logging;
use operating-system, prefix: "os/";
use shared;
end module;
51 changes: 32 additions & 19 deletions sources/commands/build.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -35,50 +35,52 @@ define constant $build-subcommand
define method execute-subcommand
(parser :: <command-line-parser>, subcmd :: <build-subcommand>)
=> (status :: false-or(<int>))
let workspace = ws/load-workspace();
let ws = ws/load-workspace();
let library-names = get-option-value(subcmd, "libraries") | #[];
let all? = get-option-value(subcmd, "all");
if (all?)
if (~empty?(library-names))
warn("Ignoring --all option. Using the specified libraries instead.");
else
library-names
:= ws/find-active-package-library-names(workspace);
library-names := active-package-libraries(ws);
if (empty?(library-names))
error("No libraries found in workspace.");
end;
end;
end;
if (empty?(library-names))
library-names
:= list(ws/workspace-default-library-name(workspace)
:= list(ws/workspace-default-library-name(ws)
| error("No libraries found in workspace and no"
" default libraries configured."));
end;
let dylan-compiler = locate-dylan-compiler();
for (name in library-names)
let command = remove(vector(dylan-compiler,
"-compile",
get-option-value(subcmd, "clean") & "-clean",
get-option-value(subcmd, "link") & "-link",
get-option-value(subcmd, "unify") & "-unify",
name),
#f);
debug("Running command %=", command);
let env = make-compilation-environment(workspace);
// Let the shell locate dylan-compiler...
let command
= join(remove(list("dylan-compiler",
"-compile",
get-option-value(subcmd, "clean") & "-clean",
get-option-value(subcmd, "link") & "-link",
get-option-value(subcmd, "unify") & "-unify",
name),
#f),
" ");
verbose("%s", command);
let env = make-compilation-environment(ws);
let exit-status
= os/run-application(command,
environment: env, // adds to the existing environment
under-shell?: #f,
working-directory: ws/workspace-directory(workspace));
environment: env, // AUGMENTS the existing environment
under-shell?: #t,
working-directory: ws/workspace-directory(ws));
if (exit-status ~== 0)
error("Build of %= failed with exit status %=.", name, exit-status);
end;
end for;
end method;

define function make-compilation-environment (ws :: ws/<workspace>) => (env :: <table>)
let val = as(<string>, ws/workspace-registry-directory(ws));
define function make-compilation-environment
(ws :: ws/<workspace>) => (env :: <table>)
let val = as(<string>, ws/registry-directory(ws));
let var = "OPEN_DYLAN_USER_REGISTRIES";
let odur = os/environment-variable(var);
if (odur)
Expand All @@ -87,3 +89,14 @@ define function make-compilation-environment (ws :: ws/<workspace>) => (env :: <
end;
tabling(<string-table>, var => val)
end function;

define function active-package-libraries
(ws :: ws/<workspace>) => (libraries :: <seq>)
collecting ()
for (lids in ws/lids-by-active-package(ws))
for (lid in lids)
collect(ws/library-name(lid));
end;
end;
end
end function;
34 changes: 34 additions & 0 deletions sources/commands/install.dylan
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Module: deft
Synopsis: install subcommand


define class <install-subcommand> (<subcommand>)
keyword name = "install";
keyword help = "Install Dylan packages.";
end class;

define constant $install-subcommand
= make(<install-subcommand>,
options: list(make(<parameter-option>,
// TODO: type: <version>
names: #("version", "v"),
default: "latest",
help: "The version to install."),
make(<positional-option>,
name: "pkg",
repeated?: #t,
help: "Packages to install.")));

define method execute-subcommand
(parser :: <command-line-parser>, subcmd :: <install-subcommand>)
=> (status :: false-or(<int>))
for (package-name in get-option-value(subcmd, "pkg"))
let vstring = get-option-value(subcmd, "version");
let release = pm/find-package-release(pm/catalog(), package-name, vstring)
| begin
note("Package %= not found.", package-name);
abort-command(1);
end;
pm/install(release);
end;
end method;
Loading

0 comments on commit 2dfb5c1

Please sign in to comment.