GithubHelp home page GithubHelp logo

premake-ninja's Introduction

premake-ninja

Premake module to support Ninja, because it's awesome.

Implementation

For each project - configuration pair we create separate .ninja file. For solution we create build.ninja file which imports other .ninja files with subninja command.

Build.ninja file sets phony targets for configuration names so you can build them from command line. And default target is the first configuration name in your project (usually default).

Tested on ubuntu-badge windows-badge macos-badge

Extra Tests

Part of integration tests of several generators in https://github.com/Jarod42/premake-sample-projects Premake5 ubuntu ninja badgePremake5 window ninja badge

TODO

  • Resources are not supported
  • Makefile not supported
  • Bundles of any sort are not supported
  • Clear methods are not supported
  • C# not supported
  • D not supported
  • ...

premake-ninja's People

Contributors

cannedfood avatar iwadon avatar jarod42 avatar jimon avatar p0358 avatar r-lyeh avatar rvc86 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

premake-ninja's Issues

Investigate what's required to commit this project to premake5 upstream

So premake/premake-core#141 is closed. Would be nice to actually commit this to upstream so it would be maintained more properly.

Honestly premake5's make action is not that complicated, so this one shouldn't be that hard either. Some topics to think about :

  • Migrate to premake5 tests.
  • Compliance with C#/D/etc.
  • Just take premake5 make action and slightly modify it to generate ninja syntax? ninja and make operate on similar concepts, so shouldn't be that hard.

Does not work with x64

To repro, add this to one of test projects:

architecture "x86_64"
platforms "x64"

Result:

Building configurations...
Running action 'ninja'...
Generated build/build.ninja...
Generated build/build_ninjatestprj_debug_x64.ninja...
Generated build/build_ninjatestprj_release_x64.ninja...
Done (40ms).
ninja: error: 'ninjatestprj_debug_x64' missing and no known rule to make it

The issue is that a file like build_ninjatestprj_release_x64.ninja will be created, but in its line is build ninjatestprj_release without _x64.

I think the _x64 should be included (cause x86 variant can exist), especially that architecture is often also reflected in the target path (such as x64/Release) in build configs.

I'm making issue rather than PR as currently I'm not too sure how to fix it...

Test fail on Linux

Running tests for current HEAD (commit e51a1cb) and it fails. See full output below.

Among other things there are message like ninja: error: unknown target 'debug' and ninja: warning: multiple rules generate ninjatestprj_lib.

[anatol@arch tests]$ python ./run_tests.py
-------------------------- test default setup
Building configurations...
Running action 'ninja'...
Generated build/build.ninja...
Generated build/build_ninjatestprj_debug.ninja...
Generated build/build_ninjatestprj_release.ninja...
Done (15ms).
ninja: Entering directory `build'
[4/4] link bin_debug/ninjatestprj
ninja: Entering directory `build'
ninja: error: unknown target 'debug'
FBuilding configurations...
Running action 'ninja'...
Generated build/build.ninja...
Generated build/build_ninjatestprj_debug.ninja...
Generated build/build_ninjatestprj_release.ninja...
Done (22ms).
ninja: Entering directory `build'
[5/5] link bin_debug/ninjatestprj
ninja: Entering directory `build'
ninja: error: unknown target 'debug'
FBuilding configurations...
Running action 'ninja'...
Generated build/build.ninja...
Generated build/build_ninjatestprj_debug.ninja...
Generated build/build_ninjatestprj_release.ninja...
Done (16ms).
ninja: Entering directory `build'
[2/2] link bin_release/libninjatestprj.so
FBuilding configurations...
Running action 'ninja'...
Generated build/build.ninja...
Generated build/build_ninjatestprj_app_debug.ninja...
Generated build/build_ninjatestprj_app_release.ninja...
Generated build/build_ninjatestprj_lib_test1_debug.ninja...
Generated build/build_ninjatestprj_lib_test1_release.ninja...
Generated build/build_ninjatestprj_lib_test2_debug.ninja...
Generated build/build_ninjatestprj_lib_test2_release.ninja...
Done (23ms).
ninja: Entering directory `build'
[6/6] link bin_debug/ninjatestprj_app
ninja: Entering directory `build'
ninja: error: unknown target 'debug'
FBuilding configurations...
Running action 'ninja'...
Generated build/build.ninja...
Generated build/build_ninjatestprj_debug.ninja...
Generated build/build_ninjatestprj_release.ninja...
Done (13ms).
ninja: Entering directory `build'
[2/2] ar bin_release/libninjatestprj.a
FBuilding configurations...
Running action 'ninja'...
Generated build/build.ninja...
Generated build/build_ninjatestprj_app_debug.ninja...
Generated build/build_ninjatestprj_app_release.ninja...
Generated build/build_ninjatestprj_lib test1_debug.ninja...
Generated build/build_ninjatestprj_lib test1_release.ninja...
Generated build/build_ninjatestprj_lib_test2_debug.ninja...
Generated build/build_ninjatestprj_lib_test2_release.ninja...
Done (20ms).
ninja: Entering directory `build'
ninja: warning: multiple rules generate ninjatestprj_lib. builds involving this target will not be correct; continuing anyway [-w dupbuild=warn]
[6/6] link bin_debug/ninjatestprj_app
ninja: Entering directory `build'
ninja: warning: multiple rules generate ninjatestprj_lib. builds involving this target will not be correct; continuing anyway [-w dupbuild=warn]
ninja: error: unknown target 'debug'
FBuilding configurations...
Running action 'ninja'...
Generated build/build.ninja...
Generated build/build_ninjatestprj_debug.ninja...
Generated build/build_ninjatestprj_release.ninja...
Done (14ms).
ninja: Entering directory `build'
[4/4] link bin_debug/ninjatestprj
ninja: Entering directory `build'
ninja: error: unknown target 'debug'
F
======================================================================
FAIL: test_include_path (__main__.TestConsoleApp)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./run_tests.py", line 146, in test_include_path
    self.check_basics("build/bin_debug/ninjatestprj", "build/bin_release/ninjatestprj")
  File "./run_tests.py", line 122, in check_basics
    self.ninja("debug")
  File "./run_tests.py", line 51, in ninja
    self.assertEqual(subprocess.call(args), 0, "looks like ninja failed")
AssertionError: 1 != 0 : looks like ninja failed

======================================================================
FAIL: test_simple (__main__.TestConsoleApp)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./run_tests.py", line 140, in test_simple
    self.check_basics("build/bin_debug/ninjatestprj", "build/bin_release/ninjatestprj")
  File "./run_tests.py", line 122, in check_basics
    self.ninja("debug")
  File "./run_tests.py", line 51, in ninja
    self.assertEqual(subprocess.call(args), 0, "looks like ninja failed")
AssertionError: 1 != 0 : looks like ninja failed

======================================================================
FAIL: test_simple (__main__.TestSharedLib)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./run_tests.py", line 172, in test_simple
    self.check_basics("build/bin_debug/ninjatestprj", "build/bin_release/ninjatestprj")
  File "./run_tests.py", line 118, in check_basics
    self.out_exist(out_debug)
  File "./run_tests.py", line 74, in out_exist
    os.path.exists(self.out_name(path, ".dylib", "lib"))
AssertionError: False is not true

======================================================================
FAIL: test_withapp (__main__.TestSharedLib)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./run_tests.py", line 178, in test_withapp
    self.check_basics("build/bin_debug/ninjatestprj_app", "build/bin_release/ninjatestprj_app")
  File "./run_tests.py", line 122, in check_basics
    self.ninja("debug")
  File "./run_tests.py", line 51, in ninja
    self.assertEqual(subprocess.call(args), 0, "looks like ninja failed")
AssertionError: 1 != 0 : looks like ninja failed

======================================================================
FAIL: test_simple (__main__.TestStaticLib)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./run_tests.py", line 154, in test_simple
    self.check_basics("build/bin_debug/ninjatestprj", "build/bin_release/ninjatestprj")
  File "./run_tests.py", line 118, in check_basics
    self.out_exist(out_debug)
  File "./run_tests.py", line 74, in out_exist
    os.path.exists(self.out_name(path, ".dylib", "lib"))
AssertionError: False is not true

======================================================================
FAIL: test_withapp (__main__.TestStaticLib)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./run_tests.py", line 160, in test_withapp
    self.check_basics("build/bin_debug/ninjatestprj_app", "build/bin_release/ninjatestprj_app")
  File "./run_tests.py", line 122, in check_basics
    self.ninja("debug")
  File "./run_tests.py", line 51, in ninja
    self.assertEqual(subprocess.call(args), 0, "looks like ninja failed")
AssertionError: 1 != 0 : looks like ninja failed

======================================================================
FAIL: test_simple (__main__.TestWindowedApp)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./run_tests.py", line 190, in test_simple
    self.check_basics("build/bin_debug/ninjatestprj", "build/bin_release/ninjatestprj")
  File "./run_tests.py", line 122, in check_basics
    self.ninja("debug")
  File "./run_tests.py", line 51, in ninja
    self.assertEqual(subprocess.call(args), 0, "looks like ninja failed")
AssertionError: 1 != 0 : looks like ninja failed

----------------------------------------------------------------------
Ran 7 tests in 0.651s

FAILED (failures=7)

Issues with including other premake files

I want to split my different projects up into their own independent premake files and then include them into the master premake file with the workspace established. It compiles perfectly fine in premake but the ninja build commands never actually build anything from the other project files. Is this not supported yet or am I doing something wrong?

ninja: error: multiple rules generate bin/converter/Converter

I am completely new to premake (after giving up all hope over CMake) but this premake5.lua file generates a make file with no questions asked. It spits out the error in title when used with ninja. Am I doing something wrong or is it wrong?

workspace "TBTED"
    configurations { "Debug", "Release" }
    kind "ConsoleApp"
    language "C++"
    targetdir "bin"

project "Converter"
    targetdir "bin/converter"
    files { "converter.cpp" }

    filter "configurations:Debug"
        defines { "_DEBUG_" }

(At the same time I will also ask on the side here if it's intentional for ninja to have a seperate file for each configuration (premake generates three files). Make only requires a single makefile, does Ninja require multiple? My bad, make does use multiple files.)

precompiled not first include error

generating two "-include precompiled.h" args,
once in CFLAGS & CXXFLAGS
and once in rule cc/cxx's command.

this causes compilation error:

clang-15: warning: precompiled header 'obj/precompiled.h.gch' was ignored because '-include obj/precompiled.h' is not first '-include'
clang-15: warning: argument unused during compilation: '-MD' [-Wunused-command-line-argument]
<built-in>:2:10: fatal error: 'obj/precompiled.h' file not found

removing -include obj/precompiled.h from command fixes this problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.