Skip to main content

A flexible build system assistant.

Project description

bulgogi-py

The Python interface for bulgogi.

Motive

  1. Rather than write a CLI from scratch, using a scripting language as the interface seemed cool and appropriate for this project.
  2. Build configurations are slow-changing and repititious, making scripts ideal for the job.

Build dependencies

The following system dependencies are required:

  • git
  • gcc
  • make
  • libtool
  • python3
    • pip
    • build
  • python3-devel

And any dependencies not listed here but found in: yaml/libyaml.

Build instructions

Use the build.sh script to make sure necessary submodules are cloned and setup correctly:


./build.sh 

Usage

To get started, install bulgogi using pip:

pip install --user bulgogi 

Once installed at the user-level, use it in your latest build project.

1. Create setup.py

First create the setup.py file in the root of your build project and declare your project:

# setup.py 
import bulgogi as bul 

bul.new_project('My Project')
bul.set_version('v1.0.0')

...

2. Declare targets

The next step is to declare targets based on your project layout:

...

target1 = bul.add_target('target1', bul.LIB)
execute = bul.add_target('execute', bul.EXE)

...

3. Declare relations

Targets need to be linked in some kind of way. This is usually referred to as 'dependency linking'.

In the Python interface for bulgogi, dependencies are linked by target ID:

...

bul.add_target_dep(execute, target1)

...

4. Commit the setup

Lastly, the build configuration must be commit to disk before it can be built:

...

bul.commit()

Putting it all together

# setup.py 
import bulgogi as bul 

bul.new_project('My Project')
bul.set_version('v1.0.0')

target1 = bul.add_target('target1', bul.LIB)
execute = bul.add_target('execute', bul.EXE)

bul.add_target_dep(execute, target1)

bul.commit()

This will generate a project.yaml file in the root of your directory and resemble something like:

execute:
  - target1

Usually configuration files are guarded from manual edits - but bulgogi in fact encourages the developer to modify the project.yaml file as they please.

Where are all the sources?

Although targets have been declared and dependencies linked, the best bulgogi can do to find the source files to copmile is to guess.

As a sane default, it will guess that each target has a directory matching its name (target1/ and execute/ in this case) and look for src and inc directories within.

This means - yes - that in theory the setup.py script can be ommitted altogether. This is not defeatist - it's to highlight that the script is most useful to standardize project configuration for all bulgogi targets, even if the project isn't your own.

Declaring sources

In the setup.py, target sources can be declared:

...

bul.add_sources(target1, 'target1/src/*.c')
bul.add_headers(target1, 'target1/inc/*.h')

...

bul.commit()

This can be done anytime after target1 has been added but before the configuration is committed to disk.

Patterns

It is evident that a specific files were not specified for the target sources. Patterns such as *.c are used instead and are known as 'globbing'.

Globbing

Globbing is a mixed subject among build system afficionados. Bulgogi offers it as a built-in feature and allows users to decide how they would like to approach.

...

# Adding individual files is allowed.
bul.add_sources(target1, 'target1/src/hello.c')
bul.add_sources(target1, 'target1/src/dog.c')
bul.add_sources(target1, 'target1/src/cat.c')

...

# Files can be 'globbed' by file-extension.
bul.add_sources(target1, 'target1/src/*.c')
bul.add_sources(target1, 'target1/src/*.cpp')

...

# Globbing can also be performed recursively.
bul.add_headers(target1, 'target1/inc/**.c')


bul.commit()

Variables

A benefit of using a feature-complete scripting language is the built-in availability of variables.

...

targets = ['target1', 'execute']
src_dir = 'src'
inc_dir = 'inc'

for target in targets:
    bul.add_sources(target, bul.names(target) + '/' + SRC_DIR + '/*.c')
    bul.add_headers(target, bul.names(target) + '/' + INC_DIR + '/*.h')

bul.commit()

TODO: Complete section and make it accurate / stop inventing stuff.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bulgogi-0.0.7.tar.gz (192.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bulgogi-0.0.7-cp311-cp311-macosx_14_0_arm64.whl (230.3 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

File details

Details for the file bulgogi-0.0.7.tar.gz.

File metadata

  • Download URL: bulgogi-0.0.7.tar.gz
  • Upload date:
  • Size: 192.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for bulgogi-0.0.7.tar.gz
Algorithm Hash digest
SHA256 475e162d82fc72fb17b9986a8522be6c04641a5b064309bb2a9a20ba35903f4e
MD5 0756b3c87d108612201755d76d619c4e
BLAKE2b-256 37ca0e95f29c38f4f1633a88d01e3464272736e5948bba78d412d15a6303fea5

See more details on using hashes here.

File details

Details for the file bulgogi-0.0.7-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for bulgogi-0.0.7-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 c164ab85720551be541b2c6b738fee9a38bf66cd6fac81259a1157bb6d2953d9
MD5 d7912c799c9732acca79442d714a128a
BLAKE2b-256 06e801a4f500c497ef1198fda5c1ea5c610bdfdf412143fa8d0175448ec7922f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page