diff --git a/.gitmodules b/.gitmodules index f15ef649bd..dfc7c07680 100644 --- a/.gitmodules +++ b/.gitmodules @@ -37,6 +37,3 @@ [submodule "documentation/website"] path = documentation/website url = https://github.com/dylan-lang/website -[submodule "sources/lib/protocol-buffers"] - path = sources/lib/protocol-buffers - url = https://github.com/cgay/protocol-buffers diff --git a/sources/environment/console/compiler-library.dylan b/sources/environment/console/compiler-library.dylan index ba322ff63c..77c222948b 100644 --- a/sources/environment/console/compiler-library.dylan +++ b/sources/environment/console/compiler-library.dylan @@ -23,9 +23,8 @@ define library dylan-compiler // Back-ends use dfmc-back-end-implementations; - // Project manager plug-ins call tool-register on load. + // Project manager plug-ins use motley; - use protobuf-tool; use tool-scepter; use tool-parser-generator; diff --git a/sources/environment/console/environment-library.dylan b/sources/environment/console/environment-library.dylan index 7bcd4d53be..7e2c0489bf 100644 --- a/sources/environment/console/environment-library.dylan +++ b/sources/environment/console/environment-library.dylan @@ -24,9 +24,8 @@ define library dylan-environment // Back-ends use dfmc-back-end-implementations; - // Project manager plug-ins call tool-register on load. + // Project manager plug-ins use motley; - use protobuf-tool; use tool-scepter; use tool-parser-generator; diff --git a/sources/environment/console/environment-module.dylan b/sources/environment/console/environment-module.dylan index a137774008..18dee450c4 100644 --- a/sources/environment/console/environment-module.dylan +++ b/sources/environment/console/environment-module.dylan @@ -20,7 +20,6 @@ define module console-environment working-directory }; use standard-io; use format; - use format-out; use commands; use command-lines; diff --git a/sources/lib/protobuf-tool/library.dylan b/sources/lib/protobuf-tool/library.dylan deleted file mode 100644 index 359d939b80..0000000000 --- a/sources/lib/protobuf-tool/library.dylan +++ /dev/null @@ -1,28 +0,0 @@ -Module: dylan-user - -define library protobuf-tool - use protocol-buffers; - - use common-dylan; - use dylan, import: { simple-debugging }; - use file-source-records; - use io; - use system; - use tools-interface; -end library; - -define module protobuf-tool - use protocol-buffers; - - use common-dylan; - use date; - use file-source-records; - use file-system; - use format; - use format-out; - use locators; - use simple-debugging, import: { debug-out }; - use streams; - use tools-interface; -end module; - diff --git a/sources/lib/protobuf-tool/protobuf-tool.dylan b/sources/lib/protobuf-tool/protobuf-tool.dylan deleted file mode 100644 index bbd2b26e9b..0000000000 --- a/sources/lib/protobuf-tool/protobuf-tool.dylan +++ /dev/null @@ -1,178 +0,0 @@ -Module: protobuf-tool -Synopsis: Support generating Dylan code from .proto files in the compiler. - - -// In addition to this code, the compiler executables have to "use protobuf-tool". - -// TODO(cgay): It looks like clean-build? is never passed at all? - -tool-register(#"protobuf", invoke-protobuf-tool); - -define constant $proto-directory = #"directory"; -define constant $proto-files = #"files"; -define constant $proto-library = #"library"; -define constant $all-headers - = vector(#"origin", $proto-directory, $proto-files, $proto-library); - -define method invoke-protobuf-tool - (spec-file :: , project-file :: false-or(), prev-run :: false-or(), - #key clean-build? :: ) - => (anything-modified? :: , modified-projects :: /* of: */) - debug-out(#"protobuf-tool", - "*** Protobuf tool invoked. Spec: %=, project: %=, prev: %=, clean: %=\n", - spec-file, project-file, prev-run, clean-build?); - if (~project-file) - // Comments in tools-interface.dylan say project-file should only be #f when invoked - // from the tool-invoke app (i.e., only during development of new plugins). - tool-error("no project file passed to protobuf-tool??"); - end; - // Note we don't do anything special for clean-build?: #t. Just re-gen the - // Dylan files and let the compiler figure out if they've changed. Sufficient? - - let generator = generator-from-spec-file(spec-file, prev-run); - if (~generator) - values(#f, #()) // No generator indicates nothing changed since prev-run. - else - let (output-files, lid-file) = generate-dylan-code(generator); - if (lid-file) - maybe-update-subproject(project-file, output-files, lid-file, prev-run) - else - modify-current-project(project-file, output-files) - end - end -end method invoke-protobuf-tool; - -define function maybe-update-subproject - (project-file :: , output-files :: , lid-file :: , - prev-run :: false-or()) - => (any-change? :: , modified-projects :: ) - // Code was generated in its own library, so the only file that might be returned - // is the LID file. - if (~prev-run - | file-modified?(lid-file, prev-run) - | any?(rcurry(file-modified?, prev-run), output-files)) - add-subproject(project-file, lid-file); - values(#t, vector(project-file)) - else - values(#f, #()) - end -end function; - -// Code was generated without a library definition or LID file so add the output files to -// the current project. The user might want to do this to add a method to a sealed -// generic function, for example. -// -// HACK: Insert the module files after the library file, which we assume to be the first -// file. When doing this, the user must define their library in a separate file from -// their modules so that the module files follow the generated protobuf module files and -// can therefore use the generated modules. What's a better way? -// Example: the project ends up looking like this: -// Files: library.dylan -// generated-pb-module1.dylan -// generated-pb-module2.dylan -// generated-pb.dylan -// user-module.dylan -// user-main.dylan -define function modify-current-project - (project-file :: , output-files :: ) - => (anything-modified? :: , modified-projects :: /* of: */) - let project = read-project-file(project-file); - let any-changed? = #f; - for (output-file in reverse(output-files)) - let relative = relative-locator(output-file, project-file); - let project-files = project.project-information-files; - if (member?(output-file, project-files, test: \=)) - debug-out(#"protobuf-tool", " File already in project: %=\n", output-file); - else - project.project-information-files - := concatenate(list(project-files[0], output-file), - copy-sequence(project-files, start: 1)); - any-changed? := #t; - debug-out(#"protobuf-tool", " Adding file to project: %=\n", output-file); - debug-out(#"protobuf-tool", " Files: %=\n", project.project-information-files); - end; - end; - if (any-changed?) - write-project-file(project-file, project); - values(#t, vector(project-file)) - else - values(#f, #()) - end -end function modify-current-project; - -/* Spec file format: -Origin: protobuf // Invoke this tool. -Files: a.proto // List of files to parse. - b.proto -Library: foo-pb // Name of library to create. If not specified then don't - // create a library; just generate module files. -Directory: generated // Where to put generated files, relative to project dir. -*/ - -define function generator-from-spec-file - (spec-file :: , prev-run :: false-or()) - => (gen :: false-or()) - let spec :: = read-file-header(spec-file); - for (_ keyed-by k in spec) - if (~member?(k, $all-headers)) - // TODO(cgay): how to just issue a warning? - tool-error("unrecognized key %= in %s", k, spec-file) - end; - end; - - let proto-files = element(spec, $proto-files, default: #f) - | tool-error("%s has no Files: header", spec-file); - let proto-files = map(method (proto-file :: ) - merge-locators(as(, proto-file), spec-file) - end, - proto-files); - if (~prev-run - | file-modified?(spec-file, prev-run) - | any?(rcurry(file-modified?, prev-run), - proto-files)) - local method one-or-none (key) - let v = element(spec, key, default: #f); - if (v) - if (v.size > 1) - tool-error("The '%s:' header in %s must have exactly one value, got %=", - format-arguments: list(key, spec-file, v)); - end; - v[0] - end; - end; - let output-directory = spec-file.locator-directory; - let dir = one-or-none($proto-directory); - if (dir) - output-directory := apply(subdirectory-locator, output-directory, - locator-path(as(, dir))); - end; - make(, - input-files: proto-files, - output-directory: output-directory, - library-name: one-or-none($proto-library)) - end if -end function; - -define function file-modified? (locator :: , since :: ) - block () - file-property(locator, #"modification-date") > since - exception (err :: ) - tool-error("could not open proto file %s: %=", - format-arguments: list(locator, err)); - end -end function; - -define function add-subproject - (project-file :: , subproject :: ) => () - let project = read-project-file(project-file); - let loc = relative-locator(subproject, project-file); - // Remove the file extension because it confuses the build system. - let loc = make(, - directory: locator-directory(loc), // may be #f - base: locator-base(loc)); - project.project-information-subprojects - := add-new!(project.project-information-subprojects, - loc, - test: \=); - write-project-file(project-file, project); -end function; diff --git a/sources/lib/protobuf-tool/protobuf-tool.lid b/sources/lib/protobuf-tool/protobuf-tool.lid deleted file mode 100644 index 4d666aeff0..0000000000 --- a/sources/lib/protobuf-tool/protobuf-tool.lid +++ /dev/null @@ -1,3 +0,0 @@ -Library: protobuf-tool -Files: library.dylan - protobuf-tool.dylan diff --git a/sources/lib/protobuf-tool/tests/pbtool-test-one-a.proto b/sources/lib/protobuf-tool/tests/pbtool-test-one-a.proto deleted file mode 100644 index ba8d43e75c..0000000000 --- a/sources/lib/protobuf-tool/tests/pbtool-test-one-a.proto +++ /dev/null @@ -1,8 +0,0 @@ -syntax = "proto2"; - -// Same package as pbtool-test-one-b.proto -package pbtool.test.one.pb; - -message Message1 { - optional string field1 = 1; -} diff --git a/sources/lib/protobuf-tool/tests/pbtool-test-one-b.proto b/sources/lib/protobuf-tool/tests/pbtool-test-one-b.proto deleted file mode 100644 index e10564e7c4..0000000000 --- a/sources/lib/protobuf-tool/tests/pbtool-test-one-b.proto +++ /dev/null @@ -1,8 +0,0 @@ -syntax = "proto2"; - -// Same package as pbtool-test-one-a.proto -package pbtool.test.one.pb; - -message Message2 { - optional string field1 = 1; -} diff --git a/sources/lib/protobuf-tool/tests/pbtool-test-one-library.dylan b/sources/lib/protobuf-tool/tests/pbtool-test-one-library.dylan deleted file mode 100644 index 0cdde48b67..0000000000 --- a/sources/lib/protobuf-tool/tests/pbtool-test-one-library.dylan +++ /dev/null @@ -1,8 +0,0 @@ -Module: dylan-user -Synopsis: Test building an app containing .proto files, compiling the proto files into the using library - -define library pbtool-test-one - use common-dylan; - use io, import: { format-out }; - use protocol-buffers; -end library; diff --git a/sources/lib/protobuf-tool/tests/pbtool-test-one-module.dylan b/sources/lib/protobuf-tool/tests/pbtool-test-one-module.dylan deleted file mode 100644 index 3f3cbc8fa6..0000000000 --- a/sources/lib/protobuf-tool/tests/pbtool-test-one-module.dylan +++ /dev/null @@ -1,8 +0,0 @@ -Module: dylan-user - -define module pbtool-test-one - use common-dylan; - use format-out; - use protocol-buffers; - use pbtool-test-one-pb; // generated from pbtool-test-one-{a,b}.proto -end module; diff --git a/sources/lib/protobuf-tool/tests/pbtool-test-one.dylan b/sources/lib/protobuf-tool/tests/pbtool-test-one.dylan deleted file mode 100644 index e46f1aeba2..0000000000 --- a/sources/lib/protobuf-tool/tests/pbtool-test-one.dylan +++ /dev/null @@ -1,12 +0,0 @@ -Module: pbtool-test-one - - -define function main - (name :: , arguments :: ) - format-out("Hello, world! Here's a : %=\n", - make(, - field1: "field1")); - exit-application(0); -end function; - -main(application-name(), application-arguments()); diff --git a/sources/lib/protobuf-tool/tests/pbtool-test-one.lid b/sources/lib/protobuf-tool/tests/pbtool-test-one.lid deleted file mode 100644 index b23b2f5f9e..0000000000 --- a/sources/lib/protobuf-tool/tests/pbtool-test-one.lid +++ /dev/null @@ -1,6 +0,0 @@ -Library: pbtool-test-one -Files: pbtool-test-one-library - pbtool-test-one-module - pbtool-test-one -Other-files: pbtool-test-one.spec -Target-type: executable diff --git a/sources/lib/protobuf-tool/tests/pbtool-test-one.spec b/sources/lib/protobuf-tool/tests/pbtool-test-one.spec deleted file mode 100644 index 17c329687f..0000000000 --- a/sources/lib/protobuf-tool/tests/pbtool-test-one.spec +++ /dev/null @@ -1,3 +0,0 @@ -Origin: protobuf -Files: pbtool-test-one-a.proto - pbtool-test-one-b.proto diff --git a/sources/lib/protobuf-tool/tests/pbtool-test-two-library.dylan b/sources/lib/protobuf-tool/tests/pbtool-test-two-library.dylan deleted file mode 100644 index 71396dec87..0000000000 --- a/sources/lib/protobuf-tool/tests/pbtool-test-two-library.dylan +++ /dev/null @@ -1,16 +0,0 @@ -Module: dylan-user -Synopsis: Test building an app containing .proto files, in its own library - -define library pbtool-test-two - use common-dylan; - use io, import: { format-out }; - use protocol-buffers; - use pbtool-test-two-pb; // generated from pbtool-test-two-a.proto -end library; - -define module pbtool-test-two - use common-dylan; - use format-out; - use protocol-buffers; - use pbtool-test-two-pb; // generated from pbtool-test-two-a.proto -end module; diff --git a/sources/lib/protobuf-tool/tests/pbtool-test-two.dylan b/sources/lib/protobuf-tool/tests/pbtool-test-two.dylan deleted file mode 100644 index 40bc300a6e..0000000000 --- a/sources/lib/protobuf-tool/tests/pbtool-test-two.dylan +++ /dev/null @@ -1,12 +0,0 @@ -Module: pbtool-test-two - - -define function main - (name :: , arguments :: ) - format-out("Hello, world! Here's a : %=\n", - make(, - field1: "field1")); - exit-application(0); -end function; - -main(application-name(), application-arguments()); diff --git a/sources/lib/protobuf-tool/tests/pbtool-test-two.lid b/sources/lib/protobuf-tool/tests/pbtool-test-two.lid deleted file mode 100644 index c7b6fdfd57..0000000000 --- a/sources/lib/protobuf-tool/tests/pbtool-test-two.lid +++ /dev/null @@ -1,5 +0,0 @@ -Library: pbtool-test-two -Files: pbtool-test-two-library - pbtool-test-two -Other-files: pbtool-test-two.spec -Target-type: executable diff --git a/sources/lib/protobuf-tool/tests/pbtool-test-two.proto b/sources/lib/protobuf-tool/tests/pbtool-test-two.proto deleted file mode 100644 index 531921ac61..0000000000 --- a/sources/lib/protobuf-tool/tests/pbtool-test-two.proto +++ /dev/null @@ -1,7 +0,0 @@ -syntax = "proto2"; - -package pbtool.test.two.pb; - -message Message1 { - optional string field1 = 1; -} diff --git a/sources/lib/protobuf-tool/tests/pbtool-test-two.spec b/sources/lib/protobuf-tool/tests/pbtool-test-two.spec deleted file mode 100644 index 68f8c45325..0000000000 --- a/sources/lib/protobuf-tool/tests/pbtool-test-two.spec +++ /dev/null @@ -1,3 +0,0 @@ -Origin: protobuf -Files: pbtool-test-two.proto -Library: pbtool-test-two-pb diff --git a/sources/lib/protocol-buffers b/sources/lib/protocol-buffers deleted file mode 160000 index 2c33ffc006..0000000000 --- a/sources/lib/protocol-buffers +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2c33ffc006eeee6e9cebf83e4eebaecfc5e5d2d8 diff --git a/sources/project-manager/projects/implementation.dylan b/sources/project-manager/projects/implementation.dylan index e4f075f6bf..c97c657cfe 100644 --- a/sources/project-manager/projects/implementation.dylan +++ b/sources/project-manager/projects/implementation.dylan @@ -288,13 +288,13 @@ define method make-project end if end; + debug-out(#"project-manager", "Make-project: %s parent: %s\n", key, + parent & parent.project-name); let project = apply(make, c, platform-name: platform-name, compiler-back-end:, back-end, keys); - debug-out(#"project-manager", "make-project(%=, key: %=, parent: %=) => %=\n", - c, key, parent & parent.project-name, project); if (mode) project-compilation-mode(project) := mode end; @@ -389,7 +389,7 @@ define function project-open-compilation-context ~project-personal-library?(project), load-namespace?: load-namespace?); if (project.project-dylan-library?) - debug-out(#"project-manager", " Opened compilation context for the Dylan library\n") + debug-out(#"project-manager", " Opened compilation context for the Dylan library") end; // we have to set the context in either case, // otherwise project closing code won't work @@ -566,7 +566,7 @@ define method close-project (project :: , #key system? = #f) *all-open-projects*); closed? else - debug-out(#"project-manager", "Closing non top level project %s\n", project.project-name); + debug-out(#"project-manager", "Closing non top level project %s", project.project-name); empty?(project.project-owners) & %close-project(project) end end method; @@ -594,7 +594,7 @@ define function project-reset-database (project :: ) let (mj, mn) = compilation-context-version(context); install-project-sources(context, make(, size: 0), mj, mn); note-database-invalidated(project); - debug-out(#"project-manager", "Reset database for project %s\n", project.project-name); + debug-out(#"project-manager", "Reset database for project %s", project.project-name); end; end; @@ -618,7 +618,7 @@ define function project-remove-database (project :: ) => () project-close-compilation-contexts(project); let db = project.project-database-location; %delete-file-if-exists(db); - debug-out(#"project-manager", "Removed database for project %s\n", project.project-name); + debug-out(#"project-manager", "Removed database for project %s", project.project-name); project-open-compilation-context(project, load-namespace?: #f); project-set-compilation-parameters(project); @@ -704,7 +704,7 @@ define function canonicalize-project-sources if (empty?(compiler-sources)) // fixup debug-out(#"project-manager", - "Fixing up sources for %s\n", + "Fixing up sources for %s", project.project-name); values(project-current-source-records(project), project-major-version(project), diff --git a/sources/project-manager/tools-interface/library.dylan b/sources/project-manager/tools-interface/library.dylan index 7a0d8153df..327aad5390 100644 --- a/sources/project-manager/tools-interface/library.dylan +++ b/sources/project-manager/tools-interface/library.dylan @@ -24,7 +24,6 @@ define module tools-interface use format; use format-out; use locators; - use simple-debugging; use streams; use file-system; diff --git a/sources/project-manager/tools-interface/tools-interface.dylan b/sources/project-manager/tools-interface/tools-interface.dylan index 49fb1a391b..042ec2db95 100644 --- a/sources/project-manager/tools-interface/tools-interface.dylan +++ b/sources/project-manager/tools-interface/tools-interface.dylan @@ -104,7 +104,7 @@ define function tool-find => (invokee :: false-or()) if (tool-registry) element(tool-registry, tool-name, default: #f) - end if + end if; end function tool-find; diff --git a/sources/project-manager/user-projects/user-projects.dylan b/sources/project-manager/user-projects/user-projects.dylan index 12ead95d14..96c1fef075 100644 --- a/sources/project-manager/user-projects/user-projects.dylan +++ b/sources/project-manager/user-projects/user-projects.dylan @@ -154,7 +154,7 @@ define method note-project-loaded (project :: ) let symbol-name :: = as(, name); unless (symbol-name == old-name) project.project-lid-library-name := symbol-name; - debug-out(#"project-manager", "Changing library name keyword to %s\n", name); + debug-out(#"project-manager", "Changing library name keyword to %s", name); end; end; end method; @@ -165,8 +165,7 @@ define constant $replace-project-string = define function %project-replace-project-ask (project :: , close? :: ) => (yes-or-no :: , project :: false-or()) - debug-out(#"project-manager", "Asking whether to replace %= %s\n", - project, project.project-name); + debug-out(#"project-manager", "Asking if to replace %= %s", project, project.project-name); let key = project.project-library-name; let text = format-to-string($replace-project-string, key, project.project-location); @@ -215,7 +214,8 @@ define method project-replace-project-with? #key project-file :: , close? = #t) => (yes-or-no :: , project :: false-or()) if (project.user-disk-project-file = project-file) - debug-out(#"project-manager", "project file %s is the same as %s\n", + debug-out(#"project-manager", + "project file %s is the same as %s", project-file, project.user-disk-project-file); values(#f, project) else @@ -302,7 +302,8 @@ define method replace-project-with? // TO DO: when replacing project the new one will not have an owner // until next compilation - is this a problem ? if (project) - debug-out(#"project-manager", "Deciding if %= %s should be replaced\n", + debug-out(#"project-manager", + "Deciding if %= %s should be replaced", project, project.project-name); if (force?) // 'force?' implies 'close?' @@ -533,8 +534,6 @@ define method import-lid-project (lid-location :: , #key to-file) when (project & project.project-namespace-loaded) close-unused-projects(); end; - debug-out(#"project-manager", "import-lid-project(%=) returning %=\n", - lid-location, project); project end; @@ -564,8 +563,9 @@ define method %import-lid-project (lid-location :: , end; if (ok?) - debug-out(#"project-manager", "Importing %s to %s\n", - lid-location, project-location); + debug-out(#"project-manager", + "Importing %s to %s", as(, lid-location), + as(, project-location)); apply(make-method, , project-file: project-location, keys); else @@ -661,11 +661,11 @@ define function open-hdp-project (project-file-location :: ) project else debug-out(#"project-manager", - "open-hdp-project: returning already opened project %= %s\n", + "Open-project: returning already opened project %= %s", opened-project, opened-project & opened-project.project-name); if (opened-project) debug-out(#"project-manager", - "open-hdp-project: the project is already open as %s\n", + "The project is already open as %s ", project-location) else user-warning("Couldn't open project in %s ", project-location) @@ -823,14 +823,10 @@ define method note-loading-namespace (project :: ) => () local method process-file(f) let full-path = merge-locators(as(, f), project.project-source-location); - let tool-name :: false-or() - = tool-name-from-specification(full-path); + let tool-name :: false-or() = + tool-name-from-specification(full-path); let tool = tool-name & tool-find(tool-name); - debug-out(#"project-manager", "process-file(%=) tool-name: %=, tool: %=\n", - f, tool-name, tool); - if (~tool) - user-warning("No tool found to process file %s", f); - else + if (tool) let tool-cache = element(project.%tools-cache, tool-name, default: #f); local method last-run-date(f, cache) block (found) diff --git a/sources/registry/generic/pbgen b/sources/registry/generic/pbgen deleted file mode 100644 index 881aac64b9..0000000000 --- a/sources/registry/generic/pbgen +++ /dev/null @@ -1 +0,0 @@ -abstract://dylan/lib/protocol-buffers/sources/pbgen/pbgen.lid diff --git a/sources/registry/generic/pbtool-test-two-pb b/sources/registry/generic/pbtool-test-two-pb deleted file mode 100644 index 5d862dac77..0000000000 --- a/sources/registry/generic/pbtool-test-two-pb +++ /dev/null @@ -1 +0,0 @@ -abstract://dylan/lib/protobuf-tool/tests/pbtool-test-two-pb.lid diff --git a/sources/registry/generic/protobuf-tool b/sources/registry/generic/protobuf-tool deleted file mode 100644 index 18371702bd..0000000000 --- a/sources/registry/generic/protobuf-tool +++ /dev/null @@ -1 +0,0 @@ -abstract://dylan/lib/protobuf-tool/protobuf-tool.lid diff --git a/sources/registry/generic/protocol-buffers b/sources/registry/generic/protocol-buffers deleted file mode 100644 index ef74935923..0000000000 --- a/sources/registry/generic/protocol-buffers +++ /dev/null @@ -1,2 +0,0 @@ -abstract://dylan/lib/protocol-buffers/sources/protocol-buffers.lid - diff --git a/sources/registry/generic/protocol-buffers-test-suite b/sources/registry/generic/protocol-buffers-test-suite deleted file mode 100644 index aa153df718..0000000000 --- a/sources/registry/generic/protocol-buffers-test-suite +++ /dev/null @@ -1 +0,0 @@ -abstract://dylan/lib/protocol-buffers/sources/test-suite.lid