Kode / khamake

Kha's build tool.
http://kha.tech
15 stars 43 forks source link

Issues Building With Latest Khamake+Koremake #178

Closed zicklag closed 5 years ago

zicklag commented 5 years ago

I've recently updated Kha to the latest and noticed that there are some errors trying to do a *-hl builds in Armory ( I have tested running Khamake without using Armory to verifiy that it is not specific to Armory ).

Issue Description

When I try to run the build I get:

$ node /home/zicklag/programs/armory/armsdk/Kha/make android-native-hl -g opengl -
-shaderversion 300 --parallelAssetConversion 4 --to testbuild_2
Using Kha from /home/zicklag/programs/armory/armsdk/Kha
Creating Kha project.
Compiling shader 1 of 8 (painter-colored.frag.glsl).
Compiling shader 2 of 8 (painter-colored.vert.glsl).
Compiling shader 3 of 8 (painter-image.frag.glsl).
Compiling shader 4 of 8 (painter-image.vert.glsl).
Compiling shader 5 of 8 (painter-text.frag.glsl).
Compiling shader 6 of 8 (painter-text.vert.glsl).
Compiling shader 7 of 8 (painter-video.frag.glsl).
Compiling shader 8 of 8 (painter-video.vert.glsl).
korefile not found.
Done.

I noticed that it doesn't create the android studio project like it used to and it complains that a korefile is not found.

An attempt to build the generated project using koremake yelds:

$ node /home/zicklag/programs/armory/armsdk/Kha/Kore/make.js --compile
korefile found.
Creating Linux project files.
{ Error: ENOENT: no such file or directory, open '/home/zicklag/programs/armory/
armory_examples/multitouch/testbuild_2/testbuild_2/android-native-hl-build/koref
ile.js'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at Promise (/home/zicklag/programs/armory/armsdk/Kha/Kore/Tools/koremake/out
/Project.js:75:27)
    at new Promise (<anonymous>)
    at loadProject (/home/zicklag/programs/armory/armsdk/Kha/Kore/Tools/koremake
/out/Project.js:54:12)
    at Project.addProject (/home/zicklag/programs/armory/armsdk/Kha/Kore/Tools/k
oremake/out/Project.js:411:37)
    at eval (eval at Promise (/home/zicklag/programs/armory/armsdk/Kha/Kore/Tool
s/koremake/out/Project.js:77:27), <anonymous>:10:15)
    at Promise (/home/zicklag/programs/armory/armsdk/Kha/Kore/Tools/koremake/out
/Project.js:77:227)
    at new Promise (<anonymous>)
    at loadProject (/home/zicklag/programs/armory/armsdk/Kha/Kore/Tools/koremake
/out/Project.js:54:12)
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/home/zicklag/programs/armory/armory_examples/multitouch/testbuild_2/te
stbuild_2/android-native-hl-build/korefile.js' }
(node:21968) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or di
rectory, open '/home/zicklag/programs/armory/armory_examples/multitouch/testbuil
d_2/testbuild_2/android-native-hl-build/korefile.js'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at Promise (/home/zicklag/programs/armory/armsdk/Kha/Kore/Tools/koremake/out
/Project.js:75:27)
    at new Promise (<anonymous>)
    at loadProject (/home/zicklag/programs/armory/armsdk/Kha/Kore/Tools/koremake
/out/Project.js:54:12)
    at Project.addProject (/home/zicklag/programs/armory/armsdk/Kha/Kore/Tools/k
oremake/out/Project.js:411:37)
    at eval (eval at Promise (/home/zicklag/programs/armory/armsdk/Kha/Kore/Tool
s/koremake/out/Project.js:77:27), <anonymous>:10:15)
    at Promise (/home/zicklag/programs/armory/armsdk/Kha/Kore/Tools/koremake/out
/Project.js:77:227)
    at new Promise (<anonymous>)
    at loadProject (/home/zicklag/programs/armory/armsdk/Kha/Kore/Tools/koremake
/out/Project.js:54:12)
(node:21968) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This
 error originated either by throwing inside of an async function without a catch
 block, or by rejecting a promise which was not handled with .catch(). (rejectio
n id: 5)
(node:21968) [DEP0018] DeprecationWarning: Unhandled promise rejections are depr
ecated. In the future, promise rejections that are not handled will terminate th
e Node.js process with a non-zero exit code.
Error: korefile did not call resolve, no project created.

There is a line in the Korefile that points to the wrong path for the subproject so I replaced that line:

< project.setDebugDir('testbuild_2/android-native-hl');
< await project.addProject('testbuild_2/android-native-hl-build');
---
> project.setDebugDir('android-native-hl');
> await project.addProject('android-native-hl-build');

and then re-ran the build:

$ node /home/zicklag/programs/armory/armsdk/Kha/Kore/make.js --compile
korefile found.
Creating Linux project files.
Compiling shader 1 of 10 (g1.frag).
Compiling shader 2 of 10 (g1.vert).
Compiling shader 3 of 10 (painter-colored.frag).
Compiling shader 4 of 10 (painter-colored.vert).
Compiling shader 5 of 10 (painter-image.frag).
Compiling shader 6 of 10 (painter-image.vert).
Compiling shader 7 of 10 (painter-text.frag).
Compiling shader 8 of 10 (painter-text.vert).
Compiling shader 9 of 10 (painter-video.frag).
Compiling shader 10 of 10 (painter-video.vert).
Compiling...
...

And it successfully compiles the native binary.

Summary

So I did manage to get a binary for Android, but I don't know how to package it, and I can't just use Android Studio because it didn't generate an Android Studio project. I don't think it is a bad idea to build the project with Koremake, but I think there should be an option to generate the project files for an applicable IDE like it did before.

Anyway, I'm not sure if you were just in the middle of working something out or not, but that is my experience. I'm just going to roll back the commits ( Kode/koremake@1ce323106a8f6e9121eb47cce9093a6a226eb914 and Kode/khamake@18800f9cb66cace491a8525013af145e109b9742 ) that caused the issue so that I can get the old behaviour back for now.

Disar commented 5 years ago

I had to give an absolute path in my khafile.js to include a kore project, can you confirm if the path shown in the error is omitting a folder? Because that's the case for me.

edit

By your error it looks like it's including the folder twice.

zicklag commented 5 years ago

The problem is that the khafile.js in the project folder, /home/zicklag/programs/armory/ armory_examples/multitouch/ and it generates a Kore project with a korefile.js in the build dir /home/zicklag/programs/armory/ armory_examples/multitouch/testbuild_2. That korefile.js tries to include the subproject in android-native-hl-build, but it fails because it appends the build dir, testbuild_2, to the addProject statement when it shouldn't. I'm going to try to write a PR to fix it.

BTW @RobDangerous I actually like the idea of not having to use Android Studio to compile the project, I just need a way to build the APK after the code is compiled.

Disar commented 5 years ago

I don't know what is happening in my case though, it omits the root folder.

also I build without android studio using gradlew in the build/android-native-build/projectname/

.\gradlew assembleDebugArm7 or .\gradlew assembleReleaseArm7

zicklag commented 5 years ago

Oh, nifty about gradlew. :+1:

About your problem, do you have some logs from a run on your side? Or maybe the korefile.js that it creates in the build folder after running Khamake?

zicklag commented 5 years ago

OK, I think I've fixed it. At least the problem that I had.

Disar commented 5 years ago
let fs = require('fs');
let path = require('path');
let project = new Project('Alchemy');
project.addDefine('HXCPP_API_LEVEL=332');
project.addDefine('HXCPP_DEBUG', 'Debug');
project.targetOptions = {"html5":{},"flash":{},"android":{"screenOrientation":"portrait"},"ios":{}};
project.setDebugDir('build/android-native');
await project.addProject('build/android-native-build');
await project.addProject('E:/Programming/haxe/Kha');
if (fs.existsSync(path.join('Libraries/alchemy', 'korefile.js'))) {
    await project.addProject(path.join('..', 'Libraries/alchemy'));
}
if (fs.existsSync(path.join('Libraries/powerbracelet', 'korefile.js'))) {
    await project.addProject(path.join('..', 'Libraries/powerbracelet'));
}
if (fs.existsSync(path.join('Libraries/korempt', 'korefile.js'))) {
    await project.addProject(path.join('..', 'Libraries/korempt'));
}
if (fs.existsSync(path.join('Libraries/modplayer', 'korefile.js'))) {
    await project.addProject(path.join('..', 'Libraries/modplayer'));
}
if (fs.existsSync(path.join('E:/Software/Haxe/lib/tweenxcore', 'korefile.js'))) {
    await project.addProject('E:/Software/Haxe/lib/tweenxcore');
}
if (fs.existsSync(path.join('E:/Software/Haxe/lib/tweenx', 'korefile.js'))) {
    await project.addProject('E:/Software/Haxe/lib/tweenx');
}
if (fs.existsSync(path.join('E:/Software/Haxe/lib/tweenxcore', 'korefile.js'))) {
    await project.addProject('E:/Software/Haxe/lib/tweenxcore');
}
if (fs.existsSync(path.join('E:/Software/Haxe/lib/hxColorToolkit', 'korefile.js'))) {
    await project.addProject('E:/Software/Haxe/lib/hxColorToolkit');
}
if (fs.existsSync(path.join('E:/Software/Haxe/lib/hxsignal', 'korefile.js'))) {
    await project.addProject('E:/Software/Haxe/lib/hxsignal');
}
if (fs.existsSync(path.join('E:/Software/Haxe/lib/hscript', 'korefile.js'))) {
    await project.addProject('E:/Software/Haxe/lib/hscript');
}
resolve(project);

It's the korempt one, so it seems fine but the error says:

Error: ENOENT: no such file or directory, open 'E:\Programming\haxe\Libraries\korempt\korefile.js'

between haxe and Libraries there should the project folder

zicklag commented 5 years ago

OK, I think I see what you mean. Could you show your khafile.js? I'll try to reproduce this real quick, and I'll add a fix for this to my PR if I figure it out.

Disar commented 5 years ago

var fs = require('fs');
let project = new Project('Alchemy');

//Assets
project.addAssets('Libraries/powerbracelet/Assets/**');

project.addAssets('Assets/**',{
    nameBaseDir: 'Assets',
    destination: '{dir}/{name}',
    name: '{dir}/{name}'
});

//Sources
project.addSources('Sources');

//Shaders
project.addShaders('Libraries/alchemy/Shaders/**');

//Libraries
project.addLibrary('alchemy');
project.addLibrary('powerbracelet');
//project.addLibrary('zui');
project.addLibrary('korempt');
project.addLibrary('modplayer');
project.addLibrary('tweenxcore');
project.addLibrary('tweenx');
project.addLibrary('hxColorToolkit');
project.addLibrary('hxsignal');
// project.addLibrary('haxeui-core');
// project.addLibrary('haxeui-kha');
project.addLibrary('hscript');

project.targetOptions.android_native.screenOrientation = 'portrait';

project.windowOptions.width = 360;
project.windowOptions.height = 640;

//project.addDefine("arch_debug");

callbacks.postHaxeCompilation = addJsFiles;

resolve(project);

function addJsFiles(){

    //-------------------------------------------------------------
    // Include files 
    //-------------------------------------------------------------
    var path = '';

    if(platform === Platform.DebugHTML5){
        path = './build/debug-html5/';
    }
    else if (platform === Platform.HTML5){
        path = './build/html5/';
    }

    if(path !== '' && fs.existsSync(path) === false){
        fs.mkdirSync(path);
    }

    if(path !== ''){

        fs.createReadStream('./jsincludes/debug/index.html').pipe(fs.createWriteStream(path + 'index.html'));
        fs.createReadStream('./jsincludes/chiptunejs/chiptune2.js').pipe(fs.createWriteStream(path + 'chiptune2.js'));
        fs.createReadStream('./jsincludes/chiptunejs/libopenmpt.js').pipe(fs.createWriteStream(path + 'libopenmpt.js'));
        fs.createReadStream('./jsincludes/chiptunejs/libopenmpt.js.mem').pipe(fs.createWriteStream(path + 'libopenmpt.js.mem'));

    }

}

//-------------------------------------------------------------
// var shaderDefines = ['#define GLE_FRAGCOORD'];

// console.log(platform);

// if(platform === Platform.DebugHTML5){
//     shaderDefines = ['#define GLE_FRAGCOORD'];
// }
// else{
//     shaderDefines = [];
// }

// var fs = require('fs');
// fs.truncate('./Libraries/alchemy/Sources/ShaderIncludes/defines.glsl',0, function(e){});

// var file = fs.createWriteStream('./Libraries/alchemy/Sources/ShaderIncludes/defines.glsl');
// file.on('error', function(err) { console.log(err) });
// shaderDefines.forEach(function(v) { file.write(v + '\n'); });
// file.end();

//-------------------------------------------------------------
//-------------------------------------------------------------

this is the full khafile.js

zicklag commented 5 years ago

You are getting the error when you run Koremake right? Are you running Koremake from inside of the build dir?

Disar commented 5 years ago

No im calling khamake from the root folder.

zicklag commented 5 years ago

Oh, and does Khamake start building the project immediately when you run it?

I'm able to run Khamake in my project folder which contains the khafile.js and it will put the build files in the ./build directory. Then I move to the build directory and I run Koremake.

# From my project dir
$ node /home/zicklag/programs/armory/armsdk/Kha/make.js
Using Kha from /home/zicklag/programs/armory/armsdk/Kha
Creating Kha project.
Exporting asset 1 of 3 (Scene.arm).
...redacted...
Compiling shader 8 of 8 (painter-video.vert.glsl).
korefile found.
Creating Linux project files.
Done.
$ cd build
$ node /home/zicklag/programs/armory/armsdk/Kha/Kore/make.js --compile
korefile found.
Creating Linux project files.
Compiling shader 1 of 10 (g1.frag).
Compiling shader 2 of 10 (g1.vert).
...redacted...
Disar commented 5 years ago

It does some parts and then it cuts off with that error.

I can build my project by giving the absolute path though. I rather not move to the build folder.

zicklag commented 5 years ago

OK, then that should be fine for now.