Skip to content

Instantly share code, notes, and snippets.

@tophyr
Created June 24, 2017 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tophyr/d8ead175ba76df511cffa57bc1f3ea36 to your computer and use it in GitHub Desktop.
Save tophyr/d8ead175ba76df511cffa57bc1f3ea36 to your computer and use it in GitHub Desktop.
CREATE TABLE target_types (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR NOT NULL,
PRIMARY KEY (id)
)
CREATE TABLE build_targets (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR UNIQUE NOT NULL,
output_file VARCHAR,
type_id INT NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (type_id) REFERENCES target_types (id)
)
CREATE TABLE target_sources (
id INT NOT NULL AUTO_INCREMENT,
path VARCHAR UNIQUE NOT NULL,
target_id INT NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (target_id) REFERENCES build_targets (id)
)
CREATE TABLE target_deps (
depender_id INT NOT NULL,
dependent_id INT NOT NULL,
PRIMARY KEY (depender_id, dependent_id),
FOREIGN KEY (depender_id) REFERENCES build_targets (id),
FOREIGN KEY (dependent_id) REFERENCES build_targets (id)
)
I want to know:
1. All the source files directly used by a given target.
2. All the targets that have source files in a given directory.
3. Any build target types that overlap source file extensions.
4. The full list of transitive dependencies of a given target.
EC: The *graph*, as a list of A->B edges (where A is depender, B is dependent)
5. The full list of targets that transitively depend on a given source file.
6. The number of completely-disjoint target graphs (islands) in the database.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment